FhirPatientDemographicsProvider implements PatientDemographicsProvider { @Override public List<PatientDemographicsDto> getPatientsDemographics(@Nonnull final Collection<String> patientsIds) { Preconditions.checkNotNull(patientsIds, "patientsIds must not be null"); if (patientsIds.isEmpty()) { return Collections.emptyList(); } final List<Patient> patients = queryPatients(patientsIds); return patients.stream() .map(this::getPatientDemographicsDto) .collect(Collectors.toList()); }  @Required void setFhirClient(final IGenericClient fhirClient); @Required void setFhirPatientIdSystem(final String fhirPatientIdSystem); @Override List<PatientDemographicsDto> getPatientsDemographics(@Nonnull final Collection<String> patientsIds);  }
@Test public void testGetPatientsDemographicsNoName() { expectedException.expect(SystemException.class); expectedException.expectMessage("FHIR validation failed - No Patient.name.text defined"); final Bundle result = new Bundle(); final Bundle.Entry entry1 = getPatientResultBundleEntry( "patient1", null, new DateTime(2016, 3, 3, 0, 0), AdministrativeGenderEnum.FEMALE); result.addEntry(entry1); mockFhirClientResult(result); patientDemographicsProvider.getPatientsDemographics(Lists.newArrayList("patient1")); }
@Test public void testGetPatientsDemographicsNoIdentifier() { expectedException.expect(SystemException.class); expectedException.expectMessage( "FHIR validation failed - No identifier for Patient with system \"patientIdSystem1\" defined"); final Bundle result = new Bundle(); final Bundle.Entry entry1 = getPatientResultBundleEntry( null, "Patient Name1", new DateTime(2016, 3, 3, 0, 0), AdministrativeGenderEnum.FEMALE); result.addEntry(entry1); mockFhirClientResult(result); patientDemographicsProvider.getPatientsDemographics(Lists.newArrayList("patient1")); }
@Test public void testGetPatientsDemographicsNoBirthDate() { expectedException.expect(SystemException.class); expectedException.expectMessage("No Patient.birthDate defined"); final Bundle result = new Bundle(); final Bundle.Entry entry1 = getPatientResultBundleEntry( "patient1", "Patient Name1", null, AdministrativeGenderEnum.FEMALE); result.addEntry(entry1); mockFhirClientResult(result); patientDemographicsProvider.getPatientsDemographics(Lists.newArrayList("patient1")); }
@Test public void testGetPatientsDemographicsNoGender() { expectedException.expect(SystemException.class); expectedException.expectMessage("No Patient.gender defined"); final Bundle result = new Bundle(); final Bundle.Entry entry1 = getPatientResultBundleEntry( "patientId", "Patient Name1", new DateTime(2016, 3, 3, 0, 0), null); result.addEntry(entry1); mockFhirClientResult(result); patientDemographicsProvider.getPatientsDemographics(Lists.newArrayList("patient1")); }