Search in sources :

Example 51 with Value

use of org.hl7.fhir.utilities.graphql.Value in project kindling by HL7.

the class PageProcessor method expandValueSetIG.

private String expandValueSetIG(ValueSet vs, boolean heirarchy) throws Exception {
    if (!hasDynamicContent(vs))
        return "";
    try {
        ValueSetExpansionOutcome result = workerContext.expandVS(vs, true, heirarchy);
        if (result.getError() != null)
            return "<hr/>\r\n" + VS_INC_START + "<!--1-->" + processExpansionError(result.getError()) + VS_INC_END;
        ValueSet exp = result.getValueset();
        if (exp == vs)
            throw new Exception("Expansion cannot be the same instance");
        exp.setCompose(null);
        exp.setText(null);
        exp.setDescription("Value Set Contents (Expansion) for " + vs.present() + " at " + Config.DATE_FORMAT().format(new Date()));
        RenderingContext lrc = rc.copy().setTooCostlyNoteEmpty(TOO_MANY_CODES_TEXT_EMPTY).setTooCostlyNoteNotEmpty(TOO_MANY_CODES_TEXT_NOT_EMPTY);
        RendererFactory.factory(exp, lrc).render(exp);
        return "<hr/>\r\n" + VS_INC_START + "" + new XhtmlComposer(XhtmlComposer.HTML).compose(exp.getText().getDiv()) + VS_INC_END;
    } catch (Exception e) {
        return "<hr/>\r\n" + VS_INC_START + "<!--2-->" + processExpansionError(e.getMessage()) + VS_INC_END;
    }
}
Also used : RenderingContext(org.hl7.fhir.r5.renderers.utils.RenderingContext) XhtmlComposer(org.hl7.fhir.utilities.xhtml.XhtmlComposer) ValueSetExpansionOutcome(org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome) ValueSet(org.hl7.fhir.r5.model.ValueSet) 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) Date(java.util.Date)

Example 52 with Value

use of org.hl7.fhir.utilities.graphql.Value in project kindling by HL7.

the class PageProcessor method generateValueSetUsage.

private String generateValueSetUsage(ValueSet vs, String prefix, boolean addTitle) throws Exception {
    List<String> items = new ArrayList<>();
    if (vs.hasUrl()) {
        for (CodeSystem cs : getCodeSystems().getList()) {
            if (cs != null) {
                if (vs.getUrl().equals(cs.getValueSet())) {
                    String p = cs.getUserString("path");
                    addItem(items, "<li>CodeSystem: This value set is the designated 'entire code system' value set for <a href=\"" + (Utilities.isAbsoluteUrl(p) ? "" : prefix) + p + "\">" + cs.getName() + "</a> " + "</li>\r\n");
                }
            }
        }
    }
    for (ConceptMap cm : getConceptMaps().getList()) {
        String p = cm.getUserString("path");
        if (cm.hasSourceUriType() && cm.getSourceUriType().equals(vs.getUrl())) {
            addItem(items, "<li>ConceptMap: Translation source in <a href=\"" + (Utilities.isAbsoluteUrl(p) ? "" : prefix) + p + "\">" + cm.present() + "</a> " + "</li>\r\n");
        } else if (cm.hasSourceCanonicalType() && (cm.getSourceCanonicalType().getValue().equals(vs.getUrl()) || vs.getUrl().endsWith("/" + cm.getSourceCanonicalType().getValue()))) {
            addItem(items, "<li>ConceptMap: Translation source in <a href=\"" + (Utilities.isAbsoluteUrl(p) ? "" : prefix) + p + "\">" + cm.getName() + "</a> " + "</li>\r\n");
        }
    }
    for (ConceptMap cm : getConceptMaps().getList()) {
        String p = cm.getUserString("path");
        if (cm.hasTargetUriType() && cm.getTargetUriType().equals(vs.getUrl())) {
            addItem(items, "<li>ConceptMap: Translation target in <a href=\"" + (Utilities.isAbsoluteUrl(p) ? "" : prefix) + p + "\">" + cm.present() + "</a> " + "</li>\r\n");
        } else if (cm.hasTargetCanonicalType() && (cm.getTargetCanonicalType().getValue().equals(vs.getUrl()) || vs.getUrl().endsWith("/" + cm.getTargetCanonicalType().getValue()))) {
            addItem(items, "<li>ConceptMap: Translation target ConceptMap <a href=\"" + (Utilities.isAbsoluteUrl(p) ? "" : prefix) + p + "\">" + cm.getName() + "</a> " + "</li>\r\n");
        }
    }
    for (ResourceDefn r : definitions.getBaseResources().values()) {
        scanForUsage(items, vs, r.getRoot(), r.getName().toLowerCase() + "-definitions.html", prefix);
        scanForOperationUsage(items, vs, r, r.getName().toLowerCase() + "-operation-", prefix);
        scanForProfileUsage(items, vs, r, prefix);
    }
    for (ResourceDefn r : definitions.getResources().values()) {
        scanForUsage(items, vs, r.getRoot(), r.getName().toLowerCase() + "-definitions.html", prefix);
        scanForOperationUsage(items, vs, r, r.getName().toLowerCase() + "-operation-", prefix);
        scanForProfileUsage(items, vs, r, prefix);
    }
    for (ElementDefn e : definitions.getInfrastructure().values()) {
        scanForUsage(items, vs, e, definitions.getSrcFile(e.getName()) + "-definitions.html", prefix);
    }
    for (ElementDefn e : definitions.getTypes().values()) {
        if (!definitions.dataTypeIsSharedInfo(e.getName())) {
            scanForUsage(items, vs, e, definitions.getSrcFile(e.getName()) + "-definitions.html", prefix);
        }
    }
    for (StructureDefinition sd : workerContext.getExtensionDefinitions()) {
        scanForUsage(items, vs, sd, sd.getUserString("path"), prefix);
    }
    for (ValueSet vsi : definitions.getValuesets().getList()) {
        String path = (String) vsi.getUserData("path");
        if (vs.hasCompose()) {
            for (ConceptSetComponent t : vs.getCompose().getInclude()) {
                for (UriType uri : t.getValueSet()) {
                    if (uri.getValue().equals(vs.getUrl())) {
                        addItem(items, "<li>ValueSet: Included in <a href=\"" + prefix + path + "\">" + Utilities.escapeXml(vs.present()) + "</a></li>\r\n");
                    }
                }
            }
            for (ConceptSetComponent t : vs.getCompose().getExclude()) {
                for (UriType uri : t.getValueSet()) {
                    if (uri.getValue().equals(vs.getUrl())) {
                        addItem(items, "<li>ValueSet: Excluded from  <a href=\"" + prefix + path + "\">" + Utilities.escapeXml(vs.present()) + "</a></li>\r\n");
                    }
                }
            }
        // for (ConceptSetComponent t : vsi.getCompose().getInclude()) {
        // if (vs.hasCodeSystem() && t.getSystem().equals(vs.getCodeSystem().getSystem()))
        // b.append(" <li>Included in Valueset <a href=\""+prefix+path+"\">"+Utilities.escapeXml(vs.getName())+"</a></li>\r\n");
        // }
        // for (ConceptSetComponent t : vsi.getCompose().getExclude()) {
        // if (vs.hasCodeSystem() && t.getSystem().equals(vs.getCodeSystem().getSystem()))
        // b.append(" <li>Excluded in Valueset <a href=\""+prefix+path+"\">"+Utilities.escapeXml(vs.getName())+"</a></li>\r\n");
        // }
        }
    }
    if (ini.getPropertyNames(vs.getUrl()) != null) {
        for (String n : ini.getPropertyNames(vs.getUrl())) {
            addItem(items, "<li>" + ini.getStringProperty(vs.getUrl(), n) + "</li>\r\n");
        }
    }
    if (items.size() == 0)
        return "<p>\r\nThis value set is not currently used\r\n</p>\r\n";
    else {
        StringBuilder b = new StringBuilder();
        for (String s : items) {
            b.append(" " + s);
        }
        return (addTitle ? "<p>\r\nThis value set is used in the following places:\r\n</p>\r\n" : "") + "<ul>\r\n" + b.toString() + "</ul>\r\n";
    }
}
Also used : ConceptSetComponent(org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent) StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) ArrayList(java.util.ArrayList) ElementDefn(org.hl7.fhir.definitions.model.ElementDefn) ConceptMap(org.hl7.fhir.r5.model.ConceptMap) CodeSystem(org.hl7.fhir.r5.model.CodeSystem) ResourceDefn(org.hl7.fhir.definitions.model.ResourceDefn) ValueSet(org.hl7.fhir.r5.model.ValueSet) UriType(org.hl7.fhir.r5.model.UriType)

Example 53 with Value

use of org.hl7.fhir.utilities.graphql.Value in project kindling by HL7.

the class PageProcessor method asText.

private String asText(List<CodeType> list) {
    StringBuilder b = new StringBuilder();
    boolean first = true;
    for (CodeType rn : list) {
        if (first) {
            first = false;
            b.append("<br/>(");
        } else
            b.append(", ");
        final String value = rn.getValue();
        if ("Any".equals(value))
            b.append("Any");
        else
            b.append("<a href=\"").append(value.toLowerCase()).append(".html\">").append(value).append("</a>");
    }
    if (!first)
        b.append(")");
    return b.toString();
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) CodeType(org.hl7.fhir.r5.model.CodeType)

Example 54 with Value

use of org.hl7.fhir.utilities.graphql.Value in project kindling by HL7.

the class PageProcessor method genNSList.

private String genNSList() throws Exception {
    StringBuilder b = new StringBuilder();
    b.append("<p>Redirects on this page:</p>\r\n");
    b.append("<ul>\r\n");
    b.append(" <li>Resources</li>\r\n");
    b.append(" <li>Data Types</li>\r\n");
    b.append(" <li>Code Systems</li>\r\n");
    b.append(" <li>Value Sets</li>\r\n");
    b.append(" <li>Extensions</li>\r\n");
    b.append(" <li>Profiles</li>\r\n");
    b.append(" <li>Naming Systems</li>\r\n");
    b.append(" <li>Examples</li>\r\n");
    b.append(" <li>Compartments</li>\r\n");
    b.append(" <li>Data Elements</li>\r\n");
    b.append(" <li>Search Parameters</li>\r\n");
    b.append(" <li>Implementation Guides</li>\r\n");
    b.append(" <li>SIDs</li>\r\n");
    b.append(" <li>Others From publish.ini</li>\r\n");
    b.append("</ul>\r\n");
    b.append("<table class=\"grid\">\r\n");
    b.append(" <tr><td><b>URL</b></td><td><b>Thing</b></td><td><b>Page</b></td></tr>");
    for (String n : definitions.sortedResourceNames()) definitions.addNs("http://hl7.org/fhir/" + n, n + " Resource", n.toLowerCase() + ".html");
    for (String n : definitions.getTypes().keySet()) definitions.addNs("http://hl7.org/fhir/" + n, "Data Type " + n, definitions.getSrcFile(n) + ".html#" + n);
    for (String n : definitions.getPrimitives().keySet()) definitions.addNs("http://hl7.org/fhir/" + n, "Primitive Data Type " + n, definitions.getSrcFile(n) + ".html#" + n);
    for (String n : definitions.getConstraints().keySet()) definitions.addNs("http://hl7.org/fhir/" + n, "Data Type Profile " + n, definitions.getSrcFile(n) + ".html#" + n);
    for (String n : definitions.getInfrastructure().keySet()) definitions.addNs("http://hl7.org/fhir/" + n, "Data Type " + n, definitions.getSrcFile(n) + ".html#" + n);
    for (CodeSystem cs : getCodeSystems().getList()) if (cs != null && cs.getUrl().startsWith("http://hl7.org/fhir"))
        definitions.addNs(cs.getUrl(), "CodeSystem " + cs.getName(), cs.getUserString("path"));
    for (ValueSet vs : getValueSets().getList()) if (vs.getUrl().startsWith("http://hl7.org/fhir"))
        definitions.addNs(vs.getUrl(), "ValueSet " + vs.present(), vs.getUserString("path"));
    for (ConceptMap cm : getConceptMaps().getList()) if (cm.getUrl().startsWith("http://hl7.org/fhir"))
        definitions.addNs(cm.getUrl(), "Concept Map" + cm.getName(), cm.getUserString("path"));
    for (StructureDefinition sd : profiles.getList()) if (sd.getUrl().startsWith("http://hl7.org/fhir") && !definitions.getResourceTemplates().containsKey(sd.getName()))
        definitions.addNs(sd.getUrl(), "Profile " + sd.getName(), sd.getUserString("path"));
    for (StructureDefinition sd : workerContext.getExtensionDefinitions()) if (sd.getUrl().startsWith("http://hl7.org/fhir"))
        definitions.addNs(sd.getUrl(), "Profile " + sd.getName(), sd.getUserString("path"));
    for (NamingSystem nss : definitions.getNamingSystems()) {
        String url = null;
        definitions.addNs("http://hl7.org/fhir/NamingSystem/" + nss.getId(), "System " + nss.getName(), nss.getUserString("path"));
        for (NamingSystemUniqueIdComponent t : nss.getUniqueId()) {
            if (t.getType() == NamingSystemIdentifierType.URI)
                url = t.getValue();
        }
        if (url != null && url.startsWith("http://hl7.org/fhir"))
            definitions.addNs(url, "System " + nss.getName(), nss.getUserString("path"));
    }
    for (String n : ini.getPropertyNames("redirects")) {
        String[] parts = ini.getStringProperty("redirects", n).split("\\;");
        definitions.addNs(n, "System " + parts[0], parts[1]);
    }
    for (ImplementationGuideDefn ig : definitions.getIgs().values()) {
        if (!ig.isCore()) {
            definitions.addNs("http://hl7.org/fhir/ImplementationGuide/" + ig.getCode(), ig.getName(), ig.getHomePage());
            definitions.addNs("http://hl7.org/fhir/" + ig.getCode(), ig.getName(), ig.getHomePage());
        }
    }
    for (Compartment t : definitions.getCompartments()) {
        definitions.addNs(t.getUri(), t.getName(), "compartmentdefinition.html#" + t.getName());
    }
    List<String> list = new ArrayList<String>();
    list.addAll(definitions.getRedirectList().keySet());
    Collections.sort(list);
    for (String url : list) {
        NamespacePair p = definitions.getRedirectList().get(url);
        b.append(" <tr><td>" + Utilities.escapeXml(url) + "</td><td>" + hsplt(Utilities.escapeXml(p.desc)) + "</td><td><a href=\"" + p.page + "\">" + hsplt(Utilities.escapeXml(p.page)) + "</a></td></tr>\r\n");
    }
    b.append("</table>\r\n");
    b.append("<p>" + Integer.toString(list.size()) + " Entries</p>\r\n");
    return b.toString();
}
Also used : NamingSystemUniqueIdComponent(org.hl7.fhir.r5.model.NamingSystem.NamingSystemUniqueIdComponent) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) Compartment(org.hl7.fhir.definitions.model.Compartment) ArrayList(java.util.ArrayList) ImplementationGuideDefn(org.hl7.fhir.definitions.model.ImplementationGuideDefn) CodeSystem(org.hl7.fhir.r5.model.CodeSystem) NamespacePair(org.hl7.fhir.definitions.model.Definitions.NamespacePair) StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) NamingSystem(org.hl7.fhir.r5.model.NamingSystem) ConceptMap(org.hl7.fhir.r5.model.ConceptMap) ValueSet(org.hl7.fhir.r5.model.ValueSet)

Example 55 with Value

use of org.hl7.fhir.utilities.graphql.Value in project kindling by HL7.

the class CDAGenerator method finish.

private void finish() throws FileNotFoundException, IOException {
    StringBuilder b = new StringBuilder();
    for (StructureDefinition sd : structures) {
        new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(target, sd.getId() + ".xml")), sd);
        b.append("   <resource>\r\n" + "     <purpose value=\"logical\"/>\r\n" + "     <name value=\"" + sd.getName() + "\"/>\r\n" + "     <sourceUri value=\"cda\\cda-logical-" + sd.getId() + ".xml\"/>\r\n" + "   </resource>\r\n");
    }
    TextFile.stringToFile(b.toString(), Utilities.path(target, "ig-template.xml"));
// dumpPaths();
}
Also used : XmlParser(org.hl7.fhir.r5.formats.XmlParser) StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) FileOutputStream(java.io.FileOutputStream)

Aggregations

Test (org.junit.jupiter.api.Test)222 ArrayList (java.util.ArrayList)183 FHIRException (org.hl7.fhir.exceptions.FHIRException)107 List (java.util.List)97 DisplayName (org.junit.jupiter.api.DisplayName)96 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)89 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)85 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)70 Identifier (org.hl7.fhir.r4.model.Identifier)69 Test (org.junit.Test)66 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)64 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)54 IOException (java.io.IOException)52 Bundle (org.hl7.fhir.r4.model.Bundle)49 Coding (org.hl7.fhir.r4.model.Coding)49 ValueSet (org.hl7.fhir.r5.model.ValueSet)48 PathEngineException (org.hl7.fhir.exceptions.PathEngineException)46 Resource (org.hl7.fhir.r4.model.Resource)46 BigDecimal (java.math.BigDecimal)45 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)44