Search in sources :

Example 36 with Narrative

use of org.hl7.fhir.r4b.model.Narrative in project openmrs-module-fhir2 by openmrs.

the class PractitionerNarrativeTest method shouldGeneratePractitionerNarrative.

/**
 * Check that the expected narrative is generated for some example Practitioner resource
 *
 * @throws IOException
 */
@Test
public void shouldGeneratePractitionerNarrative() throws IOException {
    Practitioner given = parser.parseResource(Practitioner.class, getClass().getClassLoader().getResourceAsStream(EXAMPLE_RESOURCE_PATH));
    Practitioner result = parser.parseResource(Practitioner.class, parser.encodeResourceToString(given));
    assertThat(result, notNullValue());
    assertThat(result.getText(), notNullValue());
    assertThat(result.getText().getStatusAsString(), equalTo("generated"));
    assertThat(result.getText().getDivAsString(), equalTo(readNarrativeFile(EXPECTED_NARRATIVE_PATH)));
}
Also used : Practitioner(org.hl7.fhir.r4.model.Practitioner) Test(org.junit.Test)

Example 37 with Narrative

use of org.hl7.fhir.r4b.model.Narrative 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 38 with Narrative

use of org.hl7.fhir.r4b.model.Narrative in project integration-adaptor-111 by nhsconnect.

the class ConsentMapper method extractTextBody.

private void extractTextBody(Consent consent, POCDMT000002UK01StructuredBody structuredBody) {
    List<POCDMT000002UK01Section> sections = getSectionsOfType(structuredBody);
    for (POCDMT000002UK01Section section : sections) {
        Narrative narrative = new Narrative();
        narrative.setStatus(GENERATED);
        if (section.isSetText()) {
            narrative.setDivAsString(Arrays.asList(DIV_START, section.getText().xmlText(), DIV_END).stream().collect(Collectors.joining()));
            consent.setText(narrative);
        }
    }
}
Also used : POCDMT000002UK01Section(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Section) Narrative(org.hl7.fhir.dstu3.model.Narrative)

Example 39 with Narrative

use of org.hl7.fhir.r4b.model.Narrative in project integration-adaptor-111 by nhsconnect.

the class EncounterMapper method addEncounterText.

private void addEncounterText(POCDMT000002UK01Encounter encounterITK, Encounter encounter) {
    if (encounterITK.isSetText()) {
        String divString = nodeUtil.getNodeValueString(encounterITK.getText());
        Narrative narrative = new Narrative();
        narrative.setStatus(GENERATED);
        narrative.setDivAsString(Arrays.asList(DIV_START, divString, DIV_END).stream().collect(Collectors.joining()));
        encounter.setText(narrative);
    }
}
Also used : Narrative(org.hl7.fhir.dstu3.model.Narrative)

Example 40 with Narrative

use of org.hl7.fhir.r4b.model.Narrative in project org.hl7.fhir.core by hapifhir.

the class ExtensionDefinitionGenerator method buildExtensions.

private List<StructureDefinition> buildExtensions(List<StructureDefinition> definitions) throws FHIRException {
    Set<String> types = new HashSet<>();
    List<StructureDefinition> list = new ArrayList<>();
    for (StructureDefinition type : definitions) if (type.getDerivation() == TypeDerivationRule.SPECIALIZATION && !type.getName().contains(".") && !types.contains(type.getName()) && type.getKind() != StructureDefinitionKind.PRIMITIVETYPE && !Utilities.existsInList(type.getName(), "Extension", "Narrative")) {
        types.add(type.getName());
        buildExtensions(type, list);
    }
    return list;
}
Also used : StructureDefinition(org.hl7.fhir.r4.model.StructureDefinition)

Aggregations

XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)80 FHIRException (org.hl7.fhir.exceptions.FHIRException)40 IOException (java.io.IOException)34 NotImplementedException (org.apache.commons.lang3.NotImplementedException)30 UnsupportedEncodingException (java.io.UnsupportedEncodingException)27 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)23 Test (org.junit.Test)22 MethodOutcome (ca.uhn.fhir.rest.api.MethodOutcome)19 ArrayList (java.util.ArrayList)19 XhtmlParser (org.hl7.fhir.utilities.xhtml.XhtmlParser)17 Narrative (org.hl7.fhir.r4.model.Narrative)15 Narrative (org.hl7.fhir.r5.model.Narrative)15 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)14 XhtmlComposer (org.hl7.fhir.utilities.xhtml.XhtmlComposer)14 GET (javax.ws.rs.GET)12 Path (javax.ws.rs.Path)12 Produces (javax.ws.rs.Produces)12 IBaseOperationOutcome (org.hl7.fhir.instance.model.api.IBaseOperationOutcome)12 FileNotFoundException (java.io.FileNotFoundException)10 LinkedHashMap (java.util.LinkedHashMap)10