Search in sources :

Example 56 with MedicationRequest

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));
}
Also used : CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Concept(org.openmrs.Concept) MedicationRequest(org.hl7.fhir.r4.model.MedicationRequest) Coding(org.hl7.fhir.r4.model.Coding) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.Test)

Example 57 with MedicationRequest

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);
}
Also used : DrugOrder(org.openmrs.DrugOrder) MedicationRequest(org.hl7.fhir.r4.model.MedicationRequest) OrderType(org.openmrs.OrderType) Before(org.junit.Before)

Example 58 with MedicationRequest

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));
}
Also used : DrugOrder(org.openmrs.DrugOrder) Reference(org.hl7.fhir.r4.model.Reference) Patient(org.openmrs.Patient) Test(org.junit.Test)

Example 59 with MedicationRequest

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));
}
Also used : MedicationRequest(org.hl7.fhir.r4.model.MedicationRequest) Test(org.junit.Test)

Example 60 with MedicationRequest

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()));
}
Also used : MedicationRequest(org.hl7.fhir.r4.model.MedicationRequest) Reference(org.hl7.fhir.r4.model.Reference) Provider(org.openmrs.Provider) Test(org.junit.Test)

Aggregations

MedicationRequest (org.hl7.fhir.r4.model.MedicationRequest)128 Test (org.junit.Test)128 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)78 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)58 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)48 ReferenceAndListParam (ca.uhn.fhir.rest.param.ReferenceAndListParam)44 ReferenceOrListParam (ca.uhn.fhir.rest.param.ReferenceOrListParam)44 ReferenceParam (ca.uhn.fhir.rest.param.ReferenceParam)44 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)36 Test (org.junit.jupiter.api.Test)35 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)33 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)33 Resource (org.hl7.fhir.r4.model.Resource)31 MedicationRequest (org.hl7.fhir.dstu3.model.MedicationRequest)26 TokenAndListParam (ca.uhn.fhir.rest.param.TokenAndListParam)23 TokenParam (ca.uhn.fhir.rest.param.TokenParam)23 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)23 ArrayList (java.util.ArrayList)19 Include (ca.uhn.fhir.model.api.Include)15 HashSet (java.util.HashSet)15