@Override protected Encounter getObjectByUuid(String uuid) { return Context.getEncounterService().getEncounterByUuid(uuid); } }
/** * @see org.openmrs.api.EncounterService#unretireEncounterType(org.openmrs.EncounterType) */ @Override public EncounterType unretireEncounterType(EncounterType encounterType) throws APIException { Context.getEncounterService().checkIfEncounterTypesAreLocked(); encounterType.setRetired(false); return Context.getEncounterService().saveEncounterType(encounterType); }
/** * @see org.openmrs.api.EncounterService#saveEncounterType(org.openmrs.EncounterType) */ @Override public EncounterType saveEncounterType(EncounterType encounterType) { //make sure the user has not turned off encounter types editing Context.getEncounterService().checkIfEncounterTypesAreLocked(); dao.saveEncounterType(encounterType); return encounterType; }
/** * @see EncounterService#getEncountersByPatientId(Integer) */ @Test(expected = IllegalArgumentException.class) public void getEncountersByPatientId_shouldThrowErrorIfGivenANullParameter() { Context.getEncounterService().getEncountersByPatientId(null); }
/** * @see EncounterService#getEncountersByPatientIdentifier(String) */ @Test(expected = IllegalArgumentException.class) public void getEncountersByPatientIdentifier_shouldThrowErrorIfGivenNullParameter() { Context.getEncounterService().getEncountersByPatientIdentifier(null); }
/** * @see EncounterService#canEditEncounter(Encounter, User) */ @Test(expected = IllegalArgumentException.class) public void canEditEncounter_shouldFailfIfEncounterIsNull() { // invoke method using null encounter Context.getEncounterService().canEditEncounter(null, null); }
/** * @see EncounterService#getEncounters(String,Integer,Integer,Integer,null) */ @Test public void getEncounters_shouldFetchEncountersByPatientId() { Assert.assertEquals(2, Context.getEncounterService().getEncounters(null, 3, null, null, false).size()); Assert.assertEquals(4, Context.getEncounterService().getEncounters(null, 3, null, null, true).size()); }
/** * @see EncounterService#getEncounters(String,Integer,Integer,Integer,null) */ @Test public void getEncounters_shouldMatchOnTheLocationName() { Assert.assertEquals(2, Context.getEncounterService().getEncounters("Test Location", 3, null, null, false).size()); Assert.assertEquals(4, Context.getEncounterService().getEncounters("Test Location", 3, null, null, true).size()); }
/** * @see EncounterService#getEncountersByPatientId(Integer) */ @Test public void getEncountersByPatientId_shouldNotGetVoidedEncounters() { EncounterService encounterService = Context.getEncounterService(); List<Encounter> encounters = encounterService.getEncountersByPatientId(3); assertEquals(2, encounters.size()); }
/** * @see EncounterService#getEncounters(String,Integer,Integer,Integer,null) */ @Test public void getEncounters_shouldIncludeVoidedEncountersIfIncludeVoidedIsSetToTrue() { Assert.assertEquals(2, Context.getEncounterService().getEncounters("2", 3, null, null, true).size()); }
/** * @see RequireVoidReasonSaveHandler#handle(Voidable,User,Date,String) */ @Test public void handle_shouldNotThrowExceptionIfVoidReasonIsNotBlank() { Encounter e = Context.getEncounterService().getEncounter(3); e.setVoided(true); e.setVoidReason("Some Reason"); Context.getEncounterService().saveEncounter(e); }
/** * @see EncounterService#voidEncounter(Encounter,String) */ @Test(expected = IllegalArgumentException.class) public void voidEncounter_shouldThrowErrorWithNullReasonParameter() { EncounterService encounterService = Context.getEncounterService(); Encounter type = encounterService.getEncounter(1); encounterService.voidEncounter(type, null); }
/** * @see EncounterService#retireEncounterType(EncounterType,String) */ @Test(expected = IllegalArgumentException.class) public void retireEncounterType_shouldThrowErrorIfGivenNullReasonParameter() { EncounterService encounterService = Context.getEncounterService(); EncounterType type = encounterService.getEncounterType(1); encounterService.retireEncounterType(type, null); }
/** * @see EncounterService#getEncountersByVisit(Visit, boolean) */ @Test public void getEncountersByVisit_shouldGetActiveEncountersByVisit() { List<Encounter> encounters = Context.getEncounterService().getEncountersByVisit(new Visit(1), false); assertEquals(1, encounters.size()); }
/** * @see EncounterService#getEncountersByVisit(Visit, boolean) */ @Test public void getEncountersByVisit_shouldIncludeVoidedEncountersWhenIncludeVoidedIsTrue() { List<Encounter> encounters = Context.getEncounterService().getEncountersByVisit(new Visit(1), true); assertEquals(2, encounters.size()); }
/** * @see EncounterService#getAllEncounterRoles(boolean) */ @Test public void getAllEncounterRoles_shouldGetAllEncounterRolesBasedOnIncludeRetiredFlag() { EncounterService encounterService = Context.getEncounterService(); List<EncounterRole> encounterRoles = encounterService.getAllEncounterRoles(true); assertEquals("get all encounter roles including retired", 3, encounterRoles.size()); encounterRoles = encounterService.getAllEncounterRoles(false); assertEquals("get all encounter roles excluding retired", 2, encounterRoles.size()); }
/** * @see EncounterService#getEncounters(Patient, Location, Date, Date, java.util.Collection, * java.util.Collection, java.util.Collection, boolean) */ @Test public void getEncounters_shouldExcludeVoidedEncounters() { EncounterSearchCriteria encounterSearchCriteria = new EncounterSearchCriteriaBuilder().setIncludeVoided(false) .createEncounterSearchCriteria(); assertEquals(6, Context.getEncounterService().getEncounters(encounterSearchCriteria).size()); }
/** * @throws ParseException * @see org.openmrs.api.EncounterService#getEncounters(org.openmrs.parameter.EncounterSearchCriteria) */ @Test public void getEncounters_shouldGetEncountersModifiedAfterSpecifiedDate() throws ParseException { EncounterService encounterService = Context.getEncounterService(); Assert.assertEquals(7, encounterService.getEncounters(encounterSearchForVoidedWithDateChanged("2006-01-01")).size()); Assert.assertEquals(5, encounterService.getEncounters(encounterSearchForVoidedWithDateChanged("2008-06-01")).size()); Assert.assertEquals(1, encounterService.getEncounters(encounterSearchForVoidedWithDateChanged("2010-01-01")).size()); }
@Test public void getActiveEncounterVisitHandler_shouldReturnBeanHaveBeenRegisteredWithGivenName() { String correctBeanName = OpenmrsConstants.REGISTERED_COMPONENT_NAME_PREFIX + "existingOrNewVisitAssignmentHandler"; GlobalProperty visitHandlerProperty = new GlobalProperty(OpenmrsConstants.GP_VISIT_ASSIGNMENT_HANDLER, correctBeanName); Context.getAdministrationService().saveGlobalProperty(visitHandlerProperty); EncounterVisitHandler activeEncounterVisitHandler = Context.getEncounterService().getActiveEncounterVisitHandler(); Assert.assertNotNull(activeEncounterVisitHandler); }
/** * @see EncounterTypeValidator#validate(Object, Errors) */ @Test public void validate_shouldFailIfEncounterTypeNameIsDuplicate() { Assert.assertNotNull(Context.getEncounterService().getEncounterType("Scheduled")); EncounterType newEncounterType = new EncounterType(); newEncounterType.setName("Scheduled"); Errors errors = new BindException(newEncounterType, "encounterType"); new EncounterTypeValidator().validate(newEncounterType, errors); Assert.assertTrue(errors.hasFieldErrors("name")); }