Search in sources :

Example 1 with PatientAndMatchQuality

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));
}
Also used : PersonName(org.openmrs.PersonName) PatientAndMatchQuality(org.openmrs.module.registrationcore.api.search.PatientAndMatchQuality) Patient(org.openmrs.Patient) Date(java.util.Date) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 2 with PatientAndMatchQuality

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"));
}
Also used : PersonName(org.openmrs.PersonName) PatientAndMatchQuality(org.openmrs.module.registrationcore.api.search.PatientAndMatchQuality) Patient(org.openmrs.Patient) Date(java.util.Date) PersonAttribute(org.openmrs.PersonAttribute) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 3 with PatientAndMatchQuality

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"));
}
Also used : PersonName(org.openmrs.PersonName) PatientAndMatchQuality(org.openmrs.module.registrationcore.api.search.PatientAndMatchQuality) Patient(org.openmrs.Patient) Date(java.util.Date) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 4 with PatientAndMatchQuality

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"));
}
Also used : PersonName(org.openmrs.PersonName) PersonAddress(org.openmrs.PersonAddress) PatientAndMatchQuality(org.openmrs.module.registrationcore.api.search.PatientAndMatchQuality) Patient(org.openmrs.Patient) Date(java.util.Date) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 5 with PatientAndMatchQuality

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));
}
Also used : PersonName(org.openmrs.PersonName) PatientAndMatchQuality(org.openmrs.module.registrationcore.api.search.PatientAndMatchQuality) Patient(org.openmrs.Patient) Date(java.util.Date) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Aggregations

Patient (org.openmrs.Patient)9 PatientAndMatchQuality (org.openmrs.module.registrationcore.api.search.PatientAndMatchQuality)9 Test (org.junit.Test)8 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)8 Date (java.util.Date)7 PersonName (org.openmrs.PersonName)7 PersonAttribute (org.openmrs.PersonAttribute)3 PersonAddress (org.openmrs.PersonAddress)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 DateTime (org.joda.time.DateTime)1