use of org.hl7.fhir.r5.model.IdType in project openmrs-module-fhir2 by openmrs.
the class LocationFhirResourceProviderTest method getLocationHistoryById_shouldReturnListOfResource.
@Test
public void getLocationHistoryById_shouldReturnListOfResource() {
IdType id = new IdType();
id.setValue(LOCATION_UUID);
when(locationService.get(LOCATION_UUID)).thenReturn(location);
List<Resource> resources = resourceProvider.getLocationHistoryById(id);
assertThat(resources, notNullValue());
assertThat(resources, not(empty()));
assertThat(resources.size(), equalTo(2));
}
use of org.hl7.fhir.r5.model.IdType 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.r5.model.IdType 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.r5.model.IdType in project openmrs-module-fhir2 by openmrs.
the class MedicationFhirResourceProviderTest method updateMedication_shouldUpdateRequestedMedication.
@Test
public void updateMedication_shouldUpdateRequestedMedication() {
Medication med = medication;
med.setStatus(Medication.MedicationStatus.INACTIVE);
when(fhirMedicationService.update(MEDICATION_UUID, medication)).thenReturn(med);
MethodOutcome result = resourceProvider.updateMedication(new IdType().setValue(MEDICATION_UUID), medication);
assertThat(result, notNullValue());
assertThat(result.getResource(), equalTo(med));
}
use of org.hl7.fhir.r5.model.IdType in project openmrs-module-fhir2 by openmrs.
the class ObservationTranslatorImplTest method shouldAddProvenanceResources.
@Test
public void shouldAddProvenanceResources() {
Obs obs = new Obs();
obs.setUuid(OBS_UUID);
Provenance provenance = new Provenance();
provenance.setId(new IdType(FhirUtils.newUuid()));
when(provenanceTranslator.getCreateProvenance(obs)).thenReturn(provenance);
when(provenanceTranslator.getUpdateProvenance(obs)).thenReturn(provenance);
org.hl7.fhir.r4.model.Observation result = observationTranslator.toFhirResource(obs);
assertThat(result, notNullValue());
assertThat(result.getContained(), not(empty()));
assertThat(result.getContained().size(), greaterThanOrEqualTo(2));
assertThat(result.getContained().stream().anyMatch(resource -> resource.getResourceType().name().equals(Provenance.class.getSimpleName())), is(true));
}
Aggregations