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();
}
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));
}
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));
}
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"));
}
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"));
}
Aggregations