use of org.hl7.fhir.r4b.renderers.utils.BaseWrappers.BaseWrapper in project org.hl7.fhir.core by hapifhir.
the class PatientRenderer method describe.
public void describe(XhtmlNode x, ResourceWrapper pat) throws UnsupportedEncodingException, IOException {
Identifier id = null;
PropertyWrapper pw = getProperty(pat, "identifier");
for (BaseWrapper t : pw.getValues()) {
id = chooseId(id, (Identifier) t.getBase());
}
pw = getProperty(pat, "name");
HumanName n = null;
for (BaseWrapper t : pw.getValues()) {
n = chooseName(n, (HumanName) t.getBase());
}
String gender = null;
pw = getProperty(pat, "gender");
if (valued(pw)) {
pw.value().getBase().primitiveValue();
}
DateType dt = null;
pw = getProperty(pat, "birthDate");
if (valued(pw)) {
dt = (DateType) pw.value().getBase();
}
describe(x, n, gender, dt, id);
}
use of org.hl7.fhir.r4b.renderers.utils.BaseWrappers.BaseWrapper in project org.hl7.fhir.core by hapifhir.
the class QuestionnaireResponseRenderer method renderTree.
public boolean renderTree(XhtmlNode x, ResourceWrapper qr) throws UnsupportedEncodingException, IOException {
HierarchicalTableGenerator gen = new HierarchicalTableGenerator(context.getDestDir(), context.isInlineGraphics(), true);
TableModel model = gen.new TableModel("qtree=" + qr.getId(), false);
model.setAlternating(true);
model.setDocoImg(context.getSpecificationLink() + "help16.png");
model.setDocoRef(context.getSpecificationLink() + "formats.html#table");
model.getTitles().add(gen.new Title(null, model.getDocoRef(), translate("sd.head", "LinkId"), translate("sd.hint", "The linkId for the item"), null, 0));
model.getTitles().add(gen.new Title(null, model.getDocoRef(), translate("sd.head", "Text"), translate("sd.hint", "Text for the item"), null, 0));
model.getTitles().add(gen.new Title(null, model.getDocoRef(), translate("sd.head", "Definition"), translate("sd.hint", "Minimum and Maximum # of times the the itemcan appear in the instance"), null, 0));
model.getTitles().add(gen.new Title(null, model.getDocoRef(), translate("sd.head", "Answer"), translate("sd.hint", "The type of the item"), null, 0));
boolean hasExt = false;
// first we add a root for the questionaire itself
Row row = addTreeRoot(gen, model.getRows(), qr);
List<BaseWrapper> items = qr.children("item");
for (BaseWrapper i : items) {
hasExt = renderTreeItem(gen, row.getSubRows(), qr, i) || hasExt;
}
XhtmlNode xn = gen.generate(model, context.getLocalPrefix(), 1, null);
x.getChildNodes().add(xn);
return hasExt;
}
use of org.hl7.fhir.r4b.renderers.utils.BaseWrappers.BaseWrapper in project org.hl7.fhir.core by hapifhir.
the class QuestionnaireResponseRenderer method renderTreeItem.
private boolean renderTreeItem(HierarchicalTableGenerator gen, List<Row> rows, ResourceWrapper q, BaseWrapper i) throws IOException {
Row r = gen.new Row();
rows.add(r);
boolean hasExt = false;
List<BaseWrapper> items = i.children("item");
List<BaseWrapper> answers = i.children("answer");
boolean hasItem = items != null && !items.isEmpty();
if (answers != null) {
for (BaseWrapper a : answers) {
hasItem = a.has("item");
}
}
if (hasItem) {
r.setIcon("icon-q-group.png", "Group");
} else {
r.setIcon("icon-q-string.png", "Item");
}
String linkId = i.has("linkId") ? i.get("linkId").primitiveValue() : "??";
String text = i.has("text") ? i.get("text").primitiveValue() : "";
r.getCells().add(gen.new Cell(null, context.getDefinitionsTarget() == null ? "" : context.getDefinitionsTarget() + "#item." + linkId, linkId, null, null));
r.getCells().add(gen.new Cell(null, null, text, null, null));
r.getCells().add(gen.new Cell(null, null, null, null, null));
if (answers.size() == 0) {
r.getCells().add(gen.new Cell(null, null, null, null, null));
for (BaseWrapper si : items) {
renderTreeItem(gen, r.getSubRows(), q, si);
}
} else if (answers.size() == 1) {
BaseWrapper ans = answers.get(0);
renderAnswer(gen, q, r, ans);
} else {
r.getCells().add(gen.new Cell(null, null, null, null, null));
for (BaseWrapper ans : answers) {
Row ar = gen.new Row();
ar.setIcon("icon-q-string.png", "Item");
ar.getSubRows().add(ar);
ar.getCells().add(gen.new Cell(null, null, null, null, null));
ar.getCells().add(gen.new Cell(null, null, text, null, null));
ar.getCells().add(gen.new Cell(null, null, null, null, null));
renderAnswer(gen, q, ar, ans);
}
}
return hasExt;
}
use of org.hl7.fhir.r4b.renderers.utils.BaseWrappers.BaseWrapper in project org.hl7.fhir.core by hapifhir.
the class ParametersRenderer method paramsW.
private void paramsW(XhtmlNode tbl, List<BaseWrapper> list, int indent) throws FHIRFormatError, DefinitionException, FHIRException, IOException, EOperationOutcome {
for (BaseWrapper p : list) {
XhtmlNode tr = tbl.tr();
XhtmlNode td = tr.td();
for (int i = 0; i < indent; i++) {
td.tx(XhtmlNode.NBSP);
}
if (p.has("name")) {
td.tx(p.get("name").primitiveValue());
} else {
td.tx("???");
}
if (p.has("value")) {
renderBase(tr.td(), p.get("value"));
} else if (p.has("resource")) {
ResourceWrapper rw = p.getChildByName("resource").getAsResource();
td = tr.td();
XhtmlNode para = td.para();
para.tx(rw.fhirType() + "/" + rw.getId());
para.an(rw.fhirType() + "_" + rw.getId()).tx(" ");
XhtmlNode x = rw.getNarrative();
if (x != null) {
td.addChildren(x);
} else {
ResourceRenderer rr = RendererFactory.factory(rw, context, rcontext);
rr.render(td, rw);
}
} else if (p.has("part")) {
tr.td();
PropertyWrapper pw = getProperty(p, "part");
paramsW(tbl, pw.getValues(), 1);
}
}
}
use of org.hl7.fhir.r4b.renderers.utils.BaseWrappers.BaseWrapper in project org.hl7.fhir.core by hapifhir.
the class DiagnosticReportRenderer method addObservationToTable.
private void addObservationToTable(XhtmlNode tr, ResourceWrapper obs, int i, String ref, boolean refRange, boolean flags, boolean note, boolean effectiveTime, boolean issued, DataType eff, DataType iss) throws UnsupportedEncodingException, FHIRException, IOException {
// code (+bodysite)
XhtmlNode td = tr.td();
PropertyWrapper pw = getProperty(obs, "code");
if (valued(pw)) {
render(td.ah(ref), pw.value());
}
pw = getProperty(obs, "bodySite");
if (valued(pw)) {
td.tx(" (");
render(td, pw.value());
td.tx(")");
}
// value / dataAbsentReason (in red)
td = tr.td();
pw = getProperty(obs, "value[x]");
if (valued(pw)) {
render(td, pw.value());
} else {
pw = getProperty(obs, "dataAbsentReason");
if (valued(pw)) {
XhtmlNode span = td.span("color: maroon", "Error");
span.tx("Error: ");
render(span.b(), pw.value());
}
}
if (refRange) {
// reference range
td = tr.td();
pw = getProperty(obs, "referenceRange");
if (valued(pw)) {
boolean first = true;
for (BaseWrapper v : pw.getValues()) {
if (first)
first = false;
else
td.br();
PropertyWrapper pwr = getProperty(v, "type");
if (valued(pwr)) {
render(td, pwr.value());
td.tx(": ");
}
PropertyWrapper pwt = getProperty(v, "text");
if (valued(pwt)) {
render(td, pwt.value());
} else {
PropertyWrapper pwl = getProperty(v, "low");
PropertyWrapper pwh = getProperty(v, "high");
if (valued(pwl) && valued(pwh)) {
render(td, pwl.value());
td.tx(" - ");
render(td, pwh.value());
} else if (valued(pwl)) {
td.tx(">");
render(td, pwl.value());
} else if (valued(pwh)) {
td.tx("<");
render(td, pwh.value());
} else {
td.tx("??");
}
}
pwr = getProperty(v, "appliesTo");
PropertyWrapper pwrA = getProperty(v, "age");
if (valued(pwr) || valued(pwrA)) {
boolean firstA = true;
td.tx(" for ");
if (valued(pwr)) {
for (BaseWrapper va : pwr.getValues()) {
if (firstA)
firstA = false;
else
td.tx(", ");
render(td, va);
}
}
if (valued(pwrA)) {
if (firstA)
firstA = false;
else
td.tx(", ");
td.tx("Age ");
render(td, pwrA.value());
}
}
}
}
}
if (flags) {
// flags (status other than F, interpretation, )
td = tr.td();
boolean first = true;
pw = getProperty(obs, "status");
if (valued(pw)) {
if (!pw.value().getBase().primitiveValue().equals("final")) {
if (first)
first = false;
else
td.br();
render(td, pw.value());
}
}
pw = getProperty(obs, "interpretation");
if (valued(pw)) {
for (BaseWrapper v : pw.getValues()) {
if (first)
first = false;
else
td.br();
render(td, v);
}
}
}
if (note) {
td = tr.td();
pw = getProperty(obs, "note");
if (valued(pw)) {
render(td, pw.value());
}
}
if (effectiveTime) {
// effective if different to DR
td = tr.td();
pw = getProperty(obs, "effective[x]");
if (valued(pw)) {
if (!Base.compareDeep(pw.value().getBase(), eff, true)) {
render(td, pw.value());
}
}
}
if (issued) {
// issued if different to DR
td = tr.td();
pw = getProperty(obs, "issued");
if (valued(pw)) {
if (!Base.compareDeep(pw.value().getBase(), eff, true)) {
render(td, pw.value());
}
}
}
}
Aggregations