Search in sources :

Example 1 with ConceptReferenceDesignationComponent

use of org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceDesignationComponent in project org.hl7.fhir.core by hapifhir.

the class NarrativeGenerator method genInclude.

private boolean genInclude(ResourceContext rcontext, XhtmlNode ul, ConceptSetComponent inc, String type, List<String> langs) throws FHIRException {
    boolean hasExtensions = false;
    XhtmlNode li;
    li = ul.li();
    CodeSystem e = context.fetchCodeSystem(inc.getSystem());
    if (inc.hasSystem()) {
        if (inc.getConcept().size() == 0 && inc.getFilter().size() == 0) {
            li.addText(type + " all codes defined in ");
            addCsRef(inc, li, e);
        } else {
            if (inc.getConcept().size() > 0) {
                li.addText(type + " these codes as defined in ");
                addCsRef(inc, li, e);
                XhtmlNode t = li.table("none");
                boolean hasComments = false;
                boolean hasDefinition = false;
                for (ConceptReferenceComponent c : inc.getConcept()) {
                    hasComments = hasComments || ExtensionHelper.hasExtension(c, ToolingExtensions.EXT_VS_COMMENT);
                    hasDefinition = hasDefinition || ExtensionHelper.hasExtension(c, ToolingExtensions.EXT_DEFINITION);
                }
                if (hasComments || hasDefinition)
                    hasExtensions = true;
                addTableHeaderRowStandard(t, false, true, hasDefinition, hasComments, false);
                for (ConceptReferenceComponent c : inc.getConcept()) {
                    XhtmlNode tr = t.tr();
                    XhtmlNode td = tr.td();
                    ConceptDefinitionComponent cc = getConceptForCode(e, c.getCode(), inc);
                    addCodeToTable(false, inc.getSystem(), c.getCode(), c.hasDisplay() ? c.getDisplay() : cc != null ? cc.getDisplay() : "", td);
                    td = tr.td();
                    if (!Utilities.noString(c.getDisplay()))
                        td.addText(c.getDisplay());
                    else if (cc != null && !Utilities.noString(cc.getDisplay()))
                        td.addText(cc.getDisplay());
                    td = tr.td();
                    if (ExtensionHelper.hasExtension(c, ToolingExtensions.EXT_DEFINITION))
                        smartAddText(td, ToolingExtensions.readStringExtension(c, ToolingExtensions.EXT_DEFINITION));
                    else if (cc != null && !Utilities.noString(cc.getDefinition()))
                        smartAddText(td, cc.getDefinition());
                    if (ExtensionHelper.hasExtension(c, ToolingExtensions.EXT_VS_COMMENT)) {
                        smartAddText(tr.td(), "Note: " + ToolingExtensions.readStringExtension(c, ToolingExtensions.EXT_VS_COMMENT));
                    }
                    for (ConceptReferenceDesignationComponent cd : c.getDesignation()) {
                        if (cd.hasLanguage() && !langs.contains(cd.getLanguage()))
                            langs.add(cd.getLanguage());
                    }
                }
            }
            boolean first = true;
            for (ConceptSetFilterComponent f : inc.getFilter()) {
                if (first) {
                    li.addText(type + " codes from ");
                    first = false;
                } else
                    li.tx(" and ");
                addCsRef(inc, li, e);
                li.tx(" where " + f.getProperty() + " " + describe(f.getOp()) + " ");
                if (e != null && codeExistsInValueSet(e, f.getValue())) {
                    String href = prefix + getCsRef(e);
                    if (href.contains("#"))
                        href = href + "-" + Utilities.nmtokenize(f.getValue());
                    else
                        href = href + "#" + e.getId() + "-" + Utilities.nmtokenize(f.getValue());
                    li.ah(href).addText(f.getValue());
                } else if ("concept".equals(f.getProperty()) && inc.hasSystem()) {
                    li.addText(f.getValue());
                    ValidationResult vr = context.validateCode(inc.getSystem(), f.getValue(), null);
                    if (vr.isOk()) {
                        li.tx(" (" + vr.getDisplay() + ")");
                    }
                } else
                    li.addText(f.getValue());
                String disp = ToolingExtensions.getDisplayHint(f);
                if (disp != null)
                    li.tx(" (" + disp + ")");
            }
        }
        if (inc.hasValueSet()) {
            li.tx(", where the codes are contained in ");
            boolean first = true;
            for (UriType vs : inc.getValueSet()) {
                if (first)
                    first = false;
                else
                    li.tx(", ");
                AddVsRef(rcontext, vs.asStringValue(), li);
            }
        }
    } else {
        li = ul.li();
        li.tx("Import all the codes that are contained in ");
        boolean first = true;
        for (UriType vs : inc.getValueSet()) {
            if (first)
                first = false;
            else
                li.tx(", ");
            AddVsRef(rcontext, vs.asStringValue(), li);
        }
    }
    return hasExtensions;
}
Also used : ConceptSetFilterComponent(org.hl7.fhir.dstu3.model.ValueSet.ConceptSetFilterComponent) ConceptDefinitionComponent(org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent) ConceptReferenceDesignationComponent(org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceDesignationComponent) ValidationResult(org.hl7.fhir.dstu3.context.IWorkerContext.ValidationResult) CodeSystem(org.hl7.fhir.dstu3.model.CodeSystem) ConceptReferenceComponent(org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceComponent) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) UriType(org.hl7.fhir.dstu3.model.UriType)

Example 2 with ConceptReferenceDesignationComponent

use of org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceDesignationComponent in project org.hl7.fhir.core by hapifhir.

the class ValueSetExpanderSimple method convert.

private List<ConceptDefinitionDesignationComponent> convert(List<ConceptReferenceDesignationComponent> designations) {
    List<ConceptDefinitionDesignationComponent> list = new ArrayList<ConceptDefinitionDesignationComponent>();
    for (ConceptReferenceDesignationComponent d : designations) {
        ConceptDefinitionDesignationComponent n = new ConceptDefinitionDesignationComponent();
        n.setLanguage(d.getLanguage());
        n.setUse(d.getUse());
        n.setValue(d.getValue());
        list.add(n);
    }
    return list;
}
Also used : ConceptDefinitionDesignationComponent(org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionDesignationComponent) ArrayList(java.util.ArrayList) ConceptReferenceDesignationComponent(org.hl7.fhir.r4.model.ValueSet.ConceptReferenceDesignationComponent)

Example 3 with ConceptReferenceDesignationComponent

use of org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceDesignationComponent in project org.hl7.fhir.core by hapifhir.

the class ValueSetCheckerSimple method validateCode.

private ValidationResult validateCode(Coding code, CodeSystem cs) {
    ConceptDefinitionComponent cc = cs.hasUserData("tx.cs.special") ? ((SpecialCodeSystem) cs.getUserData("tx.cs.special")).findConcept(code) : findCodeInConcept(cs.getConcept(), code.getCode());
    if (cc == null) {
        if (cs.getContent() == CodeSystemContentMode.FRAGMENT) {
            return new ValidationResult(IssueSeverity.WARNING, context.formatMessage(I18nConstants.UNKNOWN_CODE__IN_FRAGMENT, gen(code), cs.getUrl()));
        } else {
            return new ValidationResult(IssueSeverity.ERROR, context.formatMessage(I18nConstants.UNKNOWN_CODE__IN_, gen(code), cs.getUrl()));
        }
    }
    if (code.getDisplay() == null) {
        return new ValidationResult(code.getSystem(), cc);
    }
    CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
    if (cc.hasDisplay()) {
        b.append(cc.getDisplay());
        if (code.getDisplay().equalsIgnoreCase(cc.getDisplay())) {
            return new ValidationResult(code.getSystem(), cc);
        }
    }
    for (ConceptDefinitionDesignationComponent ds : cc.getDesignation()) {
        b.append(ds.getValue());
        if (code.getDisplay().equalsIgnoreCase(ds.getValue())) {
            return new ValidationResult(code.getSystem(), cc);
        }
    }
    // also check to see if the value set has another display
    ConceptReferenceComponent vs = findValueSetRef(code.getSystem(), code.getCode());
    if (vs != null && (vs.hasDisplay() || vs.hasDesignation())) {
        if (vs.hasDisplay()) {
            b.append(vs.getDisplay());
            if (code.getDisplay().equalsIgnoreCase(vs.getDisplay())) {
                return new ValidationResult(code.getSystem(), cc);
            }
        }
        for (ConceptReferenceDesignationComponent ds : vs.getDesignation()) {
            b.append(ds.getValue());
            if (code.getDisplay().equalsIgnoreCase(ds.getValue())) {
                return new ValidationResult(code.getSystem(), cc);
            }
        }
    }
    return new ValidationResult(IssueSeverity.WARNING, context.formatMessage(I18nConstants.DISPLAY_NAME_FOR__SHOULD_BE_ONE_OF__INSTEAD_OF_, code.getSystem(), code.getCode(), b.toString(), code.getDisplay()), code.getSystem(), cc);
}
Also used : ConceptDefinitionComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent) ConceptDefinitionDesignationComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionDesignationComponent) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) ConceptReferenceDesignationComponent(org.hl7.fhir.r5.model.ValueSet.ConceptReferenceDesignationComponent) ValidationResult(org.hl7.fhir.r5.context.IWorkerContext.ValidationResult) ConceptReferenceComponent(org.hl7.fhir.r5.model.ValueSet.ConceptReferenceComponent)

Example 4 with ConceptReferenceDesignationComponent

use of org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceDesignationComponent in project org.hl7.fhir.core by hapifhir.

the class ValueSetExpanderSimple method convertDesignations.

private List<ConceptDefinitionDesignationComponent> convertDesignations(List<ConceptReferenceDesignationComponent> list) {
    List<ConceptDefinitionDesignationComponent> res = new ArrayList<CodeSystem.ConceptDefinitionDesignationComponent>();
    for (ConceptReferenceDesignationComponent t : list) {
        ConceptDefinitionDesignationComponent c = new ConceptDefinitionDesignationComponent();
        c.setLanguage(t.getLanguage());
        c.setUse(t.getUse());
        c.setValue(t.getValue());
    }
    return res;
}
Also used : ConceptDefinitionDesignationComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionDesignationComponent) ArrayList(java.util.ArrayList) ConceptReferenceDesignationComponent(org.hl7.fhir.r5.model.ValueSet.ConceptReferenceDesignationComponent) CodeSystem(org.hl7.fhir.r5.model.CodeSystem)

Example 5 with ConceptReferenceDesignationComponent

use of org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceDesignationComponent in project org.hl7.fhir.core by hapifhir.

the class ValueSetExpanderSimple method convert.

private List<ConceptDefinitionDesignationComponent> convert(List<ConceptReferenceDesignationComponent> designations) {
    List<ConceptDefinitionDesignationComponent> list = new ArrayList<ConceptDefinitionDesignationComponent>();
    for (ConceptReferenceDesignationComponent d : designations) {
        ConceptDefinitionDesignationComponent n = new ConceptDefinitionDesignationComponent();
        n.setLanguage(d.getLanguage());
        n.setUse(d.getUse());
        n.setValue(d.getValue());
        list.add(n);
    }
    return list;
}
Also used : ConceptDefinitionDesignationComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionDesignationComponent) ArrayList(java.util.ArrayList) ConceptReferenceDesignationComponent(org.hl7.fhir.r5.model.ValueSet.ConceptReferenceDesignationComponent)

Aggregations

ConceptReferenceDesignationComponent (org.hl7.fhir.r5.model.ValueSet.ConceptReferenceDesignationComponent)11 ConceptReferenceDesignationComponent (org.hl7.fhir.r4b.model.ValueSet.ConceptReferenceDesignationComponent)7 ArrayList (java.util.ArrayList)6 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)5 ConceptDefinitionDesignationComponent (org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionDesignationComponent)4 Extension (org.hl7.fhir.r5.model.Extension)4 ConceptReferenceDesignationComponent (org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceDesignationComponent)3 ConceptDefinitionDesignationComponent (org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionDesignationComponent)3 ConceptReferenceDesignationComponent (org.hl7.fhir.r4.model.ValueSet.ConceptReferenceDesignationComponent)3 ConceptDefinitionDesignationComponent (org.hl7.fhir.r4b.model.CodeSystem.ConceptDefinitionDesignationComponent)3 ConceptReferenceComponent (org.hl7.fhir.r5.model.ValueSet.ConceptReferenceComponent)3 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)3 ConceptReferenceComponent (org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceComponent)2 ValidationResult (org.hl7.fhir.r4.context.IWorkerContext.ValidationResult)2 CodeSystem (org.hl7.fhir.r4.model.CodeSystem)2 Extension (org.hl7.fhir.r4b.model.Extension)2 ConceptReferenceComponent (org.hl7.fhir.r4b.model.ValueSet.ConceptReferenceComponent)2 ValueSetExpansionContainsComponent (org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent)2 ValidationResult (org.hl7.fhir.dstu3.context.IWorkerContext.ValidationResult)1 CodeSystem (org.hl7.fhir.dstu3.model.CodeSystem)1