use of org.hl7.fhir.r4.model.Medication in project elexis-server by elexis.
the class MedicationTest method loadArticleMedicationById.
@Test
public void loadArticleMedicationById() {
Medication customArticle = client.read().resource(Medication.class).withId(ArticleTyp.EIGENARTIKEL + "." + AllTests.getTestDatabaseInitializer().getArticle().getId()).execute();
assertNotNull(customArticle);
System.out.println(FhirUtil.serializeToString(customArticle));
Map<String, Coding> codeMap = parseCodeMap(customArticle);
assertEquals("test article", codeMap.get(MedicamentCoding.NAME.getUrl()).getCode());
assertEquals("0000001111111", codeMap.get(MedicamentCoding.GTIN.getOid()).getCode());
}
use of org.hl7.fhir.r4.model.Medication in project openmrs-module-fhir2 by openmrs.
the class MedicationFhirResourceProviderTest method searchForMedication_shouldReturnMatchingBundleOfMedicationByLastUpdated.
@Test
public void searchForMedication_shouldReturnMatchingBundleOfMedicationByLastUpdated() {
DateRangeParam lastUpdated = new DateRangeParam().setLowerBound(LAST_UPDATED_DATE).setUpperBound(LAST_UPDATED_DATE);
when(fhirMedicationService.searchForMedications(isNull(), isNull(), isNull(), isNull(), argThat(is(lastUpdated)), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(medication), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchForMedication(null, null, null, null, lastUpdated, null);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
assertThat(resultList.iterator().next().fhirType(), equalTo(FhirConstants.MEDICATION));
}
use of org.hl7.fhir.r4.model.Medication in project openmrs-module-fhir2 by openmrs.
the class MedicationFhirResourceProviderTest method updateMedication_shouldThrowMethodNotAllowedIfDoesNotExist.
@Test(expected = MethodNotAllowedException.class)
public void updateMedication_shouldThrowMethodNotAllowedIfDoesNotExist() {
Medication wrongMedication = new Medication();
wrongMedication.setId(WRONG_MEDICATION_UUID);
when(fhirMedicationService.update(WRONG_MEDICATION_UUID, wrongMedication)).thenThrow(MethodNotAllowedException.class);
resourceProvider.updateMedication(new IdType().setValue(WRONG_MEDICATION_UUID), wrongMedication);
}
use of org.hl7.fhir.r4.model.Medication in project openmrs-module-fhir2 by openmrs.
the class MedicationFhirResourceProviderTest method getMedicationByUuid_shouldReturnMatchingMedication.
@Test
public void getMedicationByUuid_shouldReturnMatchingMedication() {
when(fhirMedicationService.get(MEDICATION_UUID)).thenReturn(medication);
IdType id = new IdType();
id.setValue(MEDICATION_UUID);
Medication medication = resourceProvider.getMedicationByUuid(id);
assertThat(medication, notNullValue());
assertThat(medication.getId(), notNullValue());
assertThat(medication.getId(), equalTo(MEDICATION_UUID));
}
use of org.hl7.fhir.r4.model.Medication in project openmrs-module-fhir2 by openmrs.
the class MedicationFhirResourceProviderTest method searchForMedication_shouldReturnMatchingBundleOfMedicationByIngredientCode.
@Test
public void searchForMedication_shouldReturnMatchingBundleOfMedicationByIngredientCode() {
TokenAndListParam ingredientCode = new TokenAndListParam();
ingredientCode.addAnd(new TokenOrListParam().addOr(new TokenParam().setValue(CODE)));
when(fhirMedicationService.searchForMedications(isNull(), isNull(), argThat(is(ingredientCode)), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(medication), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchForMedication(null, null, ingredientCode, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
assertThat(resultList.iterator().next().fhirType(), equalTo(FhirConstants.MEDICATION));
}
Aggregations