Search in sources :

Example 86 with ConceptDefinitionComponent

use of org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent in project kindling by HL7.

the class PageProcessor method genScList.

private String genScList(String path) throws Exception {
    ResourceDefn r = definitions.getResourceByName(path.substring(0, path.indexOf(".")));
    if (r == null)
        throw new Exception("Unable to process sclist (1): " + path);
    ElementDefn e = r.getRoot().getElementByName(definitions, path.substring(path.indexOf(".") + 1), true, false);
    if (e == null)
        throw new Exception("Unable to process sclist (2): " + path);
    if (e.typeCode().equals("boolean"))
        return "true | false";
    else {
        StringBuilder b = new StringBuilder();
        boolean first = true;
        for (ConceptSetComponent inc : e.getBinding().getValueSet().getCompose().getInclude()) {
            CodeSystem cs = definitions.getCodeSystems().get(inc.getSystem());
            if (cs != null) {
                for (ConceptDefinitionComponent cc : cs.getConcept()) {
                    if (first)
                        first = false;
                    else
                        b.append(" | ");
                    b.append("<span title=\"" + cc.getDisplay() + ": " + Utilities.escapeXml(cc.getDefinition()) + "\">" + cc.getCode() + "</span>");
                }
            }
        }
        return b.toString();
    }
}
Also used : ConceptSetComponent(org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) ConceptDefinitionComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent) ElementDefn(org.hl7.fhir.definitions.model.ElementDefn) ResourceDefn(org.hl7.fhir.definitions.model.ResourceDefn) CodeSystem(org.hl7.fhir.r5.model.CodeSystem) UcumException(org.fhir.ucum.UcumException) TransformerException(javax.xml.transform.TransformerException) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) IOException(java.io.IOException) FHIRException(org.hl7.fhir.exceptions.FHIRException) URISyntaxException(java.net.URISyntaxException) PathEngineException(org.hl7.fhir.exceptions.PathEngineException) DefinitionException(org.hl7.fhir.exceptions.DefinitionException) FileNotFoundException(java.io.FileNotFoundException) NotImplementedException(org.apache.commons.lang3.NotImplementedException)

Example 87 with ConceptDefinitionComponent

use of org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent in project kindling by HL7.

the class PageProcessor method codelist.

// private String atomHeader(String n, String mode) {
// if (n.contains("-"))
// n = n.substring(0, n.indexOf('-'));
// StringBuilder b = new StringBuilder();
// b.append("<div class=\"navtop\">");
// b.append("<ul class=\"navtop\"><li class=\"spacerleft\"><span>&nbsp;</span></li>");
// if (mode == null || mode.equals("content"))
// b.append("<li class=\"selected\"><span>Content</span></li>");
// else
// b.append("<li class=\"nselected\"><span><a href=\""+n+".html\">Content</a></span></li>");
// if ("examples".equals(mode))
// b.append("<li class=\"selected\"><span>Examples</span></li>");
// else
// b.append("<li class=\"nselected\"><span><a href=\""+n+"-examples.html\">Examples</a></span></li>");
// b.append("<li class=\"spacerright\" style=\"width: 370px\"><span>&nbsp;</span></li>");
// b.append("</ul></div>\r\n");
// return b.toString();
// }
private String codelist(CodeSystem cs, String mode, boolean links, boolean heading, String source) throws Exception {
    if (cs == null)
        cs = definitions.getCodeSystems().get(mode);
    if (cs == null)
        throw new Exception("No Code system for " + mode + " from " + source);
    boolean hasComments = false;
    for (ConceptDefinitionComponent c : cs.getConcept()) hasComments = hasComments || checkHasComment(c);
    StringBuilder b = new StringBuilder();
    if (heading && !Utilities.noString(cs.getDescription()))
        b.append("<h3>" + cs.getDescription() + "</h3>\r\n");
    b.append("<table class=\"codes\">\r\n");
    for (ConceptDefinitionComponent c : cs.getConcept()) {
        genCodeItem(links, hasComments, b, c);
    }
    b.append("</table>\r\n");
    return b.toString();
}
Also used : ConceptDefinitionComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) UcumException(org.fhir.ucum.UcumException) TransformerException(javax.xml.transform.TransformerException) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) IOException(java.io.IOException) FHIRException(org.hl7.fhir.exceptions.FHIRException) URISyntaxException(java.net.URISyntaxException) PathEngineException(org.hl7.fhir.exceptions.PathEngineException) DefinitionException(org.hl7.fhir.exceptions.DefinitionException) FileNotFoundException(java.io.FileNotFoundException) NotImplementedException(org.apache.commons.lang3.NotImplementedException)

Example 88 with ConceptDefinitionComponent

use of org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent in project kindling by HL7.

the class CodeListToValueSetParser method processV3ConceptDefs.

private void processV3ConceptDefs(ConceptMap cm, String url, List<ConceptDefinitionComponent> list) throws Exception {
    for (ConceptDefinitionComponent c : list) {
        processV3Map(cm, url, c.getCode(), c.getUserString("v3"));
        processV3ConceptDefs(cm, url, c.getConcept());
    }
}
Also used : ConceptDefinitionComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent)

Example 89 with ConceptDefinitionComponent

use of org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent in project kindling by HL7.

the class CodeListToValueSetParser method execute.

public void execute(String v2map, String v3map, boolean utg) throws Exception {
    boolean hasDefine = false;
    for (int row = 0; row < sheet.rows.size(); row++) {
        hasDefine = hasDefine || Utilities.noString(sheet.getColumn(row, "System"));
    }
    Map<String, ConceptDefinitionComponent> codes = new HashMap<String, ConceptDefinitionComponent>();
    Map<String, ConceptDefinitionComponent> codesById = new HashMap<String, ConceptDefinitionComponent>();
    Map<String, ConceptSetComponent> includes = new HashMap<String, ConceptSetComponent>();
    CodeSystem cs = null;
    if (hasDefine) {
        cs = new CodeSystem();
        if (utg)
            cs.setUrl("http://terminology.hl7.org/CodeSystem/" + sheetName);
        else
            cs.setUrl("http://hl7.org/fhir/" + sheetName);
        if (!valueSet.hasCompose())
            valueSet.setCompose(new ValueSetComposeComponent());
        valueSet.getCompose().addInclude().setSystem(cs.getUrl());
        cs.setVersion(version);
        cs.setCaseSensitive(true);
        cs.setContent(CodeSystemContentMode.COMPLETE);
        codeSystems.see(cs, packageInfo);
        for (int row = 0; row < sheet.rows.size(); row++) {
            if (Utilities.noString(sheet.getColumn(row, "System"))) {
                ConceptDefinitionComponent cc = new ConceptDefinitionComponent();
                cc.setUserData("id", sheet.getColumn(row, "Id"));
                cc.setCode(sheet.getColumn(row, "Code"));
                if (codes.containsKey(cc.getCode()))
                    throw new Exception("Duplicate Code " + cc.getCode());
                codes.put(cc.getCode(), cc);
                codesById.put(cc.getUserString("id"), cc);
                cc.setDisplay(sheet.getColumn(row, "Display"));
                if (sheet.getColumn(row, "Abstract").toUpperCase().equals("Y"))
                    CodeSystemUtilities.setNotSelectable(cs, cc);
                if (cc.hasCode() && !cc.hasDisplay())
                    cc.setDisplay(Utilities.humanize(cc.getCode()));
                cc.setDefinition(Utilities.appendPeriod(sheet.getColumn(row, "Definition")));
                if (!Utilities.noString(sheet.getColumn(row, "Comment")))
                    ToolingExtensions.addCSComment(cc, sheet.getColumn(row, "Comment"));
                cc.setUserData("v2", sheet.getColumn(row, "v2"));
                cc.setUserData("v3", sheet.getColumn(row, "v3"));
                for (String ct : sheet.columns) if (ct.startsWith("Display:") && !Utilities.noString(sheet.getColumn(row, ct)))
                    cc.addDesignation().setLanguage(ct.substring(8)).setValue(sheet.getColumn(row, ct));
                String parent = sheet.getColumn(row, "Parent");
                if (Utilities.noString(parent))
                    cs.addConcept(cc);
                else if (parent.startsWith("#") && codesById.containsKey(parent.substring(1)))
                    codesById.get(parent.substring(1)).addConcept(cc);
                else if (codes.containsKey(parent))
                    codes.get(parent).addConcept(cc);
                else
                    throw new Exception("Parent " + parent + " not resolved in " + sheetName);
            }
        }
    }
    for (int row = 0; row < sheet.rows.size(); row++) {
        if (!Utilities.noString(sheet.getColumn(row, "System"))) {
            String system = sheet.getColumn(row, "System");
            ConceptSetComponent t = includes.get(system);
            if (t == null) {
                if (!valueSet.hasCompose())
                    valueSet.setCompose(new ValueSetComposeComponent());
                t = valueSet.getCompose().addInclude();
                t.setSystem(system);
                includes.put(system, t);
            }
            ConceptReferenceComponent cc = t.addConcept();
            cc.setCode(sheet.getColumn(row, "Code"));
            if (codes.containsKey(cc.getCode()))
                throw new Exception("Duplicate Code " + cc.getCode());
            codes.put(cc.getCode(), null);
            cc.setDisplay(sheet.getColumn(row, "Display"));
            if (!Utilities.noString(sheet.getColumn(row, "Definition")))
                ToolingExtensions.addDefinition(cc, sheet.getColumn(row, "Definition"));
            if (!Utilities.noString(sheet.getColumn(row, "Comment")))
                ToolingExtensions.addVSComment(cc, sheet.getColumn(row, "Comment"));
            cc.setUserDataINN("v2", sheet.getColumn(row, "v2"));
            cc.setUserDataINN("v3", sheet.getColumn(row, "v3"));
            for (String ct : sheet.columns) if (ct.startsWith("Display:") && !Utilities.noString(sheet.getColumn(row, ct)))
                cc.addDesignation().setLanguage(ct.substring(8)).setValue(sheet.getColumn(row, ct));
        }
    }
    if (!Utilities.noString(v2map)) {
        generateConceptMapV2(v2map, valueSet, cs);
    }
    if (!Utilities.noString(v3map)) {
        generateConceptMapV3(v3map, valueSet, cs);
    }
    if (cs != null)
        CodeSystemConvertor.populate(cs, valueSet);
}
Also used : ConceptSetComponent(org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent) ConceptDefinitionComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent) HashMap(java.util.HashMap) CodeSystem(org.hl7.fhir.r5.model.CodeSystem) ValueSetComposeComponent(org.hl7.fhir.r5.model.ValueSet.ValueSetComposeComponent) ConceptReferenceComponent(org.hl7.fhir.r5.model.ValueSet.ConceptReferenceComponent) ContactPoint(org.hl7.fhir.r5.model.ContactPoint)

Example 90 with ConceptDefinitionComponent

use of org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent in project kindling by HL7.

the class PageProcessor method codetoc.

private String codetoc(String n) throws Exception {
    CodeSystem cs = definitions.getCodeSystems().get(n);
    if (cs == null)
        throw new Exception("Unable to find code system '" + n + "'");
    StringBuilder b = new StringBuilder();
    for (ConceptDefinitionComponent c : cs.getConcept()) b.append("<a href=\"#" + c.getCode() + "\">" + c.getDisplay() + "</a><br/>\r\n");
    return b.toString();
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) ConceptDefinitionComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent) CodeSystem(org.hl7.fhir.r5.model.CodeSystem) UcumException(org.fhir.ucum.UcumException) TransformerException(javax.xml.transform.TransformerException) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) IOException(java.io.IOException) FHIRException(org.hl7.fhir.exceptions.FHIRException) URISyntaxException(java.net.URISyntaxException) PathEngineException(org.hl7.fhir.exceptions.PathEngineException) DefinitionException(org.hl7.fhir.exceptions.DefinitionException) FileNotFoundException(java.io.FileNotFoundException) NotImplementedException(org.apache.commons.lang3.NotImplementedException)

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