use of org.hl7.fhir.r4b.model.Composition in project summary-care-record-api by NHSDigital.
the class CompositionMapper method setPresentation.
private static void setPresentation(GpSummary gpSummary, Composition composition) throws FhirMappingException {
if (!composition.hasSection()) {
throw new FhirMappingException("Missing mandatory Composition.section");
}
Presentation presentation = new Presentation();
var htmlDocument = createNewDocument("html", "xhtml:NPfIT:PresentationText");
var bodyNode = htmlDocument.createElement("body");
htmlDocument.getDocumentElement().appendChild(bodyNode);
for (Composition.SectionComponent section : composition.getSection()) {
var h2Node = htmlDocument.createElement("h2");
h2Node.setAttribute("id", section.getCode().getCodingFirstRep().getCode());
h2Node.appendChild(htmlDocument.createTextNode(section.getTitle()));
bodyNode.appendChild(h2Node);
var divDocument = parseDocument(section.getText().getDiv().getValueAsString());
removeEmptyNodes(divDocument);
var divChildNodes = divDocument.getDocumentElement().getChildNodes();
for (int i = 0; i < divChildNodes.getLength(); i++) {
bodyNode.appendChild(htmlDocument.importNode(divChildNodes.item(i), true));
}
}
presentation.setPresentationId(randomUUID());
presentation.setPresentationText(serialize(htmlDocument));
gpSummary.setPresentation(presentation);
}
use of org.hl7.fhir.r4b.model.Composition in project integration-adaptor-111 by nhsconnect.
the class CompositionMapper method mapComposition.
public Composition mapComposition(POCDMT000002UK01ClinicalDocument1 clinicalDocument, Encounter encounter, List<CarePlan> carePlans, List<QuestionnaireResponse> questionnaireResponseList, ReferralRequest referralRequest, List<PractitionerRole> practitionerRoles) {
Composition composition = new Composition();
composition.setIdElement(resourceUtil.newRandomUuid());
Identifier docIdentifier = new Identifier();
docIdentifier.setUse(USUAL);
docIdentifier.setValue(clinicalDocument.getSetId().getRoot());
composition.setTitle(COMPOSITION_TITLE).setType(createCodeableConcept()).setStatus(FINAL).setEncounter(resourceUtil.createReference(encounter)).setSubject(encounter.getSubject()).setDateElement(DateUtil.parse(clinicalDocument.getEffectiveTime().getValue())).setIdentifier(docIdentifier);
if (clinicalDocument.getConfidentialityCode().isSetCode()) {
composition.setConfidentiality(Composition.DocumentConfidentiality.valueOf(clinicalDocument.getConfidentialityCode().getCode()));
}
if (isNotEmpty(clinicalDocument.getRelatedDocumentArray()) && clinicalDocument.getRelatedDocumentArray(0).getParentDocument().getIdArray(0).isSetRoot()) {
Identifier relatedDocIdentifier = new Identifier();
relatedDocIdentifier.setUse(USUAL);
relatedDocIdentifier.setValue(clinicalDocument.getRelatedDocumentArray(0).getParentDocument().getIdArray(0).getRoot());
composition.addRelatesTo().setCode(Composition.DocumentRelationshipType.REPLACES).setTarget(relatedDocIdentifier);
}
practitionerRoles.stream().forEach(it -> composition.addAuthor(it.getPractitioner()));
if (clinicalDocument.getComponent().isSetStructuredBody()) {
for (POCDMT000002UK01Component3 component3 : clinicalDocument.getComponent().getStructuredBody().getComponentArray()) {
SectionComponent sectionComponent = new SectionComponent();
addSectionChildren(sectionComponent, component3.getSection());
composition.addSection(sectionComponent);
}
}
for (CarePlan carePlan : carePlans) {
composition.addSection(buildSectionComponentFromResource(carePlan));
}
if (!referralRequest.isEmpty()) {
composition.addSection(buildSectionComponentFromResource(referralRequest));
}
if (questionnaireResponseList != null) {
addPathwaysToSection(composition, questionnaireResponseList);
}
return composition;
}
use of org.hl7.fhir.r4b.model.Composition in project org.hl7.fhir.core by hapifhir.
the class NarrativeGenerator method generateDocumentNarrative.
public XhtmlNode generateDocumentNarrative(Bundle feed) {
/*
When the document is presented for human consumption, applications must present the collated narrative portions of the following resources in order:
* The Composition resource
* The Subject resource
* Resources referenced in the section.content
*/
XhtmlNode root = new XhtmlNode(NodeType.Element, "div");
Composition comp = (Composition) feed.getEntry().get(0).getResource();
root.getChildNodes().add(comp.getText().getDiv());
Resource subject = ResourceUtilities.getById(feed, null, comp.getSubject().getReference());
if (subject != null && subject instanceof DomainResource) {
root.addTag("hr");
root.getChildNodes().add(((DomainResource) subject).getText().getDiv());
}
List<SectionComponent> sections = comp.getSection();
renderSections(feed, root, sections, 1);
return root;
}
use of org.hl7.fhir.r4b.model.Composition in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeComposition.
protected void composeComposition(Complex parent, String parentType, String name, Composition element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeDomainResource(t, "Composition", name, element, index);
if (element.hasIdentifier())
composeIdentifier(t, "Composition", "identifier", element.getIdentifier(), -1);
if (element.hasStatusElement())
composeEnum(t, "Composition", "status", element.getStatusElement(), -1);
if (element.hasType())
composeCodeableConcept(t, "Composition", "type", element.getType(), -1);
if (element.hasClass_())
composeCodeableConcept(t, "Composition", "class", element.getClass_(), -1);
if (element.hasSubject())
composeReference(t, "Composition", "subject", element.getSubject(), -1);
if (element.hasEncounter())
composeReference(t, "Composition", "encounter", element.getEncounter(), -1);
if (element.hasDateElement())
composeDateTime(t, "Composition", "date", element.getDateElement(), -1);
for (int i = 0; i < element.getAuthor().size(); i++) composeReference(t, "Composition", "author", element.getAuthor().get(i), i);
if (element.hasTitleElement())
composeString(t, "Composition", "title", element.getTitleElement(), -1);
if (element.hasConfidentialityElement())
composeEnum(t, "Composition", "confidentiality", element.getConfidentialityElement(), -1);
for (int i = 0; i < element.getAttester().size(); i++) composeCompositionCompositionAttesterComponent(t, "Composition", "attester", element.getAttester().get(i), i);
if (element.hasCustodian())
composeReference(t, "Composition", "custodian", element.getCustodian(), -1);
for (int i = 0; i < element.getRelatesTo().size(); i++) composeCompositionCompositionRelatesToComponent(t, "Composition", "relatesTo", element.getRelatesTo().get(i), i);
for (int i = 0; i < element.getEvent().size(); i++) composeCompositionCompositionEventComponent(t, "Composition", "event", element.getEvent().get(i), i);
for (int i = 0; i < element.getSection().size(); i++) composeCompositionSectionComponent(t, "Composition", "section", element.getSection().get(i), i);
}
use of org.hl7.fhir.r4b.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);
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