org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionComponent Java Examples
The following examples show how to use
org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionComponent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RandomCodeGenerator.java From synthea with Apache License 2.0 | 6 votes |
/** * Gets a random code from the expansion of a ValueSet. * * @param valueSetUri the URI of the ValueSet * @param seed a random seed to ensure reproducibility of this result * @return the randomly selected Code */ public static Code getCode(String valueSetUri, long seed) { if (terminologyClient == null) { throw new RuntimeException( "Unable to generate code from ValueSet URI: terminology service not configured"); } ValueSetExpansionComponent expansion = expandValueSet(valueSetUri); Random random = new Random(seed); int randomIndex = random.nextInt(expansion.getTotal()); ValueSetExpansionContainsComponent contains = expansion.getContains().get(randomIndex); validateContains(contains); return new Code(contains.getSystem(), contains.getCode(), contains.getDisplay()); }
Example #2
Source File: RandomCodeGenerator.java From synthea with Apache License 2.0 | 6 votes |
private static ValueSetExpansionComponent expandValueSet(String valueSetUri) { ValueSet response; ValueSetExpansionComponent result = new ValueSetExpansionComponent(); int total; int offset = 0; int count = 0; do { offset += count; logger.info("Sending ValueSet expand request to terminology service (" + terminologyClient .getServerBase() + "): url=" + valueSetUri + ", count=" + EXPAND_PAGE_SIZE + ", offset=" + offset); try { response = responseCache.get(new ExpandInput(valueSetUri, offset)); } catch (ExecutionException e) { throw new RuntimeException("Error expanding ValueSet", e); } validateExpansion(response.getExpansion()); total = response.getExpansion().getTotal(); count = response.getExpansion().getContains().size(); result.getContains().addAll(response.getExpansion().getContains()); } while ((offset + count) < total); result.setTotal(total); return result; }
Example #3
Source File: ValueSetExpanderSimple.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
private void addCodes(ValueSetExpansionComponent expand, List<ValueSetExpansionParameterComponent> params, Parameters expParams, List<ValueSet> filters) throws ETooCostly, FHIRException { if (expand != null) { if (expand.getContains().size() > maxExpansionSize) throw new ETooCostly("Too many codes to display (>" + Integer.toString(expand.getContains().size()) + ")"); for (ValueSetExpansionParameterComponent p : expand.getParameter()) { if (!existsInParams(params, p.getName(), p.getValue())) params.add(p); } copyImportContains(expand.getContains(), null, expParams, filters); } }
Example #4
Source File: DefaultProfileValidationSupportStu3AsR4.java From careconnect-reference-implementation with Apache License 2.0 | 5 votes |
private void addConcepts(ConceptSetComponent theInclude, ValueSetExpansionComponent theRetVal, Set<String> theWantCodes, List<ConceptDefinitionComponent> theConcepts) { for (ConceptDefinitionComponent next : theConcepts) { if (theWantCodes.isEmpty() || theWantCodes.contains(next.getCode())) { theRetVal .addContains() .setSystem(theInclude.getSystem()) .setCode(next.getCode()) .setDisplay(next.getDisplay()); } addConcepts(theInclude, theRetVal, theWantCodes, next.getConcept()); } }
Example #5
Source File: RandomCodeGenerator.java From synthea with Apache License 2.0 | 5 votes |
private static void validateExpansion(@Nonnull ValueSetExpansionComponent expansion) { if (expansion.getContains().isEmpty()) { throw new RuntimeException("ValueSet expansion does not contain any codes"); } else if (expansion.getTotalElement().isEmpty()) { throw new RuntimeException("No total element in ValueSet expand result"); } }
Example #6
Source File: ValueSetExpanderSimple.java From org.hl7.fhir.core with Apache License 2.0 | 4 votes |
private void excludeCodes(ValueSetExpansionComponent expand, List<ValueSetExpansionParameterComponent> params) { for (ValueSetExpansionContainsComponent c : expand.getContains()) { excludeCode(c.getSystem(), c.getCode()); } }
Example #7
Source File: ITerminologyServices.java From org.hl7.fhir.core with Apache License 2.0 | 2 votes |
/** * Expand the value set fragment (system | codes | filters). Note that this * might fail if the expansion is very large. If the expansion fails, then the * checkVS will be called instead */ public ValueSetExpansionComponent expandVS(ConceptSetComponent inc) throws Exception;