use of org.hl7.fhir.r5.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)));
}
use of org.hl7.fhir.r5.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;
}
use of org.hl7.fhir.r5.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);
}
}
}
use of org.hl7.fhir.r5.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);
}
}
use of org.hl7.fhir.r5.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;
}
Aggregations