use of org.hl7.fhir.r4.model.Organization in project gpconnect-demonstrator by nhsconnect.
the class OrganizationResourceProvider method getOrganizationsByODSCode.
@Search
public List<Organization> getOrganizationsByODSCode(@RequiredParam(name = Organization.SP_IDENTIFIER) TokenParam tokenParam, @Sort SortSpec sort, @Count Integer count) {
if (StringUtils.isBlank(tokenParam.getSystem()) || StringUtils.isBlank(tokenParam.getValue())) {
throw OperationOutcomeFactory.buildOperationOutcomeException(new InvalidRequestException("Missing identifier token"), SystemCode.INVALID_PARAMETER, IssueType.INVALID);
}
if (tokenParam.getSystem().equals(SystemURL.ID_ODS_ORGANIZATION_CODE) || tokenParam.getSystem().equals(SystemURL.ID_ODS_OLD_ORGANIZATION_CODE)) {
List<Organization> organizationDetails = convertOrganizaitonDetailsListToOrganizationList(organizationSearch.findOrganizationDetailsByOrgODSCode(tokenParam.getValue()));
if (organizationDetails.isEmpty()) {
return null;
}
if (sort != null && sort.getParamName().equalsIgnoreCase(Location.SP_STATUS)) {
Collections.sort(organizationDetails, (Organization a, Organization b) -> {
String aStatus = a.getName();
String bStatus = b.getName();
if (aStatus == null && bStatus == null) {
return 0;
}
if (aStatus == null && bStatus != null) {
return -1;
}
if (aStatus != null && bStatus == null) {
return 1;
}
return aStatus.compareToIgnoreCase(bStatus);
});
}
// Update startIndex if we do paging
return count != null ? organizationDetails.subList(0, count) : organizationDetails;
} else {
throw OperationOutcomeFactory.buildOperationOutcomeException(new InvalidRequestException("Invalid system code"), SystemCode.INVALID_PARAMETER, IssueType.INVALID);
}
}
use of org.hl7.fhir.r4.model.Organization in project gpconnect-demonstrator by nhsconnect.
the class PatientResourceProvider method setStaticPatientData.
private Patient setStaticPatientData(Patient patient) {
patient.setLanguage(("en-GB"));
patient.addExtension(createCodingExtension("CG", "Greek Cypriot", SystemURL.CS_CC_ETHNIC_CATEGORY, SystemURL.SD_CC_EXT_ETHNIC_CATEGORY));
patient.addExtension(createCodingExtension("SomeSnomedCode", "Some Snomed Code", SystemURL.CS_CC_RELIGIOUS_AFFILI, SystemURL.SD_CC_EXT_RELIGIOUS_AFFILI));
patient.addExtension(new Extension(SystemURL.SD_PATIENT_CADAVERIC_DON, new BooleanType(false)));
patient.addExtension(createCodingExtension("H", "UK Resident", SystemURL.CS_CC_RESIDENTIAL_STATUS, SystemURL.SD_CC_EXT_RESIDENTIAL_STATUS));
patient.addExtension(createCodingExtension("3", "To pay hotel fees only", SystemURL.CS_CC_TREATMENT_CAT, SystemURL.SD_CC_EXT_TREATMENT_CAT));
Extension nhsCommExtension = new Extension();
nhsCommExtension.setUrl(SystemURL.SD_CC_EXT_NHS_COMMUNICATION);
nhsCommExtension.addExtension(createCodingExtension("en", "English", SystemURL.CS_CC_HUMAN_LANG, SystemURL.SD_CC_EXT_COMM_LANGUAGE));
nhsCommExtension.addExtension(new Extension(SystemURL.SD_CC_COMM_PREFERRED, new BooleanType(false)));
nhsCommExtension.addExtension(createCodingExtension("RWR", "Received written", SystemURL.CS_CC_LANG_ABILITY_MODE, SystemURL.SD_CC_MODE_OF_COMM));
nhsCommExtension.addExtension(createCodingExtension("E", "Excellent", SystemURL.CS_CC_LANG_ABILITY_PROFI, SystemURL.SD_CC_COMM_PROFICIENCY));
nhsCommExtension.addExtension(new Extension(SystemURL.SD_CC_INTERPRETER_REQUIRED, new BooleanType(false)));
patient.addExtension(nhsCommExtension);
Identifier localIdentifier = new Identifier();
localIdentifier.setUse(IdentifierUse.USUAL);
localIdentifier.setSystem(SystemURL.ID_LOCAL_PATIENT_IDENTIFIER);
localIdentifier.setValue("123456");
CodeableConcept liType = new CodeableConcept();
Coding liTypeCoding = new Coding();
liTypeCoding.setCode("EN");
liTypeCoding.setDisplay("Employer number");
liTypeCoding.setSystem(SystemURL.VS_IDENTIFIER_TYPE);
liType.addCoding(liTypeCoding);
localIdentifier.setType(liType);
localIdentifier.setAssigner(new Reference("Organization/1"));
patient.addIdentifier(localIdentifier);
Calendar calendar = Calendar.getInstance();
calendar.set(2017, 1, 1);
DateTimeDt endDate = new DateTimeDt(calendar.getTime());
calendar.set(2016, 1, 1);
DateTimeDt startDate = new DateTimeDt(calendar.getTime());
Period pastPeriod = new Period().setStart(calendar.getTime()).setEnd(calendar.getTime());
patient.addName().setFamily("AnotherOfficialFamilyName").addGiven("AnotherOfficialGivenName").setUse(NameUse.OFFICIAL).setPeriod(pastPeriod);
patient.addName().setFamily("AdditionalFamily").addGiven("AdditionalGiven").setUse(NameUse.TEMP);
patient.addTelecom(staticElHelper.getValidTelecom());
patient.addAddress(staticElHelper.getValidAddress());
return patient;
}
use of org.hl7.fhir.r4.model.Organization in project gpconnect-demonstrator by nhsconnect.
the class AppointmentResourceProvider method appointmentResourceConverterToAppointmentDetail.
/**
* fhir resource Appointment to AppointmentDetail
*
* @param appointment Resource
* @return populated AppointmentDetail
*/
private AppointmentDetail appointmentResourceConverterToAppointmentDetail(Appointment appointment) {
appointmentValidation.validateAppointmentExtensions(appointment.getExtension());
if (appointmentValidation.appointmentDescriptionTooLong(appointment)) {
throwUnprocessableEntity422_InvalidResourceException("Appointment description cannot be greater then " + APPOINTMENT_DESCRIPTION_LENGTH + " characters");
}
AppointmentDetail appointmentDetail = new AppointmentDetail();
Long id = appointment.getIdElement().getIdPartAsLong();
appointmentDetail.setId(id);
appointmentDetail.setLastUpdated(getLastUpdated(appointment.getMeta().getLastUpdated()));
List<Extension> cnlExtension = appointment.getExtensionsByUrl(SystemURL.SD_EXTENSION_GPC_APPOINTMENT_CANCELLATION_REASON);
if (cnlExtension != null && !cnlExtension.isEmpty()) {
IBaseDatatype value = cnlExtension.get(0).getValue();
if (null == value) {
throwInvalidRequest400_BadRequestException("Cancellation reason missing.");
}
appointmentDetail.setCancellationReason(value.toString());
}
appointmentDetail.setStatus(appointment.getStatus().toString().toLowerCase(Locale.UK));
appointmentDetail.setMinutesDuration(appointment.getMinutesDuration());
appointmentDetail.setPriority(appointment.getPriority());
appointmentDetail.setStartDateTime(appointment.getStart());
appointmentDetail.setEndDateTime(appointment.getEnd());
List<Long> slotIds = new ArrayList<>();
for (Reference slotReference : appointment.getSlot()) {
// #200 check slots for absolute references
checkReferenceIsRelative(slotReference.getReference());
try {
String here = slotReference.getReference().substring("Slot/".length());
Long slotId = new Long(here);
slotIds.add(slotId);
} catch (NumberFormatException ex) {
throwUnprocessableEntity422_InvalidResourceException(String.format("The slot reference value data type for %s is not valid.", slotReference.getReference()));
}
}
appointmentDetail.setSlotIds(slotIds);
if (appointmentValidation.appointmentCommentTooLong(appointment)) {
throwUnprocessableEntity422_InvalidResourceException("Appointment comment cannot be greater than " + APPOINTMENT_COMMENT_LENGTH + " characters");
}
appointmentDetail.setComment(appointment.getComment());
appointmentDetail.setDescription(appointment.getDescription());
for (AppointmentParticipantComponent participant : appointment.getParticipant()) {
if (participant.getActor() != null) {
String participantReference = participant.getActor().getReference();
String actorIdString = participantReference.substring(participantReference.lastIndexOf("/") + 1);
Long actorId;
if (actorIdString.equals("null")) {
actorId = null;
} else {
actorId = Long.valueOf(actorIdString);
}
if (participantReference.contains("Patient/")) {
appointmentDetail.setPatientId(actorId);
} else if (participantReference.contains("Practitioner/")) {
appointmentDetail.setPractitionerId(actorId);
} else if (participantReference.contains("Location/")) {
appointmentDetail.setLocationId(actorId);
}
} else {
throwUnprocessableEntity422_InvalidResourceException("Participant Actor cannot be null");
}
}
if (appointment.getCreated() != null) {
Date created = appointment.getCreated();
appointmentDetail.setCreated(created);
}
// #200 check extensions for absolute references
List<Extension> extensions = appointment.getExtension();
for (Extension extension : extensions) {
try {
Reference reference = (Reference) extension.getValue();
if (reference != null) {
checkReferenceIsRelative(reference.getReference());
}
} catch (ClassCastException ex) {
}
}
List<Resource> contained = appointment.getContained();
if (contained != null && !contained.isEmpty()) {
Resource org = contained.get(0);
Organization bookingOrgRes = (Organization) org;
BookingOrgDetail bookingOrgDetail = new BookingOrgDetail();
appointmentValidation.validateBookingOrganizationValuesArePresent(bookingOrgRes);
bookingOrgDetail.setName(bookingOrgRes.getName());
// #198 add system and optional use type. Pick system phone if > 1 and available otherwise use the one supplied
Iterator<ContactPoint> iter = bookingOrgRes.getTelecom().iterator();
ContactPoint telecom = bookingOrgRes.getTelecomFirstRep();
while (iter.hasNext()) {
ContactPoint thisTelecom = iter.next();
if (thisTelecom.getSystem() == ContactPoint.ContactPointSystem.PHONE) {
telecom = thisTelecom;
break;
}
}
bookingOrgDetail.setTelephone(telecom.getValue());
bookingOrgDetail.setSystem(telecom.getSystem().toString());
if (telecom.getUse() != null && !telecom.getUse().toString().trim().isEmpty()) {
bookingOrgDetail.setUsetype(telecom.getUse().toString());
}
if (!bookingOrgRes.getIdentifier().isEmpty()) {
bookingOrgDetail.setOrgCode(bookingOrgRes.getIdentifierFirstRep().getValue());
String system = bookingOrgRes.getIdentifierFirstRep().getSystem();
// check that organization identifier system is https://fhir.nhs.uk/Id/ods-organization-code
if (system != null && !system.trim().isEmpty()) {
if (!system.equals(ID_ODS_ORGANIZATION_CODE)) {
throwUnprocessableEntity422_InvalidResourceException("Appointment organisation identifier system must be an ODS code!");
}
} else {
throwUnprocessableEntity422_InvalidResourceException("Appointment organisation identifier system must be populated!");
}
}
bookingOrgDetail.setAppointmentDetail(appointmentDetail);
appointmentDetail.setBookingOrganization(bookingOrgDetail);
// 1.2.7
appointmentDetail.setServiceCategory(appointment.getServiceCategory().getText());
appointmentDetail.setServiceType(appointment.getServiceTypeFirstRep().getText());
}
return appointmentDetail;
}
use of org.hl7.fhir.r4.model.Organization in project gpconnect-demonstrator by nhsconnect.
the class AppointmentResourceProvider method appointmentDetailToAppointmentResourceConverter.
/**
* AppointmentDetail to fhir resource Appointment
*
* @param appointmentDetail
* @return Appointment Resource
*/
private Appointment appointmentDetailToAppointmentResourceConverter(AppointmentDetail appointmentDetail) {
Appointment appointment = new Appointment();
String appointmentId = String.valueOf(appointmentDetail.getId());
String versionId = String.valueOf(appointmentDetail.getLastUpdated().getTime());
String resourceType = appointment.getResourceType().toString();
IdType id = new IdType(resourceType, appointmentId, versionId);
appointment.setId(id);
appointment.getMeta().setVersionId(versionId);
appointment.getMeta().setLastUpdated(appointmentDetail.getLastUpdated());
appointment.getMeta().addProfile(SystemURL.SD_GPC_APPOINTMENT);
Extension extension = new Extension(SystemURL.SD_EXTENSION_GPC_APPOINTMENT_CANCELLATION_REASON, new StringType(appointmentDetail.getCancellationReason()));
appointment.addExtension(extension);
// #157 derive delivery channel from slot
List<Long> sids = appointmentDetail.getSlotIds();
ScheduleDetail scheduleDetail = null;
if (sids.size() > 0) {
// get the first slot but it should not matter because for multi slot appts the deliveryChannel is always the same
SlotDetail slotDetail = slotSearch.findSlotByID(sids.get(0));
String deliveryChannel = slotDetail.getDeliveryChannelCode();
if (deliveryChannel != null && !deliveryChannel.trim().isEmpty()) {
Extension deliveryChannelExtension = new Extension(SystemURL.SD_EXTENSION_GPC_DELIVERY_CHANNEL, new CodeType(deliveryChannel));
appointment.addExtension(deliveryChannelExtension);
}
scheduleDetail = scheduleSearch.findScheduleByID(slotDetail.getScheduleReference());
}
// practitioner role extension here
// lookup the practitioner
Long practitionerID = appointmentDetail.getPractitionerId();
if (practitionerID != null) {
// #195 we need to get this detail from the schedule not the practitioner table
if (scheduleDetail != null) {
Coding roleCoding = new Coding(SystemURL.VS_GPC_PRACTITIONER_ROLE, scheduleDetail.getPractitionerRoleCode(), scheduleDetail.getPractitionerRoleDisplay());
Extension practitionerRoleExtension = new Extension(SystemURL.SD_EXTENSION_GPC_PRACTITIONER_ROLE, new CodeableConcept().addCoding(roleCoding));
appointment.addExtension(practitionerRoleExtension);
}
}
switch(appointmentDetail.getStatus().toLowerCase(Locale.UK)) {
case "pending":
appointment.setStatus(AppointmentStatus.PENDING);
break;
case "booked":
appointment.setStatus(AppointmentStatus.BOOKED);
break;
case "arrived":
appointment.setStatus(AppointmentStatus.ARRIVED);
break;
case "fulfilled":
appointment.setStatus(AppointmentStatus.FULFILLED);
break;
case "cancelled":
appointment.setStatus(AppointmentStatus.CANCELLED);
break;
case "noshow":
appointment.setStatus(AppointmentStatus.NOSHOW);
break;
default:
appointment.setStatus(AppointmentStatus.PENDING);
break;
}
appointment.setStart(appointmentDetail.getStartDateTime());
appointment.setEnd(appointmentDetail.getEndDateTime());
// #218 Date time formats
appointment.getStartElement().setPrecision(TemporalPrecisionEnum.SECOND);
appointment.getEndElement().setPrecision(TemporalPrecisionEnum.SECOND);
List<Reference> slotResources = new ArrayList<>();
for (Long slotId : appointmentDetail.getSlotIds()) {
slotResources.add(new Reference("Slot/" + slotId));
}
appointment.setSlot(slotResources);
if (appointmentDetail.getPriority() != null) {
appointment.setPriority(appointmentDetail.getPriority());
}
appointment.setComment(appointmentDetail.getComment());
appointment.setDescription(appointmentDetail.getDescription());
appointment.addParticipant().setActor(new Reference("Patient/" + appointmentDetail.getPatientId())).setStatus(ParticipationStatus.ACCEPTED);
appointment.addParticipant().setActor(new Reference("Location/" + appointmentDetail.getLocationId())).setStatus(ParticipationStatus.ACCEPTED);
if (null != appointmentDetail.getPractitionerId()) {
appointment.addParticipant().setActor(new Reference("Practitioner/" + appointmentDetail.getPractitionerId())).setStatus(ParticipationStatus.ACCEPTED);
}
if (null != appointmentDetail.getCreated()) {
appointment.setCreated(appointmentDetail.getCreated());
}
if (null != appointmentDetail.getBookingOrganization()) {
// add extension with reference to contained item
String reference = "#1";
Reference orgRef = new Reference(reference);
Extension bookingOrgExt = new Extension(SystemURL.SD_CC_APPOINTMENT_BOOKINGORG, orgRef);
appointment.addExtension(bookingOrgExt);
BookingOrgDetail bookingOrgDetail = appointmentDetail.getBookingOrganization();
Organization bookingOrg = new Organization();
bookingOrg.setId(reference);
bookingOrg.getNameElement().setValue(bookingOrgDetail.getName());
// #198 org phone now persists usetype and system
ContactPoint orgTelecom = bookingOrg.getTelecomFirstRep();
orgTelecom.setValue(bookingOrgDetail.getTelephone());
try {
orgTelecom.setSystem(ContactPointSystem.fromCode(bookingOrgDetail.getSystem().toLowerCase()));
if (bookingOrgDetail.getUsetype() != null && !bookingOrgDetail.getUsetype().trim().isEmpty()) {
orgTelecom.setUse(ContactPointUse.fromCode(bookingOrgDetail.getUsetype().toLowerCase()));
}
} catch (FHIRException ex) {
// Logger.getLogger(AppointmentResourceProvider.class.getName()).log(Level.SEVERE, null, ex);
}
bookingOrg.getMeta().addProfile(SystemURL.SD_GPC_ORGANIZATION);
if (null != bookingOrgDetail.getOrgCode()) {
bookingOrg.getIdentifierFirstRep().setSystem(SystemURL.ID_ODS_ORGANIZATION_CODE).setValue(bookingOrgDetail.getOrgCode());
}
// add contained booking organization resource
appointment.getContained().add(bookingOrg);
}
// if bookingOrganization
appointment.setMinutesDuration(appointmentDetail.getMinutesDuration());
// 1.2.7 set service category from schedule type description
appointment.setServiceCategory(new CodeableConcept().setText(scheduleDetail.getTypeDescription()));
// 1.2.7 set service type from slot type description
appointment.addServiceType(new CodeableConcept().setText(slotSearch.findSlotByID(sids.get(0)).getTypeDisply()));
return appointment;
}
use of org.hl7.fhir.r4.model.Organization in project gpconnect-demonstrator by nhsconnect.
the class PatientResourceProvider method StructuredRecordOperation.
@Operation(name = GET_STRUCTURED_RECORD_OPERATION_NAME)
public Bundle StructuredRecordOperation(@ResourceParam Parameters params) throws FHIRException {
Bundle structuredBundle = new Bundle();
Boolean getAllergies = false;
Boolean includeResolved = false;
Boolean getMedications = false;
Boolean includePrescriptionIssues = false;
Period medicationPeriod = null;
String NHS = getNhsNumber(params);
PatientDetails patientDetails = patientSearch.findPatient(NHS);
// see https://nhsconnect.github.io/gpconnect/accessrecord_structured_development_retrieve_patient_record.html#error-handling
if (patientDetails == null || patientDetails.isSensitive() || patientDetails.isDeceased() || !patientDetails.isActive()) {
throw OperationOutcomeFactory.buildOperationOutcomeException(new ResourceNotFoundException("No patient details found for patient ID: " + NHS), SystemCode.PATIENT_NOT_FOUND, IssueType.NOTFOUND);
}
if (NHS.equals(patientNoconsent)) {
throw OperationOutcomeFactory.buildOperationOutcomeException(new ForbiddenOperationException("No patient consent to share for patient ID: " + NHS), SystemCode.NO_PATIENT_CONSENT, IssueType.FORBIDDEN);
}
operationOutcome = null;
for (ParametersParameterComponent param : params.getParameter()) {
if (validateParametersName(param.getName())) {
if (param.getName().equals(SystemConstants.INCLUDE_ALLERGIES)) {
getAllergies = true;
if (param.getPart().isEmpty()) {
// addWarningIssue(param, IssueType.REQUIRED, "Miss parameter part : " + SystemConstants.INCLUDE_RESOLVED_ALLERGIES);
throw OperationOutcomeFactory.buildOperationOutcomeException(new UnprocessableEntityException("Miss parameter : " + SystemConstants.INCLUDE_RESOLVED_ALLERGIES), SystemCode.INVALID_PARAMETER, IssueType.REQUIRED);
}
boolean includeResolvedParameterPartPresent = false;
for (ParametersParameterComponent paramPart : param.getPart()) {
if (paramPart.getName().equals(SystemConstants.INCLUDE_RESOLVED_ALLERGIES)) {
if (paramPart.getValue() instanceof BooleanType) {
includeResolved = Boolean.valueOf(paramPart.getValue().primitiveValue());
includeResolvedParameterPartPresent = true;
} else {
throw OperationOutcomeFactory.buildOperationOutcomeException(new UnprocessableEntityException("Miss parameter : " + SystemConstants.INCLUDE_RESOLVED_ALLERGIES), SystemCode.INVALID_PARAMETER, IssueType.REQUIRED);
}
} else {
addWarningIssue(param, paramPart, IssueType.NOTSUPPORTED);
// throw OperationOutcomeFactory.buildOperationOutcomeException(
// new UnprocessableEntityException("Incorrect parameter passed : " + paramPart.getName()),
// SystemCode.INVALID_PARAMETER, IssueType.INVALID);
}
}
if (!includeResolvedParameterPartPresent) {
throw OperationOutcomeFactory.buildOperationOutcomeException(new UnprocessableEntityException("Miss parameter : " + SystemConstants.INCLUDE_RESOLVED_ALLERGIES), SystemCode.INVALID_PARAMETER, IssueType.REQUIRED);
}
}
if (param.getName().equals(SystemConstants.INCLUDE_MEDICATION)) {
getMedications = true;
boolean isIncludedPrescriptionIssuesExist = false;
for (ParametersParameterComponent paramPart : param.getPart()) {
if (paramPart.getName().equals(SystemConstants.INCLUDE_PRESCRIPTION_ISSUES)) {
if (paramPart.getValue() instanceof BooleanType) {
includePrescriptionIssues = Boolean.valueOf(paramPart.getValue().primitiveValue());
isIncludedPrescriptionIssuesExist = true;
}
} else if (paramPart.getName().equals(SystemConstants.MEDICATION_SEARCH_FROM_DATE) && paramPart.getValue() instanceof DateType) {
DateType startDateDt = (DateType) paramPart.getValue();
medicationPeriod = new Period();
medicationPeriod.setStart(startDateDt.getValue());
medicationPeriod.setEnd(null);
String startDate = startDateDt.asStringValue();
if (!validateStartDateParamAndEndDateParam(startDate, null)) {
// addWarningIssue(param, paramPart, IssueType.INVALID, "Invalid date used");
}
} else {
addWarningIssue(param, paramPart, IssueType.NOTSUPPORTED);
// throw OperationOutcomeFactory.buildOperationOutcomeException(
// new UnprocessableEntityException("Incorrect parameter passed : " + paramPart.getName()),
// SystemCode.INVALID_PARAMETER, IssueType.INVALID);
}
}
if (!isIncludedPrescriptionIssuesExist) {
// # 1.2.6 now defaults to true if not provided
includePrescriptionIssues = true;
}
}
} else {
// invalid parameter
addWarningIssue(param, IssueType.NOTSUPPORTED);
}
}
// for parameter
// Add Patient
Patient patient = patientDetailsToPatientResourceConverter(patientDetails);
if (patient.getIdentifierFirstRep().getValue().equals(NHS)) {
structuredBundle.addEntry().setResource(patient);
}
// Organization from patient
Set<String> orgIds = new HashSet<>();
orgIds.add(patientDetails.getManagingOrganization());
// Practitioner from patient
Set<String> practitionerIds = new HashSet<>();
List<Reference> practitionerReferenceList = patient.getGeneralPractitioner();
practitionerReferenceList.forEach(practitionerReference -> {
String[] pracRef = practitionerReference.getReference().split("/");
if (pracRef.length > 1) {
practitionerIds.add(pracRef[1]);
}
});
if (getAllergies) {
structuredBundle = structuredAllergyIntoleranceBuilder.buildStructuredAllergyIntolerence(NHS, practitionerIds, structuredBundle, includeResolved);
}
if (getMedications) {
structuredBundle = populateMedicationBundle.addMedicationBundleEntries(structuredBundle, patientDetails, includePrescriptionIssues, medicationPeriod, practitionerIds, orgIds);
}
// Add all practitioners and practitioner roles
for (String practitionerId : practitionerIds) {
Practitioner pracResource = practitionerResourceProvider.getPractitionerById(new IdType(practitionerId));
structuredBundle.addEntry().setResource(pracResource);
List<PractitionerRole> practitionerRoleList = practitionerRoleResourceProvider.getPractitionerRoleByPracticionerId(new IdType(practitionerId));
for (PractitionerRole role : practitionerRoleList) {
String[] split = role.getOrganization().getReference().split("/");
orgIds.add(split[1]);
structuredBundle.addEntry().setResource(role);
}
}
// Add all organizations
for (String orgId : orgIds) {
OrganizationDetails organizationDetails = organizationSearch.findOrganizationDetails(new Long(orgId));
Organization organization = organizationResourceProvider.convertOrganizationDetailsToOrganization(organizationDetails);
structuredBundle.addEntry().setResource(organization);
}
structuredBundle.setType(BundleType.COLLECTION);
structuredBundle.getMeta().addProfile(SystemURL.SD_GPC_STRUCTURED_BUNDLE);
if (operationOutcome != null) {
structuredBundle.addEntry().setResource(operationOutcome);
} else {
removeDuplicateResources(structuredBundle);
}
return structuredBundle;
}
Aggregations