@Test
public void testGetPatientsActiveEncounters()
{

  final Bundle result = new Bundle();
  final Bundle.Entry entry1 = getEncounterResultBundleEntry(
      "encounter1",
      "patient1",
      EncounterClassEnum.OUTPATIENT,
      EncounterStateEnum.FINISHED,
      new DateTime(2016, 10, 1, 12, 0),
      new DateTime(2016, 10, 2, 13, 0),
      "ward1",
      "Test Ward",
      "Test Location",
      "Test Doctor");
  result.addEntry(entry1);
  final Bundle.Entry entry2 = getEncounterResultBundleEntry(
      "encounter2",
      "patient2",
      EncounterClassEnum.INPATIENT,
      EncounterStateEnum.ON_LEAVE,
      new DateTime(2016, 10, 1, 12, 0),
      null,
      null,
      null,
      null,
      null);
  result.addEntry(entry2);
  final Bundle.Entry entry3 = getEncounterResultBundleEntry(
      "encounter3",
      "patient2",
      EncounterClassEnum.INPATIENT,
      EncounterStateEnum.FINISHED,
      new DateTime(2016, 9, 9, 9, 0),
      null,
      null,
      null,
      null,
      null);
  result.addEntry(entry3);
  mockFhirClientResult(result);
  final List<EncounterDto> encounterDtos =
      fhirEncounterProvider.getPatientsActiveEncounters(Lists.newArrayList("patient1", "patient2"));
  final EncounterDto encounterDto1 = encounterDtos.get(0);
  assertEquals("encounter1", encounterDto1.getId());
  assertEquals(EncounterType.OUTPATIENT, encounterDto1.getType());
  assertEquals(EncounterStatus.FINISHED, encounterDto1.getStatus());
  assertEquals("Test Doctor", encounterDto1.getDoctor());
  assertEquals("Test Location", encounterDto1.getLocation());
  assertEquals("ward1", encounterDto1.getWard().getId());
  assertEquals("Test Ward", encounterDto1.getWard().getName());
  assertEquals(new DateTime(2016, 10, 1, 12, 0), encounterDto1.getStart());
  assertEquals(new DateTime(2016, 10, 2, 13, 0), encounterDto1.getEnd());
  final EncounterDto encounterDto2 = encounterDtos.get(1);
  assertEquals("encounter2", encounterDto2.getId());
  assertEquals(EncounterType.INPATIENT, encounterDto2.getType());
  assertEquals(EncounterStatus.ON_LEAVE, encounterDto2.getStatus());
  assertNull(encounterDto2.getDoctor());
  assertNull(encounterDto2.getLocation());
  assertNull(encounterDto2.getWard());
  assertEquals(new DateTime(2016, 10, 1, 12, 0), encounterDto2.getStart());
  assertNull(encounterDto2.getEnd());
}