Search in sources :

Example 26 with ValueSetExpansionContainsComponent

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

the class Element method getAsICoding.

public ICoding getAsICoding() throws FHIRException {
    if ("code".equals(fhirType())) {
        if (property.getDefinition().getBinding().getStrength() != BindingStrength.REQUIRED)
            return null;
        ICodingImpl c = new ICodingImpl(true, true, false, false);
        c.code = primitiveValue();
        ValueSetExpansionOutcome vse = property.getContext().expandVS(property.getDefinition().getBinding(), true, false);
        if (vse.getValueset() == null)
            return null;
        for (ValueSetExpansionContainsComponent cc : vse.getValueset().getExpansion().getContains()) {
            if (cc.getCode().equals(c.code)) {
                c.system = cc.getSystem();
                if (cc.hasVersion()) {
                    c.doesVersion = true;
                    c.version = cc.getVersion();
                }
                if (cc.hasDisplay()) {
                    c.doesDisplay = true;
                    c.display = cc.getDisplay();
                }
            }
        }
        if (c.system == null)
            return null;
        return c;
    } else if ("Coding".equals(fhirType())) {
        ICodingImpl c = new ICodingImpl(true, true, true, true);
        c.system = getNamedChildValue("system");
        c.code = getNamedChildValue("code");
        c.display = getNamedChildValue("display");
        c.version = getNamedChildValue("version");
        return c;
    } else if ("Quantity".equals(fhirType())) {
        ICodingImpl c = new ICodingImpl(true, true, false, false);
        c.system = getNamedChildValue("system");
        c.code = getNamedChildValue("code");
        return c;
    } else
        return null;
}
Also used : ValueSetExpansionContainsComponent(org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent) ValueSetExpansionOutcome(org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome)

Example 27 with ValueSetExpansionContainsComponent

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

the class ValueSetCheckerSimple method findValueSetRef.

private ConceptReferenceComponent findValueSetRef(String system, String code) {
    if (valueset == null)
        return null;
    // if it has an expansion
    for (ValueSetExpansionContainsComponent exp : valueset.getExpansion().getContains()) {
        if (system.equals(exp.getSystem()) && code.equals(exp.getCode())) {
            ConceptReferenceComponent cc = new ConceptReferenceComponent();
            cc.setDisplay(exp.getDisplay());
            cc.setDesignation(exp.getDesignation());
            return cc;
        }
    }
    for (ConceptSetComponent inc : valueset.getCompose().getInclude()) {
        if (system.equals(inc.getSystem())) {
            for (ConceptReferenceComponent cc : inc.getConcept()) {
                if (cc.getCode().equals(code)) {
                    return cc;
                }
            }
        }
        for (CanonicalType url : inc.getValueSet()) {
            ConceptReferenceComponent cc = getVs(url.asStringValue()).findValueSetRef(system, code);
            if (cc != null) {
                return cc;
            }
        }
    }
    return null;
}
Also used : ConceptSetComponent(org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent) ValueSetExpansionContainsComponent(org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent) ConceptReferenceComponent(org.hl7.fhir.r5.model.ValueSet.ConceptReferenceComponent) CanonicalType(org.hl7.fhir.r5.model.CanonicalType)

Example 28 with ValueSetExpansionContainsComponent

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

the class ValueSetExpanderSimple method doExpand.

public ValueSetExpansionOutcome doExpand(ValueSet source, Parameters expParams) throws FHIRException, ETooCostly, FileNotFoundException, IOException {
    if (expParams == null)
        expParams = makeDefaultExpansion();
    source.checkNoModifiers("ValueSet", "expanding");
    focus = source.copy();
    focus.setExpansion(new ValueSet.ValueSetExpansionComponent());
    focus.getExpansion().setTimestampElement(DateTimeType.now());
    focus.getExpansion().setIdentifier(Factory.createUUID());
    for (ParametersParameterComponent p : expParams.getParameter()) {
        if (Utilities.existsInList(p.getName(), "includeDesignations", "excludeNested"))
            focus.getExpansion().addParameter().setName(p.getName()).setValue(p.getValue());
    }
    if (source.hasCompose()) {
        handleCompose(source.getCompose(), focus.getExpansion(), expParams, source.getUrl(), focus.getExpansion().getExtension(), source);
    }
    if (canBeHeirarchy) {
        for (ValueSetExpansionContainsComponent c : roots) {
            focus.getExpansion().getContains().add(c);
        }
    } else {
        for (ValueSetExpansionContainsComponent c : codes) {
            if (map.containsKey(key(c)) && (includeAbstract || !c.getAbstract())) {
                // we may have added abstract codes earlier while we still thought it might be heirarchical, but later we gave up, so now ignore them
                focus.getExpansion().getContains().add(c);
                // make sure any heirarchy is wiped
                c.getContains().clear();
            }
        }
    }
    if (total > 0) {
        focus.getExpansion().setTotal(total);
    }
    return new ValueSetExpansionOutcome(focus);
}
Also used : ValueSetExpansionContainsComponent(org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent) ValueSetExpansionComponent(org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionComponent) ValueSet(org.hl7.fhir.r5.model.ValueSet) ParametersParameterComponent(org.hl7.fhir.r5.model.Parameters.ParametersParameterComponent)

Example 29 with ValueSetExpansionContainsComponent

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

the class ValueSetExpanderSimple method excludeCode.

private void excludeCode(String theSystem, String theCode) {
    ValueSetExpansionContainsComponent n = new ValueSet.ValueSetExpansionContainsComponent();
    n.setSystem(theSystem);
    n.setCode(theCode);
    String s = key(n);
    excludeKeys.add(s);
}
Also used : ValueSetExpansionContainsComponent(org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent)

Example 30 with ValueSetExpansionContainsComponent

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

the class NarrativeGenerator method addExpansionRowToTable.

private void addExpansionRowToTable(XhtmlNode t, ValueSetExpansionContainsComponent c, int i, boolean doSystem, boolean doDefinition, Map<ConceptMap, String> mymaps, CodeSystem allCS, List<String> langs) {
    XhtmlNode tr = t.tr();
    XhtmlNode td = tr.td();
    String tgt = makeAnchor(c.getSystem(), c.getCode());
    td.an(tgt);
    String s = Utilities.padLeft("", '\u00A0', i * 2);
    td.addText(s);
    addCodeToTable(c.getAbstract(), c.getSystem(), c.getCode(), c.getDisplay(), td);
    if (doSystem) {
        td = tr.td();
        td.addText(c.getSystem());
    }
    td = tr.td();
    if (c.hasDisplayElement())
        td.addText(c.getDisplay());
    if (doDefinition) {
        CodeSystem cs = allCS;
        if (cs == null)
            cs = context.fetchCodeSystem(c.getSystem());
        td = tr.td();
        if (cs != null)
            td.addText(CodeSystemUtilities.getCodeDefinition(cs, c.getCode()));
    }
    for (ConceptMap m : mymaps.keySet()) {
        td = tr.td();
        List<TargetElementComponentWrapper> mappings = findMappingsForCode(c.getCode(), m);
        boolean first = true;
        for (TargetElementComponentWrapper mapping : mappings) {
            if (!first)
                td.br();
            first = false;
            XhtmlNode span = td.span(null, mapping.comp.getEquivalence().toString());
            span.addText(getCharForEquivalence(mapping.comp));
            XhtmlNode a = td.ah(prefix + mymaps.get(m) + "#" + mapping.comp.getCode());
            a.addText(mapping.comp.getCode());
            if (!Utilities.noString(mapping.comp.getComment()))
                td.i().tx("(" + mapping.comp.getComment() + ")");
        }
    }
    for (Extension ext : c.getExtension()) {
        if (ToolingExtensions.EXT_TRANSLATION.equals(ext.getUrl())) {
            String lang = ToolingExtensions.readStringExtension(ext, "lang");
            if (!Utilities.noString(lang) && !langs.contains(lang))
                langs.add(lang);
        }
    }
    for (ValueSetExpansionContainsComponent cc : c.getContains()) {
        addExpansionRowToTable(t, cc, i + 1, doSystem, doDefinition, mymaps, allCS, langs);
    }
}
Also used : Extension(org.hl7.fhir.dstu3.model.Extension) ValueSetExpansionContainsComponent(org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionContainsComponent) ConceptMap(org.hl7.fhir.dstu3.model.ConceptMap) CodeSystem(org.hl7.fhir.dstu3.model.CodeSystem) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

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