Search in sources :

Example 21 with ValueSetExpansionComponent

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

Example 22 with ValueSetExpansionComponent

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

the class BaseWorkerContext method expandVS.

@Override
public ValueSetExpansionComponent expandVS(ConceptSetComponent inc) {
    ValueSet vs = new ValueSet();
    vs.setCompose(new ValueSetComposeComponent());
    vs.getCompose().getInclude().add(inc);
    ValueSetExpansionOutcome vse = expandVS(vs, true);
    return vse.getValueset().getExpansion();
}
Also used : ValueSetExpansionOutcome(org.hl7.fhir.dstu2016may.terminologies.ValueSetExpander.ValueSetExpansionOutcome) ValueSet(org.hl7.fhir.dstu2016may.model.ValueSet) ValueSetComposeComponent(org.hl7.fhir.dstu2016may.model.ValueSet.ValueSetComposeComponent)

Example 23 with ValueSetExpansionComponent

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

Example 24 with ValueSetExpansionComponent

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

the class ValueSetRenderer method getConceptsForCodes.

private Map<String, ConceptDefinitionComponent> getConceptsForCodes(CodeSystem e, ConceptSetComponent inc) {
    if (e == null) {
        e = getContext().getWorker().fetchCodeSystem(inc.getSystem());
    }
    ValueSetExpansionComponent vse = null;
    if (!context.isNoSlowLookup() && !getContext().getWorker().hasCache()) {
        try {
            ValueSetExpansionOutcome vso = getContext().getWorker().expandVS(inc, false);
            ValueSet valueset = vso.getValueset();
            if (valueset == null)
                throw new TerminologyServiceException("Error Expanding ValueSet: " + vso.getError());
            vse = valueset.getExpansion();
        } catch (TerminologyServiceException e1) {
            return null;
        }
    }
    Map<String, ConceptDefinitionComponent> results = new HashMap<>();
    List<CodingValidationRequest> serverList = new ArrayList<>();
    // 1st pass, anything we can resolve internally
    for (ConceptReferenceComponent cc : inc.getConcept()) {
        String code = cc.getCode();
        ConceptDefinitionComponent v = null;
        if (e != null) {
            v = getConceptForCode(e.getConcept(), code);
        }
        if (v == null && vse != null) {
            v = getConceptForCodeFromExpansion(vse.getContains(), code);
        }
        if (v != null) {
            results.put(code, v);
        } else {
            serverList.add(new CodingValidationRequest(new Coding(inc.getSystem(), code, null)));
        }
    }
    if (!context.isNoSlowLookup() && !serverList.isEmpty()) {
        getContext().getWorker().validateCodeBatch(getContext().getTerminologyServiceOptions(), serverList, null);
        for (CodingValidationRequest vr : serverList) {
            ConceptDefinitionComponent v = vr.getResult().asConceptDefinition();
            if (v != null) {
                results.put(vr.getCoding().getCode(), v);
            }
        }
    }
    return results;
}
Also used : ValueSetExpansionComponent(org.hl7.fhir.r4b.model.ValueSet.ValueSetExpansionComponent) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ConceptReferenceComponent(org.hl7.fhir.r4b.model.ValueSet.ConceptReferenceComponent) ConceptDefinitionComponent(org.hl7.fhir.r4b.model.CodeSystem.ConceptDefinitionComponent) Coding(org.hl7.fhir.r4b.model.Coding) ValueSetExpansionOutcome(org.hl7.fhir.r4b.terminologies.ValueSetExpander.ValueSetExpansionOutcome) TerminologyServiceException(org.hl7.fhir.exceptions.TerminologyServiceException) ValueSet(org.hl7.fhir.r4b.model.ValueSet) CodingValidationRequest(org.hl7.fhir.r4b.context.IWorkerContext.CodingValidationRequest)

Example 25 with ValueSetExpansionComponent

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

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