Search in sources :

Example 21 with ValueSetExpansionParameterComponent

use of org.hl7.fhir.r4b.model.ValueSet.ValueSetExpansionParameterComponent in project org.hl7.fhir.core by hapifhir.

the class ValueSetExpanderSimple method excludeCodes.

private void excludeCodes(ConceptSetComponent exc, List<ValueSetExpansionParameterComponent> params, String ctxt) throws FHIRException {
    exc.checkNoModifiers("Compose.exclude", "expanding");
    if (exc.hasSystem() && exc.getConcept().size() == 0 && exc.getFilter().size() == 0) {
        excludeSystems.add(exc.getSystem());
    }
    if (exc.hasValueSet())
        throw fail("Processing Value set references in exclude is not yet done in " + ctxt);
    // importValueSet(imp.getValue(), params, expParams);
    CodeSystem cs = context.fetchCodeSystem(exc.getSystem());
    if ((cs == null || cs.getContent() != CodeSystemContentMode.COMPLETE) && context.supportsSystem(exc.getSystem())) {
        ValueSetExpansionOutcome vse = context.expandVS(exc, false, false);
        ValueSet valueset = vse.getValueset();
        if (valueset == null)
            throw failTSE("Error Expanding ValueSet: " + vse.getError());
        excludeCodes(valueset.getExpansion(), params);
        return;
    }
    for (ConceptReferenceComponent c : exc.getConcept()) {
        excludeCode(exc.getSystem(), c.getCode());
    }
    if (exc.getFilter().size() > 0)
        throw fail("not done yet - multiple filters");
}
Also used : CodeSystem(org.hl7.fhir.r5.model.CodeSystem) ValueSet(org.hl7.fhir.r5.model.ValueSet) ConceptReferenceComponent(org.hl7.fhir.r5.model.ValueSet.ConceptReferenceComponent)

Example 22 with ValueSetExpansionParameterComponent

use of org.hl7.fhir.r4b.model.ValueSet.ValueSetExpansionParameterComponent in project org.hl7.fhir.core by hapifhir.

the class ValueSetExpanderSimple method importValueSet.

private ValueSet importValueSet(String value, ValueSetExpansionComponent exp, Parameters expParams, boolean noInactive, ValueSet valueSet) throws ETooCostly, TerminologyServiceException, FileNotFoundException, IOException, FHIRFormatError {
    if (value == null)
        throw fail("unable to find value set with no identity");
    ValueSet vs = context.fetchResource(ValueSet.class, value);
    if (vs == null) {
        if (context.fetchResource(CodeSystem.class, value) != null) {
            throw fail("Cannot include value set " + value + " because it's actually a code system");
        } else {
            throw fail("Unable to find imported value set " + value);
        }
    }
    if (noInactive) {
        expParams = expParams.copy();
        expParams.addParameter("activeOnly", true);
    }
    ValueSetExpansionOutcome vso = new ValueSetExpanderSimple(context, allErrors).expand(vs, expParams);
    if (vso.getError() != null) {
        addErrors(vso.getAllErrors());
        throw fail("Unable to expand imported value set " + vs.getUrl() + ": " + vso.getError());
    }
    if (vs.hasVersion())
        if (!existsInParams(exp.getParameter(), "version", new UriType(vs.getUrl() + "|" + vs.getVersion())))
            exp.getParameter().add(new ValueSetExpansionParameterComponent().setName("version").setValue(new UriType(vs.getUrl() + "|" + vs.getVersion())));
    for (Extension ex : vso.getValueset().getExpansion().getExtension()) {
        if (ex.getUrl().equals(ToolingExtensions.EXT_EXP_TOOCOSTLY)) {
            if (ex.getValue() instanceof BooleanType) {
                exp.getExtension().add(new Extension(ToolingExtensions.EXT_EXP_TOOCOSTLY).setValue(new UriType(value)));
            } else {
                exp.getExtension().add(ex);
            }
        }
    }
    for (ValueSetExpansionParameterComponent p : vso.getValueset().getExpansion().getParameter()) {
        if (!existsInParams(exp.getParameter(), p.getName(), p.getValue()))
            exp.getParameter().add(p);
    }
    if (isValueSetUnionImports(valueSet)) {
        copyExpansion(vso.getValueset().getExpansion().getContains());
    }
    // if we're importing a value set, we have to be combining, so we won't try for a heirarchy
    canBeHeirarchy = false;
    return vso.getValueset();
}
Also used : Extension(org.hl7.fhir.r5.model.Extension) ValueSetExpansionParameterComponent(org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionParameterComponent) BooleanType(org.hl7.fhir.r5.model.BooleanType) ValueSet(org.hl7.fhir.r5.model.ValueSet) CodeSystem(org.hl7.fhir.r5.model.CodeSystem) UriType(org.hl7.fhir.r5.model.UriType)

Example 23 with ValueSetExpansionParameterComponent

use of org.hl7.fhir.r4b.model.ValueSet.ValueSetExpansionParameterComponent in project org.hl7.fhir.core by hapifhir.

the class ValueSetExpanderSimple method doServerIncludeCodes.

private void doServerIncludeCodes(ConceptSetComponent inc, boolean heirarchical, ValueSetExpansionComponent exp, List<ValueSet> imports, Parameters expParams, List<Extension> extensions, boolean noInactive) throws FHIRException {
    ValueSetExpansionOutcome vso = context.expandVS(inc, heirarchical, noInactive);
    if (vso.getError() != null) {
        throw failTSE("Unable to expand imported value set: " + vso.getError());
    }
    ValueSet vs = vso.getValueset();
    if (vs.hasVersion()) {
        if (!existsInParams(exp.getParameter(), "version", new UriType(vs.getUrl() + "|" + vs.getVersion()))) {
            exp.getParameter().add(new ValueSetExpansionParameterComponent().setName("version").setValue(new UriType(vs.getUrl() + "|" + vs.getVersion())));
        }
    }
    for (ValueSetExpansionParameterComponent p : vso.getValueset().getExpansion().getParameter()) {
        if (!existsInParams(exp.getParameter(), p.getName(), p.getValue())) {
            exp.getParameter().add(p);
        }
    }
    for (Extension ex : vs.getExpansion().getExtension()) {
        if (Utilities.existsInList(ex.getUrl(), ToolingExtensions.EXT_EXP_TOOCOSTLY, "http://hl7.org/fhir/StructureDefinition/valueset-unclosed")) {
            if (!hasExtension(extensions, ex.getUrl())) {
                extensions.add(ex);
            }
        }
    }
    for (ValueSetExpansionContainsComponent cc : vs.getExpansion().getContains()) {
        addCodeAndDescendents(cc, null, expParams, imports, noInactive);
    }
}
Also used : Extension(org.hl7.fhir.r5.model.Extension) ValueSetExpansionContainsComponent(org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent) ValueSetExpansionParameterComponent(org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionParameterComponent) ValueSet(org.hl7.fhir.r5.model.ValueSet) UriType(org.hl7.fhir.r5.model.UriType)

Example 24 with ValueSetExpansionParameterComponent

use of org.hl7.fhir.r4b.model.ValueSet.ValueSetExpansionParameterComponent in project org.hl7.fhir.core by hapifhir.

the class ValueSetExpanderSimple method addFragmentWarning.

private void addFragmentWarning(ValueSetExpansionComponent exp, CodeSystem cs) {
    String url = cs.getVersionedUrl();
    for (ValueSetExpansionParameterComponent p : exp.getParameter()) {
        if ("fragment".equals(p.getName()) && p.hasValueUriType() && url.equals(p.getValue().primitiveValue())) {
            return;
        }
    }
    exp.addParameter().setName("fragment").setValue(new UriType(url));
}
Also used : ValueSetExpansionParameterComponent(org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionParameterComponent) UriType(org.hl7.fhir.r5.model.UriType)

Example 25 with ValueSetExpansionParameterComponent

use of org.hl7.fhir.r4b.model.ValueSet.ValueSetExpansionParameterComponent in project org.hl7.fhir.core by hapifhir.

the class ValueSetRenderer method generateVersionNotice.

@SuppressWarnings("rawtypes")
private void generateVersionNotice(XhtmlNode x, ValueSetExpansionComponent expansion) {
    Multimap<String, String> versions = HashMultimap.create();
    for (ValueSetExpansionParameterComponent p : expansion.getParameter()) {
        if (p.getName().equals("version")) {
            String[] parts = ((PrimitiveType) p.getValue()).asStringValue().split("\\|");
            if (parts.length == 2)
                versions.put(parts[0], parts[1]);
        }
    }
    if (versions.size() > 0) {
        XhtmlNode div = null;
        XhtmlNode ul = null;
        boolean first = true;
        for (String s : versions.keySet()) {
            if (versions.size() == 1 && versions.get(s).size() == 1) {
                for (String v : versions.get(s)) {
                    // though there'll only be one
                    XhtmlNode p = x.para().style("border: black 1px dotted; background-color: #EEEEEE; padding: 8px; margin-bottom: 8px");
                    p.tx("Expansion based on ");
                    expRef(p, s, v);
                }
            } else {
                for (String v : versions.get(s)) {
                    if (first) {
                        div = x.div().style("border: black 1px dotted; background-color: #EEEEEE; padding: 8px; margin-bottom: 8px");
                        div.para().tx("Expansion based on: ");
                        ul = div.ul();
                        first = false;
                    }
                    expRef(ul.li(), s, v);
                }
            }
        }
    }
}
Also used : ValueSetExpansionParameterComponent(org.hl7.fhir.r4b.model.ValueSet.ValueSetExpansionParameterComponent) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Aggregations

TerminologyServiceException (org.hl7.fhir.exceptions.TerminologyServiceException)10 ValueSetExpansionParameterComponent (org.hl7.fhir.r4b.model.ValueSet.ValueSetExpansionParameterComponent)9 ValueSetExpansionParameterComponent (org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionParameterComponent)9 NoTerminologyServiceException (org.hl7.fhir.exceptions.NoTerminologyServiceException)6 NotImplementedException (org.apache.commons.lang3.NotImplementedException)5 UriType (org.hl7.fhir.r4b.model.UriType)5 UriType (org.hl7.fhir.r5.model.UriType)5 Sheet (org.apache.poi.ss.usermodel.Sheet)4 UriType (org.hl7.fhir.r4.model.UriType)4 ValueSet (org.hl7.fhir.r4.model.ValueSet)4 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)4 ArrayList (java.util.ArrayList)3 ValueSetExpansionParameterComponent (org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionParameterComponent)3 ValueSet (org.hl7.fhir.r4b.model.ValueSet)3 ValueSet (org.hl7.fhir.r5.model.ValueSet)3 List (java.util.List)2 UriType (org.hl7.fhir.dstu2.model.UriType)2 ValueSet (org.hl7.fhir.dstu2.model.ValueSet)2 ValueSetExpansionParameterComponent (org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionParameterComponent)2 UriType (org.hl7.fhir.dstu2016may.model.UriType)2