use of org.hl7.fhir.dstu2.model.Range in project org.hl7.fhir.core by hapifhir.
the class DataRenderer method displayRange.
public String displayRange(Range q) {
StringBuilder b = new StringBuilder();
if (q.hasLow())
b.append(q.getLow().getValue().toString());
else
b.append("?");
b.append("-");
if (q.hasHigh())
b.append(q.getHigh().getValue().toString());
else
b.append("?");
if (q.getLow().hasUnit())
b.append(" " + q.getLow().getUnit());
return b.toString();
}
use of org.hl7.fhir.dstu2.model.Range 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());
}
}
}
}
use of org.hl7.fhir.dstu2.model.Range in project org.hl7.fhir.core by hapifhir.
the class DiagnosticReportRenderer method buildObservationsTable.
private void buildObservationsTable(XhtmlNode root, List<ObservationNode> observations, DataType eff, DataType iss) throws UnsupportedEncodingException, FHIRException, IOException {
XhtmlNode tbl = root.table("grid");
boolean refRange = scanObsForRefRange(observations);
boolean flags = scanObsForFlags(observations);
boolean note = scanObsForNote(observations);
boolean effectiveTime = scanObsForEffective(observations, eff);
boolean issued = scanObsForIssued(observations, iss);
int cs = 2;
if (refRange)
cs++;
if (flags)
cs++;
if (note)
cs++;
if (issued)
cs++;
if (effectiveTime)
cs++;
XhtmlNode tr = tbl.tr();
tr.td().b().tx("Code");
tr.td().b().tx("Value");
if (refRange) {
tr.td().b().tx("Reference Range");
}
if (flags) {
tr.td().b().tx("Flags");
}
if (note) {
tr.td().b().tx("Note");
}
if (effectiveTime) {
tr.td().b().tx("When For");
}
if (issued) {
tr.td().b().tx("Reported");
}
for (ObservationNode o : observations) {
addObservationToTable(tbl, o, 0, Integer.toString(cs), refRange, flags, note, effectiveTime, issued, eff, iss);
}
}
use of org.hl7.fhir.dstu2.model.Range 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());
}
}
}
}
use of org.hl7.fhir.dstu2.model.Range in project org.hl7.fhir.core by hapifhir.
the class NarrativeGenerator method addObservationToTable.
private void addObservationToTable(XhtmlNode tr, ResourceWrapper obs, int i) {
// TODO Auto-generated method stub
// code (+bodysite)
XhtmlNode td = tr.td();
PropertyWrapper pw = getProperty(obs, "result");
if (valued(pw)) {
displayCodeableConcept(td, pw.value());
}
pw = getProperty(obs, "bodySite");
if (valued(pw)) {
td.tx(" (");
displayCodeableConcept(td, pw.value());
td.tx(")");
}
// value / dataAbsentReason (in red)
td = tr.td();
pw = getProperty(obs, "value[x]");
if (valued(pw)) {
if (pw.getTypeCode().equals("CodeableConcept"))
displayCodeableConcept(td, pw.value());
else if (pw.getTypeCode().equals("string"))
displayText(td, pw.value());
else
td.addText(pw.getTypeCode() + " not rendered yet");
}
// units
td = tr.td();
td.tx("to do");
// reference range
td = tr.td();
td.tx("to do");
// flags (status other than F, interpretation, )
td = tr.td();
td.tx("to do");
// issued if different to DR
td = tr.td();
td.tx("to do");
}
Aggregations