changes after testing complete

This commit is contained in:
Grahame Grieve 2024-06-20 09:57:25 +10:00
parent 31a7793c49
commit d23052f329
19 changed files with 323 additions and 198 deletions

View File

@ -56,7 +56,7 @@ public class BundleRenderer extends ResourceRenderer {
} else if ("collection".equals(b.primitiveValue("type")) && allEntriesAreHistoryProvenance(entries)) { } else if ("collection".equals(b.primitiveValue("type")) && allEntriesAreHistoryProvenance(entries)) {
// nothing // nothing
} else { } else {
XhtmlNode root = new XhtmlNode(NodeType.Element, "div"); XhtmlNode root = x;
root.para().addText(formatPhrase(RenderingContext.BUNDLE_HEADER_ROOT, b.getId(), b.primitiveValue("type"))); root.para().addText(formatPhrase(RenderingContext.BUNDLE_HEADER_ROOT, b.getId(), b.primitiveValue("type")));
int i = 0; int i = 0;
for (ResourceElement be : entries) { for (ResourceElement be : entries) {
@ -80,6 +80,9 @@ public class BundleRenderer extends ResourceRenderer {
} else { } else {
root.para().addText(formatPhrase(RenderingContext.BUNDLE_HEADER_ENTRY, Integer.toString(i))); root.para().addText(formatPhrase(RenderingContext.BUNDLE_HEADER_ENTRY, Integer.toString(i)));
} }
if (be.has("search")) {
renderSearch(x, be.child("search"));
}
// if (be.hasRequest()) // if (be.hasRequest())
// renderRequest(root, be.getRequest()); // renderRequest(root, be.getRequest());
// if (be.hasSearch()) // if (be.hasSearch())
@ -102,9 +105,6 @@ public class BundleRenderer extends ResourceRenderer {
} }
root.blockquote().para().addChildren(xn); root.blockquote().para().addChildren(xn);
} }
if (be.has("search")) {
renderSearch(x, be.child("search"));
}
if (be.has("request")) { if (be.has("request")) {
renderRequest(x, be.child("request")); renderRequest(x, be.child("request"));
} }

View File

@ -434,7 +434,7 @@ public class CapabilityStatementRenderer extends ResourceRenderer {
boolean first = true; boolean first = true;
for (CanonicalType ct : cap.getInstantiates()) { for (CanonicalType ct : cap.getInstantiates()) {
if (first) {first = false;} else {p.tx(", ");}; if (first) {first = false;} else {p.tx(", ");};
renderCanonical(status, res, x, CapabilityStatement.class, ct); renderCanonical(status, res, p, CapabilityStatement.class, ct);
} }
} }
if (cap.hasImports()) { if (cap.hasImports()) {
@ -443,7 +443,7 @@ public class CapabilityStatementRenderer extends ResourceRenderer {
boolean first = true; boolean first = true;
for (CanonicalType ct : cap.getImports()) { for (CanonicalType ct : cap.getImports()) {
if (first) {first = false;} else {p.tx(", ");}; if (first) {first = false;} else {p.tx(", ");};
renderCanonical(status, res, x, CapabilityStatement.class, ct); renderCanonical(status, res, p, CapabilityStatement.class, ct);
} }
} }
} }

View File

@ -736,6 +736,8 @@ public class DataRenderer extends Renderer implements CodeResolver {
renderDateTime(status, x, type); renderDateTime(status, x, type);
break; break;
case "uri" : case "uri" :
case "url" :
case "canonical" :
renderUri(status, x, type); renderUri(status, x, type);
break; break;
case "Annotation": case "Annotation":
@ -799,11 +801,21 @@ public class DataRenderer extends Renderer implements CodeResolver {
renderReference(status, x, type.child("reference")); renderReference(status, x, type.child("reference"));
} }
break; break;
case "MarkdownType": case "code":
x.tx(getTranslatedCode(type));
break;
case "markdown":
addMarkdown(x, context.getTranslated(type)); addMarkdown(x, context.getTranslated(type));
break; break;
case "Base64BinaryType": case "base64Binary":
x.tx(context.formatPhrase(RenderingContext.DATA_REND_BASE64, type.primitiveValue().length())); int length = type.primitiveValue().length();
if (length >= context.getBase64Limit()) {
x.tx(context.formatPhrase(RenderingContext.DATA_REND_BASE64, length));
} else {
x.code(type.primitiveValue());
}
break;
default: default:
if (type.isPrimitive()) { if (type.isPrimitive()) {
if (!renderPrimitiveWithNoValue(status, x, type)) { if (!renderPrimitiveWithNoValue(status, x, type)) {
@ -958,6 +970,9 @@ public class DataRenderer extends Renderer implements CodeResolver {
protected void renderUri(RenderingStatus status, XhtmlNode x, ResourceElement uri) throws FHIRFormatError, DefinitionException, IOException { protected void renderUri(RenderingStatus status, XhtmlNode x, ResourceElement uri) throws FHIRFormatError, DefinitionException, IOException {
if (!renderPrimitiveWithNoValue(status, x, uri)) { if (!renderPrimitiveWithNoValue(status, x, uri)) {
String v = uri.primitiveValue(); String v = uri.primitiveValue();
if (context.getContextUtilities().isResource(v)) {
v = "http://hl7.org/fhir/"+v;
}
if (v.startsWith("mailto:")) { if (v.startsWith("mailto:")) {
x.ah(v).addText(v.substring(7)); x.ah(v).addText(v.substring(7));
} else { } else {
@ -1555,7 +1570,7 @@ public class DataRenderer extends Renderer implements CodeResolver {
} }
public static String displayContactPoint(ResourceElement contact) { public String displayContactPoint(ResourceElement contact) {
StringBuilder s = new StringBuilder(); StringBuilder s = new StringBuilder();
s.append(describeSystem(contact.primitiveValue("system"))); s.append(describeSystem(contact.primitiveValue("system")));
if (Utilities.noString(contact.primitiveValue("value"))) if (Utilities.noString(contact.primitiveValue("value")))
@ -1563,11 +1578,11 @@ public class DataRenderer extends Renderer implements CodeResolver {
else else
s.append(contact.primitiveValue("value")); s.append(contact.primitiveValue("value"));
if (contact.has("use")) if (contact.has("use"))
s.append("("+contact.primitiveValue("use")+")"); s.append("("+getTranslatedCode(contact.child("use"))+")");
return s.toString(); return s.toString();
} }
public static String displayContactDetail(ResourceElement contact) { public String displayContactDetail(ResourceElement contact) {
CommaSeparatedStringBuilder s = new CommaSeparatedStringBuilder(); CommaSeparatedStringBuilder s = new CommaSeparatedStringBuilder();
for (ResourceElement cp : contact.children("telecom")) { for (ResourceElement cp : contact.children("telecom")) {
s.append(displayContactPoint(cp)); s.append(displayContactPoint(cp));

View File

@ -1,10 +1,10 @@
package org.hl7.fhir.r5.renderers; package org.hl7.fhir.r5.renderers;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.hl7.fhir.exceptions.DefinitionException; import org.hl7.fhir.exceptions.DefinitionException;
import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.exceptions.FHIRFormatError; import org.hl7.fhir.exceptions.FHIRFormatError;
@ -19,24 +19,24 @@ import org.hl7.fhir.r5.renderers.utils.ResourceElement;
import org.hl7.fhir.r5.utils.EOperationOutcome; import org.hl7.fhir.r5.utils.EOperationOutcome;
import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.xhtml.XhtmlNode; import org.hl7.fhir.utilities.xhtml.XhtmlNode;
public class DiagnosticReportRenderer extends ResourceRenderer { public class DiagnosticReportRenderer extends ResourceRenderer {
public class ObservationNode { public class ObservationNode {
private String ref; private String ref;
private ResourceWithReference resolution; private ResourceWithReference resolution;
private List<ObservationNode> contained; private List<ObservationNode> contained;
} }
public DiagnosticReportRenderer(RenderingContext context) { public DiagnosticReportRenderer(RenderingContext context) {
super(context); super(context);
} }
@Override @Override
public void renderResource(RenderingStatus status, XhtmlNode x, ResourceElement dr) throws IOException, FHIRException, EOperationOutcome { public void renderResource(RenderingStatus status, XhtmlNode x, ResourceElement dr) throws IOException, FHIRException, EOperationOutcome {
renderDiagnosticReport(status, x, dr); renderDiagnosticReport(status, x, dr);
} }
public void renderDiagnosticReport(RenderingStatus status, XhtmlNode x, ResourceElement dr) throws IOException, FHIRException, EOperationOutcome { public void renderDiagnosticReport(RenderingStatus status, XhtmlNode x, ResourceElement dr) throws IOException, FHIRException, EOperationOutcome {
XhtmlNode h2 = x.h2(); XhtmlNode h2 = x.h2();
renderDataType(status, h2, dr.child("code")); renderDataType(status, h2, dr.child("code"));
@ -54,9 +54,9 @@ public class DiagnosticReportRenderer extends ResourceRenderer {
XhtmlNode tbl = x.table("grid"); XhtmlNode tbl = x.table("grid");
XhtmlNode tr; XhtmlNode tr;
if (dr.has("subject")) { if (dr.has("subject")) {
tr = tbl.tr(); tr = tbl.tr();
tr.td().tx(context.formatPhrase(RenderingContext.GENERAL_SUBJ)); tr.td().tx(context.formatPhrase(RenderingContext.GENERAL_SUBJ));
populateSubjectSummary(status, tr.td(), dr.child("subject")); populateSubjectSummary(status, tr.td(), dr.child("subject"));
} }
ResourceElement eff = null; ResourceElement eff = null;
@ -77,15 +77,15 @@ public class DiagnosticReportRenderer extends ResourceRenderer {
addTableRow(status, tbl, dr, RenderingContext.DIAG_REP_REND_PER, "performer"); addTableRow(status, tbl, dr, RenderingContext.DIAG_REP_REND_PER, "performer");
addTableRow(status, tbl, dr, RenderingContext.DIAG_REP_REND_IDENTIFIER, "identifier"); addTableRow(status, tbl, dr, RenderingContext.DIAG_REP_REND_IDENTIFIER, "identifier");
addTableRow(status, tbl, dr, RenderingContext.GENERAL_REQUEST, "request"); addTableRow(status, tbl, dr, RenderingContext.GENERAL_REQUEST, "request");
x.para().b().tx(context.formatPhrase(RenderingContext.DIAG_REP_REND_REPDET)); x.para().b().tx(context.formatPhrase(RenderingContext.DIAG_REP_REND_REPDET));
List<ResourceElement> items = dr.children("result"); List<ResourceElement> items = dr.children("result");
if (!items.isEmpty()) { if (!items.isEmpty()) {
List<ObservationNode> observations = fetchObservations(items); List<ObservationNode> observations = fetchObservations(items);
buildObservationsTable(status, x, observations, eff, iss); buildObservationsTable(status, x, observations, eff, iss);
} }
if (dr.has("conclusion")) { if (dr.has("conclusion")) {
ResourceElement conc = dr.child("conclusion"); ResourceElement conc = dr.child("conclusion");
if (conc.fhirType().equals("markdown")) { if (conc.fhirType().equals("markdown")) {
@ -95,14 +95,17 @@ public class DiagnosticReportRenderer extends ResourceRenderer {
} }
} }
tbl = x.table("grid"); if (dr.hasMN("conclusionCode", "codedDiagnosis")) {
addTableRow(status, tbl, dr, RenderingContext.DIAG_REP_REND_CODECON, "conclusionCode", "codedDiagnosis"); x.para().b().tx(context.formatPhrase(RenderingContext.DIAG_REP_REND_CODECON));
addListRows(status, x.ul(), dr, RenderingContext.DIAG_REP_REND_CODECON, "conclusionCode", "codedDiagnosis");
}
for (ResourceElement cont : dr.children("contained")) { for (ResourceElement cont : dr.children("contained")) {
x.hr(); x.hr();
RendererFactory.factory(cont, context).renderResource(status, x, cont); RendererFactory.factory(cont, context).renderResource(status, x, cont);
} }
} }
private void addTableRow(RenderingStatus status, XhtmlNode tbl, ResourceElement dr, String constName, String... names) throws FHIRFormatError, DefinitionException, IOException { private void addTableRow(RenderingStatus status, XhtmlNode tbl, ResourceElement dr, String constName, String... names) throws FHIRFormatError, DefinitionException, IOException {
List<ResourceElement> items = dr.childrenMN(names); List<ResourceElement> items = dr.childrenMN(names);
if (!items.isEmpty()) { if (!items.isEmpty()) {
@ -116,20 +119,30 @@ public class DiagnosticReportRenderer extends ResourceRenderer {
} }
} }
private void addListRows(RenderingStatus status, XhtmlNode ul, ResourceElement dr, String constName, String... names) throws FHIRFormatError, DefinitionException, IOException {
List<ResourceElement> items = dr.childrenMN(names);
if (!items.isEmpty()) {
for (ResourceElement v : items) {
XhtmlNode li = ul.li();
renderDataType(status, li, v);
}
}
}
public void describeDiagnosticReport(XhtmlNode x, ResourceElement dr) { public void describeDiagnosticReport(XhtmlNode x, ResourceElement dr) {
x.tx(displayDiagnosticReport(dr)); x.tx(displayDiagnosticReport(dr));
} }
public String displayDiagnosticReport(ResourceElement dr) { public String displayDiagnosticReport(ResourceElement dr) {
return displayDataType(dr.child("code")); return displayDataType(dr.child("code"));
} }
@Override @Override
public String displayResource(ResourceElement r) throws UnsupportedEncodingException, IOException { public String displayResource(ResourceElement r) throws UnsupportedEncodingException, IOException {
return displayDiagnosticReport(r); return displayDiagnosticReport(r);
} }
private void populateSubjectSummary(RenderingStatus status, XhtmlNode container, ResourceElement subject) throws UnsupportedEncodingException, FHIRException, IOException, EOperationOutcome { private void populateSubjectSummary(RenderingStatus status, XhtmlNode container, ResourceElement subject) throws UnsupportedEncodingException, FHIRException, IOException, EOperationOutcome {
ResourceWithReference r = resolveReference(subject); ResourceWithReference r = resolveReference(subject);
if (r == null) if (r == null)
@ -139,11 +152,11 @@ public class DiagnosticReportRenderer extends ResourceRenderer {
else else
container.tx(context.formatPhrase(RenderingContext.GENERAL_TODO)); container.tx(context.formatPhrase(RenderingContext.GENERAL_TODO));
} }
private void generatePatientSummary(XhtmlNode c, ResourceElement r) throws FHIRFormatError, DefinitionException, FHIRException, IOException, EOperationOutcome { private void generatePatientSummary(XhtmlNode c, ResourceElement r) throws FHIRFormatError, DefinitionException, FHIRException, IOException, EOperationOutcome {
new PatientRenderer(context).describe(c, r); new PatientRenderer(context).describe(c, r);
} }
private List<ObservationNode> fetchObservations(List<ResourceElement> list) throws UnsupportedEncodingException, FHIRException, IOException { private List<ObservationNode> fetchObservations(List<ResourceElement> list) throws UnsupportedEncodingException, FHIRException, IOException {
List<ObservationNode> res = new ArrayList<ObservationNode>(); List<ObservationNode> res = new ArrayList<ObservationNode>();
for (ResourceElement b : list) { for (ResourceElement b : list) {
@ -162,7 +175,7 @@ public class DiagnosticReportRenderer extends ResourceRenderer {
} }
return res; return res;
} }
private void buildObservationsTable(RenderingStatus status, XhtmlNode root, List<ObservationNode> observations, ResourceElement eff, ResourceElement iss) throws UnsupportedEncodingException, FHIRException, IOException { private void buildObservationsTable(RenderingStatus status, XhtmlNode root, List<ObservationNode> observations, ResourceElement eff, ResourceElement iss) throws UnsupportedEncodingException, FHIRException, IOException {
XhtmlNode tbl = root.table("grid"); XhtmlNode tbl = root.table("grid");
boolean refRange = scanObsForRefRange(observations); boolean refRange = scanObsForRefRange(observations);
@ -198,90 +211,100 @@ public class DiagnosticReportRenderer extends ResourceRenderer {
addObservationToTable(status, tbl, o, 0, Integer.toString(cs), refRange, flags, note, effectiveTime, issued, eff, iss); addObservationToTable(status, tbl, o, 0, Integer.toString(cs), refRange, flags, note, effectiveTime, issued, eff, iss);
} }
} }
private boolean scanObsForRefRange(List<ObservationNode> observations) { private boolean scanObsForRefRange(List<ObservationNode> observations) {
for (ObservationNode o : observations) { for (ObservationNode o : observations) {
ResourceElement obs = o.resolution.getResource(); if (o.resolution != null) {
if (obs != null && obs.has("referenceRange")) { ResourceElement obs = o.resolution.getResource();
return true; if (obs != null && obs.has("referenceRange")) {
}
if (o.contained != null) {
if (scanObsForRefRange(o.contained)) {
return true; return true;
} }
} if (o.contained != null) {
if (scanObsForRefRange(o.contained)) {
return true;
}
}
}
} }
return false; return false;
} }
private boolean scanObsForNote(List<ObservationNode> observations) { private boolean scanObsForNote(List<ObservationNode> observations) {
for (ObservationNode o : observations) { for (ObservationNode o : observations) {
ResourceElement obs = o.resolution.getResource(); if (o.resolution != null) {
if (obs != null && obs.has("note")) { ResourceElement obs = o.resolution.getResource();
return true; if (obs != null && obs.has("note")) {
}
if (o.contained != null) {
if (scanObsForNote(o.contained)) {
return true; return true;
} }
} if (o.contained != null) {
if (scanObsForNote(o.contained)) {
return true;
}
}
}
} }
return false; return false;
} }
private boolean scanObsForIssued(List<ObservationNode> observations, ResourceElement iss) throws UnsupportedEncodingException, FHIRException, IOException { private boolean scanObsForIssued(List<ObservationNode> observations, ResourceElement iss) throws UnsupportedEncodingException, FHIRException, IOException {
for (ObservationNode o : observations) { for (ObservationNode o : observations) {
ResourceElement obs = o.resolution.getResource(); if (o.resolution != null) {
if (obs != null && obs.has("issued") && (iss == null || !iss.matches(obs.child("issued")))) { ResourceElement obs = o.resolution.getResource();
return true; if (obs != null && obs.has("issued") && (iss == null || !iss.matches(obs.child("issued")))) {
}
if (o.contained != null) {
if (scanObsForIssued(o.contained, iss)) {
return true; return true;
} }
} if (o.contained != null) {
if (scanObsForIssued(o.contained, iss)) {
return true;
}
}
}
} }
return false; return false;
} }
private boolean scanObsForEffective(List<ObservationNode> observations, ResourceElement eff) throws UnsupportedEncodingException, FHIRException, IOException { private boolean scanObsForEffective(List<ObservationNode> observations, ResourceElement eff) throws UnsupportedEncodingException, FHIRException, IOException {
for (ObservationNode o : observations) { for (ObservationNode o : observations) {
ResourceElement obs = o.resolution.getResource(); if (o.resolution != null) {
if (obs != null && obs.has("effective[x]") && (eff == null || !eff.matches(obs.child("effective[x]")))) { ResourceElement obs = o.resolution.getResource();
return true; if (obs != null && obs.has("effective[x]") && (eff == null || !eff.matches(obs.child("effective[x]")))) {
}
if (o.contained != null) {
if (scanObsForEffective(o.contained, eff)) {
return true; return true;
} }
} if (o.contained != null) {
if (scanObsForEffective(o.contained, eff)) {
return true;
}
}
}
} }
return false; return false;
} }
private boolean scanObsForFlags(List<ObservationNode> observations) throws UnsupportedEncodingException, FHIRException, IOException { private boolean scanObsForFlags(List<ObservationNode> observations) throws UnsupportedEncodingException, FHIRException, IOException {
for (ObservationNode o : observations) { for (ObservationNode o : observations) {
ResourceElement obs = o.resolution.getResource(); if (o.resolution != null) {
if (obs != null && (obs.has("interpretation") || obs.has("status"))) { ResourceElement obs = o.resolution.getResource();
return true; if (obs != null && (obs.has("interpretation") || obs.has("status"))) {
}
if (o.contained != null) {
if (scanObsForFlags(o.contained)) {
return true; return true;
} }
} if (o.contained != null) {
if (scanObsForFlags(o.contained)) {
return true;
}
}
}
} }
return false; return false;
} }
private void addObservationToTable(RenderingStatus status, XhtmlNode tbl, ObservationNode o, int i, String cs, boolean refRange, boolean flags, boolean note, boolean effectiveTime, boolean issued, ResourceElement eff, ResourceElement iss) throws UnsupportedEncodingException, FHIRException, IOException { private void addObservationToTable(RenderingStatus status, XhtmlNode tbl, ObservationNode o, int i, String cs, boolean refRange, boolean flags, boolean note, boolean effectiveTime, boolean issued, ResourceElement eff, ResourceElement iss) throws UnsupportedEncodingException, FHIRException, IOException {
XhtmlNode tr = tbl.tr(); XhtmlNode tr = tbl.tr();
if (o.resolution == null) { if (o.resolution == null) {
XhtmlNode td = tr.td().colspan(cs); XhtmlNode td = tr.td().colspan(cs);
td.i().tx(context.formatPhrase(RenderingContext.DIAG_REP_REND_NOTRES)); td.i().tx(context.formatPhrase(RenderingContext.DIAG_REP_REND_NOTRES, o.ref));
} else { } else {
if (o.resolution.getResource() != null) { if (o.resolution.getResource() != null) {
addObservationToTable(status, tr, o.resolution.getResource(), i, o.resolution.getReference(), refRange, flags, note, effectiveTime, issued, eff, iss); addObservationToTable(status, tr, o.resolution.getResource(), i, o.resolution.getWebPath(), refRange, flags, note, effectiveTime, issued, eff, iss);
} else { } else {
XhtmlNode td = tr.td().colspan(cs); XhtmlNode td = tr.td().colspan(cs);
td.i().tx(context.formatPhrase(RenderingContext.DIAG_REP_REND_OBS)); td.i().tx(context.formatPhrase(RenderingContext.DIAG_REP_REND_OBS));
@ -293,9 +316,9 @@ public class DiagnosticReportRenderer extends ResourceRenderer {
} }
} }
} }
private void addObservationToTable(RenderingStatus status, XhtmlNode tr, ResourceElement obs, int i, String ref, boolean refRange, boolean flags, boolean note, boolean effectiveTime, boolean issued, ResourceElement eff, ResourceElement iss) throws UnsupportedEncodingException, FHIRException, IOException { private void addObservationToTable(RenderingStatus status, XhtmlNode tr, ResourceElement obs, int i, String ref, boolean refRange, boolean flags, boolean note, boolean effectiveTime, boolean issued, ResourceElement eff, ResourceElement iss) throws UnsupportedEncodingException, FHIRException, IOException {
// code (+bodysite) // code (+bodysite)
XhtmlNode td = tr.td(); XhtmlNode td = tr.td();
if (obs.has("code")) { if (obs.has("code")) {
@ -306,7 +329,7 @@ public class DiagnosticReportRenderer extends ResourceRenderer {
renderDataType(status, td, obs.child("bodySite")); renderDataType(status, td, obs.child("bodySite"));
td.tx(")"); td.tx(")");
} }
// value / dataAbsentReason (in red) // value / dataAbsentReason (in red)
td = tr.td(); td = tr.td();
if (obs.has("value[x]")) { if (obs.has("value[x]")) {
@ -375,7 +398,7 @@ public class DiagnosticReportRenderer extends ResourceRenderer {
addCellToTable(note, status, tr, obs, null, "note"); addCellToTable(note, status, tr, obs, null, "note");
addCellToTable(effectiveTime, status, tr, obs, eff, "effective[x]"); addCellToTable(effectiveTime, status, tr, obs, eff, "effective[x]");
addCellToTable(issued, status, tr, obs, iss, "issued"); addCellToTable(issued, status, tr, obs, iss, "issued");
} }
private void addCellToTable(boolean included, RenderingStatus status, XhtmlNode tr, ResourceElement obs, ResourceElement diff, String... names) throws FHIRFormatError, DefinitionException, IOException { private void addCellToTable(boolean included, RenderingStatus status, XhtmlNode tr, ResourceElement obs, ResourceElement diff, String... names) throws FHIRFormatError, DefinitionException, IOException {
@ -393,5 +416,5 @@ public class DiagnosticReportRenderer extends ResourceRenderer {
} }
} }
} }
} }

View File

@ -24,7 +24,7 @@ public class EncounterRenderer extends ResourceRenderer {
@Override @Override
public void renderResource(RenderingStatus status, XhtmlNode x, ResourceElement r) throws FHIRFormatError, DefinitionException, IOException, FHIRException, EOperationOutcome { public void renderResource(RenderingStatus status, XhtmlNode x, ResourceElement r) throws FHIRFormatError, DefinitionException, IOException, FHIRException, EOperationOutcome {
throw new Error("todo"); x.tx("Not done yet");
} }

View File

@ -159,7 +159,7 @@ public class LibraryRenderer extends ResourceRenderer {
private void renderArtifact(RenderingStatus status, XhtmlNode t, ResourceElement ra, ResourceElement lib, boolean label, boolean display, boolean citation) throws UnsupportedEncodingException, FHIRException, IOException { private void renderArtifact(RenderingStatus status, XhtmlNode t, ResourceElement ra, ResourceElement lib, boolean label, boolean display, boolean citation) throws UnsupportedEncodingException, FHIRException, IOException {
XhtmlNode tr = t.tr(); XhtmlNode tr = t.tr();
tr.td().tx(ra.has("type") ? ra.primitiveValue("type") : null); tr.td().tx(ra.has("type") ? getTranslatedCode(ra.child("type")) : null);
if (label) { if (label) {
tr.td().tx(ra.has("label") ? ra.primitiveValue("label") : null); tr.td().tx(ra.has("label") ? ra.primitiveValue("label") : null);
} }

View File

@ -31,21 +31,20 @@ public class ListRenderer extends ResourceRenderer {
} }
XhtmlNode t = x.table("clstu"); XhtmlNode t = x.table("clstu");
XhtmlNode tr = t.tr(); XhtmlNode tr = t.tr();
XhtmlNode td = tr.td();
if (list.has("date")) { if (list.has("date")) {
td.tx(context.formatPhrase(RenderingContext.LIST_REND_DATE, displayDateTime(list.child("date")))+" "); tr.td().tx(context.formatPhrase(RenderingContext.LIST_REND_DATE, displayDateTime(list.child("date")))+" ");
} }
if (list.has("mode")) { if (list.has("mode")) {
td.tx(context.formatPhrase(RenderingContext.LIST_REND_MODE, list.primitiveValue("mode"))+" "); tr.td().tx(context.formatPhrase(RenderingContext.LIST_REND_MODE, getTranslatedCode(list.child("mode")))+" ");
} }
if (list.has("status")) { if (list.has("status")) {
td.tx(context.formatPhrase(RenderingContext.LIST_REND_STAT, list.primitiveValue("status"))+" "); tr.td().tx(context.formatPhrase(RenderingContext.LIST_REND_STAT, getTranslatedCode(list.child("status")))+" ");
} }
if (list.has("code")) { if (list.has("code")) {
td.tx(context.formatPhrase(RenderingContext.LIST_REND_CODE, displayDataType(list.child("code")))+" "); tr.td().tx(context.formatPhrase(RenderingContext.LIST_REND_CODE, displayDataType(list.child("code")))+" ");
} }
tr = t.tr(); tr = t.tr();
td = tr.td(); XhtmlNode td = tr.td();
if (list.has("subject")) { if (list.has("subject")) {
td.tx(context.formatPhrase(RenderingContext.LIST_REND_SUB)+" "); td.tx(context.formatPhrase(RenderingContext.LIST_REND_SUB)+" ");
renderReference(status, td, list.child("subject")); renderReference(status, td, list.child("subject"));

View File

@ -5,14 +5,16 @@ import java.io.UnsupportedEncodingException;
import org.hl7.fhir.exceptions.DefinitionException; import org.hl7.fhir.exceptions.DefinitionException;
import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.exceptions.FHIRFormatError; import org.hl7.fhir.exceptions.FHIRFormatError;
import org.hl7.fhir.r5.model.ElementDefinition;
import org.hl7.fhir.r5.model.Extension; import org.hl7.fhir.r5.model.Extension;
import org.hl7.fhir.r5.model.ExtensionHelper; import org.hl7.fhir.r5.model.ExtensionHelper;
import org.hl7.fhir.r5.model.OperationOutcome; import org.hl7.fhir.r5.model.OperationOutcome;
import org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity; import org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity;
import org.hl7.fhir.r5.model.OperationOutcome.OperationOutcomeIssueComponent; import org.hl7.fhir.r5.model.OperationOutcome.OperationOutcomeIssueComponent;
import org.hl7.fhir.r5.model.Resource; import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.StringType; import org.hl7.fhir.r5.model.StringType;
import org.hl7.fhir.r5.model.ValueSet;
import org.hl7.fhir.r5.renderers.Renderer.RenderingStatus; import org.hl7.fhir.r5.renderers.Renderer.RenderingStatus;
import org.hl7.fhir.r5.renderers.utils.RenderingContext; import org.hl7.fhir.r5.renderers.utils.RenderingContext;
import org.hl7.fhir.r5.renderers.utils.ResourceElement; import org.hl7.fhir.r5.renderers.utils.ResourceElement;
@ -58,7 +60,7 @@ public class OperationOutcomeRenderer extends ResourceRenderer {
} }
for (ResourceElement i : op.children("issue")) { for (ResourceElement i : op.children("issue")) {
tr = tbl.tr(); tr = tbl.tr();
tr.td().addText(i.primitiveValue("severity")); tr.td().addText(getTranslatedCode(i.child("severity")));
XhtmlNode td = tr.td(); XhtmlNode td = tr.td();
boolean d = false; boolean d = false;
for (ResourceElement s : i.has("expression") ? i.children("expression") : i.children("location")) { for (ResourceElement s : i.has("expression") ? i.children("expression") : i.children("location")) {
@ -68,8 +70,8 @@ public class OperationOutcomeRenderer extends ResourceRenderer {
d = true; d = true;
td.addText(s.primitiveValue()); td.addText(s.primitiveValue());
} }
tr.td().addText(i.child("code").primitiveValue("display")); tr.td().addText(getTranslatedCode(i.child("code")));
tr.td().addText(i.primitiveValue("details")); tr.td().addText(i.child("details").primitiveValue("text"));
smartAddText(tr.td(), i.primitiveValue("diagnostics")); smartAddText(tr.td(), i.primitiveValue("diagnostics"));
if (hasSource) { if (hasSource) {
ResourceElement ext = i.extension(ToolingExtensions.EXT_ISSUE_SOURCE); ResourceElement ext = i.extension(ToolingExtensions.EXT_ISSUE_SOURCE);
@ -78,7 +80,8 @@ public class OperationOutcomeRenderer extends ResourceRenderer {
} }
} }
} }
public void describe(XhtmlNode x, OperationOutcome oo) { public void describe(XhtmlNode x, OperationOutcome oo) {
x.tx(display(oo)); x.tx(display(oo));
} }

View File

@ -50,7 +50,7 @@ public class PatientRenderer extends ResourceRenderer {
ResourceElement dt = pat.child("birthDate"); ResourceElement dt = pat.child("birthDate");
StringBuilder b = new StringBuilder(); StringBuilder b = new StringBuilder();
if (b == null) { if (n != null) {
b.append(displayHumanName(n)); b.append(displayHumanName(n));
} else { } else {
b.append(context.formatPhrase(RenderingContext.PAT_NO_NAME)); b.append(context.formatPhrase(RenderingContext.PAT_NO_NAME));
@ -97,7 +97,7 @@ public class PatientRenderer extends ResourceRenderer {
@Override @Override
public void renderResource(RenderingStatus status, XhtmlNode x, ResourceElement pat) throws FHIRFormatError, DefinitionException, IOException, FHIRException, EOperationOutcome { public void renderResource(RenderingStatus status, XhtmlNode x, ResourceElement pat) throws FHIRFormatError, DefinitionException, IOException, FHIRException, EOperationOutcome {
if (SHORT) { if (context.isShortPatientForm()) {
ResourceElement id = null; ResourceElement id = null;
List<ResourceElement> list = pat.children("identifier"); List<ResourceElement> list = pat.children("identifier");
for (ResourceElement t : list) { for (ResourceElement t : list) {
@ -111,7 +111,7 @@ public class PatientRenderer extends ResourceRenderer {
String gender = null; String gender = null;
ResourceElement item = pat.child("gender"); ResourceElement item = pat.child("gender");
if (item != null) { if (item != null) {
gender = context.getTranslatedCode(item.primitiveValue(), "http://hl7.org/fhir/administrative-gender"); gender = getTranslatedCode(item);
} }
ResourceElement dt = pat.child("birthDate"); ResourceElement dt = pat.child("birthDate");
@ -139,7 +139,7 @@ public class PatientRenderer extends ResourceRenderer {
} }
} else { } else {
// banner // banner
describe(makeBanner(x.para()), pat); makeBanner(x.para()).tx(displayResource(pat));
x.hr(); x.hr();
XhtmlNode tbl; XhtmlNode tbl;
if (hasRenderablePhoto(pat)) { if (hasRenderablePhoto(pat)) {
@ -271,7 +271,7 @@ public class PatientRenderer extends ResourceRenderer {
renderDataType(status, li, s.child("value")); renderDataType(status, li, s.child("value"));
} }
} else { } else {
renderDataType(status, td, list.get(0)); renderDataType(status, td, list.get(0).child("value"));
} }
} else { } else {
for (ResourceElement ext : list) { for (ResourceElement ext : list) {

View File

@ -277,30 +277,30 @@ public class QuestionnaireRenderer extends TerminologyRenderer {
} }
if ("true".equals(i.extensionString("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-ResourceElement-isSubject"))) { if ("true".equals(i.extensionString("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-ResourceElement-isSubject"))) {
status.setExtensions(true); status.setExtensions(true);
flags.addPiece(gen.new Piece(getSDCLink("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-ResourceElement-isSubject", "StructureDefinition-sdc-ResourceElement-isSubject.html"), null, context.formatPhrase(RenderingContext.QUEST_SUBJECT)).addHtml(new XhtmlNode(NodeType.Element, "img").attribute("alt", "icon").attribute("src", getImgPath("icon-qi-subject.png")))); flags.addPiece(gen.new Piece(getSDCLink("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-ResourceElement-isSubject", "StructureDefinition-sdc-questionnaire-isSubject.html"), null, context.formatPhrase(RenderingContext.QUEST_SUBJECT)).addHtml(new XhtmlNode(NodeType.Element, "img").attribute("alt", "icon").attribute("src", getImgPath("icon-qi-subject.png"))));
} }
if ("true".equals(i.extensionString(ToolingExtensions.EXT_Q_HIDDEN))) { if ("true".equals(i.extensionString(ToolingExtensions.EXT_Q_HIDDEN))) {
status.setExtensions(true); status.setExtensions(true);
flags.addPiece(gen.new Piece(getSpecLink("extension-ResourceElement-hidden.html"), null, context.formatPhrase(RenderingContext.QUEST_HIDDEN)).addHtml(new XhtmlNode(NodeType.Element, "img").attribute("alt", "icon").attribute("src", getImgPath("icon-qi-hidden.png")))); flags.addPiece(gen.new Piece(getSpecLink("extension-questionnaire-hidden.html"), null, context.formatPhrase(RenderingContext.QUEST_HIDDEN)).addHtml(new XhtmlNode(NodeType.Element, "img").attribute("alt", "icon").attribute("src", getImgPath("icon-qi-hidden.png"))));
} }
if ("true".equals(i.extensionString(ToolingExtensions.EXT_Q_OTP_DISP))) { if ("true".equals(i.extensionString(ToolingExtensions.EXT_Q_OTP_DISP))) {
status.setExtensions(true); status.setExtensions(true);
flags.addPiece(gen.new Piece(getSDCLink("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-ResourceElement-optionalDisplay", "StructureDefinition-sdc-ResourceElement-optionalDisplay.html"), null, context.formatPhrase(RenderingContext.QUEST_DISPLAY)).addHtml(new XhtmlNode(NodeType.Element, "img").attribute("alt", "icon").attribute("src", getImgPath("icon-qi-optional.png")))); flags.addPiece(gen.new Piece(getSDCLink("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-ResourceElement-optionalDisplay", "StructureDefinition-sdc-questionnaire-optionalDisplay.html"), null, context.formatPhrase(RenderingContext.QUEST_DISPLAY)).addHtml(new XhtmlNode(NodeType.Element, "img").attribute("alt", "icon").attribute("src", getImgPath("icon-qi-optional.png"))));
} }
if (i.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-ResourceElement-observationLinkPeriod")) { if (i.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-ResourceElement-observationLinkPeriod")) {
status.setExtensions(true); status.setExtensions(true);
flags.addPiece(gen.new Piece(getSDCLink("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-ResourceElement-observationLinkPeriod", "StructureDefinition-sdc-ResourceElement-observationLinkPeriod.html"), null, context.formatPhrase(RenderingContext.QUEST_LINKED)).addHtml(new XhtmlNode(NodeType.Element, "img").attribute("alt", "icon").attribute("src", getImgPath("icon-qi-observation.png")))); flags.addPiece(gen.new Piece(getSDCLink("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-ResourceElement-observationLinkPeriod", "StructureDefinition-sdc-questionnaire-observationLinkPeriod.html"), null, context.formatPhrase(RenderingContext.QUEST_LINKED)).addHtml(new XhtmlNode(NodeType.Element, "img").attribute("alt", "icon").attribute("src", getImgPath("icon-qi-observation.png"))));
} }
if (i.hasExtension(ToolingExtensions.EXT_Q_CHOICE_ORIENT)) { if (i.hasExtension(ToolingExtensions.EXT_Q_CHOICE_ORIENT)) {
status.setExtensions(true); status.setExtensions(true);
String code = i.extensionString(ToolingExtensions.EXT_Q_CHOICE_ORIENT); String code = i.extensionString(ToolingExtensions.EXT_Q_CHOICE_ORIENT);
flags.addPiece(gen.new Piece(getSpecLink("extension-ResourceElement-choiceorientation.html"), null, context.formatPhrase(RenderingContext.QUEST_ORIENTATION, code)+" ").addHtml(new XhtmlNode(NodeType.Element, "img").attribute("alt", "icon").attribute("src", getImgPath("icon-qi-" + code + ".png")))); flags.addPiece(gen.new Piece(getSpecLink("extension-questionnaire-choiceorientation.html"), null, context.formatPhrase(RenderingContext.QUEST_ORIENTATION, code)+" ").addHtml(new XhtmlNode(NodeType.Element, "img").attribute("alt", "icon").attribute("src", getImgPath("icon-qi-" + code + ".png"))));
} }
if (i.hasExtension(ToolingExtensions.EXT_Q_DISPLAY_CAT)) { if (i.hasExtension(ToolingExtensions.EXT_Q_DISPLAY_CAT)) {
status.setExtensions(true); status.setExtensions(true);
ResourceElement cc = i.extensionValue(ToolingExtensions.EXT_Q_DISPLAY_CAT); ResourceElement cc = i.extensionValue(ToolingExtensions.EXT_Q_DISPLAY_CAT);
String code = getCodeFromCC(cc, "http://hl7.org/fhir/ResourceElement-display-category"); String code = getCodeFromCC(cc, "http://hl7.org/fhir/questionnaire-display-category");
flags.addPiece(gen.new Piece("https://hl7.org/fhir/R4/extension-ResourceElement-displayCategory.html", null, context.formatPhrase(RenderingContext.QUEST_CAT, code)+" ").addHtml(new XhtmlNode(NodeType.Element, "img").attribute("alt", "icon").attribute("src", getImgPath("icon-qi-" + code + ".png")))); flags.addPiece(gen.new Piece("https://hl7.org/fhir/R4/extension-questionnaire-displayCategory.html", null, context.formatPhrase(RenderingContext.QUEST_CAT, code)+" ").addHtml(new XhtmlNode(NodeType.Element, "img").attribute("alt", "icon").attribute("src", getImgPath("icon-qi-" + code + ".png"))));
} }
} }
Cell defn = gen.new Cell(); Cell defn = gen.new Cell();
@ -655,6 +655,7 @@ public class QuestionnaireRenderer extends TerminologyRenderer {
XhtmlNode p = display.para(); XhtmlNode p = display.para();
String type = i.primitiveValue("type"); String type = i.primitiveValue("type");
String typeT = getTranslatedCode(i.child("type"));
if ("group".equals(type)) { if ("group".equals(type)) {
p = p.b(); p = p.b();
} }
@ -671,13 +672,13 @@ public class QuestionnaireRenderer extends TerminologyRenderer {
switch (type) { switch (type) {
case "string": case "string":
p.tx(" "); p.tx(" ");
input = p.input(i.primitiveValue("linkId"), "text", type, 60); input = p.input(i.primitiveValue("linkId"), "text", typeT, 60);
break; break;
case "attachment": case "attachment":
break; break;
case "boolean": case "boolean":
p.tx(" "); p.tx(" ");
input = p.input(i.primitiveValue("linkId"), "checkbox", type, 1); input = p.input(i.primitiveValue("linkId"), "checkbox", typeT, 1);
break; break;
case "coding": case "coding":
input = p.select(i.primitiveValue("linkId")); input = p.select(i.primitiveValue("linkId"));
@ -685,15 +686,15 @@ public class QuestionnaireRenderer extends TerminologyRenderer {
break; break;
case "date": case "date":
p.tx(" "); p.tx(" ");
input = p.input(i.primitiveValue("linkId"), "date", type, 10); input = p.input(i.primitiveValue("linkId"), "date", typeT, 10);
break; break;
case "dateTime": case "dateTime":
p.tx(" "); p.tx(" ");
input = p.input(i.primitiveValue("linkId"), "datetime-local", type, 25); input = p.input(i.primitiveValue("linkId"), "datetime-local", typeT, 25);
break; break;
case "decimal": case "decimal":
p.tx(" "); p.tx(" ");
input = p.input(i.primitiveValue("linkId"), "number", type, 15); input = p.input(i.primitiveValue("linkId"), "number", typeT, 15);
break; break;
case "display": case "display":
break; break;
@ -701,7 +702,7 @@ public class QuestionnaireRenderer extends TerminologyRenderer {
break; break;
case "integer": case "integer":
p.tx(" "); p.tx(" ");
input = p.input(i.primitiveValue("linkId"), "number", type, 10); input = p.input(i.primitiveValue("linkId"), "number", typeT, 10);
break; break;
case "qantity": case "qantity":
p.tx(" "); p.tx(" ");
@ -742,26 +743,26 @@ public class QuestionnaireRenderer extends TerminologyRenderer {
if ("true".equals(i.extensionString("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-ResourceElement-isSubject"))) { if ("true".equals(i.extensionString("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-ResourceElement-isSubject"))) {
hasFlag = true; hasFlag = true;
flags.ah(getSDCLink("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-ResourceElement-isSubject", "StructureDefinition-sdc-ResourceElement-isSubject.html"), context.formatPhrase(RenderingContext.QUEST_SUBJECT)).img(getImgPath("icon-qi-subject.png"), "icon"); flags.ah(getSDCLink("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-ResourceElement-isSubject", "StructureDefinition-sdc-questionnaire-isSubject.html"), context.formatPhrase(RenderingContext.QUEST_SUBJECT)).img(getImgPath("icon-qi-subject.png"), "icon");
} }
if ("true".equals(i.extensionString(ToolingExtensions.EXT_Q_HIDDEN))) { if ("true".equals(i.extensionString(ToolingExtensions.EXT_Q_HIDDEN))) {
hasFlag = true; hasFlag = true;
flags.ah(Utilities.pathURL(context.getLink(KnownLinkType.SPEC), "extension-ResourceElement-hidden.html"), context.formatPhrase(RenderingContext.QUEST_HIDDEN)).img(getImgPath("icon-qi-hidden.png"), "icon"); flags.ah(Utilities.pathURL(context.getLink(KnownLinkType.SPEC), "extension-questionnaire-hidden.html"), context.formatPhrase(RenderingContext.QUEST_HIDDEN)).img(getImgPath("icon-qi-hidden.png"), "icon");
d.style("background-color: #eeeeee"); d.style("background-color: #eeeeee");
} }
if ("true".equals(i.extensionString(ToolingExtensions.EXT_Q_OTP_DISP))) { if ("true".equals(i.extensionString(ToolingExtensions.EXT_Q_OTP_DISP))) {
hasFlag = true; hasFlag = true;
flags.ah(getSDCLink("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-ResourceElement-optionalDisplay", "StructureDefinition-sdc-ResourceElement-optionalDisplay.html"), context.formatPhrase(RenderingContext.QUEST_DISPLAY)).img(getImgPath("icon-qi-optional.png"), "icon"); flags.ah(getSDCLink("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-ResourceElement-optionalDisplay", "StructureDefinition-sdc-questionnaire-optionalDisplay.html"), context.formatPhrase(RenderingContext.QUEST_DISPLAY)).img(getImgPath("icon-qi-optional.png"), "icon");
} }
if (i.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-ResourceElement-observationLinkPeriod")) { if (i.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-ResourceElement-observationLinkPeriod")) {
hasFlag = true; hasFlag = true;
flags.ah(getSDCLink("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-ResourceElement-observationLinkPeriod", "StructureDefinition-sdc-ResourceElement-observationLinkPeriod.html"), context.formatPhrase(RenderingContext.QUEST_LINKED)).img(getImgPath("icon-qi-observation.png"), "icon"); flags.ah(getSDCLink("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-ResourceElement-observationLinkPeriod", "StructureDefinition-sdc-questionnaire-observationLinkPeriod.html"), context.formatPhrase(RenderingContext.QUEST_LINKED)).img(getImgPath("icon-qi-observation.png"), "icon");
} }
if (i.hasExtension(ToolingExtensions.EXT_Q_DISPLAY_CAT)) { if (i.hasExtension(ToolingExtensions.EXT_Q_DISPLAY_CAT)) {
ResourceElement cc = i.extension(ToolingExtensions.EXT_Q_DISPLAY_CAT).child("value"); ResourceElement cc = i.extension(ToolingExtensions.EXT_Q_DISPLAY_CAT).child("value");
String code = getCodeFromCC(cc, "http://hl7.org/fhir/ResourceElement-display-category"); String code = getCodeFromCC(cc, "http://hl7.org/fhir/questionnaire-display-category");
hasFlag = true; hasFlag = true;
flags.ah("https://hl7.org/fhir/R4/extension-ResourceElement-displayCategory.html", (context.formatPhrase(RenderingContext.QUEST_CAT, code)+" ")).img(getImgPath("icon-qi-" + code + ".png"), "icon"); flags.ah("https://hl7.org/fhir/R4/extension-questionnaire-displayCategory.html", (context.formatPhrase(RenderingContext.QUEST_CAT, code)+" ")).img(getImgPath("icon-qi-" + code + ".png"), "icon");
} }
if (i.has("maxLength")) { if (i.has("maxLength")) {

View File

@ -6,8 +6,10 @@ import org.hl7.fhir.r5.comparison.VersionComparisonAnnotation;
import org.hl7.fhir.r5.context.IWorkerContext; import org.hl7.fhir.r5.context.IWorkerContext;
import org.hl7.fhir.r5.model.Base; import org.hl7.fhir.r5.model.Base;
import org.hl7.fhir.r5.model.DataType; import org.hl7.fhir.r5.model.DataType;
import org.hl7.fhir.r5.model.ElementDefinition;
import org.hl7.fhir.r5.model.Enumeration; import org.hl7.fhir.r5.model.Enumeration;
import org.hl7.fhir.r5.model.Resource; import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.ValueSet;
import org.hl7.fhir.r5.renderers.utils.RenderingContext; import org.hl7.fhir.r5.renderers.utils.RenderingContext;
import org.hl7.fhir.r5.renderers.utils.ResourceElement; import org.hl7.fhir.r5.renderers.utils.ResourceElement;
import org.hl7.fhir.r5.renderers.utils.RenderingContext.GenerationRules; import org.hl7.fhir.r5.renderers.utils.RenderingContext.GenerationRules;
@ -250,5 +252,20 @@ public class Renderer {
return ResourceElement.forType(context.getContextUtilities(), context.getProfileUtilities(), resource, type); return ResourceElement.forType(context.getContextUtilities(), context.getProfileUtilities(), resource, type);
} }
protected String getTranslatedCode(ResourceElement child) {
return context.getTranslatedCode(child.primitiveValue(), impliedCodeSystem(child));
}
protected String impliedCodeSystem(ResourceElement i) {
ElementDefinition pd = i.getPropertyDefinition();
if (pd != null && pd.hasBinding() && pd.getBinding().hasValueSet()) {
ValueSet vs = context.getWorker().fetchResource(ValueSet.class, pd.getBinding().getValueSet());
if (vs != null && vs.hasCompose() && !vs.getCompose().hasExclude() && vs.getCompose().getInclude().size() == 1) {
return vs.getCompose().getIncludeFirstRep().getSystem();
}
}
return null;
}
} }

View File

@ -179,7 +179,7 @@ public class RequirementsRenderer extends ResourceRenderer {
li.ah(c.primitiveValue("reference")).tx(desc); li.ah(c.primitiveValue("reference")).tx(desc);
} else if (t != null) { } else if (t != null) {
String desc = getResourceDescription(t, c.primitiveValue("display")); String desc = getResourceDescription(t, c.primitiveValue("display"));
li.ah(t.getReference()).tx(desc); li.ah(t.getWebPath()).tx(desc);
} else { } else {
li.ah(c.primitiveValue("reference")).tx(url); li.ah(c.primitiveValue("reference")).tx(url);
} }

View File

@ -22,6 +22,7 @@ import org.hl7.fhir.r5.model.CodeableReference;
import org.hl7.fhir.r5.model.Coding; import org.hl7.fhir.r5.model.Coding;
import org.hl7.fhir.r5.model.DataType; import org.hl7.fhir.r5.model.DataType;
import org.hl7.fhir.r5.model.DomainResource; import org.hl7.fhir.r5.model.DomainResource;
import org.hl7.fhir.r5.model.ElementDefinition;
import org.hl7.fhir.r5.model.Enumerations.PublicationStatus; import org.hl7.fhir.r5.model.Enumerations.PublicationStatus;
import org.hl7.fhir.r5.model.Extension; import org.hl7.fhir.r5.model.Extension;
import org.hl7.fhir.r5.model.Narrative; import org.hl7.fhir.r5.model.Narrative;
@ -32,6 +33,7 @@ import org.hl7.fhir.r5.model.Reference;
import org.hl7.fhir.r5.model.Resource; import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.StructureDefinition; import org.hl7.fhir.r5.model.StructureDefinition;
import org.hl7.fhir.r5.model.UriType; import org.hl7.fhir.r5.model.UriType;
import org.hl7.fhir.r5.model.ValueSet;
import org.hl7.fhir.r5.renderers.Renderer.RenderingStatus; import org.hl7.fhir.r5.renderers.Renderer.RenderingStatus;
import org.hl7.fhir.r5.renderers.utils.RenderingContext; import org.hl7.fhir.r5.renderers.utils.RenderingContext;
import org.hl7.fhir.r5.renderers.utils.RenderingContext.GenerationRules; import org.hl7.fhir.r5.renderers.utils.RenderingContext.GenerationRules;
@ -218,9 +220,9 @@ public abstract class ResourceRenderer extends DataRenderer {
// we can't resolve it as a canonical in the context. We'll try to do a local resolution instead // we can't resolve it as a canonical in the context. We'll try to do a local resolution instead
ResourceWithReference rr = resolveReference(canonical); ResourceWithReference rr = resolveReference(canonical);
if (rr != null) { if (rr != null) {
x.ah(rr.getReference()).tx(RendererFactory.factory(rr.getResource(), context).displayResource(rr.getResource())); x.ah(rr.getWebPath()).tx(RendererFactory.factory(rr.getResource(), context).displayResource(rr.getResource()));
} else { } else {
x.tx("??"); x.code(canonical.primitiveValue());
} }
} }
} }
@ -241,14 +243,19 @@ public abstract class ResourceRenderer extends DataRenderer {
} }
String url = canonical.asStringValue(); String url = canonical.asStringValue();
Resource target = context.getWorker().fetchResource(Resource.class, url, res.getResourceNative()); Resource target = context.getWorker().fetchResource(Resource.class, url, res.getResourceNative());
if (target == null || !(target instanceof CanonicalResource) || !target.hasWebPath()) { if (target == null || !(target instanceof CanonicalResource)) {
x.code().tx(url); x.code().tx(url);
} else { } else {
CanonicalResource cr = (CanonicalResource) target; CanonicalResource cr = (CanonicalResource) target;
if (url.contains("|")) { if (!target.hasWebPath()) {
x.ah(target.getWebPath()).tx(cr.present()+ context.formatPhrase(RenderingContext.RES_REND_VER) +cr.getVersion()+")"); x.code().tx(url);
x.tx(" ("+cr.present()+")");
} else { } else {
x.ah(target.getWebPath()).tx(cr.present()); if (url.contains("|")) {
x.ah(target.getWebPath()).tx(cr.present()+ context.formatPhrase(RenderingContext.RES_REND_VER) +cr.getVersion()+")");
} else {
x.ah(target.getWebPath()).tx(cr.present());
}
} }
} }
} }
@ -256,6 +263,9 @@ public abstract class ResourceRenderer extends DataRenderer {
// todo: if (r.hasExtension(ToolingExtensions.EXT_TARGET_ID) || r.hasExtension(ToolingExtensions.EXT_TARGET_PATH)) { // todo: if (r.hasExtension(ToolingExtensions.EXT_TARGET_ID) || r.hasExtension(ToolingExtensions.EXT_TARGET_PATH)) {
@Override @Override
public void renderReference(RenderingStatus status, XhtmlNode x, ResourceElement type) throws FHIRFormatError, DefinitionException, IOException { public void renderReference(RenderingStatus status, XhtmlNode x, ResourceElement type) throws FHIRFormatError, DefinitionException, IOException {
if (type == null) {
return;
}
ResourceElement display = null; ResourceElement display = null;
ResourceElement actual = null; ResourceElement actual = null;
ResourceElement id = null; ResourceElement id = null;
@ -281,7 +291,7 @@ public abstract class ResourceRenderer extends DataRenderer {
x.ah(actual.primitiveValue()).tx(disp); x.ah(actual.primitiveValue()).tx(disp);
} else { } else {
String disp = display != null && display.hasPrimitiveValue() ? displayDataType(display) : RendererFactory.factory(rr.getResource(), context).displayResource(rr.getResource()); String disp = display != null && display.hasPrimitiveValue() ? displayDataType(display) : RendererFactory.factory(rr.getResource(), context).displayResource(rr.getResource());
x.ah(rr.getReference()).tx(disp); x.ah(rr.getWebPath()).tx(disp);
} }
} else if (display != null && id != null) { } else if (display != null && id != null) {
renderDataType(status, x, display); renderDataType(status, x, display);
@ -310,8 +320,8 @@ public abstract class ResourceRenderer extends DataRenderer {
tr = resolveReference(res, r.getReference()); tr = resolveReference(res, r.getReference());
if (!r.getReference().startsWith("#")) { if (!r.getReference().startsWith("#")) {
if (tr != null && tr.getReference() != null) { if (tr != null && tr.getWebPath() != null) {
link = tr.getReference(); link = tr.getWebPath();
} else if (r.getReference().contains("?")) { } else if (r.getReference().contains("?")) {
text.append(context.formatPhrase(RenderingContext.RES_REND_COND_REF)+" "); text.append(context.formatPhrase(RenderingContext.RES_REND_COND_REF)+" ");
} else { } else {
@ -319,7 +329,7 @@ public abstract class ResourceRenderer extends DataRenderer {
} }
} }
} }
if (tr != null && tr.getReference() != null && tr.getReference().startsWith("#")) { if (tr != null && tr.getWebPath() != null && tr.getWebPath().startsWith("#")) {
text.append(context.formatPhrase(RenderingContext.RES_REND_SEE_ON_THIS_PAGE)+" "); text.append(context.formatPhrase(RenderingContext.RES_REND_SEE_ON_THIS_PAGE)+" ");
} }
// what to display: if text is provided, then that. if the reference was resolved, then show the name, or the generated narrative // what to display: if text is provided, then that. if the reference was resolved, then show the name, or the generated narrative
@ -339,7 +349,7 @@ public abstract class ResourceRenderer extends DataRenderer {
if (display != null) { if (display != null) {
text.append(": "+display); text.append(": "+display);
} }
if ((tr == null || (tr.getReference() != null && !tr.getReference().startsWith("#"))) && name != null) { if ((tr == null || (tr.getWebPath() != null && !tr.getWebPath().startsWith("#"))) && name != null) {
text.append(" \""+name+"\""); text.append(" \""+name+"\"");
} }
if (r.hasExtension(ToolingExtensions.EXT_TARGET_ID) || r.hasExtension(ToolingExtensions.EXT_TARGET_PATH)) { if (r.hasExtension(ToolingExtensions.EXT_TARGET_ID) || r.hasExtension(ToolingExtensions.EXT_TARGET_PATH)) {
@ -367,7 +377,7 @@ public abstract class ResourceRenderer extends DataRenderer {
text.append(context.formatPhrase(RenderingContext.RES_REND_DESC)); text.append(context.formatPhrase(RenderingContext.RES_REND_DESC));
} }
} }
if (tr != null && tr.getReference() != null && tr.getReference().startsWith("#")) { if (tr != null && tr.getWebPath() != null && tr.getWebPath().startsWith("#")) {
text.append(")"); text.append(")");
} }
pieces.add(gen.new Piece(link,text.toString(), null)); pieces.add(gen.new Piece(link,text.toString(), null));
@ -385,8 +395,8 @@ public abstract class ResourceRenderer extends DataRenderer {
trt = resolveReference(res, r.primitiveValue("reference")); trt = resolveReference(res, r.primitiveValue("reference"));
if (!r.primitiveValue("reference").startsWith("#")) { if (!r.primitiveValue("reference").startsWith("#")) {
if (trt != null && trt.getReference() != null) { if (trt != null && trt.getWebPath() != null) {
link = trt.getReference(); link = trt.getWebPath();
} else if (r.primitiveValue("reference").contains("?")) { } else if (r.primitiveValue("reference").contains("?")) {
text.append(context.formatPhrase(RenderingContext.RES_REND_COND_REF)+" "); text.append(context.formatPhrase(RenderingContext.RES_REND_COND_REF)+" ");
} else { } else {
@ -394,7 +404,7 @@ public abstract class ResourceRenderer extends DataRenderer {
} }
} }
} }
if (trt != null && trt.getReference() != null && trt.getReference().startsWith("#")) { if (trt != null && trt.getWebPath() != null && trt.getWebPath().startsWith("#")) {
text.append(context.formatPhrase(RenderingContext.RES_REND_SEE_ON_THIS_PAGE)+" "); text.append(context.formatPhrase(RenderingContext.RES_REND_SEE_ON_THIS_PAGE)+" ");
} }
// what to display: if text is provided, then that. if the reference was resolved, then show the name, or the generated narrative // what to display: if text is provided, then that. if the reference was resolved, then show the name, or the generated narrative
@ -414,7 +424,7 @@ public abstract class ResourceRenderer extends DataRenderer {
if (display != null) { if (display != null) {
text.append(": "+display); text.append(": "+display);
} }
if ((trt == null || (trt.getReference() != null && !trt.getReference().startsWith("#"))) && name != null) { if ((trt == null || (trt.getWebPath() != null && !trt.getWebPath().startsWith("#"))) && name != null) {
text.append(" \""+name+"\""); text.append(" \""+name+"\"");
} }
if (r.hasExtension(ToolingExtensions.EXT_TARGET_ID) || r.hasExtension(ToolingExtensions.EXT_TARGET_PATH)) { if (r.hasExtension(ToolingExtensions.EXT_TARGET_ID) || r.hasExtension(ToolingExtensions.EXT_TARGET_PATH)) {
@ -442,7 +452,7 @@ public abstract class ResourceRenderer extends DataRenderer {
text.append(context.formatPhrase(RenderingContext.RES_REND_DESC)); text.append(context.formatPhrase(RenderingContext.RES_REND_DESC));
} }
} }
if (trt != null && trt.getReference() != null && trt.getReference().startsWith("#")) { if (trt != null && trt.getWebPath() != null && trt.getWebPath().startsWith("#")) {
text.append(")"); text.append(")");
} }
pieces.add(gen.new Piece(link,text.toString(), null)); pieces.add(gen.new Piece(link,text.toString(), null));
@ -480,7 +490,7 @@ public abstract class ResourceRenderer extends DataRenderer {
} else { } else {
ResourceWithReference rr = resolveReference(resource, uri.primitiveValue()); ResourceWithReference rr = resolveReference(resource, uri.primitiveValue());
if (rr != null) { if (rr != null) {
x.ah(rr.getReference()).addText(RendererFactory.factory(rr.getResource(), context).displayResource(rr.getResource())); x.ah(rr.getWebPath()).addText(RendererFactory.factory(rr.getResource(), context).displayResource(rr.getResource()));
} else { } else {
Resource r = context.getContext().fetchResource(Resource.class, v); Resource r = context.getContext().fetchResource(Resource.class, v);
if (r != null && r.getWebPath() != null) { if (r != null && r.getWebPath() != null) {
@ -504,16 +514,21 @@ public abstract class ResourceRenderer extends DataRenderer {
protected void renderUri(RenderingStatus status, XhtmlNode x, ResourceElement uri) throws FHIRFormatError, DefinitionException, IOException { protected void renderUri(RenderingStatus status, XhtmlNode x, ResourceElement uri) throws FHIRFormatError, DefinitionException, IOException {
if (!renderPrimitiveWithNoValue(status, x, uri)) { if (!renderPrimitiveWithNoValue(status, x, uri)) {
String v = uri.primitiveValue(); String v = uri.primitiveValue();
if (context.getContextUtilities().isResource(v)) {
v = "http://hl7.org/fhir/StructureDefinition/"+v;
}
if (v.startsWith("mailto:")) { if (v.startsWith("mailto:")) {
x.ah(v).addText(v.substring(7)); x.ah(v).addText(v.substring(7));
} else { } else {
ResourceWithReference rr = resolveReference(uri); ResourceWithReference rr = resolveReference(uri);
if (rr != null) { if (rr != null) {
x.ah(rr.getReference()).addText(RendererFactory.factory(rr.getResource(), context).displayResource(rr.getResource())); x.ah(rr.getWebPath()).addText(RendererFactory.factory(rr.getResource(), context).displayResource(rr.getResource()));
} else { } else {
Resource r = context.getContext().fetchResource(Resource.class, v); Resource r = context.getContext().fetchResource(Resource.class, v);
if (r != null && r.getWebPath() != null) { if (r != null && r.getWebPath() != null) {
x.ah(r.getWebPath()).addText(RendererFactory.factory(r, context).displayResource(wrap(r))); x.ah(r.getWebPath()).addText(RendererFactory.factory(r, context).displayResource(wrap(r)));
} else if (r != null) {
x.ah(v).addText(RendererFactory.factory(r, context).displayResource(wrap(r)));
} else { } else {
String url = context.getResolver() != null ? context.getResolver().resolveUri(context, v) : null; String url = context.getResolver() != null ? context.getResolver().resolveUri(context, v) : null;
if (url != null) { if (url != null) {
@ -548,12 +563,12 @@ public abstract class ResourceRenderer extends DataRenderer {
if (container == null) { if (container == null) {
return null; return null;
} else if ("#".equals(url)) { } else if ("#".equals(url)) {
return new ResourceWithReference(ResourceReferenceKind.CONTAINER, "#hc"+container.getScopedId(), container); return new ResourceWithReference(ResourceReferenceKind.CONTAINER, url, "#hc"+container.getScopedId(), container);
} else { } else {
String tid = url.substring(1); String tid = url.substring(1);
for (ResourceElement c : container.children("contained")) { for (ResourceElement c : container.children("contained")) {
if (tid.equals(c.getId())) { if (tid.equals(c.getId())) {
return new ResourceWithReference(ResourceReferenceKind.CONTAINED, "#hc"+c.getScopedId(), c); return new ResourceWithReference(ResourceReferenceKind.CONTAINED, url, "#hc"+c.getScopedId(), c);
} }
} }
} }
@ -583,24 +598,25 @@ public abstract class ResourceRenderer extends DataRenderer {
} }
container = container.parent(); container = container.parent();
} }
}
// ok, we didn't find it in the current instance, so we go look elsewhere
if (context.getResolver() != null) {
ResourceWithReference rr = context.getResolver().resolve(context, url, version);
if (rr != null) {
return rr;
}
}
Resource r = context.getWorker().fetchResource(Resource.class, url, version);
if (r != null) {
return new ResourceWithReference(ResourceReferenceKind.EXTERNAL, r.getWebPath(), wrap(r));
} }
// }
// // ok, we didn't find it in the current instance, so we go look elsewhere
// if (context.getResolver() != null) {
// ResourceWithReference rr = context.getResolver().resolve(context, url, version);
// if (rr != null) {
// return rr;
// }
// }
// Resource r = context.getWorker().fetchResource(Resource.class, url, version);
// if (r != null) {
// return new ResourceWithReference(ResourceReferenceKind.EXTERNAL, url, r.getWebPath(), wrap(r));
// }
return null; return null;
} }
private ResourceWithReference findInBundle(ResourceElement resource, String url) { private ResourceWithReference findInBundle(ResourceElement resource, String url) {
if (url.equals("Bundle/"+resource.getId())) { if (url.equals("Bundle/"+resource.getId())) {
return new ResourceWithReference(ResourceReferenceKind.BUNDLE, "#"+resource.getScopedId(), resource); return new ResourceWithReference(ResourceReferenceKind.BUNDLE, url, "#"+resource.getScopedId(), resource);
} }
for (ResourceElement entry : resource.children("entry")) { for (ResourceElement entry : resource.children("entry")) {
if (entry.has("resource")) { if (entry.has("resource")) {
@ -608,7 +624,7 @@ public abstract class ResourceRenderer extends DataRenderer {
if (entry.has("fullUrl")) { if (entry.has("fullUrl")) {
String fu = entry.primitiveValue("fullUrl"); String fu = entry.primitiveValue("fullUrl");
if (url.equals(fu)) { if (url.equals(fu)) {
return new ResourceWithReference(ResourceReferenceKind.BUNDLE, "#"+res.getScopedId(), res); return new ResourceWithReference(ResourceReferenceKind.BUNDLE, url, "#"+res.getScopedId(), res);
} }
} }
if ("Bundle".equals(res.fhirType())) { if ("Bundle".equals(res.fhirType())) {

View File

@ -55,7 +55,7 @@ public class StructureMapRenderer extends TerminologyRenderer {
@Override @Override
public void renderResource(RenderingStatus status, XhtmlNode x, ResourceElement r) throws FHIRFormatError, DefinitionException, IOException, FHIRException, EOperationOutcome { public void renderResource(RenderingStatus status, XhtmlNode x, ResourceElement r) throws FHIRFormatError, DefinitionException, IOException, FHIRException, EOperationOutcome {
if (r.isDirect()) { if (r.isDirect()) {
renderMap(status, x, (StructureMap) r.getBase()); renderMap(status, x.pre("fml"), (StructureMap) r.getBase());
} else { } else {
throw new Error("StructureMapRenderer only renders native resources directly"); throw new Error("StructureMapRenderer only renders native resources directly");
} }

View File

@ -270,6 +270,8 @@ public class RenderingContext extends RenderingI18nContext {
private Map<String, String> namedLinks = new HashMap<>(); private Map<String, String> namedLinks = new HashMap<>();
private boolean addName = false; private boolean addName = false;
private Map<String, String> typeMap = new HashMap<>(); // type aliases that can be resolved in Markdown type links (mainly for cross-version usage) private Map<String, String> typeMap = new HashMap<>(); // type aliases that can be resolved in Markdown type links (mainly for cross-version usage)
private int base64Limit = 1024;
private boolean shortPatientForm;
/** /**
* *
@ -801,6 +803,9 @@ public class RenderingContext extends RenderingI18nContext {
} }
public String getTranslated(ResourceElement t) { public String getTranslated(ResourceElement t) {
if (t == null) {
return null;
}
if (locale != null) { if (locale != null) {
for (ResourceElement e : t.extensions(ToolingExtensions.EXT_TRANSLATION)) { for (ResourceElement e : t.extensions(ToolingExtensions.EXT_TRANSLATION)) {
String l = e.extensionString("lang"); String l = e.extensionString("lang");
@ -952,5 +957,22 @@ public class RenderingContext extends RenderingI18nContext {
} }
return contextUtilities; return contextUtilities;
} }
public int getBase64Limit() {
return base64Limit;
}
public void setBase64Limit(int base64Limit) {
this.base64Limit = base64Limit;
}
public boolean isShortPatientForm() {
return shortPatientForm;
}
public void setShortPatientForm(boolean shortPatientForm) {
this.shortPatientForm = shortPatientForm;
}
} }

View File

@ -190,13 +190,15 @@ public class Resolver {
public static class ResourceWithReference { public static class ResourceWithReference {
private ResourceReferenceKind kind; private ResourceReferenceKind kind;
private String reference; private String urlReference;
private String webPath;
private ResourceElement resource; private ResourceElement resource;
public ResourceWithReference(ResourceReferenceKind kind, String reference, ResourceElement resource) { public ResourceWithReference(ResourceReferenceKind kind, String urlReference, String webPath, ResourceElement resource) {
super(); super();
this.kind = kind; this.kind = kind;
this.reference = reference; this.urlReference = urlReference;
this.webPath = webPath;
this.resource = resource; this.resource = resource;
} }
@ -204,8 +206,12 @@ public class Resolver {
return kind; return kind;
} }
public String getReference() { public String getUrlReference() {
return reference; return urlReference;
}
public String getWebPath() {
return webPath == null ? urlReference : webPath;
} }
public ResourceElement getResource() { public ResourceElement getResource() {

View File

@ -19,6 +19,7 @@ import org.hl7.fhir.r5.model.Property;
import org.hl7.fhir.r5.model.Resource; import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.StructureDefinition; import org.hl7.fhir.r5.model.StructureDefinition;
import org.hl7.fhir.r5.model.ValueSet; import org.hl7.fhir.r5.model.ValueSet;
import org.hl7.fhir.utilities.DebugUtilities;
import org.hl7.fhir.utilities.xhtml.NodeType; import org.hl7.fhir.utilities.xhtml.NodeType;
import org.hl7.fhir.utilities.xhtml.XhtmlNode; import org.hl7.fhir.utilities.xhtml.XhtmlNode;
@ -319,33 +320,44 @@ public class ResourceElement {
private void loadElementChildren() { private void loadElementChildren() {
SourcedChildDefinitions childDefs = propertyDefinition == null ? null : profileUtils.getChildMap(classDefinition, propertyDefinition); SourcedChildDefinitions childDefs = propertyDefinition == null ? null : profileUtils.getChildMap(classDefinition, propertyDefinition);
if ((childDefs == null || childDefs.getList().isEmpty()) && (propertyDefinition != null && propertyDefinition.getType().size() == 1)) {
StructureDefinition classDefinition = profileUtils.getContext().fetchTypeDefinition(fhirType());
childDefs = profileUtils.getChildMap(classDefinition, classDefinition.getSnapshot().getElementFirstRep());
}
for (Property p : element.children()) { for (Property p : element.children()) {
String name = p.getName(); String name = p.getName();
int i = 0; int i = 0;
for (Base v : p.getValues()) { for (Base v : p.getValues()) {
ElementKind kind = determineModelKind(p, v); loadElementChild(childDefs, p, name, i, v);
int index = p.isList() ? i : -1;
ElementDefinition ed = null;
if (childDefs != null) {
for (ElementDefinition t : childDefs.getList()) {
if (t.getName().equals(name)) {
ed = t;
break;
}
}
}
if (ed != null) {
children.add(makeChild(name, index, kind, v, childDefs.getSource(), ed));
} else {
StructureDefinition sd = profileUtils.getContext().fetchTypeDefinition(v.fhirType());
ElementDefinition ted = sd.getSnapshot().getElementFirstRep();
children.add(makeChild(name, index, kind, v, sd, ted));
}
i++; i++;
} }
} }
} }
private void loadElementChild(SourcedChildDefinitions childDefs, Property p, String name, int i, Base v) {
ElementKind kind = determineModelKind(p, v);
int index = p.isList() ? i : -1;
ElementDefinition ed = null;
if (childDefs != null) {
for (ElementDefinition t : childDefs.getList()) {
if (t.getName().equals(name)) {
ed = t;
break;
}
}
}
if (ed != null) {
children.add(makeChild(name, index, kind, v, childDefs.getSource(), ed));
} else {
StructureDefinition sd = profileUtils.getContext().fetchTypeDefinition(v.fhirType());
if (sd == null) {
DebugUtilities.breakpoint();
}
ElementDefinition ted = sd.getSnapshot().getElementFirstRep();
children.add(makeChild(name, index, kind, v, sd, ted));
}
}
private ElementKind determineModelKind(Property p, Base v) { private ElementKind determineModelKind(Property p, Base v) {
if (v.isPrimitive()) { if (v.isPrimitive()) {
return ElementKind.PrimitiveType; return ElementKind.PrimitiveType;
@ -465,13 +477,25 @@ public class ResourceElement {
public boolean has(String name) { public boolean has(String name) {
loadChildren(); loadChildren();
for (ResourceElement e : children) { for (ResourceElement e : children) {
if (name.equals(e.name())) { if (name.equals(e.name()) || (name+"[x]").equals(e.name())) {
return true; return true;
} }
} }
return false; return false;
} }
public boolean hasMN(String... names) {
loadChildren();
for (ResourceElement e : children) {
for (String name : names) {
if (name.equals(e.name()) || (name+"[x]").equals(e.name())) {
return true;
}
}
}
return false;
}
public ResourceElement resource() { public ResourceElement resource() {
ResourceElement e = this.parent; ResourceElement e = this.parent;
while (e != null && !e.isResource()) { while (e != null && !e.isResource()) {
@ -814,6 +838,5 @@ public class ResourceElement {
} }
return null; return null;
} }
} }

View File

@ -265,18 +265,18 @@ public class NarrativeGenerationTests {
TextFile.stringToFile(actual, actualFileName); TextFile.stringToFile(actual, actualFileName);
String msg = CompareUtilities.checkXMLIsSame(id, expectedFileName, actualFileName); String msg = CompareUtilities.checkXMLIsSame(id, expectedFileName, actualFileName);
Assertions.assertTrue(msg == null, "Output does not match expected: "+msg); Assertions.assertTrue(msg == null, "Output does not match expected: "+msg);
//
if (test.isMeta()) { // if (test.isMeta()) {
org.hl7.fhir.r5.elementmodel.Element e = Manager.parseSingle(context, TestingUtilities.loadTestResourceStream("r5", "narrative", test.getId() + ".xml"), FhirFormat.XML); // org.hl7.fhir.r5.elementmodel.Element e = Manager.parseSingle(context, TestingUtilities.loadTestResourceStream("r5", "narrative", test.getId() + ".xml"), FhirFormat.XML);
x = RendererFactory.factory(source, rc).build(ResourceElement.forResource(rc.getContextUtilities(), rc.getProfileUtilities(), e)); // x = RendererFactory.factory(source, rc).build(ResourceElement.forResource(rc.getContextUtilities(), rc.getProfileUtilities(), e));
//
expected = TextFile.streamToString(TestingUtilities.loadTestResourceStream("r5", "narrative", "output", test.getId() + "-meta.html")); // expected = TextFile.streamToString(TestingUtilities.loadTestResourceStream("r5", "narrative", "output", test.getId() + "-meta.html"));
actual = HEADER+new XhtmlComposer(true, true).compose(x)+FOOTER; // actual = HEADER+new XhtmlComposer(true, true).compose(x)+FOOTER;
actualFileName = CompareUtilities.tempFile("narrative", test.getId() + "-meta.actual.html"); // actualFileName = CompareUtilities.tempFile("narrative", test.getId() + "-meta.actual.html");
TextFile.stringToFile(actual, actualFileName); // TextFile.stringToFile(actual, actualFileName);
msg = CompareUtilities.checkXMLIsSame(id, expectedFileName, actualFileName); // msg = CompareUtilities.checkXMLIsSame(id, expectedFileName, actualFileName);
Assertions.assertTrue(msg == null, "Meta output does not match expected: "+msg); // Assertions.assertTrue(msg == null, "Meta output does not match expected: "+msg);
} // }
} }
} }

View File

@ -190,7 +190,7 @@ DATA_REND_AFTRWKNG = after waking
DATA_REND_ATBKFST = at breakfast DATA_REND_ATBKFST = at breakfast
DATA_REND_ATDINR = at dinner DATA_REND_ATDINR = at dinner
DATA_REND_ATLUNCH = at lunch DATA_REND_ATLUNCH = at lunch
DATA_REND_BASE64 = (base64 data - {0} bytes) DATA_REND_BASE64 = (base64 data - {0} base64 chars)
DATA_REND_BFBKFST = before breakfast DATA_REND_BFBKFST = before breakfast
DATA_REND_BFDINR = before dinner DATA_REND_BFDINR = before dinner
DATA_REND_BFLUNCH = before lunch DATA_REND_BFLUNCH = before lunch
@ -252,7 +252,7 @@ DIAG_REP_REND_FOR = for
DIAG_REP_REND_IDENTIFIER = Identifier DIAG_REP_REND_IDENTIFIER = Identifier
GENERAL_TODO = Not done yet GENERAL_TODO = Not done yet
GENERAL_NOTE = Note GENERAL_NOTE = Note
DIAG_REP_REND_NOTRES = This Observation could not be resolved DIAG_REP_REND_NOTRES = The observation ''{0}'' could not be resolved
DIAG_REP_REND_OBS = Observation DIAG_REP_REND_OBS = Observation
DIAG_REP_REND_PER = Performer DIAG_REP_REND_PER = Performer
DIAG_REP_REND_REFRAN = Reference Range DIAG_REP_REND_REFRAN = Reference Range