Search in sources :

Example 16 with Medication

use of org.hl7.fhir.r4.model.Medication in project openmrs-module-fhir2 by openmrs.

the class MedicationSearchQueryTest method searchForMedications_shouldSearchMedicationsByIngredientCode.

@Test
public void searchForMedications_shouldSearchMedicationsByIngredientCode() {
    TokenAndListParam ingredientCode = new TokenAndListParam();
    ingredientCode.addAnd(new TokenOrListParam().addOr(new TokenParam().setValue(INGREDIENT_CODE_UUID)));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.INGREDIENT_SEARCH_HANDLER, ingredientCode);
    IBundleProvider result = search(theParams);
    List<Medication> resultList = get(result);
    assertThat(result, notNullValue());
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
    assertThat(resultList.get(0).getIngredientFirstRep().getItemCodeableConcept().getCodingFirstRep().getCode(), equalTo(INGREDIENT_CODE_UUID));
}
Also used : TokenOrListParam(ca.uhn.fhir.rest.param.TokenOrListParam) TokenParam(ca.uhn.fhir.rest.param.TokenParam) Medication(org.hl7.fhir.r4.model.Medication) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 17 with Medication

use of org.hl7.fhir.r4.model.Medication in project openmrs-module-fhir2 by openmrs.

the class MedicationTranslatorImplTest method toOpenmrsType_shouldNotRetireDrugIfMedicationInActive.

@Test
public void toOpenmrsType_shouldNotRetireDrugIfMedicationInActive() {
    Medication medication = new Medication();
    medication.setStatus(Medication.MedicationStatus.ACTIVE);
    medicationTranslator.toOpenmrsType(drug, medication);
    assertThat(drug, notNullValue());
    assertThat(drug.getRetired(), equalTo(false));
}
Also used : Medication(org.hl7.fhir.r4.model.Medication) Test(org.junit.Test)

Example 18 with Medication

use of org.hl7.fhir.r4.model.Medication in project openmrs-module-fhir2 by openmrs.

the class MedicationTranslatorImplTest method toOpenmrsType_shouldTranslateIdToUuid.

@Test
public void toOpenmrsType_shouldTranslateIdToUuid() {
    Medication medication = new Medication();
    medication.setId(MEDICATION_UUID);
    medicationTranslator.toOpenmrsType(drug, medication);
    assertThat(drug, notNullValue());
    assertThat(drug.getUuid(), notNullValue());
    assertThat(drug.getUuid(), equalTo(MEDICATION_UUID));
}
Also used : Medication(org.hl7.fhir.r4.model.Medication) Test(org.junit.Test)

Example 19 with Medication

use of org.hl7.fhir.r4.model.Medication in project openmrs-module-fhir2 by openmrs.

the class MedicationTranslatorImplTest method toFhirResource_shouldTranslateUuidToId.

@Test
public void toFhirResource_shouldTranslateUuidToId() {
    drug.setUuid(MEDICATION_UUID);
    Medication medication = medicationTranslator.toFhirResource(drug);
    assertThat(medication, notNullValue());
    assertThat(medication.getId(), equalTo(MEDICATION_UUID));
}
Also used : Medication(org.hl7.fhir.r4.model.Medication) Test(org.junit.Test)

Example 20 with Medication

use of org.hl7.fhir.r4.model.Medication in project openmrs-module-fhir2 by openmrs.

the class MedicationTranslatorImplTest method toOpenmrsType_shouldReturnNullWhenCalledWithNullDose.

@Test
public void toOpenmrsType_shouldReturnNullWhenCalledWithNullDose() {
    Medication medication = new Medication();
    drug.setDosageForm(null);
    medicationTranslator.toOpenmrsType(drug, medication);
    assertThat(drug.getDosageForm(), nullValue());
}
Also used : Medication(org.hl7.fhir.r4.model.Medication) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)112 Medication (org.hl7.fhir.r4.model.Medication)62 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)43 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)34 Medication (org.hl7.fhir.dstu3.model.Medication)33 BaseFhirIntegrationTest (org.openmrs.module.fhir2.BaseFhirIntegrationTest)30 TokenAndListParam (ca.uhn.fhir.rest.param.TokenAndListParam)24 TokenParam (ca.uhn.fhir.rest.param.TokenParam)24 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)20 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)20 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)19 MedicationRequest (org.hl7.fhir.r4.model.MedicationRequest)18 InputStream (java.io.InputStream)17 TokenOrListParam (ca.uhn.fhir.rest.param.TokenOrListParam)16 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)14 Coding (org.hl7.fhir.r4.model.Coding)14 Date (java.util.Date)13 ArrayList (java.util.ArrayList)12 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)12 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)11