use of org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus in project org.hl7.fhir.core by hapifhir.
the class ResourceRenderer method inject.
public static void inject(DomainResource r, XhtmlNode x, NarrativeStatus status) {
if (!x.hasAttribute("xmlns"))
x.setAttribute("xmlns", "http://www.w3.org/1999/xhtml");
if (r.hasLanguage()) {
// use both - see https://www.w3.org/TR/i18n-html-tech-lang/#langvalues
x.setAttribute("lang", r.getLanguage());
x.setAttribute("xml:lang", r.getLanguage());
}
r.getText().setUserData("renderer.generated", true);
if (!r.hasText() || !r.getText().hasDiv() || r.getText().getDiv().getChildNodes().isEmpty()) {
r.setText(new Narrative());
r.getText().setDiv(x);
r.getText().setStatus(status);
} else {
XhtmlNode n = r.getText().getDiv();
n.clear();
n.getChildNodes().addAll(x.getChildNodes());
}
}
use of org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus in project org.hl7.fhir.core by hapifhir.
the class Factory method newNarrative.
public static Narrative newNarrative(NarrativeStatus status, String html) throws IOException, FHIRException {
Narrative n = new Narrative();
n.setStatus(status);
try {
n.setDiv(new XhtmlParser().parseFragment("<div>" + Utilities.escapeXml(html) + "</div>"));
} catch (org.hl7.fhir.exceptions.FHIRException e) {
throw new FHIRException(e.getMessage(), e);
}
return n;
}
use of org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus in project org.hl7.fhir.core by hapifhir.
the class NarrativeGenerator method inject.
private void inject(Element er, XhtmlNode x, NarrativeStatus status) {
if (!x.hasAttribute("xmlns"))
x.setAttribute("xmlns", "http://www.w3.org/1999/xhtml");
Element txt = XMLUtil.getNamedChild(er, "text");
if (txt == null) {
txt = er.getOwnerDocument().createElementNS(FormatUtilities.FHIR_NS, "text");
Element n = XMLUtil.getFirstChild(er);
while (n != null && (n.getNodeName().equals("id") || n.getNodeName().equals("meta") || n.getNodeName().equals("implicitRules") || n.getNodeName().equals("language"))) n = XMLUtil.getNextSibling(n);
if (n == null)
er.appendChild(txt);
else
er.insertBefore(txt, n);
}
Element st = XMLUtil.getNamedChild(txt, "status");
if (st == null) {
st = er.getOwnerDocument().createElementNS(FormatUtilities.FHIR_NS, "status");
Element n = XMLUtil.getFirstChild(txt);
if (n == null)
txt.appendChild(st);
else
txt.insertBefore(st, n);
}
st.setAttribute("value", status.toCode());
Element div = XMLUtil.getNamedChild(txt, "div");
if (div == null) {
div = er.getOwnerDocument().createElementNS(FormatUtilities.XHTML_NS, "div");
div.setAttribute("xmlns", FormatUtilities.XHTML_NS);
txt.appendChild(div);
}
if (div.hasChildNodes())
div.appendChild(er.getOwnerDocument().createElementNS(FormatUtilities.XHTML_NS, "hr"));
new XhtmlComposer(XhtmlComposer.XML).compose(div, x);
}
use of org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus in project org.hl7.fhir.core by hapifhir.
the class NarrativeGenerator method inject.
private void inject(DomainResource r, XhtmlNode x, NarrativeStatus status) {
if (!x.hasAttribute("xmlns"))
x.setAttribute("xmlns", "http://www.w3.org/1999/xhtml");
if (!r.hasText() || !r.getText().hasDiv() || r.getText().getDiv().getChildNodes().isEmpty()) {
r.setText(new Narrative());
r.getText().setDiv(x);
r.getText().setStatus(status);
} else {
XhtmlNode n = r.getText().getDiv();
n.hr();
n.getChildNodes().addAll(x.getChildNodes());
}
}
use of org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus in project org.hl7.fhir.core by hapifhir.
the class NarrativeGenerator method inject.
private void inject(DomainResource r, XhtmlNode x, NarrativeStatus status) {
if (!r.hasText() || !r.getText().hasDiv() || r.getText().getDiv().getChildNodes().isEmpty()) {
r.setText(new Narrative());
r.getText().setDiv(x);
r.getText().setStatus(status);
} else {
XhtmlNode n = r.getText().getDiv();
n.addTag("hr");
n.getChildNodes().addAll(x.getChildNodes());
}
}
Aggregations