Search in sources :

Example 1 with PersonName

use of org.openmrs.PersonName in project openmrs-module-pihcore by PIH.

the class BaseReportTest method createPatient.

protected Patient createPatient() {
    PatientBuilder pb = data.patient();
    pb.name(new PersonName("John", "Smitty", "Smith"));
    pb.birthdate("1977-11-23").birthdateEstimated(false);
    pb.male();
    pb.identifier(Metadata.lookup(PihHaitiPatientIdentifierTypes.ZL_EMR_ID), "X3XK71", Metadata.lookup(MirebalaisLocations.MIREBALAIS_CDI_PARENT));
    return pb.save();
}
Also used : PatientBuilder(org.openmrs.contrib.testdata.builder.PatientBuilder) PersonName(org.openmrs.PersonName)

Example 2 with PersonName

use of org.openmrs.PersonName in project openmrs-module-pihcore by PIH.

the class PersonAuditInfoCohortDefinitionEvaluatorTest method testEvaluateByVoidedDetails.

@Test
public void testEvaluateByVoidedDetails() throws Exception {
    Date today = DateUtil.getStartOfDay(new Date());
    // in standardTestDataset.xml patient 999 is voided, but has no dateVoided. Fix this
    Patient voidedPatient = patientService.getPatient(999);
    voidedPatient.addName(new PersonName("A", "Non-voided", "Name"));
    patientService.voidPatient(voidedPatient, "testing");
    PersonAuditInfoCohortDefinition cd = new PersonAuditInfoCohortDefinition();
    cd.setIncludeVoided(true);
    cd.setVoidedOnOrAfter(today);
    cd.setVoidedOnOrBefore(today);
    EvaluatedCohort actual = evaluator.evaluate((CohortDefinition) cd, new EvaluationContext());
    assertThat(actual, hasExactlyIds(999));
}
Also used : PersonName(org.openmrs.PersonName) Patient(org.openmrs.Patient) EvaluatedCohort(org.openmrs.module.reporting.cohort.EvaluatedCohort) PersonAuditInfoCohortDefinition(org.openmrs.module.pihcore.reporting.cohort.definition.PersonAuditInfoCohortDefinition) EvaluationContext(org.openmrs.module.reporting.evaluation.EvaluationContext) Date(java.util.Date) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 3 with PersonName

use of org.openmrs.PersonName 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 4 with PersonName

use of org.openmrs.PersonName 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 5 with PersonName

use of org.openmrs.PersonName 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)

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