PatientMatcher { public boolean hasMatchByDemographics(Patient possibleMatch, Patient searchParams) { PersonName possibleMatchName = getPatientName(possibleMatch); PersonName searchName = getPatientName(searchParams); boolean match = isNameEquals(possibleMatchName, searchName); if (match) { match = isBirthdateEquals(possibleMatch.getDateOfBirth(), searchParams.getDateOfBirth()); } if (match) { match = isGenderEquals(possibleMatch.getGender(), searchParams.getGender()); } if (match && CollectionUtils.isNotEmpty(possibleMatch.getAddresses()) && CollectionUtils.isNotEmpty(searchParams.getAddresses())) { match = isAddressEquals(possibleMatch.getAddresses().get(0), searchParams.getAddresses().get(0)); } if (match && CollectionUtils.isNotEmpty(possibleMatch.getPhoneNumbers()) && CollectionUtils.isNotEmpty(searchParams.getPhoneNumbers())) { match = isPhoneNumberEquals(possibleMatch.getPhoneNumbers().get(0).getPhoneNumber(), searchParams .getPhoneNumbers().get(0).getPhoneNumber()); } if (LOG.isDebugEnabled()) { LOG.debug("hasMatchByDemoagraphics result ==>" + match); LOG.debug("[" + serializePatient(searchParams) + "]==[" + serializePatient(possibleMatch) + "]"); LOG.debug("[" + searchParams.getDateOfBirth() + "]==[" + possibleMatch.getDateOfBirth() + "]"); LOG.debug("[" + searchParams.getGender() + "]==[" + possibleMatch.getGender() + "]"); LOG.debug("[" + serializePatientAddress(searchParams) + "]==[" + serializePatientAddress(possibleMatch) + "]"); if (CollectionUtils.isNotEmpty(searchParams.getPhoneNumbers())) { LOG.debug("[" + searchParams.getPhoneNumbers().get(0).getPhoneNumber() + "]==[" + possibleMatch.getPhoneNumbers().get(0).getPhoneNumber() + "]"); } } return match; } protected  PatientMatcher(); static PatientMatcher getInstance(); boolean hasMatchByIds(Patient possibleMatch, Patient searchParams); boolean isPatientOptedInCriteriaMet(Patient possibleMatch); boolean hasMatchByDemographics(Patient possibleMatch, Patient searchParams);  }
@Test public void testNameEmpty() { PatientMatcher patientMatcher = createPatientMatcher(); Patient patient = createPatient(); Patient searchParams = createPatient(); searchParams.getNames().remove(0); assertFalse(patientMatcher.hasMatchByDemographics(patient, searchParams)); patient.getNames().remove(0); assertFalse(patientMatcher.hasMatchByDemographics(patient, searchParams)); }
@Test public void testHasMatchByDemographics_FirstName() { PatientMatcher patientMatcher = createPatientMatcher(); Patient patient = createPatient(); Patient searchParams = createPatient(); assertTrue(patientMatcher.hasMatchByDemographics(patient, searchParams)); searchParams.getNames().get(0).setFirstName("Bob"); assertFalse(patientMatcher.hasMatchByDemographics(patient, searchParams)); searchParams.getNames().get(0).setFirstName(null); assertFalse(patientMatcher.hasMatchByDemographics(patient, searchParams)); patient.getNames().get(0).setFirstName(null); assertFalse(patientMatcher.hasMatchByDemographics(patient, searchParams)); }
@Test public void testHasMatchByDemographics_LastName() { PatientMatcher patientMatcher = createPatientMatcher(); Patient patient = createPatient(); Patient searchParams = createPatient(); assertTrue(patientMatcher.hasMatchByDemographics(patient, searchParams)); searchParams.getNames().get(0).setLastName("Bob"); assertFalse(patientMatcher.hasMatchByDemographics(patient, searchParams)); searchParams = createPatient(); searchParams.getNames().get(0).setLastName(null); assertFalse(patientMatcher.hasMatchByDemographics(patient, searchParams)); patient.getNames().get(0).setLastName(null); assertFalse(patientMatcher.hasMatchByDemographics(patient, searchParams)); }
@Test public void testHasMatchByDemographics_Gender() { PatientMatcher patientMatcher = createPatientMatcher(); Patient patient = createPatient(); Patient searchParams = createPatient(); assertTrue(patientMatcher.hasMatchByDemographics(patient, searchParams)); searchParams.setGender("F"); assertFalse(patientMatcher.hasMatchByDemographics(patient, searchParams)); searchParams.setGender(null); assertTrue(patientMatcher.hasMatchByDemographics(patient, searchParams)); patient.setGender(null); searchParams = createPatient(); assertFalse(patientMatcher.hasMatchByDemographics(patient, searchParams)); }
@Test public void testHasMatchByDemographics_Birthdate() { PatientMatcher patientMatcher = createPatientMatcher(); Patient patient = createPatient(); Patient searchParams = createPatient(); assertTrue(patientMatcher.hasMatchByDemographics(patient, searchParams)); searchParams.setDateOfBirth("02111950"); assertFalse(patientMatcher.hasMatchByDemographics(patient, searchParams)); searchParams.setDateOfBirth(null); assertTrue(patientMatcher.hasMatchByDemographics(patient, searchParams)); patient.setDateOfBirth(null); searchParams = createPatient(); assertFalse(patientMatcher.hasMatchByDemographics(patient, searchParams)); }
@Test public void testHasMatchByDemographics_TelephoneNumbers() { PatientMatcher patientMatcher = createPatientMatcher(); Patient patient = createPatient(); Patient searchParams = createPatient(); assertTrue(patientMatcher.hasMatchByDemographics(patient, searchParams)); searchParams.getPhoneNumbers().get(0).setPhoneNumber("tel:444-555-5555"); assertFalse(patientMatcher.hasMatchByDemographics(patient, searchParams)); patient.getPhoneNumbers().get(0).setPhoneNumber("555-555-5555"); searchParams.getPhoneNumbers().get(0).setPhoneNumber("555-555-5555"); assertFalse(patientMatcher.hasMatchByDemographics(patient, searchParams)); patient.getPhoneNumbers().get(0).setPhoneNumber(null); searchParams = createPatient(); assertFalse(patientMatcher.hasMatchByDemographics(patient, searchParams)); patient = createPatient(); searchParams.getPhoneNumbers().get(0).setPhoneNumber(null); assertTrue(patientMatcher.hasMatchByDemographics(patient, searchParams)); }
@Test public void testHasMatchByDemographics_Addresses() { PatientMatcher patientMatcher = createPatientMatcher(); Patient patient = createPatient(); addAddressesToPatient(patient, "123 Street", "Dr.", "city", "nowhere", "12345"); Patient searchParams = createPatient(); addAddressesToPatient(searchParams, "123 Street", "Dr.", "city", "nowhere", "12345"); assertTrue(patientMatcher.hasMatchByDemographics(patient, searchParams)); searchParams = createPatient(); addAddressesToPatient(searchParams, "567 Street", "Dr.", "city", "nowhere", "12345"); assertFalse(patientMatcher.hasMatchByDemographics(patient, searchParams)); patient = createPatient(); addAddressesToPatient(patient, "123 Street", null, "city", "nowhere", "12345"); searchParams = createPatient(); addAddressesToPatient(searchParams, "123 Street", "Dr.", "city", "nowhere", "12345"); assertFalse(patientMatcher.hasMatchByDemographics(patient, searchParams)); }