    public SimpleObject getVisitDetails(
            @SpringBean("adminService") AdministrationService administrationService,
            @RequestParam("visitId") Visit visit,
            UiUtils uiUtils,
            EmrContext emrContext) throws ParseException {
        SimpleObject simpleObject = SimpleObject.fromObject(visit, uiUtils, "id", "location");
        User authenticatedUser = emrContext.getUserContext().getAuthenticatedUser();
        boolean canDelete = authenticatedUser.hasPrivilege(EmrConstants.PRIVILEGE_DELETE_ENCOUNTER);
        Date startDatetime = visit.getStartDatetime();
        Date stopDatetime = visit.getStopDatetime();
        simpleObject.put("startDatetime", DateFormatUtils.format(startDatetime, "dd MMM yyyy hh:mm a"));
        if (stopDatetime!=null){
            simpleObject.put("stopDatetime", DateFormatUtils.format(stopDatetime, "dd MMM yyyy hh:mm a"));
        } else {
            simpleObject.put("stopDatetime", null);
        }
        List<SimpleObject> encounters = new ArrayList<SimpleObject>();
        simpleObject.put("encounters", encounters);
        String[] datePatterns = { administrationService.getGlobalProperty(UiFrameworkConstants.GP_FORMATTER_DATETIME_FORMAT) };
        for (Encounter e : visit.getEncounters()) {
            if (!e.getVoided()) {
                SimpleObject simpleEncounter = SimpleObject.fromObject(e, uiUtils,  "encounterId", "encounterDatetime", "location", "encounterProviders.provider", "voided", "form");
                Date encounterDatetime = DateUtils.parseDate((String) simpleEncounter.get("encounterDatetime"), datePatterns);
                simpleEncounter.put("encounterDate", DateFormatUtils.format(encounterDatetime, "dd MMM yyyy"));
                simpleEncounter.put("encounterTime", DateFormatUtils.format(encounterDatetime, "hh:mm a"));
                EncounterType encounterType = e.getEncounterType();
                simpleEncounter.put("encounterType", SimpleObject.create("uuid", encounterType.getUuid(), "name", uiUtils.format(encounterType)));
                if(canDelete){
                    simpleEncounter.put("canDelete", true);
                }
                encounters.add(simpleEncounter);
            }
        }
        return simpleObject;
    }

    public SimpleObject getVisitDetails(
            @SpringBean("adminService") AdministrationService administrationService,
            @RequestParam("visitId") Visit visit,
            UiUtils uiUtils,
            EmrContext emrContext) throws ParseException {
        SimpleObject simpleObject = SimpleObject.fromObject(visit, uiUtils, "id", "location");
        User authenticatedUser = emrContext.getUserContext().getAuthenticatedUser();
        boolean canDelete = authenticatedUser.hasPrivilege(EmrConstants.PRIVILEGE_DELETE_ENCOUNTER);
        Date startDatetime = visit.getStartDatetime();
        Date stopDatetime = visit.getStopDatetime();
        simpleObject.put("startDatetime", DateFormatUtils.format(startDatetime, "dd MMM yyyy hh:mm a", emrContext.getUserContext().getLocale()));
        if (stopDatetime!=null){
            simpleObject.put("stopDatetime", DateFormatUtils.format(stopDatetime, "dd MMM yyyy hh:mm a", emrContext.getUserContext().getLocale()));
        } else {
            simpleObject.put("stopDatetime", null);
        }
        List<SimpleObject> encounters = new ArrayList<SimpleObject>();
        simpleObject.put("encounters", encounters);
        String[] datePatterns = { administrationService.getGlobalProperty(UiFrameworkConstants.GP_FORMATTER_DATETIME_FORMAT) };
        for (Encounter e : visit.getEncounters()) {
            if (!e.getVoided()) {
                SimpleObject simpleEncounter = SimpleObject.fromObject(e, uiUtils,  "encounterId", "location", "encounterProviders.provider", "voided", "form");
                simpleEncounter.put("encounterDate", DateFormatUtils.format(e.getEncounterDatetime(), "dd MMM yyyy", emrContext.getUserContext().getLocale()));
                simpleEncounter.put("encounterTime", DateFormatUtils.format(e.getEncounterDatetime(), "hh:mm a", emrContext.getUserContext().getLocale()));
                EncounterType encounterType = e.getEncounterType();
                simpleEncounter.put("encounterType", SimpleObject.create("uuid", encounterType.getUuid(), "name", uiUtils.format(encounterType)));
                if(canDelete){
                    simpleEncounter.put("canDelete", true);
                }
                encounters.add(simpleEncounter);
            }
        }
        return simpleObject;
    }
