Search in sources :

Example 6 with Encounter

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());
}
Also used : Encounter(org.openmrs.Encounter) PihCoreContextSensitiveTest(org.openmrs.module.pihcore.PihCoreContextSensitiveTest) Test(org.junit.Test)

Example 7 with Encounter

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());
}
Also used : Patient(org.openmrs.Patient) Encounter(org.openmrs.Encounter) DateTime(org.joda.time.DateTime) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 8 with Encounter

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;
}
Also used : Encounter(org.openmrs.Encounter)

Example 9 with 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());
}
Also used : Patient(org.openmrs.Patient) Encounter(org.openmrs.Encounter) DateTime(org.joda.time.DateTime) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 10 with Encounter

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
}
Also used : Patient(org.openmrs.Patient) Encounter(org.openmrs.Encounter) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

Encounter (org.openmrs.Encounter)261 Test (org.junit.Test)204 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)153 Patient (org.openmrs.Patient)91 Date (java.util.Date)87 Order (org.openmrs.Order)46 Obs (org.openmrs.Obs)41 Visit (org.openmrs.Visit)40 Location (org.openmrs.Location)38 OrderUtilTest (org.openmrs.order.OrderUtilTest)38 DrugOrder (org.openmrs.DrugOrder)37 TestOrder (org.openmrs.TestOrder)34 EncounterType (org.openmrs.EncounterType)27 ArrayList (java.util.ArrayList)25 Concept (org.openmrs.Concept)25 BindException (org.springframework.validation.BindException)25 Calendar (java.util.Calendar)21 Errors (org.springframework.validation.Errors)21 User (org.openmrs.User)20 PihCoreContextSensitiveTest (org.openmrs.module.pihcore.PihCoreContextSensitiveTest)19