use of org.openmrs.Encounter in project openmrs-core by openmrs.
the class EncounterServiceTest method getEncounters_shouldGetEncountersOnOrUpToADate.
/**
* @throws ParseException
* @see EncounterService#getEncounters(Patient, Location, Date, Date, java.util.Collection,
* java.util.Collection, java.util.Collection, boolean)
*/
@Test
public void getEncounters_shouldGetEncountersOnOrUpToADate() throws ParseException {
Date toDate = new SimpleDateFormat("yyyy-dd-MM").parse("2006-01-01");
EncounterSearchCriteria encounterSearchCriteria = new EncounterSearchCriteriaBuilder().setToDate(toDate).setIncludeVoided(true).createEncounterSearchCriteria();
List<Encounter> encounters = Context.getEncounterService().getEncounters(encounterSearchCriteria);
assertEquals(2, encounters.size());
assertEquals(15, encounters.get(0).getEncounterId().intValue());
assertEquals(1, encounters.get(1).getEncounterId().intValue());
}
use of org.openmrs.Encounter in project openmrs-core by openmrs.
the class EncounterServiceTest method purgeEncounter_shouldFailfIfUserIsNotSupposedToEditEncountersOfTypeOfGivenEncounter.
/**
* @see EncounterService#purgeEncounter(Encounter)
*/
@Test(expected = APIException.class)
public void purgeEncounter_shouldFailfIfUserIsNotSupposedToEditEncountersOfTypeOfGivenEncounter() {
// get encounter that has type with edit privilege set
Encounter encounter = getEncounterWithEditPrivilege();
User user = Context.getUserService().getUserByUsername("test_user");
assertNotNull(user);
// left this user as is - i.e. without required privilege
// and authenticate under it's account
Context.becomeUser(user.getSystemId());
// have to add privilege in order to be able to call purgeEncounter(Encounter) method
Context.addProxyPrivilege(PrivilegeConstants.PURGE_ENCOUNTERS);
Context.getEncounterService().purgeEncounter(encounter);
}
use of org.openmrs.Encounter in project openmrs-core by openmrs.
the class EncounterServiceTest method saveEncounter_shouldSetDateStoppedOnTheOriginalAfterAddingReviseOrder.
/**
* @see EncounterService#unvoidEncounter(Encounter)
*/
@Test
public void saveEncounter_shouldSetDateStoppedOnTheOriginalAfterAddingReviseOrder() {
EncounterService es = Context.getEncounterService();
TestOrder order = (TestOrder) Context.getOrderService().getOrder(7);
Assert.assertNull(order.getDateStopped());
Encounter encounter = es.getEncounter(6);
TestOrder reviseOrder = order.cloneForRevision();
reviseOrder.setOrderer(Context.getProviderService().getProvider(1));
encounter.addOrder(reviseOrder);
es.saveEncounter(encounter);
Context.flushSession();
Context.clearSession();
Date dateStopped = Context.getOrderService().getOrder(7).getDateStopped();
Assert.assertNotNull(dateStopped);
}
use of org.openmrs.Encounter in project openmrs-core by openmrs.
the class EncounterServiceTest method unvoidEncounter_shouldCascadeUnvoidToObs.
/**
* @see EncounterService#unvoidEncounter(Encounter)
*/
@Test
public void unvoidEncounter_shouldCascadeUnvoidToObs() {
EncounterService encounterService = Context.getEncounterService();
// get a voided encounter that has some voided obs
Encounter encounter = encounterService.getEncounter(2);
encounterService.unvoidEncounter(encounter);
Obs obs = Context.getObsService().getObs(4);
assertFalse(obs.getVoided());
assertNull(obs.getVoidReason());
}
use of org.openmrs.Encounter in project openmrs-core by openmrs.
the class EncounterServiceTest method voidEncounter_shouldCascadeToOrders.
/**
* @see EncounterService#voidEncounter(Encounter,String)
*/
@Test
public void voidEncounter_shouldCascadeToOrders() {
EncounterService encounterService = Context.getEncounterService();
// get a nonvoided encounter that has some obs
Encounter encounter = encounterService.getEncounter(1);
encounterService.voidEncounter(encounter, "Just Testing");
Order order = Context.getOrderService().getOrder(1);
assertTrue(order.getVoided());
assertEquals("Just Testing", order.getVoidReason());
}
Aggregations