Search in sources :

Example 86 with ValueSetExpansionContainsComponent

use of org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent in project org.hl7.fhir.core by hapifhir.

the class ValueSetExpanderSimple method doExpand.

public ValueSetExpansionOutcome doExpand(ValueSet source, Parameters expParams) throws FHIRException, ETooCostly, FileNotFoundException, IOException {
    if (expParams == null)
        expParams = makeDefaultExpansion();
    source.checkNoModifiers("ValueSet", "expanding");
    focus = source.copy();
    focus.setExpansion(new ValueSet.ValueSetExpansionComponent());
    focus.getExpansion().setTimestampElement(DateTimeType.now());
    focus.getExpansion().setIdentifier(Factory.createUUID());
    for (ParametersParameterComponent p : expParams.getParameter()) {
        if (Utilities.existsInList(p.getName(), "includeDesignations", "excludeNested"))
            focus.getExpansion().addParameter().setName(p.getName()).setValue(p.getValue());
    }
    if (source.hasCompose())
        handleCompose(source.getCompose(), focus.getExpansion(), expParams, source.getUrl(), focus.getExpansion().getExtension());
    if (canBeHeirarchy) {
        for (ValueSetExpansionContainsComponent c : roots) {
            focus.getExpansion().getContains().add(c);
        }
    } else {
        for (ValueSetExpansionContainsComponent c : codes) {
            if (map.containsKey(key(c)) && (includeAbstract || !c.getAbstract())) {
                // we may have added abstract codes earlier while we still thought it might be heirarchical, but later we gave up, so now ignore them
                focus.getExpansion().getContains().add(c);
                // make sure any heirarchy is wiped
                c.getContains().clear();
            }
        }
    }
    if (total > 0) {
        focus.getExpansion().setTotal(total);
    }
    return new ValueSetExpansionOutcome(focus);
}
Also used : ValueSetExpansionContainsComponent(org.hl7.fhir.r4b.model.ValueSet.ValueSetExpansionContainsComponent) ValueSetExpansionComponent(org.hl7.fhir.r4b.model.ValueSet.ValueSetExpansionComponent) ValueSet(org.hl7.fhir.r4b.model.ValueSet) ParametersParameterComponent(org.hl7.fhir.r4b.model.Parameters.ParametersParameterComponent)

Example 87 with ValueSetExpansionContainsComponent

use of org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent in project org.hl7.fhir.core by hapifhir.

the class ValueSetExpanderSimple method addCodeAndDescendents.

private void addCodeAndDescendents(ValueSetExpansionContainsComponent focus, ValueSetExpansionContainsComponent parent, Parameters expParams, List<ValueSet> filters) throws FHIRException {
    focus.checkNoModifiers("Expansion.contains", "expanding");
    ValueSetExpansionContainsComponent np = addCode(focus.getSystem(), focus.getCode(), focus.getDisplay(), parent, convert(focus.getDesignation()), expParams, focus.getAbstract(), focus.getInactive(), filters);
    for (ValueSetExpansionContainsComponent c : focus.getContains()) addCodeAndDescendents(focus, np, expParams, filters);
}
Also used : ValueSetExpansionContainsComponent(org.hl7.fhir.r4b.model.ValueSet.ValueSetExpansionContainsComponent)

Example 88 with ValueSetExpansionContainsComponent

use of org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent in project org.hl7.fhir.core by hapifhir.

the class ValueSetExpanderSimple method excludeCode.

private void excludeCode(String theSystem, String theCode) {
    ValueSetExpansionContainsComponent n = new ValueSet.ValueSetExpansionContainsComponent();
    n.setSystem(theSystem);
    n.setCode(theCode);
    String s = key(n);
    excludeKeys.add(s);
}
Also used : ValueSetExpansionContainsComponent(org.hl7.fhir.r4b.model.ValueSet.ValueSetExpansionContainsComponent)

Example 89 with ValueSetExpansionContainsComponent

use of org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent in project org.hl7.fhir.core by hapifhir.

the class ValueSetExpanderSimple method addCode.

private ValueSetExpansionContainsComponent addCode(String system, String code, String display, ValueSetExpansionContainsComponent parent, List<ConceptDefinitionDesignationComponent> designations, Parameters expParams, boolean isAbstract, boolean inactive, List<ValueSet> filters) {
    if (filters != null && !filters.isEmpty() && !filterContainsCode(filters, system, code))
        return null;
    ValueSetExpansionContainsComponent n = new ValueSet.ValueSetExpansionContainsComponent();
    n.setSystem(system);
    n.setCode(code);
    if (isAbstract)
        n.setAbstract(true);
    if (inactive)
        n.setInactive(true);
    if (expParams.getParameterBool("includeDesignations") && designations != null) {
        for (ConceptDefinitionDesignationComponent t : designations) {
            ToolingExtensions.addLanguageTranslation(n, t.getLanguage(), t.getValue());
        }
    }
    ConceptDefinitionDesignationComponent t = expParams.hasLanguage() ? getMatchingLang(designations, expParams.getLanguage()) : null;
    if (t == null)
        n.setDisplay(display);
    else
        n.setDisplay(t.getValue());
    String s = key(n);
    if (map.containsKey(s) || excludeKeys.contains(s)) {
        canBeHeirarchy = false;
    } else {
        codes.add(n);
        map.put(s, n);
        total++;
    }
    if (canBeHeirarchy && parent != null) {
        parent.getContains().add(n);
    } else {
        roots.add(n);
    }
    return n;
}
Also used : ValueSetExpansionContainsComponent(org.hl7.fhir.r4b.model.ValueSet.ValueSetExpansionContainsComponent) ConceptDefinitionDesignationComponent(org.hl7.fhir.r4b.model.CodeSystem.ConceptDefinitionDesignationComponent)

Example 90 with ValueSetExpansionContainsComponent

use of org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent in project org.hl7.fhir.core by hapifhir.

the class ValueSetCheckerSimple method findValueSetRef.

private ConceptReferenceComponent findValueSetRef(String system, String code) {
    if (valueset == null)
        return null;
    // if it has an expansion
    for (ValueSetExpansionContainsComponent exp : valueset.getExpansion().getContains()) {
        if (system.equals(exp.getSystem()) && code.equals(exp.getCode())) {
            ConceptReferenceComponent cc = new ConceptReferenceComponent();
            cc.setDisplay(exp.getDisplay());
            cc.setDesignation(exp.getDesignation());
            return cc;
        }
    }
    for (ConceptSetComponent inc : valueset.getCompose().getInclude()) {
        if (system.equals(inc.getSystem())) {
            for (ConceptReferenceComponent cc : inc.getConcept()) {
                if (cc.getCode().equals(code)) {
                    return cc;
                }
            }
        }
        for (CanonicalType url : inc.getValueSet()) {
            ConceptReferenceComponent cc = getVs(url.asStringValue()).findValueSetRef(system, code);
            if (cc != null) {
                return cc;
            }
        }
    }
    return null;
}
Also used : ConceptSetComponent(org.hl7.fhir.r4b.model.ValueSet.ConceptSetComponent) ValueSetExpansionContainsComponent(org.hl7.fhir.r4b.model.ValueSet.ValueSetExpansionContainsComponent) ConceptReferenceComponent(org.hl7.fhir.r4b.model.ValueSet.ConceptReferenceComponent) CanonicalType(org.hl7.fhir.r4b.model.CanonicalType)

Aggregations

ValueSetExpansionContainsComponent (org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent)32 ValueSetExpansionContainsComponent (org.hl7.fhir.r4b.model.ValueSet.ValueSetExpansionContainsComponent)22 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)20 ValueSetExpansionContainsComponent (org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent)17 ValueSet (org.hl7.fhir.r4.model.ValueSet)9 HashMap (java.util.HashMap)8 ValueSet (org.hl7.fhir.r5.model.ValueSet)8 ArrayList (java.util.ArrayList)7 ValueSetExpansionContainsComponent (org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionContainsComponent)7 ValueSetExpansionContainsComponent (org.hl7.fhir.dstu2016may.model.ValueSet.ValueSetExpansionContainsComponent)7 IOException (java.io.IOException)6 ValueSetExpansionContainsComponent (org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionContainsComponent)6 ValueSetExpansionComponent (org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionComponent)6 ConceptDefinitionComponent (org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent)6 ValueSet (org.hl7.fhir.dstu2.model.ValueSet)5 TerminologyServiceException (org.hl7.fhir.exceptions.TerminologyServiceException)5 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)5 ValueSet (org.hl7.fhir.dstu2016may.model.ValueSet)4 ValueSet (org.hl7.fhir.r4b.model.ValueSet)4 FHIRException (org.hl7.fhir.exceptions.FHIRException)3