use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestTranslatorImplTest method toOpenMrsType_shouldTranslateRequesterToOpenMrsType.
@Test
public void toOpenMrsType_shouldTranslateRequesterToOpenMrsType() {
Provider provider = new Provider();
provider.setUuid(PRACTITIONER_UUID);
Reference requesterReference = new Reference();
requesterReference.setReference(FhirConstants.PRACTITIONER + "/" + PRACTITIONER_UUID);
medicationRequest.setRequester(requesterReference);
when(providerPractitionerReferenceTranslator.toOpenmrsType(requesterReference)).thenReturn(provider);
DrugOrder result = medicationRequestTranslator.toOpenmrsType(new DrugOrder(), medicationRequest);
assertThat(result, notNullValue());
assertThat(result.getOrderer(), notNullValue());
assertThat(result.getOrderer().getUuid(), equalTo(PRACTITIONER_UUID));
}
use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestTranslatorImplTest method toFhirResource_shouldConvertActiveStatusToFhirType.
@Test
public void toFhirResource_shouldConvertActiveStatusToFhirType() {
when(medicationRequestStatusTranslator.toFhirResource(drugOrder)).thenReturn(MedicationRequest.MedicationRequestStatus.ACTIVE);
MedicationRequest result = medicationRequestTranslator.toFhirResource(drugOrder);
assertThat(result, notNullValue());
assertThat(result.getStatus(), notNullValue());
assertThat(result.getStatus(), equalTo(MedicationRequest.MedicationRequestStatus.ACTIVE));
}
use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestTranslatorImplTest method toFhirResource_shouldTranslateDrugToMedicationReference.
@Test
public void toFhirResource_shouldTranslateDrugToMedicationReference() {
Drug drug = new Drug();
drug.setUuid(DRUG_UUID);
drugOrder.setDrug(drug);
Reference medicationRef = new Reference();
medicationRef.setReference(FhirConstants.MEDICATION_REQUEST + "/" + DRUG_UUID);
when(medicationReferenceTranslator.toFhirResource(drug)).thenReturn(medicationRef);
MedicationRequest result = medicationRequestTranslator.toFhirResource(drugOrder);
assertThat(result, notNullValue());
assertThat(result.getMedication(), notNullValue());
assertThat(result.getMedication(), equalTo(medicationRef));
}
use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestTranslatorImplTest method toFhirResource_shouldTranslatePatientToFhirType.
@Test
public void toFhirResource_shouldTranslatePatientToFhirType() {
Patient patient = new Patient();
patient.setUuid(PATIENT_UUID);
drugOrder.setPatient(patient);
Reference patientReference = new Reference();
patientReference.setReference(FhirConstants.PATIENT + "/" + PATIENT_UUID);
when(patientReferenceTranslator.toFhirResource(patient)).thenReturn(patientReference);
MedicationRequest result = medicationRequestTranslator.toFhirResource(drugOrder);
assertThat(result, notNullValue());
assertThat(result.getSubject(), notNullValue());
assertThat(result.getSubject().getReference(), equalTo(patientReference.getReference()));
}
use of org.hl7.fhir.r4.model.MedicationRequest in project elexis-server by elexis.
the class MedicationRequestResourceProvider method findMedicationsByPatient.
@Search()
public List<MedicationRequest> findMedicationsByPatient(@RequiredParam(name = MedicationRequest.SP_PATIENT) IdType thePatientId) {
if (thePatientId != null && !thePatientId.isEmpty()) {
Optional<IPatient> patient = modelService.load(thePatientId.getIdPart(), IPatient.class);
if (patient.isPresent()) {
if (patient.get().isPatient()) {
IQuery<IPrescription> query = modelService.getQuery(IPrescription.class);
query.and(ModelPackage.Literals.IPRESCRIPTION__PATIENT, COMPARATOR.EQUALS, patient.get());
// TODO
// qbe.add(Prescription_.rezeptID, JPAQuery.QUERY.EQUALS, null);
List<IPrescription> prescriptions = query.execute();
if (prescriptions != null && !prescriptions.isEmpty()) {
List<MedicationRequest> ret = new ArrayList<MedicationRequest>();
for (IPrescription prescription : prescriptions) {
Optional<MedicationRequest> fhirMedicationOrder = getTransformer().getFhirObject(prescription);
fhirMedicationOrder.ifPresent(fmo -> ret.add(fmo));
}
return ret;
}
}
}
}
return null;
}
Aggregations