Search in sources :

Example 41 with Period

use of org.hl7.fhir.r4b.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));
}
Also used : TestOrder(org.openmrs.TestOrder) Period(org.hl7.fhir.r4.model.Period) Date(java.util.Date) Test(org.junit.Test) OrderUtilTest(org.openmrs.order.OrderUtilTest)

Example 42 with Period

use of org.hl7.fhir.r4b.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));
}
Also used : TestOrder(org.openmrs.TestOrder) Period(org.hl7.fhir.r4.model.Period) Date(java.util.Date) Test(org.junit.Test) OrderUtilTest(org.openmrs.order.OrderUtilTest)

Example 43 with Period

use of org.hl7.fhir.r4b.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));
}
Also used : Visit(org.openmrs.Visit) Period(org.hl7.fhir.r4.model.Period) Test(org.junit.Test)

Example 44 with Period

use of org.hl7.fhir.r4b.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));
}
Also used : Visit(org.openmrs.Visit) Encounter(org.hl7.fhir.r4.model.Encounter) Period(org.hl7.fhir.r4.model.Period) Test(org.junit.Test)

Example 45 with Period

use of org.hl7.fhir.r4b.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));
}
Also used : Visit(org.openmrs.Visit) Encounter(org.hl7.fhir.r4.model.Encounter) Period(org.hl7.fhir.r4.model.Period) Test(org.junit.Test)

Aggregations

Period (org.hl7.fhir.r4.model.Period)87 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)44 Date (java.util.Date)42 Test (org.junit.Test)42 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)40 Coding (org.hl7.fhir.r4.model.Coding)34 Test (org.junit.jupiter.api.Test)34 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)32 Period (org.hl7.fhir.dstu3.model.Period)30 ArrayList (java.util.ArrayList)29 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)27 DateTimeType (org.hl7.fhir.r4.model.DateTimeType)20 Encounter (org.hl7.fhir.r4.model.Encounter)20 Reference (org.hl7.fhir.r4.model.Reference)20 Patient (org.hl7.fhir.r4.model.Patient)19 Reference (org.hl7.fhir.dstu3.model.Reference)18 HashMap (java.util.HashMap)17 Identifier (org.hl7.fhir.r4.model.Identifier)17 NotImplementedException (org.apache.commons.lang3.NotImplementedException)15 List (java.util.List)14