Search in sources :

Example 11 with PersonAttribute

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"));
}
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 12 with PersonAttribute

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"));
}
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 13 with PersonAttribute

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));
}
Also used : Patient(org.openmrs.Patient) PersonAttribute(org.openmrs.PersonAttribute) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 14 with PersonAttribute

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));
}
Also used : Patient(org.openmrs.Patient) PersonAttribute(org.openmrs.PersonAttribute) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 15 with PersonAttribute

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());
        }
    }
}
Also used : PersonAttribute(org.openmrs.PersonAttribute)

Aggregations

PersonAttribute (org.openmrs.PersonAttribute)20 Test (org.junit.Test)12 Patient (org.openmrs.Patient)9 PersonName (org.openmrs.PersonName)7 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)5 Date (java.util.Date)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 PersonAddress (org.openmrs.PersonAddress)3 PersonAttributeType (org.openmrs.PersonAttributeType)3 PatientAndMatchQuality (org.openmrs.module.registrationcore.api.search.PatientAndMatchQuality)3 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)3 ArrayList (java.util.ArrayList)2 PersonMergeLog (org.openmrs.person.PersonMergeLog)2 DLD (ca.uhn.hl7v2.model.v25.datatype.DLD)1 IS (ca.uhn.hl7v2.model.v25.datatype.IS)1 File (java.io.File)1 URL (java.net.URL)1 Random (java.util.Random)1 Criteria (org.hibernate.Criteria)1 Ignore (org.junit.Ignore)1