Search in sources :

Example 1 with DataRenderer

use of org.hl7.fhir.r4b.renderers.DataRenderer in project org.hl7.fhir.core by hapifhir.

the class NarrativeGeneratorTests method checkDateTimeRendering.

private void checkDateTimeRendering(String src, String lang, String country, ZoneId tz, String fmt, ResourceRendererMode mode, String... expected) throws FHIRFormatError, DefinitionException, IOException {
    rc.setLocale(new java.util.Locale(lang, country));
    rc.setTimeZoneId(tz);
    if (fmt == null) {
        rc.setDateTimeFormat(null);
        rc.setDateFormat(null);
    } else {
        // really, it would be better to test patterns based on FormatStyle here, since
        // that's what will be used in the real world, but
        rc.setDateTimeFormat(DateTimeFormatter.ofPattern(fmt));
        rc.setDateFormat(DateTimeFormatter.ofPattern(fmt));
    }
    rc.setMode(mode);
    DateTimeType dt = new DateTimeType(src);
    String actual = new DataRenderer(rc).display(dt);
    Assert.assertTrue("Actual = " + actual + ", expected one of " + Utilities.toString(expected), Utilities.existsInList(actual, expected));
    XhtmlNode node = new XhtmlNode(NodeType.Element, "p");
    new DataRenderer(rc).render(node, dt);
    actual = new XhtmlComposer(true, false).compose(node);
    Assert.assertTrue(actual.startsWith("<p>"));
    Assert.assertTrue(actual.endsWith("</p>"));
    Assert.assertTrue("Actual = " + actual + ", expected one of " + Utilities.toString(expected), Utilities.existsInList(actual.substring(0, actual.length() - 4).substring(3), expected));
}
Also used : DateTimeType(org.hl7.fhir.r5.model.DateTimeType) DataRenderer(org.hl7.fhir.r5.renderers.DataRenderer) XhtmlComposer(org.hl7.fhir.utilities.xhtml.XhtmlComposer) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 2 with DataRenderer

use of org.hl7.fhir.r4b.renderers.DataRenderer in project org.hl7.fhir.core by hapifhir.

the class AdditionalBindingsRenderer method render.

private void render(List<XhtmlNode> children, boolean doDoco) throws FHIRFormatError, DefinitionException, IOException {
    boolean doco = false;
    boolean usage = false;
    boolean any = false;
    for (AdditionalBindingDetail binding : bindings) {
        doco = doco || (doDoco && binding.doco != null);
        usage = usage || binding.usage != null;
        any = any || binding.any;
    }
    XhtmlNode tr = new XhtmlNode(NodeType.Element, "tr");
    children.add(tr);
    tr.td().style("font-size: 11px").b().tx("Additional Bindings");
    tr.td().style("font-size: 11px").tx("Purpose");
    if (usage) {
        tr.td().style("font-size: 11px").tx("Usage");
    }
    if (any) {
        tr.td().style("font-size: 11px").tx("Any");
    }
    if (doco) {
        tr.td().style("font-size: 11px").tx("Documentation");
    }
    for (AdditionalBindingDetail binding : bindings) {
        tr = new XhtmlNode(NodeType.Element, "tr");
        if (binding.unchanged) {
            tr.style("opacity: 0.5");
        }
        children.add(tr);
        BindingResolution br = pkp == null ? makeNullBr(binding) : pkp.resolveBinding(profile, binding.valueSet, path);
        if (br.url != null) {
            tr.td().style("font-size: 11px").ah(Utilities.isAbsoluteUrl(br.url) || !pkp.prependLinks() ? br.url : corePath + br.url, binding.valueSet).tx(br.display);
        } else {
            tr.td().style("font-size: 11px").span(null, binding.valueSet).tx(br.display);
        }
        renderPurpose(tr.td().style("font-size: 11px"), binding.purpose);
        if (usage) {
            if (binding.usage != null) {
                new DataRenderer(context).render(tr.td(), binding.usage);
            } else {
                tr.td();
            }
        }
        if (any) {
            if (binding.any) {
                tr.td().style("font-size: 11px").tx("Any repeat");
            } else {
                tr.td().style("font-size: 11px").tx("All repeats");
            }
        }
        if (doco) {
            if (binding.doco != null) {
                String d = md.processMarkdown("Binding.description", binding.doco);
                tr.td().style("font-size: 11px").innerHTML(d);
            } else {
                tr.td().style("font-size: 11px");
            }
        }
    }
}
Also used : BindingResolution(org.hl7.fhir.r5.conformance.ProfileUtilities.ProfileKnowledgeProvider.BindingResolution) DataRenderer(org.hl7.fhir.r5.renderers.DataRenderer) AdditionalBindingDetail(org.hl7.fhir.r5.conformance.AdditionalBindingsRenderer.AdditionalBindingDetail) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 3 with DataRenderer

use of org.hl7.fhir.r4b.renderers.DataRenderer in project kindling by HL7.

the class PageProcessor method getProfileContext.

private String getProfileContext(CanonicalResource mr, String prefix) throws DefinitionException {
    DataRenderer gen = new DataRenderer(workerContext);
    CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
    for (UsageContext uc : mr.getUseContext()) {
        String vs = gen.display(uc.getValue());
        if (vs != null)
            b.append(gen.display(uc.getCode()) + ": " + vs);
    }
    for (CodeableConcept cc : mr.getJurisdiction()) {
        b.append("Country: " + gen.displayCodeableConcept(cc));
    }
    if (mr.getExperimental()) {
        if (isTrialUse(mr))
            b.append("Not yet ready for Production use");
        else
            b.append("Not Intended for Production use");
    }
    if (b.length() == 0)
        return "<a href=\"" + prefix + "metadatatypes.html#UsageContext\">Use Context</a>: Any";
    else
        return "<a href=\"" + prefix + "metadatatypes.html#UsageContext\">Use Context</a>: " + b.toString();
}
Also used : DataRenderer(org.hl7.fhir.r5.renderers.DataRenderer) UsageContext(org.hl7.fhir.r5.model.UsageContext) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) CodeableConcept(org.hl7.fhir.r5.model.CodeableConcept)

Example 4 with DataRenderer

use of org.hl7.fhir.r4b.renderers.DataRenderer in project org.hl7.fhir.core by hapifhir.

the class NarrativeGeneratorTests method checkDateTimeRendering.

private void checkDateTimeRendering(String src, String lang, String country, ZoneId tz, String fmt, ResourceRendererMode mode, String... expected) throws FHIRFormatError, DefinitionException, IOException {
    rc.setLocale(new java.util.Locale(lang, country));
    rc.setTimeZoneId(tz);
    if (fmt == null) {
        rc.setDateTimeFormat(null);
        rc.setDateFormat(null);
    } else {
        // really, it would be better to test patterns based on FormatStyle here, since
        // that's what will be used in the real world, but
        rc.setDateTimeFormat(DateTimeFormatter.ofPattern(fmt));
        rc.setDateFormat(DateTimeFormatter.ofPattern(fmt));
    }
    rc.setMode(mode);
    DateTimeType dt = new DateTimeType(src);
    String actual = new DataRenderer(rc).display(dt);
    Assert.assertTrue("Actual = " + actual + ", expected one of " + Utilities.toString(expected), Utilities.existsInList(actual, expected));
    XhtmlNode node = new XhtmlNode(NodeType.Element, "p");
    new DataRenderer(rc).render(node, dt);
    actual = new XhtmlComposer(true, false).compose(node);
    Assert.assertTrue(actual.startsWith("<p>"));
    Assert.assertTrue(actual.endsWith("</p>"));
    Assert.assertTrue("Actual = " + actual + ", expected one of " + Utilities.toString(expected), Utilities.existsInList(actual.substring(0, actual.length() - 4).substring(3), expected));
}
Also used : DateTimeType(org.hl7.fhir.r4b.model.DateTimeType) DataRenderer(org.hl7.fhir.r4b.renderers.DataRenderer) Locale(java.util.Locale) XhtmlComposer(org.hl7.fhir.utilities.xhtml.XhtmlComposer) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 5 with DataRenderer

use of org.hl7.fhir.r4b.renderers.DataRenderer in project org.hl7.fhir.core by hapifhir.

the class AdditionalBindingsRenderer method render.

private void render(List<XhtmlNode> children, boolean doDoco) throws FHIRFormatError, DefinitionException, IOException {
    boolean doco = false;
    boolean usage = false;
    boolean any = false;
    for (AdditionalBindingDetail binding : bindings) {
        doco = doco || (doDoco && binding.doco != null);
        usage = usage || binding.usage != null;
        any = any || binding.any;
    }
    XhtmlNode tr = new XhtmlNode(NodeType.Element, "tr");
    children.add(tr);
    tr.td().style("font-size: 11px").b().tx("Additional Bindings");
    tr.td().style("font-size: 11px").tx("Purpose");
    if (usage) {
        tr.td().style("font-size: 11px").tx("Usage");
    }
    if (any) {
        tr.td().style("font-size: 11px").tx("Any");
    }
    if (doco) {
        tr.td().style("font-size: 11px").tx("Documentation");
    }
    for (AdditionalBindingDetail binding : bindings) {
        tr = new XhtmlNode(NodeType.Element, "tr");
        if (binding.unchanged) {
            tr.style("opacity: 0.5");
        }
        children.add(tr);
        BindingResolution br = pkp == null ? makeNullBr(binding) : pkp.resolveBinding(profile, binding.valueSet, path);
        if (br.url != null) {
            tr.td().style("font-size: 11px").ah(Utilities.isAbsoluteUrl(br.url) || !pkp.prependLinks() ? br.url : corePath + br.url, binding.valueSet).tx(br.display);
        } else {
            tr.td().style("font-size: 11px").span(null, binding.valueSet).tx(br.display);
        }
        renderPurpose(tr.td().style("font-size: 11px"), binding.purpose);
        if (usage) {
            if (binding.usage != null) {
                new DataRenderer(context).render(tr.td(), binding.usage);
            } else {
                tr.td();
            }
        }
        if (any) {
            if (binding.any) {
                tr.td().style("font-size: 11px").tx("Any repeat");
            } else {
                tr.td().style("font-size: 11px").tx("All repeats");
            }
        }
        if (doco) {
            if (binding.doco != null) {
                String d = md.processMarkdown("Binding.description", binding.doco);
                tr.td().style("font-size: 11px").innerHTML(d);
            } else {
                tr.td().style("font-size: 11px");
            }
        }
    }
}
Also used : BindingResolution(org.hl7.fhir.r4b.conformance.ProfileUtilities.ProfileKnowledgeProvider.BindingResolution) DataRenderer(org.hl7.fhir.r4b.renderers.DataRenderer) AdditionalBindingDetail(org.hl7.fhir.r4b.conformance.AdditionalBindingsRenderer.AdditionalBindingDetail) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Aggregations

XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)4 DataRenderer (org.hl7.fhir.r5.renderers.DataRenderer)3 DataRenderer (org.hl7.fhir.r4b.renderers.DataRenderer)2 XhtmlComposer (org.hl7.fhir.utilities.xhtml.XhtmlComposer)2 Locale (java.util.Locale)1 AdditionalBindingDetail (org.hl7.fhir.r4b.conformance.AdditionalBindingsRenderer.AdditionalBindingDetail)1 BindingResolution (org.hl7.fhir.r4b.conformance.ProfileUtilities.ProfileKnowledgeProvider.BindingResolution)1 DateTimeType (org.hl7.fhir.r4b.model.DateTimeType)1 AdditionalBindingDetail (org.hl7.fhir.r5.conformance.AdditionalBindingsRenderer.AdditionalBindingDetail)1 BindingResolution (org.hl7.fhir.r5.conformance.ProfileUtilities.ProfileKnowledgeProvider.BindingResolution)1 CodeableConcept (org.hl7.fhir.r5.model.CodeableConcept)1 DateTimeType (org.hl7.fhir.r5.model.DateTimeType)1 UsageContext (org.hl7.fhir.r5.model.UsageContext)1 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)1