use of org.hl7.fhir.r4b.renderers.utils.BaseWrappers.ResourceWrapper in project org.hl7.fhir.core by hapifhir.
the class ResourceRenderer method renderCanonical.
public void renderCanonical(ResourceWrapper rw, XhtmlNode x, String url, boolean allowLinks) throws UnsupportedEncodingException, IOException {
if (url == null) {
return;
}
Resource target = context.getWorker().fetchResource(Resource.class, url);
if (target == null || !(target instanceof CanonicalResource)) {
x.code().tx(url);
} else {
CanonicalResource cr = (CanonicalResource) target;
if (url.contains("|")) {
if (target.hasUserData("path")) {
x.ah(target.getUserString("path")).tx(cr.present() + " (version " + cr.getVersion() + ")");
} else {
url = url.substring(0, url.indexOf("|"));
x.code().tx(url);
x.tx(": " + cr.present() + " (version " + cr.getVersion() + ")");
}
} else {
if (target.hasUserData("path")) {
x.ah(target.getUserString("path")).tx(cr.present());
} else {
url = url.substring(0, url.indexOf("|"));
x.code().tx(url);
x.tx(": " + cr.present());
}
}
}
}
use of org.hl7.fhir.r4b.renderers.utils.BaseWrappers.ResourceWrapper in project org.hl7.fhir.core by hapifhir.
the class ResourceRenderer method render.
public XhtmlNode render(ResourceWrapper r) throws IOException, FHIRException, EOperationOutcome {
assert r.getContext() == context;
XhtmlNode x = new XhtmlNode(NodeType.Element, "div");
boolean hasExtensions = render(x, r);
if (r.hasNarrative()) {
r.injectNarrative(x, hasExtensions ? NarrativeStatus.EXTENSIONS : NarrativeStatus.GENERATED);
}
return x;
}
use of org.hl7.fhir.r4b.renderers.utils.BaseWrappers.ResourceWrapper in project org.hl7.fhir.core by hapifhir.
the class ResourceRenderer method renderReference.
public void renderReference(ResourceWrapper rw, XhtmlNode x, Reference r, boolean allowLinks) throws UnsupportedEncodingException, IOException {
if (r == null) {
x.tx("null!");
return;
}
XhtmlNode c = null;
ResourceWithReference tr = null;
if (r.hasReferenceElement() && allowLinks) {
tr = resolveReference(rw, r.getReference());
if (!r.getReference().startsWith("#")) {
if (tr != null && tr.getReference() != null)
c = x.ah(tr.getReference());
else
c = x.ah(r.getReference());
} else {
c = x.ah(r.getReference());
}
} else {
c = x.span(null, null);
}
if (tr != null && tr.getReference() != null && tr.getReference().startsWith("#")) {
c.tx("See above (");
}
// what to display: if text is provided, then that. if the reference was resolved, then show the name, or the generated narrative
String display = r.hasDisplayElement() ? r.getDisplay() : null;
String name = tr != null && tr.getResource() != null ? tr.getResource().getNameFromResource() : null;
if (display == null && (tr == null || tr.getResource() == null)) {
c.addText(r.getReference());
} else if (context.isTechnicalMode()) {
c.addText(r.getReference());
if (display != null) {
c.addText(": " + display);
}
if ((tr == null || !tr.getReference().startsWith("#")) && name != null) {
x.addText(" \"" + name + "\"");
}
if (r.hasExtension(ToolingExtensions.EXT_TARGET_ID)) {
x.addText("(#" + r.getExtensionString(ToolingExtensions.EXT_TARGET_ID) + ")");
} else if (r.hasExtension(ToolingExtensions.EXT_TARGET_PATH)) {
x.addText("(#/" + r.getExtensionString(ToolingExtensions.EXT_TARGET_PATH) + ")");
}
} else {
if (display != null) {
c.addText(display);
} else if (name != null) {
c.addText(name);
} else {
c.tx(". Generated Summary: ");
if (tr != null) {
new ProfileDrivenRenderer(context).generateResourceSummary(c, tr.getResource(), true, r.getReference().startsWith("#"), true);
}
}
}
if (tr != null && tr.getReference() != null && tr.getReference().startsWith("#")) {
c.tx(")");
}
}
use of org.hl7.fhir.r4b.renderers.utils.BaseWrappers.ResourceWrapper in project org.hl7.fhir.core by hapifhir.
the class ResourceRenderer method renderReference.
public void renderReference(ResourceWrapper rw, XhtmlNode x, BaseWrapper r) throws UnsupportedEncodingException, IOException {
XhtmlNode c = x;
ResourceWithReference tr = null;
String v;
if (r.has("reference")) {
v = r.get("reference").primitiveValue();
tr = resolveReference(rw, v);
if (!v.startsWith("#")) {
if (tr != null && tr.getReference() != null)
c = x.ah(tr.getReference());
else
c = x.ah(v);
}
} else {
v = "";
}
// what to display: if text is provided, then that. if the reference was resolved, then show the generated narrative
if (r.has("display")) {
c.addText(r.get("display").primitiveValue());
if (tr != null && tr.getResource() != null) {
c.tx(". Generated Summary: ");
new ProfileDrivenRenderer(context).generateResourceSummary(c, tr.getResource(), true, v.startsWith("#"), false);
}
} else if (tr != null && tr.getResource() != null) {
new ProfileDrivenRenderer(context).generateResourceSummary(c, tr.getResource(), v.startsWith("#"), v.startsWith("#"), false);
} else {
c.addText(v);
}
}
use of org.hl7.fhir.r4b.renderers.utils.BaseWrappers.ResourceWrapper in project org.hl7.fhir.core by hapifhir.
the class PatientRenderer method describe.
public void describe(XhtmlNode x, ResourceWrapper pat) throws UnsupportedEncodingException, IOException {
Identifier id = null;
PropertyWrapper pw = getProperty(pat, "identifier");
for (BaseWrapper t : pw.getValues()) {
id = chooseId(id, (Identifier) t.getBase());
}
pw = getProperty(pat, "name");
HumanName n = null;
for (BaseWrapper t : pw.getValues()) {
n = chooseName(n, (HumanName) t.getBase());
}
String gender = null;
pw = getProperty(pat, "gender");
if (valued(pw)) {
pw.value().getBase().primitiveValue();
}
DateType dt = null;
pw = getProperty(pat, "birthDate");
if (valued(pw)) {
dt = (DateType) pw.value().getBase();
}
describe(x, n, gender, dt, id);
}
Aggregations