use of org.openmrs.module.emrapi.visit.VisitDomainWrapper in project openmrs-module-pihcore by PIH.
the class RequireUtilTest method shouldReturnTrueIfVisitActive.
@Test
public void shouldReturnTrueIfVisitActive() {
VisitDomainWrapper visit = mock(VisitDomainWrapper.class);
when(visit.isActive()).thenReturn(true);
AppContextModel appContextModel = uiSessionContext.generateAppContextModel();
appContextModel.put("visit", visit);
assertThat(appFrameworkService.checkRequireExpression(extensionRequiring(patientHasActiveVisit()), appContextModel), is(true));
}
use of org.openmrs.module.emrapi.visit.VisitDomainWrapper in project openmrs-module-pihcore by PIH.
the class PihCloseStaleVisitsTaskTest method test_shouldKeepVisitOpenIfItHasEDTriageAndEncounterWithinFortyEightHours.
@Test
public void test_shouldKeepVisitOpenIfItHasEDTriageAndEncounterWithinFortyEightHours() 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 to 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();
// because recently-created visits won't be closed
visit.setDateCreated(DateUtils.addHours(new Date(), -30));
visit.setStartDatetime(DateUtils.addHours(new Date(), -60));
visit.setPatient(patient);
visit.setLocation(location);
visit.setVisitType(emrApiProperties.getAtFacilityVisitType());
// create ED Triage encounterdmit to hospital
Encounter edTriage = new Encounter();
edTriage.setPatient(patient);
edTriage.setEncounterType(encounterService.getEncounterTypeByUuid(ED_TRIAGE_ENCOUNTER_TYPE_UUID));
edTriage.setEncounterDatetime(visit.getStartDatetime());
encounterService.saveEncounter(edTriage);
// create a another encounter within 48 hours
Encounter consult = new Encounter();
consult.setPatient(patient);
consult.setEncounterType(emrApiProperties.getVisitNoteEncounterType());
consult.setEncounterDatetime(DateUtils.addHours(new Date(), -47));
encounterService.saveEncounter(consult);
visit.addEncounter(edTriage);
visit.addEncounter(consult);
visitService.saveVisit(visit);
VisitDomainWrapper activeVisit = adtService.getActiveVisit(patient, location);
// sanity check
assertNotNull(activeVisit);
new PihCloseStaleVisitsTask().run();
activeVisit = adtService.getActiveVisit(patient, location);
assertNotNull(activeVisit);
}
Aggregations