Search in sources :

Example 46 with Value

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

the class PageProcessor method getNormativeList.

private String getNormativeList(String genlevel, String name) {
    Map<String, PageInfo> map = normativePackages.get(name);
    if (map.size() == 0) {
        return "<p>No Content Yet</p>";
    } else {
        StringBuilder b = new StringBuilder();
        b.append("<div style=\"border: 1px grey solid; padding: 5px\">\r\n");
        // b.append("<ul style=\"column-count: 3\">\r\n");
        // for (String s : sorted(map.keySet())) {
        // b.append("  <li><a href=\""+s+"\">"+map.get(s)+"</a></li>\r\n");
        // }
        // b.append("</ul></div>\r\n");
        b.append("<table class=\"none\"><tr>\r\n");
        // pages, resources, operations, value sets, code systems
        normativeCell(b, map, PageInfoType.PAGE);
        normativeCell(b, map, PageInfoType.RESOURCE);
        normativeCell(b, map, PageInfoType.OPERATION);
        normativeCell(b, map, PageInfoType.VALUESET);
        normativeCell(b, map, PageInfoType.CODESYSTEM);
        b.append("</tr></table></div>\r\n");
        return b.toString();
    }
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder)

Example 47 with Value

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

the class PageProcessor method resolveBinding.

public BindingResolution resolveBinding(StructureDefinition profile, String ref, String description, String path) throws FHIRException {
    BindingResolution br = new BindingResolution();
    if (ref.contains("|"))
        ref = ref.substring(0, ref.indexOf("|"));
    if (ref.startsWith("http://terminology.hl7.org/ValueSet/v3-") || ref.startsWith("http://terminology.hl7.org/ValueSet/v2-")) {
        ValueSet vs = workerContext.fetchResource(ValueSet.class, ref);
        if (vs == null) {
            br.url = "v3/" + ref.substring(39) + "/vs.html";
            br.display = ref.substring(39);
        } else {
            br.url = vs.getUserString("path");
            br.display = vs.present();
        }
    } else if (definitions.getValuesets().has(ref)) {
        ValueSet vs = definitions.getValuesets().get(ref);
        br.url = vs.getUserString("path");
        br.display = vs.present();
    } else if (ref.startsWith("ValueSet/")) {
        ValueSet vs = definitions.getValuesets().get(ref.substring(8));
        if (vs == null) {
            br.url = ref.substring(9) + ".html";
            br.display = ref.substring(9);
        } else {
            br.url = vs.getUserString("path");
            br.display = vs.present();
        }
    } else if (ref.startsWith("http://hl7.org/fhir/ValueSet/")) {
        ValueSet vs = definitions.getValuesets().get(ref);
        if (vs == null)
            vs = definitions.getExtraValuesets().get(ref);
        if (vs != null) {
            br.url = vs.getUserString("path");
            if (Utilities.noString(br.url))
                br.url = ref.substring(23) + ".html";
            br.display = vs.present();
        } else if (ref.substring(23).equals("use-context")) {
            // special case because this happens before the value set is created
            br.url = "valueset-" + ref.substring(23) + ".html";
            br.display = "Context of Use ValueSet";
        } else if (ref.startsWith("http://terminology.hl7.org/ValueSet/v3-")) {
            br.url = "v3/" + ref.substring(26) + "/index.html";
            br.display = ref.substring(26);
        } else if (ref.startsWith("http://terminology.hl7.org/ValueSet/v2-")) {
            br.url = "v2/" + ref.substring(26) + "/index.html";
            br.display = ref.substring(26);
        } else if (ref.startsWith("#")) {
            br.url = null;
            br.display = ref;
        } else {
            br.url = ref;
            br.display = "????";
            getValidationErrors().add(new ValidationMessage(Source.Publisher, IssueType.NOTFOUND, -1, -1, path, "Unresolved Value set " + ref, IssueSeverity.WARNING));
        }
    } else {
        br.url = ref;
        if (ref.equals("http://tools.ietf.org/html/bcp47"))
            br.display = "IETF BCP-47";
        else if (ref.equals("http://www.rfc-editor.org/bcp/bcp13.txt"))
            br.display = "IETF BCP-13";
        else if (ref.equals("http://www.ncbi.nlm.nih.gov/nuccore?db=nuccore"))
            br.display = "NucCore";
        else if (ref.equals("https://rtmms.nist.gov/rtmms/index.htm#!rosetta"))
            br.display = "Rosetta";
        else if (ref.equals("http://www.iso.org/iso/country_codes.htm"))
            br.display = "ISO Country Codes";
        else if (ref.equals("http://www.ncbi.nlm.nih.gov/clinvar/variation"))
            br.display = "ClinVar";
        else if (!Utilities.noString(description))
            br.display = description;
        else
            br.display = "????";
    }
    return br;
}
Also used : ValidationMessage(org.hl7.fhir.utilities.validation.ValidationMessage) ValueSet(org.hl7.fhir.r5.model.ValueSet)

Example 48 with Value

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

the class PageProcessor method profileDictionaryLink.

private String profileDictionaryLink(ConstraintStructure profile) {
    String uri = ToolingExtensions.readStringExtension(profile.getResource(), "http://hl7.org/fhir/StructureDefinition/datadictionary");
    if (Utilities.noString(uri))
        return "<!-- no uri -->";
    Dictionary dict = definitions.getDictionaries().get(uri);
    if (dict == null)
        return "<p>This profile specifies that the value of the " + profile.getResource().getSnapshot().getElement().get(0).getPath() + " resource must be a valid Observation as defined in the data dictionary (Unknown? - " + uri + ").</p>";
    else
        return "<p>This profile specifies that the value of the " + profile.getResource().getSnapshot().getElement().get(0).getPath() + " resource must be a valid Observation as defined in the data dictionary <a href=\"" + uri + ".html\">" + dict.getName() + "</a>.</p>";
}
Also used : Dictionary(org.hl7.fhir.definitions.model.Dictionary)

Example 49 with Value

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

the class PageProcessor method renderExample.

private void renderExample(StringBuilder b, OperationExample ex, String type) throws Exception {
    if (Utilities.noString(ex.getComment()))
        b.append("<p>" + type + ":</p>\r\n");
    else
        b.append("<p>" + processMarkdown("op-example", type + ": " + Utilities.capitalize(ex.getComment()), "") + "</p>\r\n");
    b.append("<pre>\r\n");
    String[] lines = ex.getContent().split("\\r\\n");
    for (String l : lines) {
        if (l.startsWith("$bundle ")) {
            b.append(Utilities.escapeXml("<Bundle xml=\"http://hl7.org/fhir\">\r\n"));
            b.append(Utilities.escapeXml("  <id value=\"" + UUID.randomUUID().toString().toLowerCase() + "\"/>\r\n"));
            b.append(Utilities.escapeXml("  <type value=\"searchset\"/>\r\n"));
            Example e = getExampleByRef(l.substring(8));
            addExample(b, e);
            for (Example x : e.getInbounds()) {
                addExample(b, x);
            }
            b.append(Utilities.escapeXml("</Bundle>\r\n"));
        } else {
            b.append(l);
            b.append("\r\n");
        }
    }
    b.append("</pre>\r\n");
}
Also used : Example(org.hl7.fhir.definitions.model.Example) OperationExample(org.hl7.fhir.definitions.model.Operation.OperationExample)

Example 50 with Value

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

the class PageProcessor method expandVS.

public String expandVS(ValueSet vs, String prefix, String base) {
    try {
        ValueSetExpansionOutcome result = workerContext.expandVS(vs, true, true);
        if (result.getError() != null)
            return "<hr/>\r\n" + VS_INC_START + "<!--3-->" + processExpansionError(result.getError()) + VS_INC_END;
        if (result.getValueset() == null)
            return "<hr/>\r\n" + VS_INC_START + "<!--4-->" + processExpansionError("(no error returned)") + 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()));
        int i = countContains(exp.getExpansion().getContains());
        IniFile sini = new IniFile(Utilities.path(folders.rootDir, "temp", "stats.ini"));
        sini.setIntegerProperty("valuesets", vs.getId(), i, null);
        sini.save();
        RenderingContext lrc = rc.copy().setLocalPrefix(prefix).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) {
        e.printStackTrace();
        return "<hr/>\r\n" + VS_INC_START + "<!--5-->" + processExpansionError(e instanceof NullPointerException ? "NullPointerException" : e.getMessage()) + " " + Utilities.escapeXml(stack(e)) + VS_INC_END;
    }
}
Also used : RenderingContext(org.hl7.fhir.r5.renderers.utils.RenderingContext) IniFile(org.hl7.fhir.utilities.IniFile) 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) ContactPoint(org.hl7.fhir.r5.model.ContactPoint)

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