use of org.openmrs.Patient in project openmrs-module-pihcore by PIH.
the class VitalsDataSetManagerTest method setup.
@Before
@Override
public void setup() throws Exception {
super.setup();
Patient p = createPatient("X3XK71");
Encounter e = createVitalsEncounter(p);
visit = createVisit(e);
}
use of org.openmrs.Patient 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.Patient 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.Patient 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"));
}
use of org.openmrs.Patient in project openmrs-module-pihcore by PIH.
the class PihCloseStaleVisitsTaskTest method test_shouldNotCloseVisitIfMostRecentDispositionKeepsVisitOpen.
@Test
public void test_shouldNotCloseVisitIfMostRecentDispositionKeepsVisitOpen() throws Exception {
ContextSensitiveMetadataTestUtils.setupDispositionDescriptor(conceptService, dispositionService);
ContextSensitiveMetadataTestUtils.setupAdmissionDecisionConcept(conceptService, emrApiProperties);
ContextSensitiveMetadataTestUtils.setupSupportsVisitLocationTag(locationService);
// patient already has one visit in test dataset
Patient patient = patientService.getPatient(7);
// need o tag the unknown location so we don't run into an error when testing against the existing visits in the test dataset
Location unknownLocation = locationService.getLocation(1);
unknownLocation.addTag(emrApiProperties.getSupportsVisitsLocationTag());
locationService.saveLocation(unknownLocation);
Location location = locationService.getLocation(2);
location.addTag(emrApiProperties.getSupportsVisitsLocationTag());
locationService.saveLocation(location);
Visit visit = new Visit();
visit.setStartDatetime(DateUtils.addHours(new Date(), -14));
visit.setPatient(patient);
visit.setLocation(location);
visit.setVisitType(emrApiProperties.getAtFacilityVisitType());
// create an encounter with a disposition obs
Encounter encounter = new Encounter();
encounter.setPatient(patient);
encounter.setEncounterType(encounterService.getEncounterType(1));
encounter.setEncounterDatetime(visit.getStartDatetime());
Obs dispositionObsGroup = new Obs();
dispositionObsGroup.setConcept(dispositionService.getDispositionDescriptor().getDispositionSetConcept());
Obs dispositionObs = new Obs();
dispositionObs.setConcept(dispositionService.getDispositionDescriptor().getDispositionConcept());
// this fake code is set in ContextSensitiveMetadataTestUtils
dispositionObs.setValueCoded(emrConceptService.getConcept(EmrApiConstants.EMR_CONCEPT_SOURCE_NAME + ":Admit to hospital"));
dispositionObsGroup.addGroupMember(dispositionObs);
encounter.addObs(dispositionObsGroup);
encounterService.saveEncounter(encounter);
visit.addEncounter(encounter);
visitService.saveVisit(visit);
VisitDomainWrapper activeVisit = adtService.getActiveVisit(patient, location);
// sanity check
assertNotNull(activeVisit);
new PihCloseStaleVisitsTask().execute();
activeVisit = adtService.getActiveVisit(patient, location);
assertNotNull(activeVisit);
}
Aggregations