changes after testing complete
This commit is contained in:
parent
31a7793c49
commit
d23052f329
|
@ -56,7 +56,7 @@ public class BundleRenderer extends ResourceRenderer {
|
|||
} else if ("collection".equals(b.primitiveValue("type")) && allEntriesAreHistoryProvenance(entries)) {
|
||||
// nothing
|
||||
} else {
|
||||
XhtmlNode root = new XhtmlNode(NodeType.Element, "div");
|
||||
XhtmlNode root = x;
|
||||
root.para().addText(formatPhrase(RenderingContext.BUNDLE_HEADER_ROOT, b.getId(), b.primitiveValue("type")));
|
||||
int i = 0;
|
||||
for (ResourceElement be : entries) {
|
||||
|
@ -80,6 +80,9 @@ public class BundleRenderer extends ResourceRenderer {
|
|||
} else {
|
||||
root.para().addText(formatPhrase(RenderingContext.BUNDLE_HEADER_ENTRY, Integer.toString(i)));
|
||||
}
|
||||
if (be.has("search")) {
|
||||
renderSearch(x, be.child("search"));
|
||||
}
|
||||
// if (be.hasRequest())
|
||||
// renderRequest(root, be.getRequest());
|
||||
// if (be.hasSearch())
|
||||
|
@ -102,9 +105,6 @@ public class BundleRenderer extends ResourceRenderer {
|
|||
}
|
||||
root.blockquote().para().addChildren(xn);
|
||||
}
|
||||
if (be.has("search")) {
|
||||
renderSearch(x, be.child("search"));
|
||||
}
|
||||
if (be.has("request")) {
|
||||
renderRequest(x, be.child("request"));
|
||||
}
|
||||
|
|
|
@ -434,7 +434,7 @@ public class CapabilityStatementRenderer extends ResourceRenderer {
|
|||
boolean first = true;
|
||||
for (CanonicalType ct : cap.getInstantiates()) {
|
||||
if (first) {first = false;} else {p.tx(", ");};
|
||||
renderCanonical(status, res, x, CapabilityStatement.class, ct);
|
||||
renderCanonical(status, res, p, CapabilityStatement.class, ct);
|
||||
}
|
||||
}
|
||||
if (cap.hasImports()) {
|
||||
|
@ -443,7 +443,7 @@ public class CapabilityStatementRenderer extends ResourceRenderer {
|
|||
boolean first = true;
|
||||
for (CanonicalType ct : cap.getImports()) {
|
||||
if (first) {first = false;} else {p.tx(", ");};
|
||||
renderCanonical(status, res, x, CapabilityStatement.class, ct);
|
||||
renderCanonical(status, res, p, CapabilityStatement.class, ct);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -736,6 +736,8 @@ public class DataRenderer extends Renderer implements CodeResolver {
|
|||
renderDateTime(status, x, type);
|
||||
break;
|
||||
case "uri" :
|
||||
case "url" :
|
||||
case "canonical" :
|
||||
renderUri(status, x, type);
|
||||
break;
|
||||
case "Annotation":
|
||||
|
@ -799,11 +801,21 @@ public class DataRenderer extends Renderer implements CodeResolver {
|
|||
renderReference(status, x, type.child("reference"));
|
||||
}
|
||||
break;
|
||||
case "MarkdownType":
|
||||
case "code":
|
||||
x.tx(getTranslatedCode(type));
|
||||
break;
|
||||
case "markdown":
|
||||
addMarkdown(x, context.getTranslated(type));
|
||||
break;
|
||||
case "Base64BinaryType":
|
||||
x.tx(context.formatPhrase(RenderingContext.DATA_REND_BASE64, type.primitiveValue().length()));
|
||||
case "base64Binary":
|
||||
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:
|
||||
if (type.isPrimitive()) {
|
||||
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 {
|
||||
if (!renderPrimitiveWithNoValue(status, x, uri)) {
|
||||
String v = uri.primitiveValue();
|
||||
if (context.getContextUtilities().isResource(v)) {
|
||||
v = "http://hl7.org/fhir/"+v;
|
||||
}
|
||||
if (v.startsWith("mailto:")) {
|
||||
x.ah(v).addText(v.substring(7));
|
||||
} 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();
|
||||
s.append(describeSystem(contact.primitiveValue("system")));
|
||||
if (Utilities.noString(contact.primitiveValue("value")))
|
||||
|
@ -1563,11 +1578,11 @@ public class DataRenderer extends Renderer implements CodeResolver {
|
|||
else
|
||||
s.append(contact.primitiveValue("value"));
|
||||
if (contact.has("use"))
|
||||
s.append("("+contact.primitiveValue("use")+")");
|
||||
s.append("("+getTranslatedCode(contact.child("use"))+")");
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
public static String displayContactDetail(ResourceElement contact) {
|
||||
public String displayContactDetail(ResourceElement contact) {
|
||||
CommaSeparatedStringBuilder s = new CommaSeparatedStringBuilder();
|
||||
for (ResourceElement cp : contact.children("telecom")) {
|
||||
s.append(displayContactPoint(cp));
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package org.hl7.fhir.r5.renderers;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import org.hl7.fhir.exceptions.DefinitionException;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
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.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
|
||||
|
||||
|
||||
public class DiagnosticReportRenderer extends ResourceRenderer {
|
||||
|
||||
|
||||
public class ObservationNode {
|
||||
private String ref;
|
||||
private ResourceWithReference resolution;
|
||||
private List<ObservationNode> contained;
|
||||
}
|
||||
|
||||
|
||||
public DiagnosticReportRenderer(RenderingContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void renderResource(RenderingStatus status, XhtmlNode x, ResourceElement dr) throws IOException, FHIRException, EOperationOutcome {
|
||||
renderDiagnosticReport(status, x, dr);
|
||||
}
|
||||
|
||||
|
||||
public void renderDiagnosticReport(RenderingStatus status, XhtmlNode x, ResourceElement dr) throws IOException, FHIRException, EOperationOutcome {
|
||||
XhtmlNode h2 = x.h2();
|
||||
renderDataType(status, h2, dr.child("code"));
|
||||
|
@ -54,9 +54,9 @@ public class DiagnosticReportRenderer extends ResourceRenderer {
|
|||
XhtmlNode tbl = x.table("grid");
|
||||
XhtmlNode tr;
|
||||
if (dr.has("subject")) {
|
||||
tr = tbl.tr();
|
||||
tr.td().tx(context.formatPhrase(RenderingContext.GENERAL_SUBJ));
|
||||
populateSubjectSummary(status, tr.td(), dr.child("subject"));
|
||||
tr = tbl.tr();
|
||||
tr.td().tx(context.formatPhrase(RenderingContext.GENERAL_SUBJ));
|
||||
populateSubjectSummary(status, tr.td(), dr.child("subject"));
|
||||
}
|
||||
|
||||
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_IDENTIFIER, "identifier");
|
||||
addTableRow(status, tbl, dr, RenderingContext.GENERAL_REQUEST, "request");
|
||||
|
||||
|
||||
x.para().b().tx(context.formatPhrase(RenderingContext.DIAG_REP_REND_REPDET));
|
||||
|
||||
|
||||
List<ResourceElement> items = dr.children("result");
|
||||
if (!items.isEmpty()) {
|
||||
List<ObservationNode> observations = fetchObservations(items);
|
||||
buildObservationsTable(status, x, observations, eff, iss);
|
||||
}
|
||||
|
||||
|
||||
if (dr.has("conclusion")) {
|
||||
ResourceElement conc = dr.child("conclusion");
|
||||
if (conc.fhirType().equals("markdown")) {
|
||||
|
@ -95,14 +95,17 @@ public class DiagnosticReportRenderer extends ResourceRenderer {
|
|||
}
|
||||
}
|
||||
|
||||
tbl = x.table("grid");
|
||||
addTableRow(status, tbl, dr, RenderingContext.DIAG_REP_REND_CODECON, "conclusionCode", "codedDiagnosis");
|
||||
if (dr.hasMN("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")) {
|
||||
x.hr();
|
||||
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 {
|
||||
List<ResourceElement> items = dr.childrenMN(names);
|
||||
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) {
|
||||
x.tx(displayDiagnosticReport(dr));
|
||||
}
|
||||
|
||||
|
||||
public String displayDiagnosticReport(ResourceElement dr) {
|
||||
return displayDataType(dr.child("code"));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String displayResource(ResourceElement r) throws UnsupportedEncodingException, IOException {
|
||||
return displayDiagnosticReport(r);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void populateSubjectSummary(RenderingStatus status, XhtmlNode container, ResourceElement subject) throws UnsupportedEncodingException, FHIRException, IOException, EOperationOutcome {
|
||||
ResourceWithReference r = resolveReference(subject);
|
||||
if (r == null)
|
||||
|
@ -139,11 +152,11 @@ public class DiagnosticReportRenderer extends ResourceRenderer {
|
|||
else
|
||||
container.tx(context.formatPhrase(RenderingContext.GENERAL_TODO));
|
||||
}
|
||||
|
||||
|
||||
private void generatePatientSummary(XhtmlNode c, ResourceElement r) throws FHIRFormatError, DefinitionException, FHIRException, IOException, EOperationOutcome {
|
||||
new PatientRenderer(context).describe(c, r);
|
||||
}
|
||||
|
||||
|
||||
private List<ObservationNode> fetchObservations(List<ResourceElement> list) throws UnsupportedEncodingException, FHIRException, IOException {
|
||||
List<ObservationNode> res = new ArrayList<ObservationNode>();
|
||||
for (ResourceElement b : list) {
|
||||
|
@ -162,7 +175,7 @@ public class DiagnosticReportRenderer extends ResourceRenderer {
|
|||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
private void buildObservationsTable(RenderingStatus status, XhtmlNode root, List<ObservationNode> observations, ResourceElement eff, ResourceElement iss) throws UnsupportedEncodingException, FHIRException, IOException {
|
||||
XhtmlNode tbl = root.table("grid");
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean scanObsForRefRange(List<ObservationNode> observations) {
|
||||
for (ObservationNode o : observations) {
|
||||
ResourceElement obs = o.resolution.getResource();
|
||||
if (obs != null && obs.has("referenceRange")) {
|
||||
return true;
|
||||
}
|
||||
if (o.contained != null) {
|
||||
if (scanObsForRefRange(o.contained)) {
|
||||
if (o.resolution != null) {
|
||||
ResourceElement obs = o.resolution.getResource();
|
||||
if (obs != null && obs.has("referenceRange")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (o.contained != null) {
|
||||
if (scanObsForRefRange(o.contained)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private boolean scanObsForNote(List<ObservationNode> observations) {
|
||||
for (ObservationNode o : observations) {
|
||||
ResourceElement obs = o.resolution.getResource();
|
||||
if (obs != null && obs.has("note")) {
|
||||
return true;
|
||||
}
|
||||
if (o.contained != null) {
|
||||
if (scanObsForNote(o.contained)) {
|
||||
if (o.resolution != null) {
|
||||
ResourceElement obs = o.resolution.getResource();
|
||||
if (obs != null && obs.has("note")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (o.contained != null) {
|
||||
if (scanObsForNote(o.contained)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private boolean scanObsForIssued(List<ObservationNode> observations, ResourceElement iss) throws UnsupportedEncodingException, FHIRException, IOException {
|
||||
for (ObservationNode o : observations) {
|
||||
ResourceElement obs = o.resolution.getResource();
|
||||
if (obs != null && obs.has("issued") && (iss == null || !iss.matches(obs.child("issued")))) {
|
||||
return true;
|
||||
}
|
||||
if (o.contained != null) {
|
||||
if (scanObsForIssued(o.contained, iss)) {
|
||||
if (o.resolution != null) {
|
||||
ResourceElement obs = o.resolution.getResource();
|
||||
if (obs != null && obs.has("issued") && (iss == null || !iss.matches(obs.child("issued")))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (o.contained != null) {
|
||||
if (scanObsForIssued(o.contained, iss)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private boolean scanObsForEffective(List<ObservationNode> observations, ResourceElement eff) throws UnsupportedEncodingException, FHIRException, IOException {
|
||||
for (ObservationNode o : observations) {
|
||||
ResourceElement obs = o.resolution.getResource();
|
||||
if (obs != null && obs.has("effective[x]") && (eff == null || !eff.matches(obs.child("effective[x]")))) {
|
||||
return true;
|
||||
}
|
||||
if (o.contained != null) {
|
||||
if (scanObsForEffective(o.contained, eff)) {
|
||||
if (o.resolution != null) {
|
||||
ResourceElement obs = o.resolution.getResource();
|
||||
if (obs != null && obs.has("effective[x]") && (eff == null || !eff.matches(obs.child("effective[x]")))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (o.contained != null) {
|
||||
if (scanObsForEffective(o.contained, eff)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private boolean scanObsForFlags(List<ObservationNode> observations) throws UnsupportedEncodingException, FHIRException, IOException {
|
||||
for (ObservationNode o : observations) {
|
||||
ResourceElement obs = o.resolution.getResource();
|
||||
if (obs != null && (obs.has("interpretation") || obs.has("status"))) {
|
||||
return true;
|
||||
}
|
||||
if (o.contained != null) {
|
||||
if (scanObsForFlags(o.contained)) {
|
||||
if (o.resolution != null) {
|
||||
ResourceElement obs = o.resolution.getResource();
|
||||
if (obs != null && (obs.has("interpretation") || obs.has("status"))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (o.contained != null) {
|
||||
if (scanObsForFlags(o.contained)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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 {
|
||||
XhtmlNode tr = tbl.tr();
|
||||
if (o.resolution == null) {
|
||||
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 {
|
||||
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 {
|
||||
XhtmlNode td = tr.td().colspan(cs);
|
||||
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 {
|
||||
|
||||
|
||||
// code (+bodysite)
|
||||
XhtmlNode td = tr.td();
|
||||
if (obs.has("code")) {
|
||||
|
@ -306,7 +329,7 @@ public class DiagnosticReportRenderer extends ResourceRenderer {
|
|||
renderDataType(status, td, obs.child("bodySite"));
|
||||
td.tx(")");
|
||||
}
|
||||
|
||||
|
||||
// value / dataAbsentReason (in red)
|
||||
td = tr.td();
|
||||
if (obs.has("value[x]")) {
|
||||
|
@ -375,7 +398,7 @@ public class DiagnosticReportRenderer extends ResourceRenderer {
|
|||
addCellToTable(note, status, tr, obs, null, "note");
|
||||
addCellToTable(effectiveTime, status, tr, obs, eff, "effective[x]");
|
||||
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 {
|
||||
|
@ -393,5 +416,5 @@ public class DiagnosticReportRenderer extends ResourceRenderer {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public class EncounterRenderer extends ResourceRenderer {
|
|||
|
||||
@Override
|
||||
public void renderResource(RenderingStatus status, XhtmlNode x, ResourceElement r) throws FHIRFormatError, DefinitionException, IOException, FHIRException, EOperationOutcome {
|
||||
throw new Error("todo");
|
||||
x.tx("Not done yet");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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 {
|
||||
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) {
|
||||
tr.td().tx(ra.has("label") ? ra.primitiveValue("label") : null);
|
||||
}
|
||||
|
|
|
@ -31,21 +31,20 @@ public class ListRenderer extends ResourceRenderer {
|
|||
}
|
||||
XhtmlNode t = x.table("clstu");
|
||||
XhtmlNode tr = t.tr();
|
||||
XhtmlNode td = tr.td();
|
||||
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")) {
|
||||
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")) {
|
||||
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")) {
|
||||
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();
|
||||
td = tr.td();
|
||||
XhtmlNode td = tr.td();
|
||||
if (list.has("subject")) {
|
||||
td.tx(context.formatPhrase(RenderingContext.LIST_REND_SUB)+" ");
|
||||
renderReference(status, td, list.child("subject"));
|
||||
|
|
|
@ -5,14 +5,16 @@ import java.io.UnsupportedEncodingException;
|
|||
|
||||
import org.hl7.fhir.exceptions.DefinitionException;
|
||||
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.ExtensionHelper;
|
||||
import org.hl7.fhir.r5.model.OperationOutcome;
|
||||
import org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity;
|
||||
import org.hl7.fhir.r5.model.OperationOutcome.OperationOutcomeIssueComponent;
|
||||
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.utils.RenderingContext;
|
||||
import org.hl7.fhir.r5.renderers.utils.ResourceElement;
|
||||
|
@ -58,7 +60,7 @@ public class OperationOutcomeRenderer extends ResourceRenderer {
|
|||
}
|
||||
for (ResourceElement i : op.children("issue")) {
|
||||
tr = tbl.tr();
|
||||
tr.td().addText(i.primitiveValue("severity"));
|
||||
tr.td().addText(getTranslatedCode(i.child("severity")));
|
||||
XhtmlNode td = tr.td();
|
||||
boolean d = false;
|
||||
for (ResourceElement s : i.has("expression") ? i.children("expression") : i.children("location")) {
|
||||
|
@ -68,8 +70,8 @@ public class OperationOutcomeRenderer extends ResourceRenderer {
|
|||
d = true;
|
||||
td.addText(s.primitiveValue());
|
||||
}
|
||||
tr.td().addText(i.child("code").primitiveValue("display"));
|
||||
tr.td().addText(i.primitiveValue("details"));
|
||||
tr.td().addText(getTranslatedCode(i.child("code")));
|
||||
tr.td().addText(i.child("details").primitiveValue("text"));
|
||||
smartAddText(tr.td(), i.primitiveValue("diagnostics"));
|
||||
if (hasSource) {
|
||||
ResourceElement ext = i.extension(ToolingExtensions.EXT_ISSUE_SOURCE);
|
||||
|
@ -78,7 +80,8 @@ public class OperationOutcomeRenderer extends ResourceRenderer {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void describe(XhtmlNode x, OperationOutcome oo) {
|
||||
x.tx(display(oo));
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public class PatientRenderer extends ResourceRenderer {
|
|||
ResourceElement dt = pat.child("birthDate");
|
||||
|
||||
StringBuilder b = new StringBuilder();
|
||||
if (b == null) {
|
||||
if (n != null) {
|
||||
b.append(displayHumanName(n));
|
||||
} else {
|
||||
b.append(context.formatPhrase(RenderingContext.PAT_NO_NAME));
|
||||
|
@ -97,7 +97,7 @@ public class PatientRenderer extends ResourceRenderer {
|
|||
|
||||
@Override
|
||||
public void renderResource(RenderingStatus status, XhtmlNode x, ResourceElement pat) throws FHIRFormatError, DefinitionException, IOException, FHIRException, EOperationOutcome {
|
||||
if (SHORT) {
|
||||
if (context.isShortPatientForm()) {
|
||||
ResourceElement id = null;
|
||||
List<ResourceElement> list = pat.children("identifier");
|
||||
for (ResourceElement t : list) {
|
||||
|
@ -111,7 +111,7 @@ public class PatientRenderer extends ResourceRenderer {
|
|||
String gender = null;
|
||||
ResourceElement item = pat.child("gender");
|
||||
if (item != null) {
|
||||
gender = context.getTranslatedCode(item.primitiveValue(), "http://hl7.org/fhir/administrative-gender");
|
||||
gender = getTranslatedCode(item);
|
||||
}
|
||||
ResourceElement dt = pat.child("birthDate");
|
||||
|
||||
|
@ -139,7 +139,7 @@ public class PatientRenderer extends ResourceRenderer {
|
|||
}
|
||||
} else {
|
||||
// banner
|
||||
describe(makeBanner(x.para()), pat);
|
||||
makeBanner(x.para()).tx(displayResource(pat));
|
||||
x.hr();
|
||||
XhtmlNode tbl;
|
||||
if (hasRenderablePhoto(pat)) {
|
||||
|
@ -271,7 +271,7 @@ public class PatientRenderer extends ResourceRenderer {
|
|||
renderDataType(status, li, s.child("value"));
|
||||
}
|
||||
} else {
|
||||
renderDataType(status, td, list.get(0));
|
||||
renderDataType(status, td, list.get(0).child("value"));
|
||||
}
|
||||
} else {
|
||||
for (ResourceElement ext : list) {
|
||||
|
|
|
@ -277,30 +277,30 @@ public class QuestionnaireRenderer extends TerminologyRenderer {
|
|||
}
|
||||
if ("true".equals(i.extensionString("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-ResourceElement-isSubject"))) {
|
||||
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))) {
|
||||
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))) {
|
||||
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")) {
|
||||
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)) {
|
||||
status.setExtensions(true);
|
||||
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)) {
|
||||
status.setExtensions(true);
|
||||
ResourceElement cc = i.extensionValue(ToolingExtensions.EXT_Q_DISPLAY_CAT);
|
||||
String code = getCodeFromCC(cc, "http://hl7.org/fhir/ResourceElement-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"))));
|
||||
String code = getCodeFromCC(cc, "http://hl7.org/fhir/questionnaire-display-category");
|
||||
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();
|
||||
|
@ -655,6 +655,7 @@ public class QuestionnaireRenderer extends TerminologyRenderer {
|
|||
XhtmlNode p = display.para();
|
||||
|
||||
String type = i.primitiveValue("type");
|
||||
String typeT = getTranslatedCode(i.child("type"));
|
||||
if ("group".equals(type)) {
|
||||
p = p.b();
|
||||
}
|
||||
|
@ -671,13 +672,13 @@ public class QuestionnaireRenderer extends TerminologyRenderer {
|
|||
switch (type) {
|
||||
case "string":
|
||||
p.tx(" ");
|
||||
input = p.input(i.primitiveValue("linkId"), "text", type, 60);
|
||||
input = p.input(i.primitiveValue("linkId"), "text", typeT, 60);
|
||||
break;
|
||||
case "attachment":
|
||||
break;
|
||||
case "boolean":
|
||||
p.tx(" ");
|
||||
input = p.input(i.primitiveValue("linkId"), "checkbox", type, 1);
|
||||
input = p.input(i.primitiveValue("linkId"), "checkbox", typeT, 1);
|
||||
break;
|
||||
case "coding":
|
||||
input = p.select(i.primitiveValue("linkId"));
|
||||
|
@ -685,15 +686,15 @@ public class QuestionnaireRenderer extends TerminologyRenderer {
|
|||
break;
|
||||
case "date":
|
||||
p.tx(" ");
|
||||
input = p.input(i.primitiveValue("linkId"), "date", type, 10);
|
||||
input = p.input(i.primitiveValue("linkId"), "date", typeT, 10);
|
||||
break;
|
||||
case "dateTime":
|
||||
p.tx(" ");
|
||||
input = p.input(i.primitiveValue("linkId"), "datetime-local", type, 25);
|
||||
input = p.input(i.primitiveValue("linkId"), "datetime-local", typeT, 25);
|
||||
break;
|
||||
case "decimal":
|
||||
p.tx(" ");
|
||||
input = p.input(i.primitiveValue("linkId"), "number", type, 15);
|
||||
input = p.input(i.primitiveValue("linkId"), "number", typeT, 15);
|
||||
break;
|
||||
case "display":
|
||||
break;
|
||||
|
@ -701,7 +702,7 @@ public class QuestionnaireRenderer extends TerminologyRenderer {
|
|||
break;
|
||||
case "integer":
|
||||
p.tx(" ");
|
||||
input = p.input(i.primitiveValue("linkId"), "number", type, 10);
|
||||
input = p.input(i.primitiveValue("linkId"), "number", typeT, 10);
|
||||
break;
|
||||
case "qantity":
|
||||
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"))) {
|
||||
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))) {
|
||||
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");
|
||||
}
|
||||
if ("true".equals(i.extensionString(ToolingExtensions.EXT_Q_OTP_DISP))) {
|
||||
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")) {
|
||||
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)) {
|
||||
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;
|
||||
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")) {
|
||||
|
|
|
@ -6,8 +6,10 @@ import org.hl7.fhir.r5.comparison.VersionComparisonAnnotation;
|
|||
import org.hl7.fhir.r5.context.IWorkerContext;
|
||||
import org.hl7.fhir.r5.model.Base;
|
||||
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.Resource;
|
||||
import org.hl7.fhir.r5.model.ValueSet;
|
||||
import org.hl7.fhir.r5.renderers.utils.RenderingContext;
|
||||
import org.hl7.fhir.r5.renderers.utils.ResourceElement;
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -179,7 +179,7 @@ public class RequirementsRenderer extends ResourceRenderer {
|
|||
li.ah(c.primitiveValue("reference")).tx(desc);
|
||||
} else if (t != null) {
|
||||
String desc = getResourceDescription(t, c.primitiveValue("display"));
|
||||
li.ah(t.getReference()).tx(desc);
|
||||
li.ah(t.getWebPath()).tx(desc);
|
||||
} else {
|
||||
li.ah(c.primitiveValue("reference")).tx(url);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.hl7.fhir.r5.model.CodeableReference;
|
|||
import org.hl7.fhir.r5.model.Coding;
|
||||
import org.hl7.fhir.r5.model.DataType;
|
||||
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.Extension;
|
||||
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.StructureDefinition;
|
||||
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.utils.RenderingContext;
|
||||
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
|
||||
ResourceWithReference rr = resolveReference(canonical);
|
||||
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 {
|
||||
x.tx("??");
|
||||
x.code(canonical.primitiveValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -241,14 +243,19 @@ public abstract class ResourceRenderer extends DataRenderer {
|
|||
}
|
||||
String url = canonical.asStringValue();
|
||||
Resource target = context.getWorker().fetchResource(Resource.class, url, res.getResourceNative());
|
||||
if (target == null || !(target instanceof CanonicalResource) || !target.hasWebPath()) {
|
||||
x.code().tx(url);
|
||||
if (target == null || !(target instanceof CanonicalResource)) {
|
||||
x.code().tx(url);
|
||||
} else {
|
||||
CanonicalResource cr = (CanonicalResource) target;
|
||||
if (url.contains("|")) {
|
||||
x.ah(target.getWebPath()).tx(cr.present()+ context.formatPhrase(RenderingContext.RES_REND_VER) +cr.getVersion()+")");
|
||||
if (!target.hasWebPath()) {
|
||||
x.code().tx(url);
|
||||
x.tx(" ("+cr.present()+")");
|
||||
} 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)) {
|
||||
@Override
|
||||
public void renderReference(RenderingStatus status, XhtmlNode x, ResourceElement type) throws FHIRFormatError, DefinitionException, IOException {
|
||||
if (type == null) {
|
||||
return;
|
||||
}
|
||||
ResourceElement display = null;
|
||||
ResourceElement actual = null;
|
||||
ResourceElement id = null;
|
||||
|
@ -281,7 +291,7 @@ public abstract class ResourceRenderer extends DataRenderer {
|
|||
x.ah(actual.primitiveValue()).tx(disp);
|
||||
} else {
|
||||
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) {
|
||||
renderDataType(status, x, display);
|
||||
|
@ -310,8 +320,8 @@ public abstract class ResourceRenderer extends DataRenderer {
|
|||
tr = resolveReference(res, r.getReference());
|
||||
|
||||
if (!r.getReference().startsWith("#")) {
|
||||
if (tr != null && tr.getReference() != null) {
|
||||
link = tr.getReference();
|
||||
if (tr != null && tr.getWebPath() != null) {
|
||||
link = tr.getWebPath();
|
||||
} else if (r.getReference().contains("?")) {
|
||||
text.append(context.formatPhrase(RenderingContext.RES_REND_COND_REF)+" ");
|
||||
} 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)+" ");
|
||||
}
|
||||
// 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) {
|
||||
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+"\"");
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
if (tr != null && tr.getReference() != null && tr.getReference().startsWith("#")) {
|
||||
if (tr != null && tr.getWebPath() != null && tr.getWebPath().startsWith("#")) {
|
||||
text.append(")");
|
||||
}
|
||||
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"));
|
||||
|
||||
if (!r.primitiveValue("reference").startsWith("#")) {
|
||||
if (trt != null && trt.getReference() != null) {
|
||||
link = trt.getReference();
|
||||
if (trt != null && trt.getWebPath() != null) {
|
||||
link = trt.getWebPath();
|
||||
} else if (r.primitiveValue("reference").contains("?")) {
|
||||
text.append(context.formatPhrase(RenderingContext.RES_REND_COND_REF)+" ");
|
||||
} 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)+" ");
|
||||
}
|
||||
// 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) {
|
||||
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+"\"");
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
if (trt != null && trt.getReference() != null && trt.getReference().startsWith("#")) {
|
||||
if (trt != null && trt.getWebPath() != null && trt.getWebPath().startsWith("#")) {
|
||||
text.append(")");
|
||||
}
|
||||
pieces.add(gen.new Piece(link,text.toString(), null));
|
||||
|
@ -480,7 +490,7 @@ public abstract class ResourceRenderer extends DataRenderer {
|
|||
} else {
|
||||
ResourceWithReference rr = resolveReference(resource, uri.primitiveValue());
|
||||
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 {
|
||||
Resource r = context.getContext().fetchResource(Resource.class, v);
|
||||
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 {
|
||||
if (!renderPrimitiveWithNoValue(status, x, uri)) {
|
||||
String v = uri.primitiveValue();
|
||||
if (context.getContextUtilities().isResource(v)) {
|
||||
v = "http://hl7.org/fhir/StructureDefinition/"+v;
|
||||
}
|
||||
if (v.startsWith("mailto:")) {
|
||||
x.ah(v).addText(v.substring(7));
|
||||
} else {
|
||||
ResourceWithReference rr = resolveReference(uri);
|
||||
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 {
|
||||
Resource r = context.getContext().fetchResource(Resource.class, v);
|
||||
if (r != null && r.getWebPath() != null) {
|
||||
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 {
|
||||
String url = context.getResolver() != null ? context.getResolver().resolveUri(context, v) : null;
|
||||
if (url != null) {
|
||||
|
@ -548,12 +563,12 @@ public abstract class ResourceRenderer extends DataRenderer {
|
|||
if (container == null) {
|
||||
return null;
|
||||
} else if ("#".equals(url)) {
|
||||
return new ResourceWithReference(ResourceReferenceKind.CONTAINER, "#hc"+container.getScopedId(), container);
|
||||
return new ResourceWithReference(ResourceReferenceKind.CONTAINER, url, "#hc"+container.getScopedId(), container);
|
||||
} else {
|
||||
String tid = url.substring(1);
|
||||
for (ResourceElement c : container.children("contained")) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
|
||||
private ResourceWithReference findInBundle(ResourceElement resource, String url) {
|
||||
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")) {
|
||||
if (entry.has("resource")) {
|
||||
|
@ -608,7 +624,7 @@ public abstract class ResourceRenderer extends DataRenderer {
|
|||
if (entry.has("fullUrl")) {
|
||||
String fu = entry.primitiveValue("fullUrl");
|
||||
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())) {
|
||||
|
|
|
@ -55,7 +55,7 @@ public class StructureMapRenderer extends TerminologyRenderer {
|
|||
@Override
|
||||
public void renderResource(RenderingStatus status, XhtmlNode x, ResourceElement r) throws FHIRFormatError, DefinitionException, IOException, FHIRException, EOperationOutcome {
|
||||
if (r.isDirect()) {
|
||||
renderMap(status, x, (StructureMap) r.getBase());
|
||||
renderMap(status, x.pre("fml"), (StructureMap) r.getBase());
|
||||
} else {
|
||||
throw new Error("StructureMapRenderer only renders native resources directly");
|
||||
}
|
||||
|
|
|
@ -270,6 +270,8 @@ public class RenderingContext extends RenderingI18nContext {
|
|||
private Map<String, String> namedLinks = new HashMap<>();
|
||||
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 int base64Limit = 1024;
|
||||
private boolean shortPatientForm;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -801,6 +803,9 @@ public class RenderingContext extends RenderingI18nContext {
|
|||
}
|
||||
|
||||
public String getTranslated(ResourceElement t) {
|
||||
if (t == null) {
|
||||
return null;
|
||||
}
|
||||
if (locale != null) {
|
||||
for (ResourceElement e : t.extensions(ToolingExtensions.EXT_TRANSLATION)) {
|
||||
String l = e.extensionString("lang");
|
||||
|
@ -952,5 +957,22 @@ public class RenderingContext extends RenderingI18nContext {
|
|||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -190,13 +190,15 @@ public class Resolver {
|
|||
public static class ResourceWithReference {
|
||||
|
||||
private ResourceReferenceKind kind;
|
||||
private String reference;
|
||||
private String urlReference;
|
||||
private String webPath;
|
||||
private ResourceElement resource;
|
||||
|
||||
public ResourceWithReference(ResourceReferenceKind kind, String reference, ResourceElement resource) {
|
||||
public ResourceWithReference(ResourceReferenceKind kind, String urlReference, String webPath, ResourceElement resource) {
|
||||
super();
|
||||
this.kind = kind;
|
||||
this.reference = reference;
|
||||
this.urlReference = urlReference;
|
||||
this.webPath = webPath;
|
||||
this.resource = resource;
|
||||
}
|
||||
|
||||
|
@ -204,8 +206,12 @@ public class Resolver {
|
|||
return kind;
|
||||
}
|
||||
|
||||
public String getReference() {
|
||||
return reference;
|
||||
public String getUrlReference() {
|
||||
return urlReference;
|
||||
}
|
||||
|
||||
public String getWebPath() {
|
||||
return webPath == null ? urlReference : webPath;
|
||||
}
|
||||
|
||||
public ResourceElement getResource() {
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.hl7.fhir.r5.model.Property;
|
|||
import org.hl7.fhir.r5.model.Resource;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||
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.XhtmlNode;
|
||||
|
||||
|
@ -319,33 +320,44 @@ public class ResourceElement {
|
|||
|
||||
private void loadElementChildren() {
|
||||
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()) {
|
||||
String name = p.getName();
|
||||
int i = 0;
|
||||
for (Base v : p.getValues()) {
|
||||
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());
|
||||
ElementDefinition ted = sd.getSnapshot().getElementFirstRep();
|
||||
children.add(makeChild(name, index, kind, v, sd, ted));
|
||||
}
|
||||
loadElementChild(childDefs, p, name, i, v);
|
||||
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) {
|
||||
if (v.isPrimitive()) {
|
||||
return ElementKind.PrimitiveType;
|
||||
|
@ -465,13 +477,25 @@ public class ResourceElement {
|
|||
public boolean has(String name) {
|
||||
loadChildren();
|
||||
for (ResourceElement e : children) {
|
||||
if (name.equals(e.name())) {
|
||||
if (name.equals(e.name()) || (name+"[x]").equals(e.name())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
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() {
|
||||
ResourceElement e = this.parent;
|
||||
while (e != null && !e.isResource()) {
|
||||
|
@ -814,6 +838,5 @@ public class ResourceElement {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -265,18 +265,18 @@ public class NarrativeGenerationTests {
|
|||
TextFile.stringToFile(actual, actualFileName);
|
||||
String msg = CompareUtilities.checkXMLIsSame(id, expectedFileName, actualFileName);
|
||||
Assertions.assertTrue(msg == null, "Output does not match expected: "+msg);
|
||||
|
||||
if (test.isMeta()) {
|
||||
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));
|
||||
|
||||
expected = TextFile.streamToString(TestingUtilities.loadTestResourceStream("r5", "narrative", "output", test.getId() + "-meta.html"));
|
||||
actual = HEADER+new XhtmlComposer(true, true).compose(x)+FOOTER;
|
||||
actualFileName = CompareUtilities.tempFile("narrative", test.getId() + "-meta.actual.html");
|
||||
TextFile.stringToFile(actual, actualFileName);
|
||||
msg = CompareUtilities.checkXMLIsSame(id, expectedFileName, actualFileName);
|
||||
Assertions.assertTrue(msg == null, "Meta output does not match expected: "+msg);
|
||||
}
|
||||
//
|
||||
// if (test.isMeta()) {
|
||||
// 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));
|
||||
//
|
||||
// expected = TextFile.streamToString(TestingUtilities.loadTestResourceStream("r5", "narrative", "output", test.getId() + "-meta.html"));
|
||||
// actual = HEADER+new XhtmlComposer(true, true).compose(x)+FOOTER;
|
||||
// actualFileName = CompareUtilities.tempFile("narrative", test.getId() + "-meta.actual.html");
|
||||
// TextFile.stringToFile(actual, actualFileName);
|
||||
// msg = CompareUtilities.checkXMLIsSame(id, expectedFileName, actualFileName);
|
||||
// Assertions.assertTrue(msg == null, "Meta output does not match expected: "+msg);
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
|
@ -190,7 +190,7 @@ DATA_REND_AFTRWKNG = after waking
|
|||
DATA_REND_ATBKFST = at breakfast
|
||||
DATA_REND_ATDINR = at dinner
|
||||
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_BFDINR = before dinner
|
||||
DATA_REND_BFLUNCH = before lunch
|
||||
|
@ -252,7 +252,7 @@ DIAG_REP_REND_FOR = for
|
|||
DIAG_REP_REND_IDENTIFIER = Identifier
|
||||
GENERAL_TODO = Not done yet
|
||||
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_PER = Performer
|
||||
DIAG_REP_REND_REFRAN = Reference Range
|
||||
|
|
Loading…
Reference in New Issue