Search in sources :

Example 11 with ValueSetExpansionComponent

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

the class NarrativeGenerator method generateVersionNotice.

@SuppressWarnings("rawtypes")
private void generateVersionNotice(XhtmlNode x, ValueSetExpansionComponent expansion) {
    Map<String, String> versions = new HashMap<String, String>();
    boolean firstVersion = true;
    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.isEmpty()) {
                StringBuilder b = new StringBuilder();
                if (firstVersion) {
                    // the first version
                    // set the <p> tag and style attribute
                    x.para().setAttribute("style", "border: black 1px dotted; background-color: #EEEEEE; padding: 8px");
                    firstVersion = false;
                } else {
                    // the second (or greater) version
                    // add line break before the version text
                    x.br();
                }
                b.append("Expansion based on ");
                boolean firstPart = true;
                for (String s : versions.keySet()) {
                    if (firstPart)
                        firstPart = false;
                    else
                        b.append(", ");
                    if (!s.equals("http://snomed.info/sct"))
                        b.append(describeSystem(s) + " version " + versions.get(s));
                    else {
                        parts = versions.get(s).split("\\/");
                        if (parts.length >= 5) {
                            String m = describeModule(parts[4]);
                            if (parts.length == 7)
                                b.append("SNOMED CT " + m + " edition " + formatSCTDate(parts[6]));
                            else
                                b.append("SNOMED CT " + m + " edition");
                        } else
                            b.append(describeSystem(s) + " version " + versions.get(s));
                    }
                }
                // add the version text
                x.addText(b.toString());
            }
        }
    }
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) HashMap(java.util.HashMap) ValueSetExpansionParameterComponent(org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionParameterComponent)

Example 12 with ValueSetExpansionComponent

use of org.hl7.fhir.r4b.model.ValueSet.ValueSetExpansionComponent 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 13 with ValueSetExpansionComponent

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

the class NarrativeGenerator method generateVersionNotice.

@SuppressWarnings("rawtypes")
private void generateVersionNotice(XhtmlNode x, ValueSetExpansionComponent expansion) {
    Map<String, String> versions = new HashMap<String, String>();
    boolean firstVersion = true;
    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.isEmpty()) {
                StringBuilder b = new StringBuilder();
                if (firstVersion) {
                    // the first version
                    // set the <p> tag and style attribute
                    x.para().setAttribute("style", "border: black 1px dotted; background-color: #EEEEEE; padding: 8px");
                    firstVersion = false;
                } else {
                    // the second (or greater) version
                    // add line break before the version text
                    x.br();
                }
                b.append("Expansion based on ");
                boolean firstPart = true;
                for (String s : versions.keySet()) {
                    if (firstPart)
                        firstPart = false;
                    else
                        b.append(", ");
                    if (!s.equals("http://snomed.info/sct"))
                        b.append(describeSystem(s) + " version " + versions.get(s));
                    else {
                        parts = versions.get(s).split("\\/");
                        if (parts.length >= 5) {
                            String m = describeModule(parts[4]);
                            if (parts.length == 7)
                                b.append("SNOMED CT " + m + " edition " + formatSCTDate(parts[6]));
                            else
                                b.append("SNOMED CT " + m + " edition");
                        } else
                            b.append(describeSystem(s) + " version " + versions.get(s));
                    }
                }
                // add the version text
                x.addText(b.toString());
            }
        }
    }
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder)

Example 14 with ValueSetExpansionComponent

use of org.hl7.fhir.r4b.model.ValueSet.ValueSetExpansionComponent 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.r4b.model.ValueSet.ValueSetExpansionParameterComponent) UriType(org.hl7.fhir.r4b.model.UriType)

Example 15 with ValueSetExpansionComponent

use of org.hl7.fhir.r4b.model.ValueSet.ValueSetExpansionComponent 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)

Aggregations

UriType (org.hl7.fhir.r4b.model.UriType)7 ValueSetExpansionParameterComponent (org.hl7.fhir.r4b.model.ValueSet.ValueSetExpansionParameterComponent)7 UriType (org.hl7.fhir.r5.model.UriType)7 ValueSetExpansionParameterComponent (org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionParameterComponent)7 ArrayList (java.util.ArrayList)6 ValueSet (org.hl7.fhir.r4.model.ValueSet)5 ValueSetExpansionComponent (org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionComponent)5 ValueSetExpansionContainsComponent (org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent)5 ValueSet (org.hl7.fhir.r4b.model.ValueSet)5 ValueSet (org.hl7.fhir.r5.model.ValueSet)5 TerminologyServiceException (org.hl7.fhir.exceptions.TerminologyServiceException)4 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)4 HashMap (java.util.HashMap)3 List (java.util.List)2 ValueSet (org.hl7.fhir.dstu2.model.ValueSet)2 ValueSet (org.hl7.fhir.dstu2016may.model.ValueSet)2 ValueSet (org.hl7.fhir.dstu3.model.ValueSet)2 CodeSystem (org.hl7.fhir.r4b.model.CodeSystem)2 ConceptDefinitionComponent (org.hl7.fhir.r4b.model.CodeSystem.ConceptDefinitionComponent)2 Extension (org.hl7.fhir.r4b.model.Extension)2