Search in sources :

Example 1 with SectionComponent

use of org.hl7.fhir.r4.model.Composition.SectionComponent in project integration-adaptor-111 by nhsconnect.

the class CompositionMapper method getSectionText.

private SectionComponent getSectionText(POCDMT000002UK01Section sectionComponent5) {
    SectionComponent sectionComponent = new SectionComponent();
    if (sectionComponent5.isSetTitle()) {
        sectionComponent.setTitle(nodeUtil.getAllText(sectionComponent5.getTitle().getDomNode()));
    }
    String content = extractSectionText(sectionComponent5);
    if (StringUtils.isNotEmpty(content)) {
        Narrative narrative = new Narrative();
        narrative.setStatus(GENERATED);
        XhtmlNode xhtmlNode = new XhtmlNode();
        xhtmlNode.setNodeType(NodeType.Document);
        xhtmlNode.addText(content);
        narrative.setDiv(xhtmlNode);
        sectionComponent.setText(narrative);
    }
    return sectionComponent;
}
Also used : Narrative(org.hl7.fhir.dstu3.model.Narrative) SectionComponent(org.hl7.fhir.dstu3.model.Composition.SectionComponent) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 2 with SectionComponent

use of org.hl7.fhir.r4.model.Composition.SectionComponent 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;
}
Also used : Composition(org.hl7.fhir.dstu3.model.Composition) CarePlan(org.hl7.fhir.dstu3.model.CarePlan) Identifier(org.hl7.fhir.dstu3.model.Identifier) POCDMT000002UK01Component3(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Component3) SectionComponent(org.hl7.fhir.dstu3.model.Composition.SectionComponent)

Example 3 with SectionComponent

use of org.hl7.fhir.r4.model.Composition.SectionComponent 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;
}
Also used : Composition(org.hl7.fhir.dstu2.model.Composition) DomainResource(org.hl7.fhir.dstu2.model.DomainResource) Resource(org.hl7.fhir.dstu2.model.Resource) DomainResource(org.hl7.fhir.dstu2.model.DomainResource) SectionComponent(org.hl7.fhir.dstu2.model.Composition.SectionComponent) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 4 with SectionComponent

use of org.hl7.fhir.r4.model.Composition.SectionComponent 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.hr();
        root.getChildNodes().add(((DomainResource) subject).getText().getDiv());
    }
    List<SectionComponent> sections = comp.getSection();
    renderSections(feed, root, sections, 1);
    return root;
}
Also used : Composition(org.hl7.fhir.dstu3.model.Composition) DomainResource(org.hl7.fhir.dstu3.model.DomainResource) DomainResource(org.hl7.fhir.dstu3.model.DomainResource) MetadataResource(org.hl7.fhir.dstu3.model.MetadataResource) Resource(org.hl7.fhir.dstu3.model.Resource) SectionComponent(org.hl7.fhir.dstu3.model.Composition.SectionComponent) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 5 with SectionComponent

use of org.hl7.fhir.r4.model.Composition.SectionComponent 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.hr();
        root.getChildNodes().add(((DomainResource) subject).getText().getDiv());
    }
    List<SectionComponent> sections = comp.getSection();
    renderSections(feed, root, sections, 1);
    return root;
}
Also used : SectionComponent(org.hl7.fhir.r4.model.Composition.SectionComponent) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Aggregations

SectionComponent (org.hl7.fhir.dstu3.model.Composition.SectionComponent)10 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)7 SectionComponent (org.hl7.fhir.r4.model.Composition.SectionComponent)4 Element (org.w3c.dom.Element)4 Composition (org.hl7.fhir.dstu3.model.Composition)3 Coding (org.hl7.fhir.dstu3.model.Coding)2 Narrative (org.hl7.fhir.dstu3.model.Narrative)2 ArrayList (java.util.ArrayList)1 Composition (org.hl7.fhir.dstu2.model.Composition)1 SectionComponent (org.hl7.fhir.dstu2.model.Composition.SectionComponent)1 DomainResource (org.hl7.fhir.dstu2.model.DomainResource)1 Resource (org.hl7.fhir.dstu2.model.Resource)1 Composition (org.hl7.fhir.dstu2016may.model.Composition)1 SectionComponent (org.hl7.fhir.dstu2016may.model.Composition.SectionComponent)1 DomainResource (org.hl7.fhir.dstu2016may.model.DomainResource)1 Resource (org.hl7.fhir.dstu2016may.model.Resource)1 CarePlan (org.hl7.fhir.dstu3.model.CarePlan)1 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)1 DomainResource (org.hl7.fhir.dstu3.model.DomainResource)1 Identifier (org.hl7.fhir.dstu3.model.Identifier)1