use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestTranslatorImplTest method toFhirResource_shouldTranslateOrderReasonToReasonCode.
@Test
public void toFhirResource_shouldTranslateOrderReasonToReasonCode() {
Concept concept = new Concept();
concept.setUuid(CONCEPT_UUID);
concept.setConceptId(10023);
drugOrder.setOrderReason(concept);
CodeableConcept codeableConcept = new CodeableConcept();
codeableConcept.addCoding(new Coding().setCode(concept.getConceptId().toString()));
when(conceptTranslator.toFhirResource(concept)).thenReturn(codeableConcept);
MedicationRequest result = medicationRequestTranslator.toFhirResource(drugOrder);
assertThat(result, notNullValue());
assertThat(result.getReasonCode(), not(empty()));
assertThat(result.getReasonCodeFirstRep(), equalTo(codeableConcept));
}
use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestTranslatorImplTest method setup.
@Before
public void setup() {
medicationRequestTranslator = new MedicationRequestTranslatorImpl();
medicationRequestTranslator.setStatusTranslator(medicationRequestStatusTranslator);
medicationRequestTranslator.setPractitionerReferenceTranslator(providerPractitionerReferenceTranslator);
medicationRequestTranslator.setMedicationRequestPriorityTranslator(medicationRequestPriorityTranslator);
medicationRequestTranslator.setMedicationReferenceTranslator(medicationReferenceTranslator);
medicationRequestTranslator.setConceptTranslator(conceptTranslator);
medicationRequestTranslator.setDosageTranslator(dosageTranslator);
medicationRequestTranslator.setEncounterReferenceTranslator(encounterReferenceTranslator);
medicationRequestTranslator.setPatientReferenceTranslator(patientReferenceTranslator);
medicationRequestTranslator.setOrderIdentifierTranslator(new OrderIdentifierTranslatorImpl());
drugOrder = new DrugOrder();
drugOrder.setUuid(DRUG_ORDER_UUID);
setOrderNumberByReflection(drugOrder, DRUG_ORDER_NUMBER);
OrderType ordertype = new OrderType();
ordertype.setUuid(DRUG_ORDER_TYPE_UUID);
drugOrder.setOrderType(ordertype);
discontinuedDrugOrder = new DrugOrder();
discontinuedDrugOrder.setUuid(DISCONTINUED_DRUG_ORDER_UUID);
setOrderNumberByReflection(discontinuedDrugOrder, DISCONTINUED_DRUG_ORDER_NUMBER);
discontinuedDrugOrder.setPreviousOrder(drugOrder);
medicationRequest = new MedicationRequest();
medicationRequest.setId(DRUG_ORDER_UUID);
}
use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestTranslatorImplTest method toOpenMrsType_shouldTranslatePatientToOpenMrsType.
@Test
public void toOpenMrsType_shouldTranslatePatientToOpenMrsType() {
Patient patient = new Patient();
patient.setUuid(PATIENT_UUID);
Reference patientReference = new Reference();
patientReference.setReference(FhirConstants.PATIENT + "/" + PATIENT_UUID);
medicationRequest.setSubject(patientReference);
when(patientReferenceTranslator.toOpenmrsType(patientReference)).thenReturn(patient);
DrugOrder result = medicationRequestTranslator.toOpenmrsType(new DrugOrder(), medicationRequest);
assertThat(result, notNullValue());
assertThat(result.getPatient(), notNullValue());
assertThat(result.getPatient().getUuid(), equalTo(PATIENT_UUID));
}
use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestTranslatorImplTest method toFhirResource_shouldTranslateToFhirResourceWithReplacesFieldGivenDiscontinuedOrder.
@Test
public void toFhirResource_shouldTranslateToFhirResourceWithReplacesFieldGivenDiscontinuedOrder() {
discontinuedDrugOrder.setAction(Order.Action.DISCONTINUE);
MedicationRequest result = medicationRequestTranslator.toFhirResource(discontinuedDrugOrder);
assertThat(result, notNullValue());
assertThat(result.getId(), notNullValue());
assertThat(result.getId(), equalTo(DISCONTINUED_DRUG_ORDER_UUID));
assertThat(result.getPriorPrescription().getReference(), equalTo(PRIOR_MEDICATION_REQUEST_REFERENCE));
assertThat(result.getPriorPrescription().getIdentifier().getValue(), equalTo(DRUG_ORDER_NUMBER));
}
use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestTranslatorImplTest method toFhirResource_shouldTranslateOrdererToFhirType.
@Test
public void toFhirResource_shouldTranslateOrdererToFhirType() {
Provider provider = new Provider();
provider.setUuid(PRACTITIONER_UUID);
drugOrder.setOrderer(provider);
Reference requesterReference = new Reference();
requesterReference.setReference(FhirConstants.PRACTITIONER + "/" + PRACTITIONER_UUID);
when(providerPractitionerReferenceTranslator.toFhirResource(provider)).thenReturn(requesterReference);
MedicationRequest result = medicationRequestTranslator.toFhirResource(drugOrder);
assertThat(result, notNullValue());
assertThat(result.getRequester(), notNullValue());
assertThat(result.getRequester().getReference(), equalTo(requesterReference.getReference()));
}
Aggregations