use of org.hl7.fhir.r4.model.Provenance in project openmrs-module-fhir2 by openmrs.
the class FhirTaskTranslatorImplTest method toFhirResource_shouldAddProvenanceResources.
@Test
public void toFhirResource_shouldAddProvenanceResources() {
FhirTask task = new FhirTask();
task.setUuid(TASK_UUID);
Provenance provenance = new Provenance();
provenance.setId(new IdType(FhirUtils.newUuid()));
when(provenanceTranslator.getCreateProvenance(task)).thenReturn(provenance);
when(provenanceTranslator.getUpdateProvenance(task)).thenReturn(provenance);
org.hl7.fhir.r4.model.Task result = taskTranslator.toFhirResource(task);
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.r4.model.Provenance in project openmrs-module-fhir2 by openmrs.
the class ConditionTranslatorImplTest method shouldAddProvenanceToConditionResource.
@Test
public void shouldAddProvenanceToConditionResource() {
Provenance provenance = new Provenance();
provenance.setId(new IdType(FhirUtils.newUuid()));
when(provenanceTranslator.getCreateProvenance(openmrsCondition)).thenReturn(provenance);
when(provenanceTranslator.getUpdateProvenance(openmrsCondition)).thenReturn(provenance);
org.hl7.fhir.r4.model.Condition result = conditionTranslator.toFhirResource(openmrsCondition);
List<Resource> resources = result.getContained();
assertThat(resources, Matchers.notNullValue());
assertThat(resources, Matchers.not(empty()));
assertThat(resources.stream().findAny().isPresent(), CoreMatchers.is(true));
assertThat(resources.stream().findAny().get().isResource(), CoreMatchers.is(true));
assertThat(resources.stream().findAny().get().getResourceType().name(), Matchers.equalTo(Provenance.class.getSimpleName()));
}
use of org.hl7.fhir.r4.model.Provenance 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));
}
use of org.hl7.fhir.r4.model.Provenance 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.r4.model.Provenance 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));
}
Aggregations