Search in sources :

Example 61 with PersonName

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"));
}
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 62 with PersonName

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));
}
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 63 with PersonName

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"));
}
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 64 with PersonName

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"));
}
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 65 with PersonName

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();
}
Also used : PatientBuilder(org.openmrs.contrib.testdata.builder.PatientBuilder) PersonName(org.openmrs.PersonName)

Aggregations

PersonName (org.openmrs.PersonName)108 Test (org.junit.Test)81 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)57 Patient (org.openmrs.Patient)41 Person (org.openmrs.Person)39 Date (java.util.Date)26 PatientIdentifier (org.openmrs.PatientIdentifier)19 PersonAddress (org.openmrs.PersonAddress)19 User (org.openmrs.User)17 PatientServiceImplTest (org.openmrs.api.impl.PatientServiceImplTest)17 PatientIdentifierType (org.openmrs.PatientIdentifierType)13 Location (org.openmrs.Location)12 ArrayList (java.util.ArrayList)9 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)9 PersonMergeLog (org.openmrs.person.PersonMergeLog)8 PersonAttribute (org.openmrs.PersonAttribute)7 PatientAndMatchQuality (org.openmrs.module.registrationcore.api.search.PatientAndMatchQuality)7 BindException (org.springframework.validation.BindException)7 Errors (org.springframework.validation.Errors)6 Provider (org.openmrs.Provider)5