Search in sources :

Example 1 with ValueSetExpansionContainsComponent

use of org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent in project kindling by HL7.

the class MarkDownPreProcessor method presentExpansion.

private static String presentExpansion(List<ValueSetExpansionContainsComponent> contains, BuildWorkerContext workerContext) {
    StringBuilder b = new StringBuilder();
    for (ValueSetExpansionContainsComponent cc : contains) {
        b.append(" - **");
        b.append(cc.getCode());
        b.append("** (\"");
        b.append(cc.getDisplay());
        b.append("\"): ");
        ConceptDefinitionComponent definition = workerContext.getCodeDefinition(cc.getSystem(), cc.getCode());
        b.append(definition.getDefinition());
        b.append("\r\n");
    }
    return b.toString();
}
Also used : ValueSetExpansionContainsComponent(org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent) ConceptDefinitionComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent)

Example 2 with ValueSetExpansionContainsComponent

use of org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent in project kindling by HL7.

the class XSDGenerator method generateEnum.

private void generateEnum(String en) throws IOException {
    if (allenums.contains(en))
        return;
    allenums.add(en);
    write("  <xs:simpleType name=\"" + en + "-list\">\r\n");
    write("    <xs:restriction base=\"code-primitive\">\r\n");
    ValueSet vs = enums.get(en);
    vs.setUserData(ToolResourceUtilities.NAME_VS_USE_MARKER, true);
    ValueSet ex = workerContext.expandVS(vs, true, false).getValueset();
    for (ValueSetExpansionContainsComponent cc : ex.getExpansion().getContains()) {
        genIncludedCode(cc);
    }
    write("    </xs:restriction>\r\n");
    write("  </xs:simpleType>\r\n");
    write("  <xs:complexType name=\"" + en + "\">\r\n");
    write("    <xs:annotation>\r\n");
    write("      <xs:documentation xml:lang=\"en\">" + Utilities.escapeXml(enumDefs.get(en)) + "</xs:documentation>\r\n");
    write("      <xs:documentation xml:lang=\"en\">If the element is present, it must have either a @value, an @id, or extensions</xs:documentation>\r\n");
    write("    </xs:annotation>\r\n");
    write("    <xs:complexContent>\r\n");
    write("      <xs:extension base=\"Element\">\r\n");
    write("        <xs:attribute name=\"value\" type=\"" + en + "-list\" use=\"optional\"/>\r\n");
    write("      </xs:extension>\r\n");
    write("    </xs:complexContent>\r\n");
    write("  </xs:complexType>\r\n");
}
Also used : ValueSetExpansionContainsComponent(org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent) ValueSet(org.hl7.fhir.r5.model.ValueSet)

Example 3 with ValueSetExpansionContainsComponent

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

the class SpecDifferenceEvaluator method compareBindings.

private boolean compareBindings(JsonObject element, ElementDefinitionBindingComponent rev, ElementDefinitionBindingComponent orig) {
    boolean res = false;
    if (rev.getStrength() != orig.getStrength()) {
        element.addProperty("binding-strength-changed", true);
        res = true;
    }
    if (!Base.compareDeep(rev.getValueSet(), orig.getValueSet(), false)) {
        element.addProperty("binding-valueset-changed", true);
        res = true;
    }
    if (!maxValueSetsMatch(rev, orig)) {
        element.addProperty("max-valueset-changed", true);
        res = true;
    }
    if (rev.getStrength() == BindingStrength.REQUIRED && orig.getStrength() == BindingStrength.REQUIRED) {
        JsonArray oa = new JsonArray();
        JsonArray ra = new JsonArray();
        ValueSet vrev = getValueSet(rev.getValueSet(), revision.getExpansions());
        ValueSet vorig = getValueSet(rev.getValueSet(), original.getExpansions());
        if (vrev != null && vorig != null) {
            for (ValueSetExpansionContainsComponent cc : vorig.getExpansion().getContains()) {
                if (!hasCode(vrev, cc))
                    oa.add(new JsonPrimitive(cc.getCode()));
            }
            for (ValueSetExpansionContainsComponent cc : vrev.getExpansion().getContains()) {
                if (!hasCode(vorig, cc))
                    ra.add(new JsonPrimitive(cc.getCode()));
            }
        }
        if (oa.size() > 0 || ra.size() > 0) {
            element.addProperty("binding-codes-changed", true);
            res = true;
        }
        if (oa.size() > 0)
            element.add("removed-codes", oa);
        if (ra.size() > 0)
            element.add("added-codes", ra);
    }
    return res;
}
Also used : JsonArray(com.google.gson.JsonArray) ValueSetExpansionContainsComponent(org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent) JsonPrimitive(com.google.gson.JsonPrimitive)

Example 4 with ValueSetExpansionContainsComponent

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

the class ValueSetExpanderSimple method expand.

@Override
public ValueSetExpansionOutcome expand(ValueSet source) {
    try {
        focus = source.copy();
        focus.setExpansion(new ValueSet.ValueSetExpansionComponent());
        focus.getExpansion().setTimestampElement(DateTimeType.now());
        focus.getExpansion().setIdentifier(Factory.createUUID());
        handleDefine(source, focus.getExpansion().getParameter());
        if (source.hasCompose())
            handleCompose(source.getCompose(), focus.getExpansion().getParameter());
        for (ValueSetExpansionContainsComponent c : codes) {
            if (map.containsKey(key(c))) {
                focus.getExpansion().getContains().add(c);
            }
        }
        return new ValueSetExpansionOutcome(focus, null);
    } catch (Exception e) {
        // that might fail too, but it might not, later.
        return new ValueSetExpansionOutcome(new ValueSetCheckerSimple(source, factory, context), e.getMessage());
    }
}
Also used : ValueSetExpansionContainsComponent(org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionContainsComponent) ValueSetExpansionComponent(org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionComponent) ValueSet(org.hl7.fhir.dstu2.model.ValueSet) NotImplementedException(org.apache.commons.lang3.NotImplementedException) IOException(java.io.IOException) TerminologyServiceException(org.hl7.fhir.exceptions.TerminologyServiceException) FileNotFoundException(java.io.FileNotFoundException)

Example 5 with ValueSetExpansionContainsComponent

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

the class ValueSetExpanderSimple method importValueSet.

private void importValueSet(String value, List<ValueSetExpansionParameterComponent> params) throws ETooCostly, TerminologyServiceException, FileNotFoundException, IOException {
    if (value == null)
        throw new TerminologyServiceException("unable to find value set with no identity");
    ValueSet vs = context.fetchResource(ValueSet.class, value);
    if (vs == null)
        throw new TerminologyServiceException("Unable to find imported value set " + value);
    ValueSetExpansionOutcome vso = factory.getExpander().expand(vs);
    if (vso.getService() != null)
        throw new TerminologyServiceException("Unable to expand imported value set " + value);
    if (vs.hasVersion())
        if (!existsInParams(params, "version", new UriType(vs.getUrl() + "?version=" + vs.getVersion())))
            params.add(new ValueSetExpansionParameterComponent().setName("version").setValue(new UriType(vs.getUrl() + "?version=" + vs.getVersion())));
    for (ValueSetExpansionParameterComponent p : vso.getValueset().getExpansion().getParameter()) {
        if (!existsInParams(params, p.getName(), p.getValue()))
            params.add(p);
    }
    for (ValueSetExpansionContainsComponent c : vso.getValueset().getExpansion().getContains()) {
        addCode(c.getSystem(), c.getCode(), c.getDisplay());
    }
}
Also used : ValueSetExpansionContainsComponent(org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionContainsComponent) ValueSetExpansionParameterComponent(org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionParameterComponent) TerminologyServiceException(org.hl7.fhir.exceptions.TerminologyServiceException) ValueSet(org.hl7.fhir.dstu2.model.ValueSet) UriType(org.hl7.fhir.dstu2.model.UriType)

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)16 HashMap (java.util.HashMap)8 ValueSet (org.hl7.fhir.r4.model.ValueSet)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 ConceptDefinitionComponent (org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent)6 ValueSet (org.hl7.fhir.dstu2.model.ValueSet)5 TerminologyServiceException (org.hl7.fhir.exceptions.TerminologyServiceException)5 ValueSetExpansionComponent (org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionComponent)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