Search in sources :

Example 6 with ConceptDefinitionComponent

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

the class ValueSetGenerator method genMessageEvents.

private void genMessageEvents(ValueSet vs) {
    if (!vs.hasCompose())
        vs.setCompose(new ValueSetComposeComponent());
    vs.getCompose().addInclude().setSystem("http://hl7.org/fhir/message-events");
    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 10: is " + ec + ", want to set to " + "fhir");
    }
    vs.setUserData("path", "valueset-" + vs.getId() + ".html");
    CodeSystem cs = new CodeSystem();
    CodeSystemConvertor.populate(cs, vs);
    cs.setUserData("filename", vs.getUserString("filename").replace("valueset-", "codesystem-"));
    cs.setUserData("path", vs.getUserString("path").replace("valueset-", "codesystem-"));
    cs.setUrl("http://hl7.org/fhir/message-events");
    cs.setVersion(version);
    cs.setCaseSensitive(true);
    cs.setContent(CodeSystemContentMode.COMPLETE);
    definitions.getCodeSystems().see(cs, packageInfo);
    List<String> codes = new ArrayList<String>();
    codes.addAll(definitions.getEvents().keySet());
    Collections.sort(codes);
    for (String s : codes) {
        ConceptDefinitionComponent c = cs.addConcept();
        EventDefn e = definitions.getEvents().get(s);
        c.setCode(s);
        c.setDisplay(transform(e.getCode(), e.getTitle()));
        c.setDefinition(e.getDefinition());
    }
    markSpecialStatus(vs, cs, false);
}
Also used : ConceptDefinitionComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent) ArrayList(java.util.ArrayList) CodeType(org.hl7.fhir.r5.model.CodeType) EventDefn(org.hl7.fhir.definitions.model.EventDefn) ValueSetComposeComponent(org.hl7.fhir.r5.model.ValueSet.ValueSetComposeComponent) CodeSystem(org.hl7.fhir.r5.model.CodeSystem)

Example 7 with ConceptDefinitionComponent

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

the class ValueSetGenerator method genDataTypes.

private void genDataTypes(ValueSet vs) throws Exception {
    if (!vs.hasCompose())
        vs.setCompose(new ValueSetComposeComponent());
    vs.getCompose().addInclude().setSystem("http://hl7.org/fhir/data-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 6: 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/data-types");
    cs.setVersion(version);
    cs.setCaseSensitive(true);
    cs.setContent(CodeSystemContentMode.COMPLETE);
    definitions.getCodeSystems().see(cs, packageInfo);
    List<String> codes = new ArrayList<String>();
    for (TypeRef t : definitions.getKnownTypes()) codes.add(t.getName());
    Collections.sort(codes);
    for (String s : codes) {
        if (!definitions.dataTypeIsSharedInfo(s)) {
            ConceptDefinitionComponent c = cs.addConcept();
            c.setCode(s);
            c.setDisplay(s);
            if (definitions.getPrimitives().containsKey(s))
                c.setDefinition(definitions.getPrimitives().get(s).getDefinition());
            else if (definitions.getConstraints().containsKey(s))
                // don't add these: c.setDefinition(definitions.getConstraints().get(s).getDefinition());
                ;
            else if (definitions.hasElementDefn(s))
                c.setDefinition(definitions.getElementDefn(s).getDefinition());
            else
                c.setDefinition("...to do...");
        }
    }
    ToolingExtensions.addCSComment(cs.addConcept().setCode("xhtml").setDisplay("XHTML").setDefinition("XHTML format, as defined by W3C, but restricted usage (mainly, no active content)"), "Special case: xhtml can only be used in the narrative Data Type");
    markSpecialStatus(vs, cs, true);
}
Also used : ConceptDefinitionComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent) TypeRef(org.hl7.fhir.definitions.model.TypeRef) 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)

Example 8 with ConceptDefinitionComponent

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

the class ValueSetGenerator method loadOperationOutcomeValueSet.

public void loadOperationOutcomeValueSet(BindingSpecification cd) throws Exception {
    ValueSet vs = new ValueSet();
    cd.setValueSet(vs);
    cd.setBindingMethod(BindingMethod.ValueSet);
    vs.setId("operation-outcome");
    vs.setUrl("http://hl7.org/fhir/ValueSet/" + vs.getId());
    vs.setName("OperationOutcomeCodes");
    vs.setTitle("Operation Outcome Codes");
    vs.setPublisher("HL7 (FHIR Project)");
    vs.setVersion(version);
    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 11: is " + ec + ", want to set to " + "fhir");
    }
    vs.setUserData("path", "valueset-" + vs.getId() + ".html");
    ContactDetail c = vs.addContact();
    c.addTelecom().setSystem(ContactPointSystem.URL).setValue("http://hl7.org/fhir");
    c.addTelecom().setSystem(ContactPointSystem.EMAIL).setValue("fhir@lists.hl7.org");
    vs.setDescription("Operation Outcome codes used by FHIR test servers (see Implementation file translations.xml)");
    vs.setStatus(PublicationStatus.DRAFT);
    if (!vs.hasCompose())
        vs.setCompose(new ValueSetComposeComponent());
    vs.getCompose().addInclude().setSystem("http://terminology.hl7.org/CodeSystem/operation-outcome");
    CodeSystem cs = new CodeSystem();
    cs.setHierarchyMeaning(CodeSystemHierarchyMeaning.ISA);
    Set<String> codes = translator.listTranslations("ecode");
    for (String s : sorted(codes)) {
        Map<String, String> langs = translator.translations(s);
        ConceptDefinitionComponent cv = cs.addConcept();
        cv.setCode(s);
        cv.setDisplay(langs.get("en"));
        for (String lang : langs.keySet()) {
            if (!lang.equals("en")) {
                String value = langs.get(lang);
                ConceptDefinitionDesignationComponent dc = cv.addDesignation();
                dc.setLanguage(lang);
                dc.setValue(value);
                dc.getUse().setSystem("http://terminology.hl7.org/CodeSystem/designation-usage").setCode("display");
            }
        }
    }
    CodeSystemConvertor.populate(cs, vs);
    cs.setUrl("http://terminology.hl7.org/CodeSystem/operation-outcome");
    cs.setVersion(version);
    cs.setCaseSensitive(true);
    cs.setContent(CodeSystemContentMode.COMPLETE);
    definitions.getCodeSystems().see(cs, packageInfo);
}
Also used : ContactDetail(org.hl7.fhir.r5.model.ContactDetail) ConceptDefinitionComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent) ConceptDefinitionDesignationComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionDesignationComponent) CodeType(org.hl7.fhir.r5.model.CodeType) ValueSet(org.hl7.fhir.r5.model.ValueSet) ValueSetComposeComponent(org.hl7.fhir.r5.model.ValueSet.ValueSetComposeComponent) CodeSystem(org.hl7.fhir.r5.model.CodeSystem)

Example 9 with ConceptDefinitionComponent

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

the class CodeListToValueSetParser method processV2ConceptDefs.

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

Example 10 with ConceptDefinitionComponent

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

the class IEEE11073Convertor method generateMDC.

public static CodeSystem generateMDC(String src, String dst, UcumService ucum) throws IOException, FHIRException {
    CSVReader csv = new CSVReader(new FileInputStream(src));
    csv.readHeaders();
    CodeSystem cs = new CodeSystem();
    Map<String, String> ucumIssues = new HashMap<String, String>();
    int errorCount = 0;
    cs.setId("MDC");
    cs.setUrl("urn:iso:std:iso:11073:10101");
    cs.setVersion("[todo]");
    cs.setName("11073:10101 codes for the FHIR community");
    cs.setStatus(PublicationStatus.ACTIVE);
    cs.setExperimental(false);
    cs.setDateElement(new DateTimeType());
    cs.setPublisher("HL7 (FHIR Project)");
    ContactDetail cd = cs.addContact();
    ContactPoint cp = cd.addTelecom();
    cp.setSystem(ContactPointSystem.URL);
    cp.setValue("http://ieee?");
    cs.setDescription("1073 Codes for the FHIR community (generated from the Rosetta data");
    Identifier i = new Identifier();
    cs.setIdentifier(i);
    i.setSystem("urn:ietf:rfc:3986");
    i.setValue("urn:oid:2.16.840.1.113883.6.24");
    cs.setCaseSensitive(false);
    cs.setContent(CodeSystemContentMode.COMPLETE);
    cs.addProperty().setCode("ucum").setDescription("UCUM units associated with Concept").setType(PropertyType.STRING);
    cs.addProperty().setCode("unit").setDescription("MDC units associated with Concept").setType(PropertyType.STRING);
    cs.addProperty().setCode("refid").setDescription("MDC Reference Id for Concept").setType(PropertyType.CODE);
    Set<String> codes = new HashSet<String>();
    while (csv.line()) {
        if (csv.has("CF_CODE10")) {
            String code = csv.cell("CF_CODE10");
            if (codes.contains(code))
                System.out.println("Duplicate Code " + code);
            else {
                codes.add(code);
                ConceptDefinitionComponent c = cs.addConcept();
                c.setCode(code);
                c.setDisplay(csv.cell("Common Term"));
                c.setDefinition(csv.cell("Term Description"));
                String vd = csv.cell("Vendor_Description");
                if (!c.hasDefinition())
                    c.setDefinition(vd);
                if (!c.hasDisplay())
                    c.setDisplay(vd);
                String refid = csv.cell("REFID");
                c.addProperty().setCode("refid").setValue(new CodeType().setValue(refid));
                if (csv.has("Synonym"))
                    c.addDesignation().setValue(csv.cell("Synonym")).setUse(new Coding().setSystem("http://hl7.org/fhir/designation-use").setCode("synonym"));
                if (csv.has("Acronym"))
                    c.addDesignation().setValue(csv.cell("Acronym")).setUse(new Coding().setSystem("http://hl7.org/fhir/designation-use").setDisplay("acronym"));
                if (csv.has("Systematic Name")) {
                    String sysName = csv.cell("Systematic Name");
                    if (!c.hasDefinition())
                        c.setDefinition(sysName);
                    c.addDesignation().setValue(sysName).setUse(new Coding().setSystem("http://hl7.org/fhir/designation-use").setCode("structured-name"));
                }
                if (csv.has("UOM_MDC"))
                    c.addProperty().setCode("unit").setValue(new StringType().setValue(csv.cell("UOM_MDC")));
                if (csv.has("UOM_UCUM")) {
                    CommaSeparatedStringBuilder ul = new CommaSeparatedStringBuilder();
                    for (String u : csv.cell("UOM_UCUM").split(" ")) {
                        String msg = ucum.validate(u);
                        if (msg != null) {
                            errorCount++;
                            ucumIssues.put(u, msg);
                        } else
                            ul.append(u);
                    }
                    if (ul.length() > 0)
                        c.addProperty().setCode("ucum").setValue(new StringType().setValue(ul.toString()));
                }
            }
        }
    }
    csv.close();
    new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dst, "codesystem-" + cs.getId() + ".xml")), cs);
    System.out.println(errorCount + "UCUM errors");
    for (String u : sorted(ucumIssues.keySet())) System.out.println("Invalid UCUM code: " + u + " because " + ucumIssues.get(u));
    return cs;
}
Also used : XmlParser(org.hl7.fhir.dstu3.formats.XmlParser) CSVReader(org.hl7.fhir.utilities.CSVReader) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) FileInputStream(java.io.FileInputStream) ConceptDefinitionComponent(org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent) FileOutputStream(java.io.FileOutputStream)

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