Search in sources :

Example 11 with PractitionerRole

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)));
}
Also used : PractitionerRole(org.hl7.fhir.r4.model.PractitionerRole) Test(org.junit.Test)

Example 12 with PractitionerRole

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;
}
Also used : ConsentCreateException(org.hl7.gravity.refimpl.sdohexchange.exception.ConsentCreateException) Bundle(org.hl7.fhir.r4.model.Bundle) Reference(org.hl7.fhir.r4.model.Reference) ConsentPrepareBundleFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.factory.ConsentPrepareBundleFactory) PractitionerRole(org.hl7.fhir.r4.model.PractitionerRole)

Example 13 with PractitionerRole

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);
}
Also used : Coding(org.hl7.fhir.dstu3.model.Coding) PractitionerRole(org.hl7.fhir.dstu3.model.PractitionerRole) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.jupiter.api.Test)

Example 14 with PractitionerRole

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;
}
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 15 with PractitionerRole

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;
}
Also used : EncounterParticipantComponent(org.hl7.fhir.dstu3.model.Encounter.EncounterParticipantComponent) Arrays(java.util.Arrays) REFERRAL(uk.nhs.adaptors.oneoneone.cda.report.enums.MessageHeaderEvent.REFERRAL) Identifier(org.hl7.fhir.dstu3.model.Identifier) Coding(org.hl7.fhir.dstu3.model.Coding) NodeUtil(uk.nhs.adaptors.oneoneone.cda.report.util.NodeUtil) POCDMT000002UK01Section(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Section) AppointmentService(uk.nhs.adaptors.oneoneone.cda.report.service.AppointmentService) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept) ArrayList(java.util.ArrayList) Organization(org.hl7.fhir.dstu3.model.Organization) Group(org.hl7.fhir.dstu3.model.Group) Period(org.hl7.fhir.dstu3.model.Period) POCDMT000002UK01ClinicalDocument1(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01ClinicalDocument1) POCDMT000002UK01Component3(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Component3) EncounterParticipantComponent(org.hl7.fhir.dstu3.model.Encounter.EncounterParticipantComponent) POCDMT000002UK01PatientRole(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01PatientRole) FINISHED(org.hl7.fhir.dstu3.model.Encounter.EncounterStatus.FINISHED) Reference(org.hl7.fhir.dstu3.model.Reference) EncounterLocationComponent(org.hl7.fhir.dstu3.model.Encounter.EncounterLocationComponent) IVLTS(uk.nhs.connect.iucds.cda.ucr.IVLTS) Collectors(java.util.stream.Collectors) POCDMT000002UK01Entry(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Entry) Encounter(org.hl7.fhir.dstu3.model.Encounter) DISCHARGE_DETAILS(uk.nhs.adaptors.oneoneone.cda.report.enums.MessageHeaderEvent.DISCHARGE_DETAILS) List(java.util.List) Component(org.springframework.stereotype.Component) POCDMT000002UK01Encounter(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Encounter) Narrative(org.hl7.fhir.dstu3.model.Narrative) Patient(org.hl7.fhir.dstu3.model.Patient) GENERATED(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.GENERATED) ResourceUtil(uk.nhs.adaptors.oneoneone.cda.report.util.ResourceUtil) Optional(java.util.Optional) POCDMT000002UK01Informant12(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Informant12) AllArgsConstructor(lombok.AllArgsConstructor) Arrays.stream(java.util.Arrays.stream) PractitionerRole(org.hl7.fhir.dstu3.model.PractitionerRole) POCDMT000002UK01Informant12(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Informant12) Optional(java.util.Optional)

Aggregations

PractitionerRole (org.hl7.fhir.r4.model.PractitionerRole)26 Reference (org.hl7.fhir.r4.model.Reference)19 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)16 Coding (org.hl7.fhir.r4.model.Coding)15 Identifier (org.hl7.fhir.r4.model.Identifier)13 ArrayList (java.util.ArrayList)12 Practitioner (org.hl7.fhir.r4.model.Practitioner)12 Resource (org.hl7.fhir.r4.model.Resource)12 List (java.util.List)11 PractitionerRole (org.hl7.fhir.dstu3.model.PractitionerRole)11 RelatedPerson (org.hl7.fhir.r4.model.RelatedPerson)10 Optional (java.util.Optional)9 DateTimeType (org.hl7.fhir.r4.model.DateTimeType)7 EncounterParticipantComponent (org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent)7 Period (org.hl7.fhir.r4.model.Period)7 Test (org.junit.jupiter.api.Test)7 Identifiable (org.openehealth.ipf.commons.ihe.xds.core.metadata.Identifiable)7 Component (org.springframework.stereotype.Component)7 ContactPoint (org.hl7.fhir.r4.model.ContactPoint)6 RequiredArgsConstructor (lombok.RequiredArgsConstructor)5