Search in sources :

Example 36 with ValueSetExpansionContainsComponent

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

the class QuestionnaireBuilder method makeTypeList.

private ValueSet makeTypeList(StructureDefinition profile, List<TypeRefComponent> types, String path) {
    ValueSet vs = new ValueSet();
    vs.setName("Type options for " + path);
    vs.setDescription(vs.present());
    vs.setStatus(PublicationStatus.ACTIVE);
    vs.setExpansion(new ValueSetExpansionComponent());
    vs.getExpansion().setIdentifier(Factory.createUUID());
    vs.getExpansion().setTimestampElement(DateTimeType.now());
    for (TypeRefComponent t : types) {
        if (t.hasTarget()) {
            for (UriType u : t.getTargetProfile()) {
                if (u.getValue().startsWith("http://hl7.org/fhir/StructureDefinition/")) {
                    ValueSetExpansionContainsComponent cc = vs.getExpansion().addContains();
                    cc.setCode(u.getValue().substring(40));
                    cc.setSystem("http://hl7.org/fhir/resource-types");
                    cc.setDisplay(cc.getCode());
                }
            }
        } else if (!t.hasProfile()) {
            ValueSetExpansionContainsComponent cc = vs.getExpansion().addContains();
            cc.setCode(t.getWorkingCode());
            cc.setDisplay(t.getWorkingCode());
            cc.setSystem("http://hl7.org/fhir/data-types");
        } else
            for (UriType u : t.getProfile()) {
                ProfileUtilities pu = new ProfileUtilities(context, null, null);
                StructureDefinition ps = pu.getProfile(profile, u.getValue());
                if (ps != null) {
                    ValueSetExpansionContainsComponent cc = vs.getExpansion().addContains();
                    cc.setCode(u.getValue());
                    cc.setDisplay(ps.getType());
                    cc.setSystem("http://hl7.org/fhir/resource-types");
                }
            }
    }
    return vs;
}
Also used : ValueSetExpansionComponent(org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionComponent) ValueSetExpansionContainsComponent(org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent) StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) TypeRefComponent(org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent) ProfileUtilities(org.hl7.fhir.r5.conformance.ProfileUtilities) ValueSet(org.hl7.fhir.r5.model.ValueSet) UriType(org.hl7.fhir.r5.model.UriType)

Example 37 with ValueSetExpansionContainsComponent

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

the class NarrativeGenerator method addLanguageRow.

private void addLanguageRow(ValueSetExpansionContainsComponent c, XhtmlNode t, List<String> langs) {
    XhtmlNode tr = t.tr();
    tr.td().addText(c.getCode());
    for (String lang : langs) {
        String d = null;
        for (Extension ext : c.getExtension()) {
            if (ToolingExtensions.EXT_TRANSLATION.equals(ext.getUrl())) {
                String l = ToolingExtensions.readStringExtension(ext, "lang");
                if (lang.equals(l))
                    d = ToolingExtensions.readStringExtension(ext, "content");
                ;
            }
        }
        tr.td().addText(d == null ? "" : d);
    }
    for (ValueSetExpansionContainsComponent cc : c.getContains()) {
        addLanguageRow(cc, t, langs);
    }
}
Also used : Extension(org.hl7.fhir.dstu3.model.Extension) ValueSetExpansionContainsComponent(org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionContainsComponent) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 38 with ValueSetExpansionContainsComponent

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

the class NarrativeGenerator method generateExpansion.

private boolean generateExpansion(XhtmlNode x, ValueSet vs, ValueSet src, boolean header) throws FHIRFormatError, DefinitionException, IOException {
    boolean hasExtensions = false;
    List<String> langs = new ArrayList<String>();
    Map<ConceptMap, String> mymaps = new HashMap<ConceptMap, String>();
    if (header) {
        XhtmlNode h = x.addTag(getHeader());
        h.tx("Value Set Contents");
        if (IsNotFixedExpansion(vs))
            addMarkdown(x, vs.getDescription());
        if (vs.hasCopyright())
            generateCopyright(x, vs);
    }
    if (ToolingExtensions.hasExtension(vs.getExpansion(), "http://hl7.org/fhir/StructureDefinition/valueset-toocostly"))
        x.para().setAttribute("style", "border: maroon 1px solid; background-color: #FFCCCC; font-weight: bold; padding: 8px").addText(vs.getExpansion().getContains().isEmpty() ? tooCostlyNoteEmpty : tooCostlyNoteNotEmpty);
    else {
        Integer count = countMembership(vs);
        if (count == null)
            x.para().tx("This value set does not contain a fixed number of concepts");
        else
            x.para().tx("This value set contains " + count.toString() + " concepts");
    }
    generateVersionNotice(x, vs.getExpansion());
    CodeSystem allCS = null;
    // checkDoSystem(vs, src);
    boolean doSystem = true;
    boolean doDefinition = checkDoDefinition(vs.getExpansion().getContains());
    if (doSystem && allFromOneSystem(vs)) {
        doSystem = false;
        XhtmlNode p = x.para();
        p.tx("All codes from system ");
        allCS = context.fetchCodeSystem(vs.getExpansion().getContains().get(0).getSystem());
        String ref = null;
        if (allCS != null)
            ref = getCsRef(allCS);
        if (ref == null)
            p.code(vs.getExpansion().getContains().get(0).getSystem());
        else
            p.ah(prefix + ref).code(vs.getExpansion().getContains().get(0).getSystem());
    }
    XhtmlNode t = x.table("codes");
    XhtmlNode tr = t.tr();
    tr.td().b().tx("Code");
    if (doSystem)
        tr.td().b().tx("System");
    tr.td().b().tx("Display");
    if (doDefinition)
        tr.td().b().tx("Definition");
    addMapHeaders(tr, mymaps);
    for (ValueSetExpansionContainsComponent c : vs.getExpansion().getContains()) {
        addExpansionRowToTable(t, c, 0, doSystem, doDefinition, mymaps, allCS, langs);
    }
    if (langs.size() > 0) {
        Collections.sort(langs);
        x.para().b().tx("Additional Language Displays");
        t = x.table("codes");
        tr = t.tr();
        tr.td().b().tx("Code");
        for (String lang : langs) tr.td().b().addText(describeLang(lang));
        for (ValueSetExpansionContainsComponent c : vs.getExpansion().getContains()) {
            addLanguageRow(c, t, langs);
        }
    }
    return hasExtensions;
}
Also used : ValueSetExpansionContainsComponent(org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionContainsComponent) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ConceptMap(org.hl7.fhir.dstu3.model.ConceptMap) CodeSystem(org.hl7.fhir.dstu3.model.CodeSystem) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 39 with ValueSetExpansionContainsComponent

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

the class QuestionnaireBuilder method makeTypeList.

private ValueSet makeTypeList(StructureDefinition profile, List<TypeRefComponent> types, String path) {
    ValueSet vs = new ValueSet();
    vs.setName("Type options for " + path);
    vs.setDescription(vs.present());
    vs.setStatus(PublicationStatus.ACTIVE);
    vs.setExpansion(new ValueSetExpansionComponent());
    vs.getExpansion().setIdentifier(Factory.createUUID());
    vs.getExpansion().setTimestampElement(DateTimeType.now());
    for (TypeRefComponent t : types) {
        if (t.hasTarget()) {
            for (UriType u : t.getTargetProfile()) {
                if (u.getValue().startsWith("http://hl7.org/fhir/StructureDefinition/")) {
                    ValueSetExpansionContainsComponent cc = vs.getExpansion().addContains();
                    cc.setCode(u.getValue().substring(40));
                    cc.setSystem("http://hl7.org/fhir/resource-types");
                    cc.setDisplay(cc.getCode());
                }
            }
        } else if (!t.hasProfile()) {
            ValueSetExpansionContainsComponent cc = vs.getExpansion().addContains();
            cc.setCode(t.getWorkingCode());
            cc.setDisplay(t.getWorkingCode());
            cc.setSystem("http://hl7.org/fhir/data-types");
        } else
            for (UriType u : t.getProfile()) {
                ProfileUtilities pu = new ProfileUtilities(context, null, null);
                StructureDefinition ps = pu.getProfile(profile, u.getValue());
                if (ps != null) {
                    ValueSetExpansionContainsComponent cc = vs.getExpansion().addContains();
                    cc.setCode(u.getValue());
                    cc.setDisplay(ps.getType());
                    cc.setSystem("http://hl7.org/fhir/resource-types");
                }
            }
    }
    return vs;
}
Also used : ValueSetExpansionComponent(org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionComponent) ValueSetExpansionContainsComponent(org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent) StructureDefinition(org.hl7.fhir.r4.model.StructureDefinition) TypeRefComponent(org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent) ProfileUtilities(org.hl7.fhir.r4.conformance.ProfileUtilities) ValueSet(org.hl7.fhir.r4.model.ValueSet) UriType(org.hl7.fhir.r4.model.UriType)

Example 40 with ValueSetExpansionContainsComponent

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

the class ValueSetCheckerSimple method findCodeInExpansion.

private ValidationResult findCodeInExpansion(Coding code, List<ValueSetExpansionContainsComponent> contains) {
    for (ValueSetExpansionContainsComponent containsComponent : contains) {
        if (containsComponent.getSystem().equals(code.getSystem()) && containsComponent.getCode().equals(code.getCode())) {
            ConceptDefinitionComponent ccd = new ConceptDefinitionComponent();
            ccd.setCode(containsComponent.getCode());
            ccd.setDisplay(containsComponent.getDisplay());
            ValidationResult res = new ValidationResult(code.getSystem(), ccd);
            return res;
        }
        if (containsComponent.hasContains()) {
            ValidationResult res = findCodeInExpansion(code, containsComponent.getContains());
            if (res != null) {
                return res;
            }
        }
    }
    return null;
}
Also used : ValueSetExpansionContainsComponent(org.hl7.fhir.r4b.model.ValueSet.ValueSetExpansionContainsComponent) ConceptDefinitionComponent(org.hl7.fhir.r4b.model.CodeSystem.ConceptDefinitionComponent) ValidationResult(org.hl7.fhir.r4b.context.IWorkerContext.ValidationResult)

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