Search in sources :

Example 66 with ValueSetExpansionContainsComponent

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

the class ValueSetComparer method compareConcepts.

private void compareConcepts(List<ValueSetExpansionContainsComponent> left, List<ValueSetExpansionContainsComponent> right, StructuralMatch<ValueSetExpansionContainsComponent> combined, List<ValueSetExpansionContainsComponent> union, List<ValueSetExpansionContainsComponent> intersection, String path, ValueSetComparison res) {
    List<ValueSetExpansionContainsComponent> matchR = new ArrayList<>();
    for (ValueSetExpansionContainsComponent l : left) {
        ValueSetExpansionContainsComponent r = findInList(right, l);
        if (r == null) {
            union.add(l);
            combined.getChildren().add(new StructuralMatch<ValueSetExpansionContainsComponent>(l, vmI(IssueSeverity.INFORMATION, "Removed from expansion", path)));
        } else {
            matchR.add(r);
            ValueSetExpansionContainsComponent ccU = merge(l, r);
            ValueSetExpansionContainsComponent ccI = intersect(l, r);
            union.add(ccU);
            intersection.add(ccI);
            StructuralMatch<ValueSetExpansionContainsComponent> sm = new StructuralMatch<ValueSetExpansionContainsComponent>(l, r);
            compareItem(sm.getMessages(), path, l, r, res);
            combined.getChildren().add(sm);
            compareConcepts(l.getContains(), r.getContains(), sm, ccU.getContains(), ccI.getContains(), path + ".where(code = '" + l.getCode() + "').contains", res);
        }
    }
    for (ValueSetExpansionContainsComponent r : right) {
        if (!matchR.contains(r)) {
            union.add(r);
            combined.getChildren().add(new StructuralMatch<ValueSetExpansionContainsComponent>(vmI(IssueSeverity.INFORMATION, "Added to expansion", path), r));
        }
    }
}
Also used : ValueSetExpansionContainsComponent(org.hl7.fhir.r4b.model.ValueSet.ValueSetExpansionContainsComponent) ArrayList(java.util.ArrayList)

Example 67 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.r4.model.ValueSet.ValueSetExpansionContainsComponent)

Example 68 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().getParameter(), expParams, source.getUrl());
    if (canBeHeirarchy) {
        for (ValueSetExpansionContainsComponent c : roots) {
            focus.getExpansion().getContains().add(c);
        }
    } else {
        for (ValueSetExpansionContainsComponent c : codes) {
            if (map.containsKey(key(c)) && !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.r4.model.ValueSet.ValueSetExpansionContainsComponent) ValueSetExpansionComponent(org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionComponent) ValueSet(org.hl7.fhir.r4.model.ValueSet) ParametersParameterComponent(org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent)

Example 69 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.r4.model.ValueSet.ValueSetExpansionContainsComponent) ConceptDefinitionDesignationComponent(org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionDesignationComponent)

Example 70 with ValueSetExpansionContainsComponent

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

the class ValueSetExpanderSimple method copyImportContains.

private void copyImportContains(List<ValueSetExpansionContainsComponent> list, ValueSetExpansionContainsComponent parent, Parameters expParams, List<ValueSet> filter) throws FHIRException {
    for (ValueSetExpansionContainsComponent c : list) {
        c.checkNoModifiers("Imported Expansion in Code System", "expanding");
        ValueSetExpansionContainsComponent np = addCode(c.getSystem(), c.getCode(), c.getDisplay(), parent, null, expParams, c.getAbstract(), c.getInactive(), filter);
        copyImportContains(c.getContains(), np, expParams, filter);
    }
}
Also used : ValueSetExpansionContainsComponent(org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent)

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