Search in sources :

Example 16 with SectionComponent

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

Example 17 with SectionComponent

use of org.hl7.fhir.dstu2016may.model.Composition.SectionComponent in project eCRNow by drajer-health.

the class FhirGeneratorUtilsTest method getSectionComponentTest.

@Test
public void getSectionComponentTest() {
    SectionComponent sc = FhirGeneratorUtils.getSectionComponent("TestValue", "123456", "Covid-19");
    assertNotNull(sc);
    assertNotNull(sc.getCode());
    assertEquals("Covid-19", sc.getCode().getText());
}
Also used : SectionComponent(org.hl7.fhir.r4.model.Composition.SectionComponent) Test(org.junit.Test)

Example 18 with SectionComponent

use of org.hl7.fhir.dstu2016may.model.Composition.SectionComponent in project eCRNow by drajer-health.

the class FhirGeneratorUtils method getSectionComponent.

public static SectionComponent getSectionComponent(String system, String code, String display) {
    CodeableConcept cc = getCodeableConcept(system, code, display);
    SectionComponent sc = null;
    if (cc != null) {
        sc = new SectionComponent();
        sc.setCode(cc);
    }
    return sc;
}
Also used : SectionComponent(org.hl7.fhir.r4.model.Composition.SectionComponent) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 19 with SectionComponent

use of org.hl7.fhir.dstu2016may.model.Composition.SectionComponent in project eCRNow by drajer-health.

the class EicrCompositionGenerator method convertR4FhirBundletoCdaEicr.

public static Composition convertR4FhirBundletoCdaEicr(R4FhirData data) {
    Composition comp = new Composition();
    // Add version number extension.
    comp.addExtension(FhirGeneratorConstants.COMP_CLIN_DOC_VERSION_NUM_URL, new StringType(String.valueOf(FhirGeneratorConstants.VERSION_NUM)));
    // Add Type
    comp.setType(FhirGeneratorUtils.getCodeableConcept(FhirGeneratorConstants.LOINC_CS_URL, FhirGeneratorConstants.COMP_TYPE_CODE, FhirGeneratorConstants.COMP_TYPE_CODE_DISPLAY));
    // Setup Patient.
    comp.getSubject().setResource(data.getPatient());
    // Setup Encounter
    if (data.getEncounter() != null)
        comp.getEncounter().setResource(data.getEncounter());
    // Add Authors.
    List<Reference> auths = new ArrayList<>();
    // Add organization
    if (data.getOrganization() != null)
        auths.add(FhirGeneratorUtils.getReference(data.getOrganization()));
    if (data.getPractitioner() != null)
        auths.add(FhirGeneratorUtils.getReference(data.getPractitioner()));
    comp.setAuthor(auths);
    // Add Reason for Visit Section;
    SectionComponent rvs = FhirGeneratorUtils.getSectionComponent(FhirGeneratorConstants.LOINC_CS_URL, FhirGeneratorConstants.REASON_FOR_VISIT_CODE, FhirGeneratorConstants.REASON_FOR_VISIT_CODE_DISPLAY);
    // Set the Section Code Display to be the narrative text.
    rvs.getCode().setTextElement(new StringType(FhirGeneratorUtils.getReasonForVisitNarrativeText(data.getEncounter())));
    comp.getSection().add(rvs);
    return comp;
}
Also used : Composition(org.hl7.fhir.r4.model.Composition) StringType(org.hl7.fhir.r4.model.StringType) Reference(org.hl7.fhir.r4.model.Reference) ArrayList(java.util.ArrayList) SectionComponent(org.hl7.fhir.r4.model.Composition.SectionComponent)

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