Search in sources :

Example 11 with VisitType

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());
}
Also used : VisitType(org.openmrs.VisitType) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 12 with VisitType

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());
}
Also used : Calendar(java.util.Calendar) VisitType(org.openmrs.VisitType) Encounter(org.openmrs.Encounter) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 13 with VisitType

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);
}
Also used : VisitType(org.openmrs.VisitType) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 14 with 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());
}
Also used : VisitType(org.openmrs.VisitType) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 15 with VisitType

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;
}
Also used : HashMap(java.util.HashMap) VisitType(org.openmrs.VisitType) VisitDomainWrapper(org.openmrs.module.emrapi.visit.VisitDomainWrapper) Location(org.openmrs.Location)

Aggregations

VisitType (org.openmrs.VisitType)30 Test (org.junit.Test)18 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)18 Visit (org.openmrs.Visit)11 Encounter (org.openmrs.Encounter)6 ArrayList (java.util.ArrayList)5 Date (java.util.Date)5 Patient (org.openmrs.Patient)5 EncounterType (org.openmrs.EncounterType)4 Location (org.openmrs.Location)4 HashMap (java.util.HashMap)3 Before (org.junit.Before)3 Calendar (java.util.Calendar)2 Concept (org.openmrs.Concept)2 VisitAttribute (org.openmrs.VisitAttribute)2 VisitAttributeType (org.openmrs.VisitAttributeType)2 APIException (org.openmrs.api.APIException)2 VisitService (org.openmrs.api.VisitService)2 PatientDomainWrapper (org.openmrs.module.emrapi.patient.PatientDomainWrapper)2 VisitDomainWrapper (org.openmrs.module.emrapi.visit.VisitDomainWrapper)2