use of org.openmrs.Encounter in project openmrs-module-pihcore by PIH.
the class ReopenVisitActionTest method reopenVisitAction_shouldNotReopenVisitIfSubsequentVisitAtSameLocation.
@Test
public void reopenVisitAction_shouldNotReopenVisitIfSubsequentVisitAtSameLocation() {
Encounter encounter = Context.getEncounterService().getEncounter(1001);
// sanity check
assertNotNull(encounter.getVisit().getStopDatetime());
when(mockSession.getEncounter()).thenReturn(encounter);
reopenVisitAction.applyAction(mockSession);
assertNotNull(encounter.getVisit().getStopDatetime());
}
use of org.openmrs.Encounter in project openmrs-module-pihcore by PIH.
the class PihPatientMergeActionsTest method shouldVoidMostRecentRegistrationEncountersOnNonPreferredPatientIfMoreRecentThanPreferred.
@Test
public void shouldVoidMostRecentRegistrationEncountersOnNonPreferredPatientIfMoreRecentThanPreferred() {
Patient preferred = new Patient(1);
Patient nonPreferred = new Patient(2);
Encounter preferredEncounter1 = createEncounter(1, new DateTime(2012, 9, 10, 0, 0, 0).toDate());
Encounter preferredEncounter2 = createEncounter(2, new DateTime(2012, 10, 10, 0, 0, 0).toDate());
Encounter nonPreferredEncounter1 = createEncounter(3, new DateTime(2012, 11, 10, 0, 0, 0).toDate());
Encounter nonPreferredEncounter2 = createEncounter(4, new DateTime(2012, 12, 10, 0, 0, 0).toDate());
when(encounterService.getEncounters(preferred, null, null, null, null, Collections.singleton(registration), null, null, null, false)).thenReturn(Arrays.asList(preferredEncounter1, preferredEncounter2));
when(encounterService.getEncounters(nonPreferred, null, null, null, null, Collections.singleton(registration), null, null, null, false)).thenReturn(Arrays.asList(nonPreferredEncounter1, nonPreferredEncounter2));
pihPatientMergeActions.beforeMergingPatients(preferred, nonPreferred);
verify(encounterService, never()).voidEncounter(eq(preferredEncounter1), anyString());
verify(encounterService, never()).voidEncounter(eq(preferredEncounter2), anyString());
verify(encounterService).voidEncounter(eq(nonPreferredEncounter1), anyString());
verify(encounterService).voidEncounter(eq(nonPreferredEncounter2), anyString());
}
use of org.openmrs.Encounter in project openmrs-module-pihcore by PIH.
the class PihPatientMergeActionsTest method createEncounter.
private Encounter createEncounter(int id, Date date) {
Encounter encounter = new Encounter(id);
encounter.setEncounterDatetime(date);
return encounter;
}
use of org.openmrs.Encounter in project openmrs-module-pihcore by PIH.
the class PihPatientMergeActionsTest method shouldNotVoidMostRecentRegistrationEncounterOnNonPreferredPatientIfNotMoreRecentThanPreferred.
@Test
public void shouldNotVoidMostRecentRegistrationEncounterOnNonPreferredPatientIfNotMoreRecentThanPreferred() {
Patient preferred = new Patient(1);
Patient nonPreferred = new Patient(2);
Encounter preferredEncounter1 = createEncounter(1, new DateTime(2012, 10, 10, 0, 0, 0).toDate());
Encounter preferredEncounter2 = createEncounter(2, new DateTime(2012, 11, 10, 0, 0, 0).toDate());
Encounter nonPreferredEncounter1 = createEncounter(3, new DateTime(2012, 1, 10, 0, 0, 0).toDate());
Encounter nonPreferredEncounter2 = createEncounter(4, new DateTime(2012, 2, 10, 0, 0, 0).toDate());
when(encounterService.getEncounters(preferred, null, null, null, null, Collections.singleton(registration), null, null, null, false)).thenReturn(Arrays.asList(preferredEncounter1, preferredEncounter2));
when(encounterService.getEncounters(nonPreferred, null, null, null, null, Collections.singleton(registration), null, null, null, false)).thenReturn(Arrays.asList(nonPreferredEncounter1, nonPreferredEncounter2));
pihPatientMergeActions.beforeMergingPatients(preferred, nonPreferred);
verify(encounterService, never()).voidEncounter(eq(preferredEncounter1), anyString());
verify(encounterService, never()).voidEncounter(eq(preferredEncounter2), anyString());
verify(encounterService, never()).voidEncounter(eq(nonPreferredEncounter1), anyString());
verify(encounterService, never()).voidEncounter(eq(nonPreferredEncounter2), anyString());
}
use of org.openmrs.Encounter in project openmrs-module-pihcore by PIH.
the class PihPatientMergeActionsTest method shouldNotFailIfNoEncounters.
@Test
public void shouldNotFailIfNoEncounters() {
Patient preferred = new Patient(1);
Patient nonPreferred = new Patient(2);
when(encounterService.getEncounters(preferred, null, null, null, null, Collections.singleton(registration), null, null, null, false)).thenReturn(null);
when(encounterService.getEncounters(nonPreferred, null, null, null, null, Collections.singleton(registration), null, null, null, false)).thenReturn(Collections.singletonList(new Encounter()));
pihPatientMergeActions.beforeMergingPatients(preferred, nonPreferred);
// just make sure no NPE
}
Aggregations