/** * @see org.openmrs.api.VisitService#retireVisitType(org.openmrs.VisitType, java.lang.String) */ @Override public VisitType retireVisitType(VisitType visitType, String reason) { return Context.getVisitService().saveVisitType(visitType); }
/** * @see org.openmrs.api.VisitService#unretireVisitType(org.openmrs.VisitType) */ @Override public VisitType unretireVisitType(VisitType visitType) { return Context.getVisitService().saveVisitType(visitType); }
@Test(expected = APIException.class) public void saveVisitType_shouldThrowErrorWhenNameIsEmptyString() { VisitType visitType = new VisitType("", null); visitService.saveVisitType(visitType); }
@Test(expected = APIException.class) public void saveVisitType_shouldThrowErrorWhenNameIsNull() { visitService.saveVisitType(new VisitType()); }
@Test public void saveVisitType_shouldSaveNewVisitType() { List<VisitType> visitTypes = visitService.getVisitTypes("Some Name"); assertEquals(0, visitTypes.size()); VisitType visitType = new VisitType("Some Name", "Description"); visitService.saveVisitType(visitType); visitTypes = visitService.getVisitTypes("Some Name"); assertEquals(1, visitTypes.size()); //Should create a new visit type row. assertEquals(4, visitService.getAllVisitTypes().size()); }
/** * @see DelegatingCrudResource#save(java.lang.Object) */ @Override public VisitType save(VisitType visitType) { return Context.getVisitService().saveVisitType(visitType); }
@Test public void saveVisitType_shouldSaveEditedVisitType() { VisitType visitType = visitService.getVisitType(1); assertNotNull(visitType); assertEquals("Initial HIV Clinic Visit", visitType.getName()); visitType.setName("Edited Name"); visitType.setDescription("Edited Description"); visitService.saveVisitType(visitType); visitType = visitService.getVisitType(1); assertNotNull(visitType); assertEquals("Edited Name", visitType.getName()); assertEquals("Edited Description", visitType.getDescription()); //Should not change the number of visit types. assertEquals(3, visitService.getAllVisitTypes().size()); }