use of org.openmrs.PersonName in project openmrs-module-pihcore by PIH.
the class PihPatientSearchAlgorithmTest method exactAddressFieldMatchShouldIncreaseScore.
@Test
public void exactAddressFieldMatchShouldIncreaseScore() {
// 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
PersonAddress address = new PersonAddress();
address.setCityVillage("shiseso");
patient.addAddress(address);
results = searchAlgorithm.findSimilarPatients(patient, null, null, 10);
double scoreWithAddress = results.get(0).getScore();
// in our test config we've weighed cityVillage at 1 point
assertThat(scoreWithAddress - scoreWithoutAddress, is(1.0));
assertTrue(results.get(0).getMatchedFields().contains("addresses.cityVillage"));
}
use of org.openmrs.PersonName in project openmrs-module-pihcore by PIH.
the class PihPatientSearchAlgorithmTest method shouldDisregardAccentMarksWhenMakingMatch.
@Test
public void shouldDisregardAccentMarksWhenMakingMatch() {
Patient patient = new Patient();
PersonName name = new PersonName();
patient.addName(name);
// this is an exact name match against the database
name.setGivenName("Jarus");
name.setFamilyName("Rapondi");
patient.setBirthdate(new Date());
patient.setGender("M");
List<PatientAndMatchQuality> results = searchAlgorithm.findSimilarPatients(patient, null, null, 10);
double score = results.get(0).getScore();
// now we add some accent marks
name.setGivenName("Járùs");
name.setFamilyName("Rápóndi");
// if we do a search again, the score should be the same, assuming the accent marks were ignored
results = searchAlgorithm.findSimilarPatients(patient, null, null, 10);
assertThat(results.get(0).getScore(), is(score));
}
use of org.openmrs.PersonName 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.PersonName 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.PersonName in project openmrs-module-pihcore by PIH.
the class BaseReportTest method createPatient.
protected Patient createPatient(String identifier) {
PatientBuilder pb = data.patient();
pb.name(new PersonName("John", "Smitty", "Smith"));
pb.birthdate("1977-11-23").birthdateEstimated(false);
pb.male();
pb.personAttribute(Metadata.lookup(HaitiPersonAttributeTypes.TELEPHONE_NUMBER), "555-1234");
pb.personAttribute(Metadata.lookup(HaitiPersonAttributeTypes.UNKNOWN_PATIENT), "false");
pb.personAttribute(Metadata.lookup(HaitiPersonAttributeTypes.MOTHERS_FIRST_NAME), "Isabel");
address(pb, haitiAddressBundle.getAddressComponents(), "USA", "MA", "Boston", "JP", "Pondside", "");
pb.identifier(Metadata.lookup(PihHaitiPatientIdentifierTypes.ZL_EMR_ID), identifier, Metadata.lookup(MirebalaisLocations.MIREBALAIS_CDI_PARENT));
pb.identifier(Metadata.lookup(HaitiPatientIdentifierTypes.BIOMETRIC_REF_NUMBER), UUID.randomUUID().toString(), Metadata.lookup(MirebalaisLocations.MIREBALAIS_CDI_PARENT));
return pb.save();
}
Aggregations