use of org.hl7.fhir.r5.model.Composition in project org.hl7.fhir.core by hapifhir.
the class TurtleTests method test_composition_example.
@Test
public void test_composition_example() throws FileNotFoundException, IOException, Exception {
System.out.println("composition-example.ttl");
new Turtle().parse(TextFile.fileToString("C:\\work\\org.hl7.fhir\\build\\publish\\composition-example.ttl"));
}
use of org.hl7.fhir.r5.model.Composition in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeCompositionCompositionEventComponent.
protected void composeCompositionCompositionEventComponent(Complex parent, String parentType, String name, Composition.CompositionEventComponent element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeBackboneElement(t, "event", name, element, index);
for (int i = 0; i < element.getCode().size(); i++) composeCodeableConcept(t, "Composition", "code", element.getCode().get(i), i);
if (element.hasPeriod())
composePeriod(t, "Composition", "period", element.getPeriod(), -1);
for (int i = 0; i < element.getDetail().size(); i++) composeReference(t, "Composition", "detail", element.getDetail().get(i), i);
}
use of org.hl7.fhir.r5.model.Composition in project org.hl7.fhir.core by hapifhir.
the class BundleRenderer method renderDocument.
private boolean renderDocument(XhtmlNode x, Bundle b) throws UnsupportedEncodingException, FHIRException, IOException, EOperationOutcome {
// from the spec:
//
// When the document is presented for human consumption, applications SHOULD present the collated narrative portions in order:
// * The subject resource Narrative
// * The Composition resource Narrative
// * The section.text Narratives
Composition comp = (Composition) b.getEntry().get(0).getResource();
Resource subject = resolveReference(b, comp.getSubject());
if (subject != null) {
XhtmlNode nx = (subject instanceof DomainResource) ? ((DomainResource) subject).getText().getDiv() : null;
if (nx != null) {
x.addChildren(nx);
} else {
RendererFactory.factory(subject, context).render(x, subject);
}
}
x.hr();
if (comp.getText().hasDiv()) {
x.addChildren(comp.getText().getDiv());
x.hr();
}
for (SectionComponent section : comp.getSection()) {
addSection(x, section, 2, false);
}
return false;
}
use of org.hl7.fhir.r5.model.Composition in project org.hl7.fhir.core by hapifhir.
the class NarrativeGenerator method renderBundle.
public XhtmlNode renderBundle(Bundle b) throws FHIRException {
if (b.getType() == BundleType.DOCUMENT) {
if (!b.hasEntry() || !(b.getEntryFirstRep().hasResource() && b.getEntryFirstRep().getResource() instanceof Composition))
throw new FHIRException("Invalid document - first entry is not a Composition");
Composition dr = (Composition) b.getEntryFirstRep().getResource();
return dr.getText().getDiv();
} else {
XhtmlNode root = new XhtmlNode(NodeType.Element, "div");
root.para().addText("Bundle " + b.getId() + " of type " + b.getType().toCode());
int i = 0;
for (BundleEntryComponent be : b.getEntry()) {
i++;
if (be.hasResource() && be.getResource().hasId())
root.an(be.getResource().getResourceType().name().toLowerCase() + "_" + be.getResource().getId());
root.hr();
root.para().addText("Entry " + Integer.toString(i) + (be.hasFullUrl() ? " - Full URL = " + be.getFullUrl() : ""));
if (be.hasRequest())
renderRequest(root, be.getRequest());
if (be.hasSearch())
renderSearch(root, be.getSearch());
if (be.hasResponse())
renderResponse(root, be.getResponse());
if (be.hasResource()) {
root.para().addText("Resource " + be.getResource().fhirType() + ":");
if (be.hasResource() && be.getResource() instanceof DomainResource) {
DomainResource dr = (DomainResource) be.getResource();
if (dr.getText().hasDiv())
root.blockquote().getChildNodes().addAll(dr.getText().getDiv().getChildNodes());
}
}
}
return root;
}
}
use of org.hl7.fhir.r5.model.Composition in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeCompositionSectionComponent.
protected void composeCompositionSectionComponent(Complex parent, String parentType, String name, Composition.SectionComponent element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeBackboneElement(t, "section", name, element, index);
if (element.hasTitleElement())
composeString(t, "Composition", "title", element.getTitleElement(), -1);
if (element.hasCode())
composeCodeableConcept(t, "Composition", "code", element.getCode(), -1);
for (int i = 0; i < element.getAuthor().size(); i++) composeReference(t, "Composition", "author", element.getAuthor().get(i), i);
if (element.hasFocus())
composeReference(t, "Composition", "focus", element.getFocus(), -1);
if (element.hasText())
composeNarrative(t, "Composition", "text", element.getText(), -1);
if (element.hasModeElement())
composeEnum(t, "Composition", "mode", element.getModeElement(), -1);
if (element.hasOrderedBy())
composeCodeableConcept(t, "Composition", "orderedBy", element.getOrderedBy(), -1);
for (int i = 0; i < element.getEntry().size(); i++) composeReference(t, "Composition", "entry", element.getEntry().get(i), i);
if (element.hasEmptyReason())
composeCodeableConcept(t, "Composition", "emptyReason", element.getEmptyReason(), -1);
for (int i = 0; i < element.getSection().size(); i++) composeCompositionSectionComponent(t, "Composition", "section", element.getSection().get(i), i);
}
Aggregations