use of org.hl7.fhir.r4.model.Medication in project openmrs-module-fhir2 by openmrs.
the class MedicationFhirResourceProviderTest method searchForMedication_shouldReturnMatchingBundleOfMedicationByDosageForm.
@Test
public void searchForMedication_shouldReturnMatchingBundleOfMedicationByDosageForm() {
TokenAndListParam dosageFormCode = new TokenAndListParam();
dosageFormCode.addAnd(new TokenOrListParam().addOr(new TokenParam().setValue(CODE)));
when(fhirMedicationService.searchForMedications(isNull(), argThat(is(dosageFormCode)), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(medication), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchForMedication(null, dosageFormCode, null, null, null, null);
List<Medication> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
assertThat(resultList.get(0).fhirType(), equalTo(FhirConstants.MEDICATION));
}
use of org.hl7.fhir.r4.model.Medication in project openmrs-module-fhir2 by openmrs.
the class MedicationFhirResourceProviderTest method getMedicationByUuid_shouldThrowResourceNotFoundException.
@Test(expected = ResourceNotFoundException.class)
public void getMedicationByUuid_shouldThrowResourceNotFoundException() {
IdType id = new IdType();
id.setValue(WRONG_MEDICATION_UUID);
Medication medication = resourceProvider.getMedicationById(id);
assertThat(medication, nullValue());
}
use of org.hl7.fhir.r4.model.Medication in project openmrs-module-fhir2 by openmrs.
the class MedicationFhirResourceProviderTest method createMedication_shouldCreateNewMedication.
@Test
public void createMedication_shouldCreateNewMedication() {
when(fhirMedicationService.create(any(org.hl7.fhir.r4.model.Medication.class))).thenReturn(medication);
MethodOutcome result = resourceProvider.createMedication(Medication30_40.convertMedication(medication));
assertThat(result, notNullValue());
assertThat(result.getCreated(), is(true));
assertThat(result.getResource(), notNullValue());
assertThat(result.getResource().getIdElement().getIdPart(), equalTo(medication.getId()));
}
use of org.hl7.fhir.r4.model.Medication in project openmrs-module-fhir2 by openmrs.
the class MedicationFhirResourceProviderTest method searchForMedication_shouldReturnMatchingBundleOfMedicationByCode.
@Test
public void searchForMedication_shouldReturnMatchingBundleOfMedicationByCode() {
TokenAndListParam code = new TokenAndListParam();
code.addAnd(new TokenOrListParam().addOr(new TokenParam().setValue(CODE)));
when(fhirMedicationService.searchForMedications(argThat(is(code)), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(medication), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchForMedication(code, null, null, null, null, null);
List<Medication> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
assertThat(resultList.get(0).fhirType(), equalTo(FhirConstants.MEDICATION));
}
use of org.hl7.fhir.r4.model.Medication in project openmrs-module-fhir2 by openmrs.
the class MedicationFhirResourceProviderTest method searchForMedication_shouldReturnMatchingBundleOfMedicationByUUID.
@Test
public void searchForMedication_shouldReturnMatchingBundleOfMedicationByUUID() {
TokenAndListParam uuid = new TokenAndListParam();
uuid.addAnd(new TokenParam().setValue(MEDICATION_UUID));
when(fhirMedicationService.searchForMedications(isNull(), isNull(), isNull(), argThat(is(uuid)), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(medication), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchForMedication(null, null, null, uuid, null, null);
List<Medication> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
assertThat(resultList.get(0).fhirType(), equalTo(FhirConstants.MEDICATION));
}
Aggregations