use of org.hl7.fhir.r4.model.Period in project openmrs-module-fhir2 by openmrs.
the class ServiceRequestTranslatorImplTest method toFhirResource_shouldTranslateOccurrenceFromScheduled.
@Test
public void toFhirResource_shouldTranslateOccurrenceFromScheduled() {
TestOrder testOrder = new TestOrder();
Date fromDate = new Date();
Date toDate = new Date();
testOrder.setUrgency(TestOrder.Urgency.ON_SCHEDULED_DATE);
testOrder.setScheduledDate(fromDate);
testOrder.setAutoExpireDate(toDate);
when(taskService.searchForTasks(any(), any(), any(), any(), any(), any(), any())).thenReturn(new MockIBundleProvider<>(Collections.emptyList(), PREFERRED_PAGE_SIZE, COUNT));
Period result = translator.toFhirResource(testOrder).getOccurrencePeriod();
assertThat(result, notNullValue());
assertThat(result.getStart(), equalTo(fromDate));
assertThat(result.getEnd(), equalTo(toDate));
}
use of org.hl7.fhir.r4.model.Period in project openmrs-module-fhir2 by openmrs.
the class ServiceRequestTranslatorImplTest method toFhirResource_shouldTranslateOccurrence.
@Test
public void toFhirResource_shouldTranslateOccurrence() {
TestOrder testOrder = new TestOrder();
Date fromDate = new Date();
Date toDate = new Date();
testOrder.setDateActivated(fromDate);
testOrder.setAutoExpireDate(toDate);
when(taskService.searchForTasks(any(), any(), any(), any(), any(), any(), any())).thenReturn(new MockIBundleProvider<>(Collections.emptyList(), PREFERRED_PAGE_SIZE, COUNT));
Period result = translator.toFhirResource(testOrder).getOccurrencePeriod();
assertThat(result, notNullValue());
assertThat(result.getStart(), equalTo(fromDate));
assertThat(result.getEnd(), equalTo(toDate));
}
use of org.hl7.fhir.r4.model.Period in project openmrs-module-fhir2 by openmrs.
the class VisitPeriodTranslatorImplTest method toFhirResource_shouldMapPairOfDatesToPeriod.
@Test
public void toFhirResource_shouldMapPairOfDatesToPeriod() {
Visit visit = new Visit();
visit.setStartDatetime(periodStart);
visit.setStopDatetime(periodEnd);
Period result = visitPeriodTranslator.toFhirResource(visit);
assertThat(result, notNullValue());
assertThat(result.getStart(), equalTo(periodStart));
assertThat(result.getEnd(), equalTo(periodEnd));
}
use of org.hl7.fhir.r4.model.Period in project openmrs-module-fhir2 by openmrs.
the class VisitPeriodTranslatorImplTest method toOpenmrsObject_shouldMapPeriodToVisit.
@Test
public void toOpenmrsObject_shouldMapPeriodToVisit() {
Encounter fhirEncounter = new Encounter();
Period period = new Period();
period.setStart(periodStart);
period.setEnd(periodEnd);
fhirEncounter.setPeriod(period);
Visit result = visitPeriodTranslator.toOpenmrsType(new Visit(), period);
assertThat(result, notNullValue());
assertThat(result.getStartDatetime(), equalTo(periodStart));
assertThat(result.getStopDatetime(), equalTo(periodEnd));
}
use of org.hl7.fhir.r4.model.Period in project openmrs-module-fhir2 by openmrs.
the class VisitTranslatorImplTest method toOpenmrsType_shouldConvertPeriodToStartStopDatetime.
@Test
public void toOpenmrsType_shouldConvertPeriodToStartStopDatetime() {
Encounter encounter = new Encounter();
Period period = new Period();
period.setStart(periodStart);
period.setEnd(periodEnd);
encounter.setPeriod(period);
when(visitPeriodTranslator.toOpenmrsType(any(), any())).thenCallRealMethod();
Visit result = visitTranslator.toOpenmrsType(new Visit(), encounter);
assertThat(result, notNullValue());
assertThat(result.getStartDatetime(), equalTo(periodStart));
assertThat(result.getStopDatetime(), equalTo(periodEnd));
}
Aggregations