use of org.openmrs.PersonAttribute in project openmrs-module-pihcore by PIH.
the class PihPatientSearchAlgorithmTest method shouldMatchPhoneNumberOnNumericsOnly.
@Test
public void shouldMatchPhoneNumberOnNumericsOnly() {
// first get the base score for this patient
Patient patient = new Patient();
PersonName name = new PersonName();
patient.addName(name);
name.setGivenName("Jarusz");
name.setFamilyName("Rapondee");
patient.setBirthdate(new Date());
patient.setGender("M");
List<PatientAndMatchQuality> results = searchAlgorithm.findSimilarPatients(patient, null, null, 10);
double scoreWithoutAddress = results.get(0).getScore();
// now add in address and recalculate
PersonAttribute attribute = new PersonAttribute();
attribute.setAttributeType(personService.getPersonAttributeTypeByName(HaitiPersonAttributeTypes.TELEPHONE_NUMBER.name()));
attribute.setValue("6178675309");
patient.addAttribute(attribute);
results = searchAlgorithm.findSimilarPatients(patient, null, null, 10);
double scoreWithAddress = results.get(0).getScore();
// in our test config we've weighed telephone at 3 points
assertThat(scoreWithAddress - scoreWithoutAddress, is(3.0));
assertTrue(results.get(0).getMatchedFields().contains("attributes.Telephone Number"));
}
use of org.openmrs.PersonAttribute in project openmrs-module-pihcore by PIH.
the class PihPatientSearchAlgorithmTest method shouldMatchMothersNameViaPhonetics.
@Test
public void shouldMatchMothersNameViaPhonetics() {
// first get the base score for this patient
Patient patient = new Patient();
PersonName name = new PersonName();
patient.addName(name);
name.setGivenName("Jarusz");
name.setFamilyName("Rapondee");
patient.setBirthdate(new Date());
patient.setGender("M");
List<PatientAndMatchQuality> results = searchAlgorithm.findSimilarPatients(patient, null, null, 10);
double scoreWithoutAddress = results.get(0).getScore();
// now add in address and recalculate
PersonAttribute attribute = new PersonAttribute();
attribute.setAttributeType(personService.getPersonAttributeTypeByName(HaitiPersonAttributeTypes.MOTHERS_FIRST_NAME.name()));
attribute.setValue("Mary");
patient.addAttribute(attribute);
results = searchAlgorithm.findSimilarPatients(patient, null, null, 10);
double scoreWithAddress = results.get(0).getScore();
// in our test config we've weighed mother's first name at 5 points
assertThat(scoreWithAddress - scoreWithoutAddress, is(5.0));
assertTrue(results.get(0).getMatchedFields().contains("attributes.First Name of Mother"));
}
use of org.openmrs.PersonAttribute in project openmrs-module-pihcore by PIH.
the class PihPatientMergeActionsTest method shouldRemoveNonPreferredPhoneNumberAndMothersNameIfPresentOnPreferredPatient.
@Test
public void shouldRemoveNonPreferredPhoneNumberAndMothersNameIfPresentOnPreferredPatient() {
Patient preferred = new Patient();
Patient nonPreferred = new Patient();
PersonAttribute preferredPhoneNumber = new PersonAttribute(phoneNumber, "preferred");
PersonAttribute preferredMothersName = new PersonAttribute(mothersName, "preferred");
preferred.addAttribute(preferredPhoneNumber);
preferred.addAttribute(preferredMothersName);
PersonAttribute nonPreferredPhoneNumber = new PersonAttribute(phoneNumber, "non-preferred");
PersonAttribute nonPreferredMothersName = new PersonAttribute(mothersName, "non-preferred");
nonPreferred.addAttribute(nonPreferredPhoneNumber);
nonPreferred.addAttribute(nonPreferredMothersName);
// sanity check
assertThat(preferred.getActiveAttributes().size(), is(2));
assertThat(nonPreferred.getActiveAttributes().size(), is(2));
pihPatientMergeActions.beforeMergingPatients(preferred, nonPreferred);
assertThat(preferred.getActiveAttributes().size(), is(2));
assertThat(nonPreferred.getActiveIdentifiers().size(), is(0));
}
use of org.openmrs.PersonAttribute in project openmrs-module-pihcore by PIH.
the class PihPatientMergeActionsTest method shouldNotFailIfNonPreferredPatientDoesNotHaveAttributes.
@Test
public void shouldNotFailIfNonPreferredPatientDoesNotHaveAttributes() {
Patient preferred = new Patient();
Patient nonPreferred = new Patient();
PersonAttribute preferredPhoneNumber = new PersonAttribute(phoneNumber, "preferred");
PersonAttribute preferredMothersName = new PersonAttribute(mothersName, "preferred");
preferred.addAttribute(preferredPhoneNumber);
preferred.addAttribute(preferredMothersName);
pihPatientMergeActions.beforeMergingPatients(preferred, nonPreferred);
assertThat(preferred.getAttributes().size(), is(2));
assertThat(nonPreferred.getAttributes().size(), is(0));
}
use of org.openmrs.PersonAttribute in project openmrs-core by openmrs.
the class PatientServiceImpl method mergePersonAttributes.
private void mergePersonAttributes(Patient preferred, Patient notPreferred, PersonMergeLogData mergedData) {
// copy person attributes
for (PersonAttribute attr : notPreferred.getAttributes()) {
if (!attr.getVoided()) {
PersonAttribute tmpAttr = attr.copy();
tmpAttr.setPerson(null);
tmpAttr.setUuid(UUID.randomUUID().toString());
preferred.addAttribute(tmpAttr);
mergedData.addCreatedAttribute(tmpAttr.getUuid());
}
}
}
Aggregations