use of org.openmrs.module.registrationcore.api.search.PatientAndMatchQuality in project openmrs-module-pihcore by PIH.
the class PihPatientSearchAlgorithmTest method shouldExcludeVoidedPatients.
@Test
public void shouldExcludeVoidedPatients() {
Patient patientToVoid = patientService.getPatient(13);
patientService.voidPatient(patientToVoid, "test");
Context.flushSession();
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);
assertThat(results.size(), is(0));
}
use of org.openmrs.module.registrationcore.api.search.PatientAndMatchQuality in project openmrs-module-pihcore by PIH.
the class PihPatientSearchAlgorithmTest method exactPersonAttributeFieldMatchShouldIncreaseScore.
@Test
public void exactPersonAttributeFieldMatchShouldIncreaseScore() {
// 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("Birthplace"));
attribute.setValue("boston");
patient.addAttribute(attribute);
results = searchAlgorithm.findSimilarPatients(patient, null, null, 10);
double scoreWithAddress = results.get(0).getScore();
// in our test config we've weighed birthplace at 1 point
assertThat(scoreWithAddress - scoreWithoutAddress, is(1.0));
assertTrue(results.get(0).getMatchedFields().contains("attributes.Birthplace"));
}
use of org.openmrs.module.registrationcore.api.search.PatientAndMatchQuality in project openmrs-module-pihcore by PIH.
the class PihPatientSearchAlgorithmTest method shouldFindNamePhoneticsMatch.
@Test
public void shouldFindNamePhoneticsMatch() {
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);
assertThat(results.size(), is(1));
assertThat(results.get(0).getPatient().getPersonName().getGivenName(), is("Jarus"));
assertThat(results.get(0).getPatient().getPersonName().getFamilyName(), is("Rapondi"));
}
use of org.openmrs.module.registrationcore.api.search.PatientAndMatchQuality 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.module.registrationcore.api.search.PatientAndMatchQuality 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));
}
Aggregations