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;
}
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();
}
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);
}
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;
}
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();
}
Aggregations