use of org.openmrs.VisitType in project openmrs-core by openmrs.
the class VisitServiceTest method getVisitType_shouldGetCorrectVisitType.
@Test
public void getVisitType_shouldGetCorrectVisitType() {
VisitType visitType = visitService.getVisitType(1);
assertNotNull(visitType);
assertEquals("Initial HIV Clinic Visit", visitType.getName());
}
use of org.openmrs.VisitType in project openmrs-core by openmrs.
the class ExistingOrNewVisitAssignmentHandlerTest method beforeCreateEncounter_shouldAssignFirstVisitTypeIfMappingGlobalPropertyIsNotSet.
/**
* @see ExistingVisitAssignmentHandler#beforeCreateEncounter(Encounter)
*/
@Test
public void beforeCreateEncounter_shouldAssignFirstVisitTypeIfMappingGlobalPropertyIsNotSet() {
VisitType visitType = Context.getVisitService().getAllVisitTypes().get(0);
Encounter encounter = Context.getEncounterService().getEncounter(1);
Assert.assertNull(encounter.getVisit());
Calendar calendar = Calendar.getInstance();
calendar.setTime(encounter.getEncounterDatetime());
calendar.set(Calendar.YEAR, 1900);
encounter.setEncounterDatetime(calendar.getTime());
new ExistingOrNewVisitAssignmentHandler().beforeCreateEncounter(encounter);
Assert.assertNotNull(encounter.getVisit());
Assert.assertEquals(visitType, encounter.getVisit().getVisitType());
}
use of org.openmrs.VisitType in project openmrs-core by openmrs.
the class VisitServiceTest method saveVisitType_shouldThrowErrorWhenNameIsEmptyString.
@Test(expected = APIException.class)
public void saveVisitType_shouldThrowErrorWhenNameIsEmptyString() {
VisitType visitType = new VisitType("", null);
visitService.saveVisitType(visitType);
}
use of org.openmrs.VisitType in project openmrs-core by openmrs.
the class VisitServiceTest method getVisitTypeByUuid_shouldGetCorrentVisitType.
@Test
public void getVisitTypeByUuid_shouldGetCorrentVisitType() {
VisitType visitType = visitService.getVisitTypeByUuid("c0c579b0-8e59-401d-8a4a-976a0b183519");
assertNotNull(visitType);
assertEquals("Initial HIV Clinic Visit", visitType.getName());
}
use of org.openmrs.VisitType in project openmrs-module-coreapps by openmrs.
the class ActiveVisitsPageController method get.
public String get(UiSessionContext sessionContext, PageModel model, @SpringBean AdtService service, @SpringBean("visitService") VisitService visitService, @RequestParam("app") AppDescriptor app, @SpringBean("visitTypeHelper") VisitTypeHelper visitTypeHelper) {
Location sessionLocation = sessionContext.getSessionLocation();
if (sessionLocation == null) {
return "redirect:login.htm";
}
Location visitLocation = null;
if (sessionLocation != null) {
visitLocation = service.getLocationThatSupportsVisits(sessionLocation);
}
if (visitLocation == null) {
throw new IllegalStateException("Configuration required: no visit location found based on session location");
}
List<VisitDomainWrapper> activeVisits = service.getActiveVisits(visitLocation);
model.addAttribute("visitSummaries", activeVisits);
String patientPageUrl = app.getConfig().get("patientPageUrl").getTextValue();
model.addAttribute("patientPageUrl", patientPageUrl);
// used to determine whether or not we display a link to the patient in the results list
model.addAttribute("canViewVisits", Context.hasPrivilege(CoreAppsConstants.PRIVILEGE_PATIENT_VISITS));
// retrieve all different visit types, with their color and short name
Map<Integer, Object> visitTypesWithAttr = new HashMap<Integer, Object>();
List<VisitType> allVisitTypes = visitService.getAllVisitTypes();
for (VisitType type : allVisitTypes) {
Map<String, Object> typeAttr = visitTypeHelper.getVisitTypeColorAndShortName(type);
visitTypesWithAttr.put(type.getVisitTypeId(), typeAttr);
}
model.addAttribute("visitTypesWithAttr", visitTypesWithAttr);
return null;
}
Aggregations