Search in sources :

Example 6 with MedicationRequest

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;
}
Also used : BundleEntryComponent(org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent)

Example 7 with MedicationRequest

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;
}
Also used : IIdType(org.hl7.fhir.instance.model.api.IIdType)

Aggregations

UnprocessableEntityException (ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException)3 FHIRException (org.hl7.fhir.exceptions.FHIRException)3 ArrayList (java.util.ArrayList)2 DateTimeDt (ca.uhn.fhir.model.primitive.DateTimeDt)1 StringDt (ca.uhn.fhir.model.primitive.StringDt)1 Date (java.util.Date)1 Annotation (org.hl7.fhir.dstu3.model.Annotation)1 BundleEntryComponent (org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent)1 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)1 MedicationRequest (org.hl7.fhir.dstu3.model.MedicationRequest)1 MedicationRequestDispenseRequestComponent (org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestDispenseRequestComponent)1 Reference (org.hl7.fhir.dstu3.model.Reference)1 IIdType (org.hl7.fhir.instance.model.api.IIdType)1