use of org.hl7.fhir.dstu2.model.IdType in project openmrs-module-fhir2 by openmrs.
the class PatientTranslatorImplTest method shouldNotAddUpdateProvenanceIfDateChangedAndChangedByAreBothNull.
@Test
public void shouldNotAddUpdateProvenanceIfDateChangedAndChangedByAreBothNull() {
Provenance provenance = new Provenance();
provenance.setId(new IdType(FhirUtils.newUuid()));
org.openmrs.Patient patient = new org.openmrs.Patient();
patient.setUuid(PATIENT_UUID);
patient.setDateChanged(null);
patient.setChangedBy(null);
when(provenanceTranslator.getCreateProvenance(patient)).thenReturn(provenance);
when(provenanceTranslator.getUpdateProvenance(patient)).thenReturn(null);
org.hl7.fhir.r4.model.Patient result = patientTranslator.toFhirResource(patient);
assertThat(result, notNullValue());
assertThat(result.getContained(), not(empty()));
assertThat(result.getContained().size(), equalTo(1));
assertThat(result.getContained().stream().anyMatch(resource -> resource.getResourceType().name().equals(Provenance.class.getSimpleName())), is(true));
}
use of org.hl7.fhir.dstu2.model.IdType in project openmrs-module-fhir2 by openmrs.
the class PatientTranslatorImplTest method shouldAddProvenanceResources.
@Test
public void shouldAddProvenanceResources() {
org.openmrs.Patient patient = new org.openmrs.Patient();
patient.setUuid(PATIENT_UUID);
Provenance provenance = new Provenance();
provenance.setId(new IdType(FhirUtils.newUuid()));
when(provenanceTranslator.getCreateProvenance(patient)).thenReturn(provenance);
when(provenanceTranslator.getUpdateProvenance(patient)).thenReturn(provenance);
org.hl7.fhir.r4.model.Patient result = patientTranslator.toFhirResource(patient);
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));
}
use of org.hl7.fhir.dstu2.model.IdType in project openmrs-module-fhir2 by openmrs.
the class AllergyIntoleranceFhirR3ResourceProviderTest method getAllergyIntoleranceByUuid_shouldReturnMatchingAllergy.
@Test
public void getAllergyIntoleranceByUuid_shouldReturnMatchingAllergy() {
when(service.get(ALLERGY_UUID)).thenReturn(allergyIntolerance);
IdType id = new IdType();
id.setValue(ALLERGY_UUID);
AllergyIntolerance allergy = resourceProvider.getAllergyIntoleranceById(id);
assertThat(allergy, notNullValue());
assertThat(allergy.getId(), notNullValue());
assertThat(allergy.getId(), equalTo(ALLERGY_UUID));
}
use of org.hl7.fhir.dstu2.model.IdType in project openmrs-module-fhir2 by openmrs.
the class AllergyIntoleranceFhirR3ResourceProviderTest method getAllergyIntoleranceHistory_shouldReturnProvenanceResources.
@Test
public void getAllergyIntoleranceHistory_shouldReturnProvenanceResources() {
IdType id = new IdType();
id.setValue(ALLERGY_UUID);
when(service.get(ALLERGY_UUID)).thenReturn(allergyIntolerance);
List<Resource> resources = resourceProvider.getAllergyIntoleranceHistoryById(id);
assertThat(resources, not(empty()));
assertThat(resources.stream().findAny().isPresent(), is(true));
assertThat(resources.stream().findAny().get().getResourceType().name(), equalTo(Provenance.class.getSimpleName()));
}
use of org.hl7.fhir.dstu2.model.IdType in project openmrs-module-fhir2 by openmrs.
the class AllergyIntoleranceFhirR3ResourceProviderTest method updateAllergyIntolerance_shouldUpdateAllergyIntolerance.
@Test
public void updateAllergyIntolerance_shouldUpdateAllergyIntolerance() {
when(service.update(eq(ALLERGY_UUID), any(org.hl7.fhir.r4.model.AllergyIntolerance.class))).thenReturn(allergyIntolerance);
MethodOutcome result = resourceProvider.updateAllergyIntolerance(new IdType().setValue(ALLERGY_UUID), AllergyIntolerance30_40.convertAllergyIntolerance(allergyIntolerance));
assertThat(result, notNullValue());
assertThat(result.getResource(), notNullValue());
assertThat(result.getResource().getIdElement().getIdPart(), equalTo(ALLERGY_UUID));
}
Aggregations