Search in sources :

Example 41 with PractitionerRole

use of org.hl7.fhir.r4.model.PractitionerRole in project elexis-server by elexis.

the class PractitionerRoleResourceProvider method getAllPractitionerRoles.

private List<PractitionerRole> getAllPractitionerRoles() {
    // all Kontakt marked as user
    IQuery<IUser> query = modelService.getQuery(IUser.class);
    List<IUser> practitioners = query.execute();
    List<PractitionerRole> ret = new ArrayList<PractitionerRole>();
    if (!practitioners.isEmpty()) {
        for (IUser user : practitioners) {
            Optional<PractitionerRole> fhirPractitionerRole = getTransformer().getFhirObject(user);
            fhirPractitionerRole.ifPresent(fp -> ret.add(fp));
        }
    }
    return ret;
}
Also used : ArrayList(java.util.ArrayList) IUser(ch.elexis.core.model.IUser) PractitionerRole(org.hl7.fhir.r4.model.PractitionerRole)

Example 42 with PractitionerRole

use of org.hl7.fhir.r4.model.PractitionerRole in project Gravity-SDOH-Exchange-RI by FHIR.

the class TaskService method getRole.

private PractitionerRole getRole(UserDto user) {
    Bundle prs = cpClient.search().forResource(PractitionerRole.class).where(PractitionerRole.PRACTITIONER.hasId(user.getId())).and(new StringClientParam(Constants.PARAM_PROFILE).matches().value(UsCoreProfiles.PRACTITIONER_ROLE)).and(new StringClientParam(PractitionerRole.SP_ORGANIZATION + "." + Constants.PARAM_PROFILE).matches().value(UsCoreProfiles.ORGANIZATION)).returnBundle(Bundle.class).execute();
    List<PractitionerRole> roles = FhirUtil.getFromBundle(prs, PractitionerRole.class);
    if (roles.isEmpty()) {
        throw new IllegalStateException("No Practitioner role with US Core profile which references to US Core Organization have been found.");
    } else if (roles.size() > 1) {
        throw new IllegalStateException("More than one Practitioner role with US Core profile which references to US Core Organization have been " + "found.");
    }
    return roles.stream().findFirst().get();
}
Also used : StringClientParam(ca.uhn.fhir.rest.gclient.StringClientParam) Bundle(org.hl7.fhir.r4.model.Bundle) PractitionerRole(org.hl7.fhir.r4.model.PractitionerRole)

Example 43 with PractitionerRole

use of org.hl7.fhir.r4.model.PractitionerRole in project integration-adaptor-111 by nhsconnect.

the class PractitionerRoleMapperTest method shouldMapAuthorRoles.

@Test
public void shouldMapAuthorRoles() {
    mockAuthors();
    POCDMT000002UK01Author[] authors = new POCDMT000002UK01Author[] { author };
    List<PractitionerRole> practitionerRoles = practitionerRoleMapper.mapAuthorRoles(authors);
    assertThat(practitionerRoles.size()).isEqualTo(1);
    PractitionerRole role = practitionerRoles.get(0);
    Coding codingFirstRep = role.getCodeFirstRep().getCodingFirstRep();
    assertThat(codingFirstRep.getCode()).isEqualTo(CODE);
    assertThat(codingFirstRep.getSystem()).isEqualTo(CODE_SYSTEM);
    assertThat(codingFirstRep.getDisplay()).isEqualTo(DISPLAY_NAME);
    assertThat(role.getPractitionerTarget()).isEqualTo(practitioner);
    assertThat(role.getOrganizationTarget()).isEqualTo(organization);
}
Also used : Coding(org.hl7.fhir.dstu3.model.Coding) POCDMT000002UK01Author(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Author) PractitionerRole(org.hl7.fhir.dstu3.model.PractitionerRole) Test(org.junit.jupiter.api.Test)

Example 44 with PractitionerRole

use of org.hl7.fhir.r4.model.PractitionerRole in project integration-adaptor-111 by nhsconnect.

the class EncounterReportBundleService method createEncounterBundle.

public Bundle createEncounterBundle(POCDMT000002UK01ClinicalDocument1 clinicalDocument, ItkReportHeader header, String messageId) throws XmlException {
    Bundle bundle = createBundle(clinicalDocument);
    MessageHeader messageHeader = messageHeaderService.createMessageHeader(header, messageId, clinicalDocument.getEffectiveTime().getValue());
    List<HealthcareService> healthcareServiceList = healthcareServiceMapper.mapHealthcareService(clinicalDocument);
    List<PractitionerRole> authorPractitionerRoles = practitionerRoleMapper.mapAuthorRoles(clinicalDocument.getAuthorArray());
    Optional<PractitionerRole> responsibleParty = practitionerRoleMapper.mapResponsibleParty(clinicalDocument);
    Encounter encounter = encounterMapper.mapEncounter(clinicalDocument, authorPractitionerRoles, responsibleParty, messageHeader.getEvent());
    Consent consent = consentMapper.mapConsent(clinicalDocument, encounter);
    List<QuestionnaireResponse> questionnaireResponseList = pathwayUtil.getQuestionnaireResponses(clinicalDocument, encounter.getSubject(), resourceUtil.createReference(encounter));
    Condition condition = conditionMapper.mapCondition(clinicalDocument, encounter, questionnaireResponseList);
    List<CarePlan> carePlans = carePlanMapper.mapCarePlan(clinicalDocument, encounter, condition);
    Device device = deviceMapper.mapDevice();
    ReferralRequest referralRequest = referralRequestMapper.mapReferralRequest(clinicalDocument, encounter, healthcareServiceList, resourceUtil.createReference(condition), resourceUtil.createReference(device));
    Composition composition = compositionMapper.mapComposition(clinicalDocument, encounter, carePlans, questionnaireResponseList, referralRequest, authorPractitionerRoles);
    List<Observation> observations = observationMapper.mapObservations(clinicalDocument, encounter);
    RelatedPerson relatedPerson = relatedPersonMapper.createEmergencyContactRelatedPerson(clinicalDocument, encounter);
    addMessageHeader(bundle, messageHeader);
    addEncounter(bundle, encounter);
    addServiceProvider(bundle, encounter);
    addParticipants(bundle, encounter);
    addLocation(bundle, encounter);
    addSubject(bundle, encounter);
    addHealthcareService(bundle, healthcareServiceList);
    addIncomingReferral(bundle, referralRequest);
    addAppointment(bundle, encounter);
    addEntry(bundle, composition);
    addCarePlan(bundle, carePlans);
    addEntry(bundle, consent);
    addEntry(bundle, condition);
    addQuestionnaireResponses(bundle, questionnaireResponseList);
    addObservations(bundle, observations);
    addPractitionerRoles(bundle, authorPractitionerRoles, responsibleParty);
    addRelatedPerson(bundle, relatedPerson);
    addEntry(bundle, device);
    ListResource listResource = getReferenceFromBundle(bundle, clinicalDocument, encounter, device);
    addEntry(bundle, listResource);
    return bundle;
}
Also used : Condition(org.hl7.fhir.dstu3.model.Condition) ReferralRequest(org.hl7.fhir.dstu3.model.ReferralRequest) Composition(org.hl7.fhir.dstu3.model.Composition) Bundle(org.hl7.fhir.dstu3.model.Bundle) Device(org.hl7.fhir.dstu3.model.Device) HealthcareService(org.hl7.fhir.dstu3.model.HealthcareService) PractitionerRole(org.hl7.fhir.dstu3.model.PractitionerRole) QuestionnaireResponse(org.hl7.fhir.dstu3.model.QuestionnaireResponse) RelatedPerson(org.hl7.fhir.dstu3.model.RelatedPerson) CarePlan(org.hl7.fhir.dstu3.model.CarePlan) Consent(org.hl7.fhir.dstu3.model.Consent) Observation(org.hl7.fhir.dstu3.model.Observation) Encounter(org.hl7.fhir.dstu3.model.Encounter) MessageHeader(org.hl7.fhir.dstu3.model.MessageHeader) ListResource(org.hl7.fhir.dstu3.model.ListResource)

Example 45 with PractitionerRole

use of org.hl7.fhir.r4.model.PractitionerRole in project integration-adaptor-111 by nhsconnect.

the class PractitionerRoleMapper method mapResponsibleParty.

public Optional<PractitionerRole> mapResponsibleParty(POCDMT000002UK01ClinicalDocument1 clinicalDocument) {
    if (clinicalDocument.isSetComponentOf()) {
        POCDMT000002UK01Component1 componentOf = clinicalDocument.getComponentOf();
        if (componentOf.getEncompassingEncounter().isSetResponsibleParty()) {
            PractitionerRole role = new PractitionerRole();
            role.setIdElement(resourceUtil.newRandomUuid());
            POCDMT000002UK01ResponsibleParty responsibleParty = componentOf.getEncompassingEncounter().getResponsibleParty();
            POCDMT000002UK01AssignedEntity assignedEntity = responsibleParty.getAssignedEntity();
            role.setCode(asList(getCode(assignedEntity.getCode())));
            if (assignedEntity.isSetRepresentedOrganization()) {
                Organization organization = organizationMapper.mapOrganization(assignedEntity.getRepresentedOrganization());
                role.setOrganization(resourceUtil.createReference(organization));
                role.setOrganizationTarget(organization);
            }
            Practitioner practitioner = practitionerMapper.mapPractitioner(assignedEntity);
            role.setPractitioner(resourceUtil.createReference(practitioner));
            role.setPractitionerTarget(practitioner);
            return Optional.of(role);
        }
    }
    return empty();
}
Also used : Practitioner(org.hl7.fhir.dstu3.model.Practitioner) POCDMT000002UK01Component1(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Component1) Organization(org.hl7.fhir.dstu3.model.Organization) POCDMT000002UK01ResponsibleParty(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01ResponsibleParty) PractitionerRole(org.hl7.fhir.dstu3.model.PractitionerRole) POCDMT000002UK01AssignedEntity(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01AssignedEntity)

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