Search in sources :

Example 31 with ValueSetExpansionParameterComponent

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

the class ValueSetRenderer method generateContentModeNotice.

private void generateContentModeNotice(XhtmlNode x, ValueSetExpansionComponent expansion, String mode, String text) {
    Multimap<String, String> versions = HashMultimap.create();
    for (ValueSetExpansionParameterComponent p : expansion.getParameter()) {
        if (p.getName().equals(mode)) {
            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: #ffcccc; padding: 8px; margin-bottom: 8px");
                    p.tx(text + " ");
                    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(text + "s: ");
                        ul = div.ul();
                        first = false;
                    }
                    expRef(ul.li(), s, v);
                }
            }
        }
    }
}
Also used : ValueSetExpansionParameterComponent(org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionParameterComponent) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 32 with ValueSetExpansionParameterComponent

use of org.hl7.fhir.r5.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.r5.model.ValueSet.ValueSetExpansionParameterComponent) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 33 with ValueSetExpansionParameterComponent

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

the class ValueSetSpreadsheetGenerator method genExpansionParams.

private void genExpansionParams(List<ValueSetExpansionParameterComponent> params) {
    Sheet sheet = makeSheet("Expansion Parameters");
    addHeaders(sheet, "Parameter", "Value");
    for (ValueSetExpansionParameterComponent p : params) {
        addRow(sheet, p.getName(), dr.display(p.getValue()));
    }
}
Also used : ValueSetExpansionParameterComponent(org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionParameterComponent) Sheet(org.apache.poi.ss.usermodel.Sheet)

Example 34 with ValueSetExpansionParameterComponent

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

the class ValueSetExpanderSimple method importValueSet.

private ValueSet importValueSet(String value, List<ValueSetExpansionParameterComponent> params, ExpansionProfile profile) throws ETooCostly, TerminologyServiceException, FileNotFoundException, IOException, FHIRFormatError {
    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, profile);
    if (vso.getError() != null)
        throw new TerminologyServiceException("Unable to expand imported value set: " + vso.getError());
    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() + "|" + vs.getVersion())))
            params.add(new ValueSetExpansionParameterComponent().setName("version").setValue(new UriType(vs.getUrl() + "|" + vs.getVersion())));
    for (ValueSetExpansionParameterComponent p : vso.getValueset().getExpansion().getParameter()) {
        if (!existsInParams(params, p.getName(), p.getValue()))
            params.add(p);
    }
    // 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 : NoTerminologyServiceException(org.hl7.fhir.exceptions.NoTerminologyServiceException) TerminologyServiceException(org.hl7.fhir.exceptions.TerminologyServiceException) ValueSet(org.hl7.fhir.dstu3.model.ValueSet)

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