use of org.hl7.fhir.dstu3.model.MedicationRequest in project gpconnect-demonstrator by nhsconnect.
the class PopulateMedicationBundle method createBundleEntries.
private List<BundleEntryComponent> createBundleEntries(MedicationStatementDetail statementDetail, Boolean includePrescriptionIssues, PatientDetails patientDetails, Set<String> practitionerIds, Set<String> orgIds) {
List<BundleEntryComponent> bundleEntryComponents = new ArrayList<>();
MedicationStatement medStatement = medicationStatementResourceProvider.getMedicationStatementResource(statementDetail);
bundleEntryComponents.add(new BundleEntryComponent().setResource(medStatement));
bundleEntryComponents.add(new BundleEntryComponent().setResource(medicationResourceProvider.getMedicationResourceForBundle(statementDetail.getMedicationId())));
MedicationRequest medicationRequest = medicationRequestResourceProvider.getMedicationRequestPlanResource(statementDetail.getMedicationRequestPlanId());
bundleEntryComponents.add(new BundleEntryComponent().setResource(medicationRequest));
if (includePrescriptionIssues) {
List<MedicationRequest> prescriptionIssues = medicationRequestResourceProvider.getMedicationRequestOrderResources(medicationRequest.getGroupIdentifier().getValue());
prescriptionIssues.forEach(requestOrder -> bundleEntryComponents.add(new BundleEntryComponent().setResource(requestOrder)));
}
List<MedicationRequest> allMedReqs = new ArrayList<>();
allMedReqs.add(medicationRequest);
allMedReqs.addAll(allMedReqs);
practitionerIds.addAll(getPractitionerIds(medStatement, allMedReqs));
orgIds.addAll(getOrganisationIds(allMedReqs));
return bundleEntryComponents;
}
use of org.hl7.fhir.dstu3.model.MedicationRequest in project gpconnect-demonstrator by nhsconnect.
the class PopulateMedicationBundle method getOrganisationIds.
private Set<String> getOrganisationIds(List<MedicationRequest> allMedReqs) {
Set<String> orgIds = new HashSet<>();
for (MedicationRequest medReq : allMedReqs) {
IIdType performerOrganizationRef = medReq.getDispenseRequest().getPerformer().getReferenceElement();
IIdType requesterOnBehalfOfOrganizationRef = medReq.getRequester().getOnBehalfOf().getReferenceElement();
if (performerOrganizationRef != null && performerOrganizationRef.getIdPart() != null) {
orgIds.add(performerOrganizationRef.getIdPart());
}
if (requesterOnBehalfOfOrganizationRef != null && requesterOnBehalfOfOrganizationRef.getIdPart() != null) {
orgIds.add(requesterOnBehalfOfOrganizationRef.getIdPart());
}
}
return orgIds;
}
Aggregations