Search in sources :

Example 51 with ConceptDefinitionComponent

use of org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent in project org.hl7.fhir.core by hapifhir.

the class CodeSystemComparer method merge.

private ConceptDefinitionComponent merge(ConceptDefinitionComponent l, ConceptDefinitionComponent r, List<PropertyComponent> destProps, CodeSystemComparison res) {
    ConceptDefinitionComponent cd = l.copy();
    if (!l.hasDisplay() && r.hasDisplay()) {
        cd.setDisplay(r.getDisplay());
    }
    if (!l.hasDefinition() && r.hasDefinition()) {
        cd.setDefinition(r.getDefinition());
    }
    mergeProps(cd, l, r, destProps, res);
    mergeDesignations(cd, l, r);
    return cd;
}
Also used : ConceptDefinitionComponent(org.hl7.fhir.r4b.model.CodeSystem.ConceptDefinitionComponent)

Example 52 with ConceptDefinitionComponent

use of org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent in project org.hl7.fhir.core by hapifhir.

the class CodeSystemComparer method intersect.

private ConceptDefinitionComponent intersect(ConceptDefinitionComponent l, ConceptDefinitionComponent r, CodeSystemComparison res) {
    ConceptDefinitionComponent cd = l.copy();
    if (l.hasDisplay() && !r.hasDisplay()) {
        cd.setDisplay(null);
    }
    if (l.hasDefinition() && !r.hasDefinition()) {
        cd.setDefinition(null);
    }
    intersectProps(cd, l, r, res);
    // mergeDesignations(cd, l, r);
    return cd;
}
Also used : ConceptDefinitionComponent(org.hl7.fhir.r4b.model.CodeSystem.ConceptDefinitionComponent)

Example 53 with ConceptDefinitionComponent

use of org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent in project org.hl7.fhir.core by hapifhir.

the class CodeSystemRenderer method generateCodeSystemContent.

private boolean generateCodeSystemContent(XhtmlNode x, CodeSystem cs, boolean hasExtensions, List<UsedConceptMap> maps) throws FHIRFormatError, DefinitionException, IOException {
    XhtmlNode p = x.para();
    if (cs.getContent() == CodeSystemContentMode.COMPLETE)
        p.tx(getContext().getWorker().translator().translateAndFormat("xhtml-gen-cs", getContext().getLang(), "This code system %s defines the following codes", cs.getUrl()) + ":");
    else if (cs.getContent() == CodeSystemContentMode.EXAMPLE)
        p.tx(getContext().getWorker().translator().translateAndFormat("xhtml-gen-cs", getContext().getLang(), "This code system %s defines some example codes", cs.getUrl()) + ":");
    else if (cs.getContent() == CodeSystemContentMode.FRAGMENT)
        p.tx(getContext().getWorker().translator().translateAndFormat("xhtml-gen-cs", getContext().getLang(), "This code system %s defines many codes, of which the following are a subset", cs.getUrl()) + ":");
    else if (cs.getContent() == CodeSystemContentMode.NOTPRESENT) {
        p.tx(getContext().getWorker().translator().translateAndFormat("xhtml-gen-cs", getContext().getLang(), "This code system %s defines many codes, but they are not represented here", cs.getUrl()));
        return false;
    }
    XhtmlNode t = x.table("codes");
    boolean definitions = false;
    boolean commentS = false;
    boolean deprecated = false;
    boolean display = false;
    boolean hierarchy = false;
    boolean version = false;
    boolean ignoreStatus = false;
    boolean isSupplement = cs.getContent() == CodeSystemContentMode.SUPPLEMENT;
    List<PropertyComponent> properties = new ArrayList<>();
    for (PropertyComponent cp : cs.getProperty()) {
        if (showPropertyInTable(cp)) {
            boolean exists = false;
            for (ConceptDefinitionComponent c : cs.getConcept()) {
                exists = exists || conceptsHaveProperty(c, cp);
            }
            if (exists) {
                properties.add(cp);
                if ("status".equals(cp.getCode())) {
                    ignoreStatus = true;
                }
            }
        }
    }
    for (ConceptDefinitionComponent c : cs.getConcept()) {
        commentS = commentS || conceptsHaveComments(c);
        deprecated = deprecated || conceptsHaveDeprecated(cs, c, ignoreStatus);
        display = display || conceptsHaveDisplay(c);
        version = version || conceptsHaveVersion(c);
        hierarchy = hierarchy || c.hasConcept();
        definitions = definitions || conceptsHaveDefinition(c);
    }
    CodeSystemNavigator csNav = new CodeSystemNavigator(cs);
    hierarchy = hierarchy || csNav.isRestructure();
    List<String> langs = new ArrayList<>();
    addMapHeaders(addTableHeaderRowStandard(t, hierarchy, display, definitions, commentS, version, deprecated, properties, null, false), maps);
    for (ConceptDefinitionComponent c : csNav.getConcepts(null)) {
        hasExtensions = addDefineRowToTable(t, c, 0, hierarchy, display, definitions, commentS, version, deprecated, maps, cs.getUrl(), cs, properties, csNav, langs, isSupplement) || hasExtensions;
    }
    if (langs.size() > 0) {
        Collections.sort(langs);
        x.para().b().tx("Additional Language Displays");
        t = x.table("codes");
        XhtmlNode tr = t.tr();
        tr.td().b().tx("Code");
        for (String lang : langs) tr.td().b().addText(describeLang(lang));
        for (ConceptDefinitionComponent c : cs.getConcept()) {
            addLanguageRow(c, t, langs);
        }
    }
    return hasExtensions;
}
Also used : ConceptPropertyComponent(org.hl7.fhir.r4b.model.CodeSystem.ConceptPropertyComponent) PropertyComponent(org.hl7.fhir.r4b.model.CodeSystem.PropertyComponent) ConceptDefinitionComponent(org.hl7.fhir.r4b.model.CodeSystem.ConceptDefinitionComponent) ArrayList(java.util.ArrayList) CodeSystemNavigator(org.hl7.fhir.r4b.terminologies.CodeSystemUtilities.CodeSystemNavigator) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 54 with ConceptDefinitionComponent

use of org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent in project org.hl7.fhir.core by hapifhir.

the class ResourceRenderer method renderCommitteeLink.

protected void renderCommitteeLink(XhtmlNode x, CanonicalResource cr) {
    String code = ToolingExtensions.readStringExtension(cr, ToolingExtensions.EXT_WORKGROUP);
    CodeSystem cs = context.getWorker().fetchCodeSystem("http://terminology.hl7.org/CodeSystem/hl7-work-group");
    if (cs == null || !cs.hasUserData("path"))
        x.tx(code);
    else {
        ConceptDefinitionComponent cd = CodeSystemUtilities.findCode(cs.getConcept(), code);
        if (cd == null) {
            x.tx(code);
        } else {
            x.ah(cs.getUserString("path") + "#" + cs.getId() + "-" + cd.getCode()).tx(cd.getDisplay());
        }
    }
}
Also used : ConceptDefinitionComponent(org.hl7.fhir.r4b.model.CodeSystem.ConceptDefinitionComponent) CodeSystem(org.hl7.fhir.r4b.model.CodeSystem)

Example 55 with ConceptDefinitionComponent

use of org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent in project org.hl7.fhir.core by hapifhir.

the class ValueSetRenderer method getConceptForCodeFromExpansion.

private ConceptDefinitionComponent getConceptForCodeFromExpansion(List<ValueSetExpansionContainsComponent> list, String code) {
    for (ValueSetExpansionContainsComponent c : list) {
        if (code.equals(c.getCode())) {
            ConceptDefinitionComponent res = new ConceptDefinitionComponent();
            res.setCode(c.getCode());
            res.setDisplay(c.getDisplay());
            return res;
        }
        ConceptDefinitionComponent v = getConceptForCodeFromExpansion(c.getContains(), code);
        if (v != null)
            return v;
    }
    return null;
}
Also used : ValueSetExpansionContainsComponent(org.hl7.fhir.r4b.model.ValueSet.ValueSetExpansionContainsComponent) ConceptDefinitionComponent(org.hl7.fhir.r4b.model.CodeSystem.ConceptDefinitionComponent)

Aggregations

ConceptDefinitionComponent (org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent)54 ArrayList (java.util.ArrayList)26 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)26 ConceptDefinitionComponent (org.hl7.fhir.r4b.model.CodeSystem.ConceptDefinitionComponent)22 CodeSystem (org.hl7.fhir.r5.model.CodeSystem)21 ConceptDefinitionComponent (org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent)17 ConceptDefinitionComponent (org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent)16 ValueSet (org.hl7.fhir.dstu2.model.ValueSet)15 FHIRException (org.hl7.fhir.exceptions.FHIRException)14 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)12 ConceptPropertyComponent (org.hl7.fhir.r4b.model.CodeSystem.ConceptPropertyComponent)10 ConceptPropertyComponent (org.hl7.fhir.r5.model.CodeSystem.ConceptPropertyComponent)10 IOException (java.io.IOException)9 HashMap (java.util.HashMap)9 NotImplementedException (org.apache.commons.lang3.NotImplementedException)9 TerminologyServiceException (org.hl7.fhir.exceptions.TerminologyServiceException)9 FileNotFoundException (java.io.FileNotFoundException)8 ConceptDefinitionComponent (org.hl7.fhir.dstu2016may.model.CodeSystem.ConceptDefinitionComponent)8 ValidationResult (org.hl7.fhir.r5.context.IWorkerContext.ValidationResult)8 ConceptDefinitionDesignationComponent (org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionDesignationComponent)8