Search in sources :

Example 1 with ConceptDefinitionComponent

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

the class PageProcessor method findTranslations.

private void findTranslations(Set<String> res, List<ConceptDefinitionComponent> list) {
    for (ConceptDefinitionComponent cc : list) {
        for (ConceptDefinitionDesignationComponent cd : cc.getDesignation()) {
            if (cd.hasLanguage())
                res.add(cd.getLanguage());
        }
        Extension ex = cc.getExtensionByUrl(ToolingExtensions.EXT_CS_COMMENT);
        if (ex != null) {
            for (String l : ToolingExtensions.getLanguageTranslations(ex).keySet()) res.add(l);
        }
        findTranslations(res, cc.getConcept());
    }
}
Also used : Extension(org.hl7.fhir.r5.model.Extension) ConceptDefinitionComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent) ConceptDefinitionDesignationComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionDesignationComponent)

Example 2 with ConceptDefinitionComponent

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

the class PageProcessor method summariseSCTCLD.

private String summariseSCTCLD(ValueSet vs) {
    boolean hasNonSCT = false;
    for (ConceptSetComponent cc : vs.getCompose().getInclude()) {
        if (!"http://snomed.info/sct".equals(cc.getSystem()))
            hasNonSCT = true;
    }
    StringBuilder b = new StringBuilder();
    b.append("<ul>");
    for (ConceptSetComponent cc : vs.getCompose().getInclude()) {
        if ("http://snomed.info/sct".equals(cc.getSystem())) {
            if (!cc.hasConcept() && !cc.hasFilter()) {
                b.append("<li>any SCT concept</li>");
            } else if (cc.hasConcept()) {
                b.append("<li>" + Integer.toString(cc.getConcept().size()) + " enumerated concepts</li>");
            } else {
                if (cc.getFilter().size() != 1 || !cc.getFilter().get(0).getProperty().equals("concept"))
                    b.append("<li>ERROR!</li>");
                else {
                    ConceptDefinitionComponent def = workerContext.getCodeDefinition("http://snomed.info/sct", cc.getFilter().get(0).getValue());
                    b.append("<li>" + cc.getFilter().get(0).getOp().toCode() + " " + (def == null ? cc.getFilter().get(0).getValue() : Utilities.escapeXml(def.getDisplay())) + "</li>");
                }
            }
        }
    }
    if (hasNonSCT)
        b.append("<li>other code systems</li>");
    b.append("</ul>");
    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)

Example 3 with ConceptDefinitionComponent

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

the class PageProcessor method getSnomedCTConcept.

public void getSnomedCTConcept(Map<String, SnomedConceptUsage> concepts, ValueSet vs, ConceptSetFilterComponent c) throws Exception {
    ConceptDefinitionComponent def = workerContext.getCodeDefinition("http://snomed.info/sct", c.getValue());
    if (def == null) {
        throw new Exception("Unable to retrieve definition for SNOMED code: " + c.getValue());
    }
    String d = def.getDisplay();
    if (concepts.containsKey(c.getValue()))
        concepts.get(c.getValue()).update(d, vs);
    else
        concepts.put(c.getValue(), new SnomedConceptUsage(c.getValue(), d, vs));
}
Also used : ConceptDefinitionComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent) 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 4 with ConceptDefinitionComponent

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

the class MarkDownPreProcessor method presentExpansion.

private static String presentExpansion(List<ValueSetExpansionContainsComponent> contains, BuildWorkerContext workerContext) {
    StringBuilder b = new StringBuilder();
    for (ValueSetExpansionContainsComponent cc : contains) {
        b.append(" - **");
        b.append(cc.getCode());
        b.append("** (\"");
        b.append(cc.getDisplay());
        b.append("\"): ");
        ConceptDefinitionComponent definition = workerContext.getCodeDefinition(cc.getSystem(), cc.getCode());
        b.append(definition.getDefinition());
        b.append("\r\n");
    }
    return b.toString();
}
Also used : ValueSetExpansionContainsComponent(org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent) ConceptDefinitionComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent)

Example 5 with ConceptDefinitionComponent

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

the class ValueSetGenerator method genResourceTypes.

private void genResourceTypes(ValueSet vs) {
    if (!vs.hasCompose())
        vs.setCompose(new ValueSetComposeComponent());
    vs.getCompose().addInclude().setSystem("http://hl7.org/fhir/resource-types");
    vs.setUserData("filename", "valueset-" + vs.getId());
    if (!vs.hasExtension(ToolingExtensions.EXT_WORKGROUP)) {
        vs.addExtension().setUrl(ToolingExtensions.EXT_WORKGROUP).setValue(new CodeType("fhir"));
    } else {
        String ec = ToolingExtensions.readStringExtension(vs, ToolingExtensions.EXT_WORKGROUP);
        if (!ec.equals("fhir"))
            System.out.println("ValueSet " + vs.getUrl() + " WG mismatch 7: is " + ec + ", want to set to " + "fhir");
    }
    vs.setUserData("path", "valueset-" + vs.getId() + ".html");
    CodeSystem cs = new CodeSystem();
    CodeSystemConvertor.populate(cs, vs);
    cs.setUrl("http://hl7.org/fhir/resource-types");
    cs.setVersion(version);
    cs.setCaseSensitive(true);
    cs.setContent(CodeSystemContentMode.COMPLETE);
    definitions.getCodeSystems().see(cs, packageInfo);
    List<String> codes = new ArrayList<String>();
    codes.addAll(definitions.getBaseResources().keySet());
    codes.addAll(definitions.getKnownResources().keySet());
    Collections.sort(codes);
    for (String s : codes) {
        DefinedCode rd = definitions.getKnownResources().get(s);
        ConceptDefinitionComponent c = cs.addConcept();
        Map<String, String> t;
        if (rd == null) {
            t = translator.translations(s);
            c.setCode(s);
            c.setDisplay(definitions.getBaseResources().get(s).getName());
            c.setDefinition((definitions.getBaseResources().get(s).isAbstract() ? "--- Abstract Type! ---" : "") + definitions.getBaseResources().get(s).getDefinition());
        } else {
            t = translator.translations(rd.getCode());
            c.setCode(rd.getCode());
            c.setDisplay(rd.getCode());
            c.setDefinition(rd.getDefinition());
        }
        if (t != null) {
            for (String l : t.keySet()) c.addDesignation().setLanguage(l).setValue(t.get(l)).getUse().setSystem("http://terminology.hl7.org/CodeSystem/designation-usage").setCode("display");
        }
    }
    markSpecialStatus(vs, cs, true);
}
Also used : ConceptDefinitionComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent) DefinedCode(org.hl7.fhir.definitions.model.DefinedCode) ArrayList(java.util.ArrayList) CodeType(org.hl7.fhir.r5.model.CodeType) ValueSetComposeComponent(org.hl7.fhir.r5.model.ValueSet.ValueSetComposeComponent) CodeSystem(org.hl7.fhir.r5.model.CodeSystem)

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 ValueSet (org.hl7.fhir.dstu2.model.ValueSet)15 ConceptDefinitionComponent (org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent)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