Search in sources :

Example 51 with ConceptSetComponent

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

the class NarrativeGenerator method countMembership.

private Integer countMembership(ValueSet vs) {
    int count = 0;
    if (vs.hasExpansion())
        count = count + conceptCount(vs.getExpansion().getContains());
    else {
        if (vs.hasCompose()) {
            if (vs.getCompose().hasExclude()) {
                try {
                    ValueSetExpansionOutcome vse = context.expandVS(vs, true, false);
                    count = 0;
                    count += conceptCount(vse.getValueset().getExpansion().getContains());
                    return count;
                } catch (Exception e) {
                    return null;
                }
            }
            for (ConceptSetComponent inc : vs.getCompose().getInclude()) {
                if (inc.hasFilter())
                    return null;
                if (!inc.hasConcept())
                    return null;
                count = count + inc.getConcept().size();
            }
        }
    }
    return count;
}
Also used : ValueSetExpansionOutcome(org.hl7.fhir.r4.terminologies.ValueSetExpander.ValueSetExpansionOutcome) ParseException(java.text.ParseException) TerminologyServiceException(org.hl7.fhir.exceptions.TerminologyServiceException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) NotImplementedException(org.apache.commons.lang3.NotImplementedException) DefinitionException(org.hl7.fhir.exceptions.DefinitionException) IOException(java.io.IOException) FHIRException(org.hl7.fhir.exceptions.FHIRException)

Example 52 with ConceptSetComponent

use of org.hl7.fhir.r4b.model.ValueSet.ConceptSetComponent 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) throws FHIRException {
    ValueSetExpansionOutcome vso = context.expandVS(inc, heirarchical);
    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);
    }
}
Also used : Extension(org.hl7.fhir.r4b.model.Extension) ValueSetExpansionContainsComponent(org.hl7.fhir.r4b.model.ValueSet.ValueSetExpansionContainsComponent) ValueSetExpansionParameterComponent(org.hl7.fhir.r4b.model.ValueSet.ValueSetExpansionParameterComponent) ValueSet(org.hl7.fhir.r4b.model.ValueSet) UriType(org.hl7.fhir.r4b.model.UriType)

Example 53 with ConceptSetComponent

use of org.hl7.fhir.r4b.model.ValueSet.ConceptSetComponent 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);
        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.r4b.model.CodeSystem) ValueSet(org.hl7.fhir.r4b.model.ValueSet) ConceptReferenceComponent(org.hl7.fhir.r4b.model.ValueSet.ConceptReferenceComponent)

Example 54 with ConceptSetComponent

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

the class ValueSetUtilities method markStatus.

public static void markStatus(ValueSet vs, String wg, StandardsStatus status, String pckage, String fmm, IWorkerContext context, String normativeVersion) throws FHIRException {
    if (vs.hasUserData("external.url"))
        return;
    if (wg != null) {
        if (!ToolingExtensions.hasExtension(vs, ToolingExtensions.EXT_WORKGROUP) || (!Utilities.existsInList(ToolingExtensions.readStringExtension(vs, ToolingExtensions.EXT_WORKGROUP), "fhir", "vocab") && Utilities.existsInList(wg, "fhir", "vocab"))) {
            ToolingExtensions.setCodeExtension(vs, ToolingExtensions.EXT_WORKGROUP, wg);
        }
    }
    if (status != null) {
        StandardsStatus ss = ToolingExtensions.getStandardsStatus(vs);
        if (ss == null || ss.isLowerThan(status))
            ToolingExtensions.setStandardsStatus(vs, status, normativeVersion);
        if (pckage != null) {
            if (!vs.hasUserData("ballot.package"))
                vs.setUserData("ballot.package", pckage);
            else if (!pckage.equals(vs.getUserString("ballot.package")))
                if (!"infrastructure".equals(vs.getUserString("ballot.package")))
                    System.out.println("Value Set " + vs.getUrl() + ": ownership clash " + pckage + " vs " + vs.getUserString("ballot.package"));
        }
        if (status == StandardsStatus.NORMATIVE) {
            vs.setExperimental(false);
            vs.setStatus(PublicationStatus.ACTIVE);
        }
    }
    if (fmm != null) {
        String sfmm = ToolingExtensions.readStringExtension(vs, ToolingExtensions.EXT_FMM_LEVEL);
        if (Utilities.noString(sfmm) || Integer.parseInt(sfmm) < Integer.parseInt(fmm)) {
            ToolingExtensions.setIntegerExtension(vs, ToolingExtensions.EXT_FMM_LEVEL, Integer.parseInt(fmm));
        }
        if (Integer.parseInt(fmm) <= 1) {
            vs.setExperimental(true);
        }
    }
    if (vs.hasUserData("cs"))
        CodeSystemUtilities.markStatus((CodeSystem) vs.getUserData("cs"), wg, status, pckage, fmm, normativeVersion);
    else if (status == StandardsStatus.NORMATIVE && context != null) {
        for (ConceptSetComponent csc : vs.getCompose().getInclude()) {
            if (csc.hasSystem()) {
                CodeSystem cs = context.fetchCodeSystem(csc.getSystem());
                if (cs != null) {
                    CodeSystemUtilities.markStatus(cs, wg, status, pckage, fmm, normativeVersion);
                }
            }
        }
    }
}
Also used : ConceptSetComponent(org.hl7.fhir.r4b.model.ValueSet.ConceptSetComponent) StandardsStatus(org.hl7.fhir.utilities.StandardsStatus) CodeSystem(org.hl7.fhir.r4b.model.CodeSystem)

Example 55 with ConceptSetComponent

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

the class ValueSetRenderer method scanDesignations.

private void scanDesignations(ConceptSetComponent inc, List<String> langs, Map<String, String> designations) {
    for (ConceptReferenceComponent cc : inc.getConcept()) {
        for (Extension ext : cc.getExtension()) {
            if (ToolingExtensions.EXT_TRANSLATION.equals(ext.getUrl())) {
                String lang = ToolingExtensions.readStringExtension(ext, "lang");
                if (!Utilities.noString(lang) && !langs.contains(lang)) {
                    langs.add(lang);
                }
            }
        }
        for (ConceptReferenceDesignationComponent d : cc.getDesignation()) {
            String lang = d.getLanguage();
            if (!Utilities.noString(lang) && !langs.contains(lang)) {
                langs.add(lang);
            } else {
                // can we present this as a designation that we know?
                String disp = getDisplayForDesignation(d);
                String url = getUrlForDesignation(d);
                if (disp == null) {
                    disp = getDisplayForUrl(url);
                }
                if (disp != null && !designations.containsKey(url)) {
                    designations.put(url, disp);
                }
            }
        }
    }
}
Also used : Extension(org.hl7.fhir.r5.model.Extension) ConceptReferenceDesignationComponent(org.hl7.fhir.r5.model.ValueSet.ConceptReferenceDesignationComponent) ConceptReferenceComponent(org.hl7.fhir.r5.model.ValueSet.ConceptReferenceComponent)

Aggregations

ConceptSetComponent (org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent)25 ArrayList (java.util.ArrayList)22 ConceptSetComponent (org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent)21 IOException (java.io.IOException)20 TerminologyServiceException (org.hl7.fhir.exceptions.TerminologyServiceException)20 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)19 FHIRException (org.hl7.fhir.exceptions.FHIRException)17 HashMap (java.util.HashMap)15 ConceptSetComponent (org.hl7.fhir.dstu3.model.ValueSet.ConceptSetComponent)14 ConceptReferenceComponent (org.hl7.fhir.r5.model.ValueSet.ConceptReferenceComponent)14 ValueSet (org.hl7.fhir.r4.model.ValueSet)13 ValueSet (org.hl7.fhir.r5.model.ValueSet)13 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)12 NoTerminologyServiceException (org.hl7.fhir.exceptions.NoTerminologyServiceException)12 ConceptSetComponent (org.hl7.fhir.r4b.model.ValueSet.ConceptSetComponent)12 FileNotFoundException (java.io.FileNotFoundException)10 NotImplementedException (org.apache.commons.lang3.NotImplementedException)10 CodeSystem (org.hl7.fhir.r5.model.CodeSystem)10 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)10 ValueSet (org.hl7.fhir.dstu3.model.ValueSet)9