Search in sources :

Example 26 with ValueSet

use of org.hl7.fhir.dstu2.model.ValueSet in project kindling by HL7.

the class PageProcessor method generateVSforNS.

private void generateVSforNS(StringBuilder s, String ns, CanonicalResourceManager<ValueSet> vslist, boolean hasId, ImplementationGuideDefn ig) throws FHIRException {
    List<String> sorts = new ArrayList<String>();
    for (ValueSet vs : vslist.getList()) {
        ImplementationGuideDefn vig = (ImplementationGuideDefn) vs.getUserData(ToolResourceUtilities.NAME_RES_IG);
        if (ig == vig) {
            String n = getNamespace(vs.getUrl());
            if (ns.equals(n) && !vs.getUrl().startsWith("http://terminology.hl7.org/ValueSet/v2-") && !vs.getUrl().startsWith("http://terminology.hl7.org/ValueSet/v3-"))
                sorts.add(vs.getUrl());
        }
    }
    if (!sorts.isEmpty()) {
        s.append(" <tr><td colspan=\"5\" style=\"background: #DFDFDF\"><b>Namespace: </b>" + ns + "</td></tr>\r\n");
        Collections.sort(sorts);
        for (String sn : sorts) {
            ValueSet ae = vslist.get(sn);
            String n = getTail(sn);
            ValueSet vs = ae;
            if (wantPublish(vs)) {
                String path = ae.hasUserData("external.url") ? ae.getUserString("external.url") : pathTail(Utilities.changeFileExt(ae.getUserString("path"), ".html"));
                s.append(" <tr><td><a href=\"" + path + "\">" + n + "</a>");
                if (StandardsStatus.NORMATIVE == ToolingExtensions.getStandardsStatus(vs))
                    s.append(" <a href=\"versions.html#std-process\" title=\"Normative Content\" class=\"normative-flag\">N</a>");
                s.append("</td><td>" + Utilities.escapeXml(vs.getDescription()) + "</td><td>" + sourceSummary(vs) + "</td>");
                if (hasId)
                    s.append("<td>" + Utilities.oidTail(ValueSetUtilities.getOID(ae)) + "</td>");
                s.append("</tr>\r\n");
            }
        }
    }
}
Also used : ArrayList(java.util.ArrayList) ImplementationGuideDefn(org.hl7.fhir.definitions.model.ImplementationGuideDefn) ValueSet(org.hl7.fhir.r5.model.ValueSet)

Example 27 with ValueSet

use of org.hl7.fhir.dstu2.model.ValueSet in project kindling by HL7.

the class ValueSetGenerator method genAbstractTypes.

private void genAbstractTypes(ValueSet vs) {
    if (!vs.hasCompose())
        vs.setCompose(new ValueSetComposeComponent());
    vs.getCompose().addInclude().setSystem("http://hl7.org/fhir/abstract-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 8: is " + ec + ", want to set to " + "fhir");
    }
    vs.setUserData("path", "valueset-" + vs.getId() + ".html");
    CodeSystem cs = new CodeSystem();
    cs.setUserData("filename", vs.getUserString("filename").replace("valueset-", "codesystem-"));
    cs.setUserData("path", vs.getUserString("path").replace("valueset-", "codesystem-"));
    CodeSystemConvertor.populate(cs, vs);
    cs.setUrl("http://hl7.org/fhir/abstract-types");
    cs.setVersion(version);
    cs.setCaseSensitive(true);
    cs.setContent(CodeSystemContentMode.COMPLETE);
    definitions.getCodeSystems().see(cs, packageInfo);
    cs.addConcept().setCode("Type").setDisplay("Type").setDefinition("A place holder that means any kind of data type");
    cs.addConcept().setCode("Any").setDisplay("Any").setDefinition("A place holder that means any kind of resource");
    markSpecialStatus(vs, cs, true);
}
Also used : CodeType(org.hl7.fhir.r5.model.CodeType) ValueSetComposeComponent(org.hl7.fhir.r5.model.ValueSet.ValueSetComposeComponent) CodeSystem(org.hl7.fhir.r5.model.CodeSystem)

Example 28 with ValueSet

use of org.hl7.fhir.dstu2.model.ValueSet 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)

Example 29 with ValueSet

use of org.hl7.fhir.dstu2.model.ValueSet 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 30 with ValueSet

use of org.hl7.fhir.dstu2.model.ValueSet 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)

Aggregations

ValueSet (org.hl7.fhir.r5.model.ValueSet)159 ValueSet (org.hl7.fhir.r4.model.ValueSet)116 Test (org.junit.jupiter.api.Test)115 ArrayList (java.util.ArrayList)101 FHIRException (org.hl7.fhir.exceptions.FHIRException)100 IOException (java.io.IOException)97 ValueSet (org.hl7.fhir.dstu3.model.ValueSet)59 ValueSet (org.hl7.fhir.r4b.model.ValueSet)59 FileNotFoundException (java.io.FileNotFoundException)58 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)56 TerminologyServiceException (org.hl7.fhir.exceptions.TerminologyServiceException)46 HashMap (java.util.HashMap)45 Test (org.junit.Test)45 CodeSystem (org.hl7.fhir.r5.model.CodeSystem)43 File (java.io.File)36 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)36 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)31 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)29 RestIntegrationTest (org.opencds.cqf.ruler.test.RestIntegrationTest)29 FileInputStream (java.io.FileInputStream)27