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));
}
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");
}
}
}
}
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();
}
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));
}
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");
}
}
}
}
Aggregations