use of org.hl7.fhir.r4.model.PractitionerRole in project openmrs-module-fhir2 by openmrs.
the class PractitionerRoleNarrativeTest method shouldGeneratePractitionerRoleNarrative.
/**
* Check that the expected narrative is generated for some example PractitionerRole resource
*
* @throws IOException
*/
@Test
public void shouldGeneratePractitionerRoleNarrative() throws IOException {
PractitionerRole given = parser.parseResource(PractitionerRole.class, getClass().getClassLoader().getResourceAsStream(EXAMPLE_RESOURCE_PATH));
PractitionerRole result = parser.parseResource(PractitionerRole.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.r4.model.PractitionerRole in project Gravity-SDOH-Exchange-RI by FHIR.
the class ConsentService method retrieveOrganization.
private Reference retrieveOrganization(UserDto userDto) {
Bundle bundle = new ConsentPrepareBundleFactory(userDto.getId()).createPrepareBundle();
Bundle consentResponseBundle = ehrClient.transaction().withBundle(bundle).execute();
Bundle consentBundle = FhirUtil.getFirstFromBundle(consentResponseBundle, Bundle.class);
PractitionerRole practitionerRole = FhirUtil.getFirstFromBundle(consentBundle, PractitionerRole.class);
Reference organization = practitionerRole.getOrganization();
if (organization == null) {
throw new ConsentCreateException("No Organization found for Consent creation.");
}
return organization;
}
use of org.hl7.fhir.r4.model.PractitionerRole in project integration-adaptor-111 by nhsconnect.
the class PractitionerRoleMapperTest method shouldMapResponsibleParty.
@Test
public void shouldMapResponsibleParty() {
mockResponsibleParty();
when(resourceUtil.newRandomUuid()).thenReturn(new IdType(RANDOM_UUID));
PractitionerRole role = practitionerRoleMapper.mapResponsibleParty(clinicalDocument).get();
Coding codingFirstRep = role.getCodeFirstRep().getCodingFirstRep();
assertThat(codingFirstRep.getCode()).isEqualTo(CODE);
assertThat(codingFirstRep.getSystem()).isEqualTo(CODE_SYSTEM);
assertThat(codingFirstRep.getDisplay()).isEqualTo(DISPLAY_NAME);
assertThat(role.getOrganizationTarget()).isEqualTo(organization);
assertThat(role.getPractitionerTarget()).isEqualTo(practitioner);
assertThat(role.getIdElement().getValue()).isEqualTo(RANDOM_UUID);
}
use of org.hl7.fhir.r4.model.PractitionerRole 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.r4.model.PractitionerRole in project integration-adaptor-111 by nhsconnect.
the class EncounterMapper method getEncounterParticipantComponents.
private List<EncounterParticipantComponent> getEncounterParticipantComponents(POCDMT000002UK01ClinicalDocument1 clinicalDocument, List<PractitionerRole> authorPractitionerRoles, Optional<PractitionerRole> responsibleParty, Encounter encounter) {
List<EncounterParticipantComponent> encounterParticipantComponents = stream(clinicalDocument.getParticipantArray()).filter(it -> !PARTCIPANT_TYPE_CODE_REFT.equals(it.getTypeCode())).map(participantMapper::mapEncounterParticipant).collect(Collectors.toList());
if (authorPractitionerRoles.size() > 0) {
authorPractitionerRoles.stream().map(it -> buildParticipantComponent(it, AUTHOR_PARTICIPANT_CODE, AUTHOR_PARTICIPANT_DISPLAY)).forEach(encounterParticipantComponents::add);
}
if (clinicalDocument.sizeOfInformantArray() > 0) {
stream(clinicalDocument.getInformantArray()).map(informantMapper::mapInformantIntoParticipantComponent).filter(Optional::isPresent).map(Optional::get).forEach(encounterParticipantComponents::add);
for (POCDMT000002UK01Informant12 informant : clinicalDocument.getInformantArray()) {
EncounterParticipantComponent encounterParticipantComponent = participantMapper.mapEncounterRelatedPerson(informant, encounter);
encounterParticipantComponents.add(encounterParticipantComponent);
}
}
if (clinicalDocument.isSetDataEnterer()) {
encounterParticipantComponents.add(dataEntererMapper.mapDataEntererIntoParticipantComponent(clinicalDocument.getDataEnterer()));
}
responsibleParty.ifPresent(it -> encounterParticipantComponents.add(buildParticipantComponent(it, RESPONSIBLE_PARTY_PARTICIPANT_CODE, RESPONSIBLE_PARTY_PARTICIPANT_DISPLAY)));
return encounterParticipantComponents;
}
Aggregations