//This method returns all users details
        public static List <RbacUser> GetAllUsers()
        {
            List <RbacUser> retList = (List <RbacUser>)DanpheCache.Get("RBAC-Users-All");

            if (retList == null)
            {
                RbacDbContext dbContext = new RbacDbContext(connStringName);
                retList = dbContext.Users.ToList();
                DanpheCache.Add("RBAC-Users-All", retList, cacheExpiryMinutes);
            }
            return(retList);
        }
        //This method return All Permissions without checking user and other thing
        //It checks cache if list is in chache then it takes from cache else get all permission from db
        public static List <RbacPermission> GetAllPermissions()
        {
            List <RbacPermission> retList = (List <RbacPermission>)DanpheCache.Get("RBAC-Perms-All");

            if (retList == null)
            {
                RbacDbContext dbContext = new RbacDbContext(connStringName);
                retList = dbContext.Permissions.ToList();
                DanpheCache.Add("RBAC-Perms-All", retList, cacheExpiryMinutes);
            }
            return(retList);
        }
示例#3
0
        public DateTime GetCounterDay_Active(string connString)
        {
            DateTime currCounterDay = (DateTime)DanpheCache.Get("currCounterDay");

            if (currCounterDay == null)
            {
                DanpheEMR.DalLayer.BillingDbContext billingDbcontext = new DalLayer.BillingDbContext(connString);
            }


            return(currCounterDay);
        }
        public static List <RbacPermission> GetUserAllPermissions(int userId)
        {
            List <RbacPermission> retList = (List <RbacPermission>)DanpheCache.Get("RBAC-UserPermissions-UserId" + userId);

            if (retList == null)
            {
                var isUsrSysAdmin = (from usRole in RBAC.GetAllUserRoleMaps()
                                     where usRole.UserId == userId
                                     join role in RBAC.GetAllRoles()
                                     on usRole.RoleId equals role.RoleId
                                     where role.IsSysAdmin == true
                                     select role).Count() > 0;
                //return all permissions if current user is systemadmin.
                if (isUsrSysAdmin)
                {
                    retList = RBAC.GetAllPermissions();
                }
                else
                {
                    retList = (from urole in RBAC.GetAllUserRoleMaps()
                               where urole.UserId == userId && urole.IsActive == true
                               join role in RBAC.GetAllRoles()
                               on urole.RoleId equals role.RoleId
                               join rolePmap in RBAC.GetAllRolePermissionMaps()
                               on urole.RoleId equals rolePmap.RoleId
                               join perm in RBAC.GetAllPermissions()
                               on rolePmap.PermissionId equals perm.PermissionId
                               where rolePmap.IsActive == true
                               join app in RBAC.GetAllApplications()
                               on perm.ApplicationId equals app.ApplicationId
                               where app.IsActive == true
                               select perm).ToList();
                }
                DanpheCache.Add("RBAC-UserPermissions-UserId" + userId, retList, cacheExpiryMinutes);
            }
            return(retList);
        }
示例#5
0
        public string Get(string reqType, string EmpIds, string dates)
        {
            DanpheHTTPResponse <object> responseData = new DanpheHTTPResponse <object>();
            SchedulingDbContext         schDbContext = new SchedulingDbContext(connString);
            MasterDbContext             masterDb     = new MasterDbContext(connString);

            try
            {
                List <DepartmentModel> allDeptsFromCache = (List <DepartmentModel>)DanpheCache.GetMasterData(MasterDataEnum.Department);
                List <EmployeeModel>   empListFromCache  = (List <EmployeeModel>)DanpheCache.GetMasterData(MasterDataEnum.Employee);

                #region GET: List of Employees
                if (reqType == "employeelist")
                {
                    var result = (from e in empListFromCache
                                  join d in allDeptsFromCache on e.DepartmentId equals d.DepartmentId
                                  select new
                    {
                        e.EmployeeId,
                        d.DepartmentId,
                        d.DepartmentName,
                        EmployeeName = e.Salutation + ". " + e.FirstName + " " + (string.IsNullOrEmpty(e.MiddleName) ? "" : e.MiddleName + " ") + e.LastName,
                    }).ToList();

                    responseData.Status  = "OK";
                    responseData.Results = result;
                }
                #endregion
                #region GET: Employee Schedules
                else if (reqType == "getEmpSchedule")
                {
                    string[]      employeeIDs = EmpIds.Split(',');
                    string[]      curDates    = dates.Split(',');
                    List <object> res         = new List <object>();

                    var abc = (from emp in empListFromCache
                               join dept in allDeptsFromCache on emp.DepartmentId equals dept.DepartmentId
                               join e in employeeIDs on emp.EmployeeId.ToString() equals e
                               select new
                    {
                        emp.EmployeeId,
                        EmployeeName = emp.Salutation + ". " + emp.FirstName + " " + (string.IsNullOrEmpty(emp.MiddleName) ? "" : emp.MiddleName + " ") + emp.LastName,
                        DepartmentName = dept.DepartmentName,
                        defSCH = (from daywise in schDbContext.DayWiseAvailability
                                  where daywise.EmployeeId == emp.EmployeeId
                                  select new
                        {
                            daywise.DayName,
                            IsWorkingDay = daywise.IsWorking
                        }).ToList(),
                        loadSCH = (from em in schDbContext.Employee
                                   join sch in schDbContext.EmpSchedules on em.EmployeeId equals sch.EmployeeId into schTemp
                                   from s in schTemp.DefaultIfEmpty()
                                   join date in curDates on s.Date.ToString() equals date
                                   where em.EmployeeId == emp.EmployeeId
                                   select new
                        {
                            Id = s.EmployeeSCHId,
                            TxnType = "Update",
                            Date = s.Date.Value,
                            s.DayName,
                            s.IsWorkingDay
                        }).ToList(),
                    }).ToList();

                    responseData.Status  = "OK";
                    responseData.Results = abc;
                }
                #endregion
                #region GET: list of shifts master
                else if (reqType == "getShiftList")
                {
                    var shiftList = schDbContext.ShiftsMaster.OrderByDescending(a => a.IsDefault).ToList();

                    responseData.Status  = "OK";
                    responseData.Results = shiftList;
                }
                #endregion
                #region GET: list of Employee working hours
                else if (reqType == "getEmpWHList")
                {
                    List <object> res = new List <object>();

                    var empDetails = (from emp in masterDb.Employees
                                      join dept in masterDb.Departments on emp.DepartmentId equals dept.DepartmentId
                                      join role in masterDb.EmployeeRole on emp.EmployeeRoleId equals role.EmployeeRoleId
                                      select new
                    {
                        emp.EmployeeId,
                        EmployeeName = emp.Salutation + ". " + emp.FirstName + " " + (string.IsNullOrEmpty(emp.MiddleName) ? "" : emp.MiddleName + " ") + emp.LastName,
                        emp.DepartmentId,
                        dept.DepartmentName,
                        emp.EmployeeRoleId,
                        role.EmployeeRoleName
                    }).ToList();

                    var empWorkingHours = (from emp in empDetails
                                           join m in schDbContext.EmpShiftMAP on emp.EmployeeId equals m.EmployeeId into mTemp
                                           from map in mTemp.DefaultIfEmpty()
                                           join shift in schDbContext.ShiftsMaster on(map != null ? map.ShiftId : 0) equals shift.ShiftId
                                           where (map != null ? map.IsActive : false) == true
                                           group new { emp, map, shift } by new
                    {
                        emp.EmployeeId,
                        emp.EmployeeName,
                        emp.EmployeeRoleName,
                        emp.DepartmentName
                    } into WH
                                           select new
                    {
                        WH.Key.EmployeeId,
                        WH.Key.EmployeeName,
                        WH.Key.DepartmentName,
                        WH.Key.EmployeeRoleName,
                        NoOfShifts = WH.Select(a => a.map.ShiftId).Count(),
                        Shifts = WH.Select(a => new
                        {
                            a.map.EmployeeShiftMapId,
                            a.map.ShiftId,
                            a.shift.ShiftName,
                            a.shift.StartTime,
                            a.shift.EndTime,
                            a.shift.TotalHrs,
                            a.map.IsActive,
                            a.shift.IsDefault
                            //,IsEditable = (from m in schDbContext.EmpShiftMAP
                            //              where m.ShiftId == a.map.ShiftId
                            //              select new { m.ShiftId }).Count().Equals(1)
                        }).OrderBy(z => z.StartTime).ToList(),
                        TotalWorkingHrs = WH.Sum(a => a.shift.TotalHrs)
                    }).ToList();

                    var empNOworkingHours = (from emp in empDetails
                                             where !schDbContext.EmpShiftMAP.Any(x => x.EmployeeId == emp.EmployeeId && x.IsActive == true)
                                             select new
                    {
                        emp.EmployeeId,
                        emp.EmployeeName,
                        emp.EmployeeRoleName,
                        emp.DepartmentName,
                        NoOfShifts = 0,
                        TotalWorkingHrs = 0
                    }).ToList();

                    foreach (var x in empWorkingHours)
                    {
                        res.Add(x);
                    }
                    foreach (var x in empNOworkingHours)
                    {
                        res.Add(x);
                    }

                    //var workingHours = (from map in schDbContext.EmpShiftMAP
                    //                    join e in schDbContext.Employee on map.EmployeeId equals e.EmployeeId
                    //                    join d in allDepts on e.DepartmentId equals d.DepartmentId
                    //                    join s in schDbContext.ShiftsMaster on map.ShiftId equals s.ShiftId
                    //                    join r in schDbContext.EmpRole on e.EmployeeRoleId equals r.EmployeeRoleId
                    //                    where map.IsActive == true
                    //                    group new { map, e, s } by new
                    //                    {
                    //                        e.EmployeeId,
                    //                        EmployeeName = e.Salutation + ". " + e.FirstName + " " + (string.IsNullOrEmpty(e.MiddleName) ? "" : e.MiddleName + " ") + e.LastName,
                    //                        d.DepartmentId,
                    //                        d.DepartmentName,
                    //                        r.EmployeeRoleName
                    //                    } into x
                    //                    select new
                    //                    {
                    //                        x.Key.EmployeeId,
                    //                        x.Key.EmployeeName,
                    //                        x.Key.DepartmentId,
                    //                        x.Key.DepartmentName,
                    //                        x.Key.EmployeeRoleName,
                    //                        NoOfShifts = x.Select(a => a.map.ShiftId).Count(),
                    //                        Shifts = x.Select(a => new
                    //                        {
                    //                            a.map.EmployeeShiftMapId,
                    //                            a.map.ShiftId,
                    //                            a.s.ShiftName,
                    //                            a.s.StartTime,
                    //                            a.s.EndTime,
                    //                            a.s.TotalHrs,
                    //                            a.map.IsActive,
                    //                            a.s.IsDefault
                    //                            //,IsEditable = (from m in schDbContext.EmpShiftMAP
                    //                            //              where m.ShiftId == a.map.ShiftId
                    //                            //              select new { m.ShiftId }).Count().Equals(1)
                    //                        }).OrderBy(z => z.StartTime).ToList(),
                    //                        TotalWorkingHrs = x.Sum(a => a.s.TotalHrs)
                    //                    }).ToList();

                    responseData.Status  = "OK";
                    responseData.Results = res;
                }
                #endregion
                #region GET: list of default shifts master
                else if (reqType == "getDefaultShifts")
                {
                    var defShifts = (from s in schDbContext.ShiftsMaster
                                     where s.IsDefault == true
                                     select s).OrderBy(x => x.StartTime).ToList();

                    responseData.Status  = "OK";
                    responseData.Results = defShifts;
                }
                #endregion
                #region
                else if (reqType == "getEmployeeNoShift")
                {
                    //getting employee that doesnt have any active shift assigned to him/her (from EmployeeShiftMAP table)
                    var empList = (from e in empListFromCache
                                   where !schDbContext.EmpShiftMAP.Any(x => x.EmployeeId == e.EmployeeId && x.IsActive == true)
                                   select e).ToList();

                    responseData.Status  = "OK";
                    responseData.Results = empList;
                }
                #endregion
            }

            catch (Exception ex)
            {
                responseData.Status       = "Failed";
                responseData.ErrorMessage = ex.Message + " exception details:" + ex.ToString();
            }

            return(DanpheJSONConvert.SerializeObject(responseData, true));
        }
        public string Get(string type, string reqType, string inputValue, int employeeId, int countryId, int wardId, int bedTypeId, string departmentName)
        {
            string returnValue = string.Empty;
            DanpheHTTPResponse <object> responseData = new DanpheHTTPResponse <object>();

            if (type == "department")
            {
                //get the value from danphecache
                List <DepartmentModel> deptList = (List <DepartmentModel>)DanpheCache.GetMasterData(MasterDataEnum.Department);
                //search in the departmentlist
                List <DepartmentModel> filteredList = new List <DepartmentModel>();

                if (string.IsNullOrEmpty(inputValue))
                {
                    //when the request is coming from appointment, we've to return only those values where IsAppointmentApplicable=true.
                    if (reqType == "appointment")
                    {
                        filteredList = (from d in deptList
                                        where d.IsAppointmentApplicable == true
                                        select d).ToList();
                    }
                    else
                    {
                        filteredList = deptList;
                    }
                }
                else
                {
                    filteredList = (from d in deptList
                                    where d.DepartmentName.ToLower().Contains(inputValue.ToLower())
                                    select d).ToList();
                }

                //add into DanpheHTTPResponse format.
                var formatedResult = new DanpheHTTPResponse <List <DepartmentModel> >()
                {
                    Results = filteredList, Status = "OK"
                };
                returnValue = DanpheJSONConvert.SerializeObject(formatedResult, true);
                return(returnValue);
            }
            // this is used to get the CountrySubDivision to countryId
            else if (type == "GetCountrySubDivision")
            {
                MasterDbContext dbMaster = new MasterDbContext(connString);
                List <CountrySubDivisionModel> CountrySubDivision = new List <CountrySubDivisionModel>();
                //if countryId == 0 then bring all the CountrySubDivision from the CountrySubDivision table
                //else bring accroding to the countryId given
                if (countryId == 0)
                {
                    //filtering isactive records only--needs revision: sud 12apr'18
                    CountrySubDivision = (from s in dbMaster.CountrySubDivision
                                          where s.IsActive == true
                                          select s).ToList();
                }
                else
                {
                    //filtering isactive records only--needs revision: sud 12apr'18
                    CountrySubDivision = (from SubDivision in dbMaster.CountrySubDivision
                                          select SubDivision).Where(s => s.CountryId == countryId && s.IsActive == true).ToList();
                }
                var formatedResult = new DanpheHTTPResponse <List <CountrySubDivisionModel> >()
                {
                    Results = CountrySubDivision, Status = "OK"
                };
                returnValue = DanpheJSONConvert.SerializeObject(formatedResult, true);
            }
            else if (type == "get-countries")
            {
                MasterDbContext     dbMaster = new MasterDbContext(connString);
                List <CountryModel> Country  = new List <CountryModel>();
                Country = (from country in dbMaster.Country
                           where country.IsActive == true
                           select country).ToList();
                var formatedResult = new DanpheHTTPResponse <List <CountryModel> >()
                {
                    Results = Country, Status = "OK"
                };
                returnValue = DanpheJSONConvert.SerializeObject(formatedResult, true);
            }
            else if (type == "departmentByEmployeeId")
            {
                //get the value from danphecache
                List <DepartmentModel> deptList         = (List <DepartmentModel>)DanpheCache.GetMasterData(MasterDataEnum.Department);
                List <EmployeeModel>   empListFromCache = (List <EmployeeModel>)DanpheCache.GetMasterData(MasterDataEnum.Employee);
                DepartmentModel        department       = (from d in deptList
                                                           join e in empListFromCache on d.DepartmentId equals e.DepartmentId
                                                           where e.EmployeeId == employeeId
                                                           select d).FirstOrDefault();
                //search in the departmentlist

                //add into DanpheHTTPResponse format.
                var formatedResult = new DanpheHTTPResponse <DepartmentModel>()
                {
                    Results = department, Status = "OK"
                };
                returnValue = DanpheJSONConvert.SerializeObject(formatedResult, true);
                return(returnValue);
            }
            else if (type == "departmentemployee")
            {
                List <EmployeeModel> empListFromCache = (List <EmployeeModel>)DanpheCache.GetMasterData(MasterDataEnum.Employee);
                List <EmployeeModel> filteredList     = new List <EmployeeModel>();
                string status = string.Empty;

                if (string.IsNullOrEmpty(inputValue) || inputValue == "0")
                {
                    //if request has come from appointment, only provide those employees where appointment is applicable .
                    //else return all employees.
                    if (reqType == "appointment")
                    {
                        // List<DepartmentModel> allDeptsFromCache = (List<DepartmentModel>)DanpheCache.GetMasterData(MasterDataEnum.Department);
                        //sud: 15Jun'18 -- removed departmentjoin as IsAppointmentApplicable field is now added in Employee Level as well.
                        //List<EmployeeModel> apptEmployees = (from e in empListFromCache
                        //                                     join d in allDeptsFromCache
                        //                                     on e.DepartmentId equals d.DepartmentId
                        //                                     where d.IsAppointmentApplicable == true
                        //                                     select e
                        //                     ).ToList();

                        List <EmployeeModel> apptEmployees = empListFromCache.Where(emp => emp.IsAppointmentApplicable.HasValue &&
                                                                                    emp.IsAppointmentApplicable == emp.IsActive == true).ToList();

                        filteredList = apptEmployees;
                    }
                    else
                    {
                        filteredList = empListFromCache;
                    }


                    status = "OK";
                }
                else
                {
                    //inputValue should be integer, else it'll crash.

                    int deptId = 0;
                    if (int.TryParse(inputValue, out deptId))
                    {
                        filteredList = (from e in empListFromCache
                                        where e.DepartmentId == deptId
                                        select e).ToList <EmployeeModel>();
                        status = "OK";
                    }
                    else
                    {
                        status = "Failed";
                    }
                }

                var formattedList = new DanpheHTTPResponse <List <EmployeeModel> >()
                {
                    Results = filteredList, Status = status
                };
                returnValue = DanpheJSONConvert.SerializeObject(formattedList, true);
                return(returnValue);
            }

            //used in lab-signature component and radiology component and can be used wherever required in future [Reusable]
            else if (type == "signatories") //changed
            {
                List <DepartmentModel> deptList         = (List <DepartmentModel>)DanpheCache.GetMasterData(MasterDataEnum.Department);
                List <EmployeeModel>   empListFromCache = (List <EmployeeModel>)DanpheCache.GetMasterData(MasterDataEnum.Employee);
                List <EmployeeModel>   filteredList     = new List <EmployeeModel>();

                MasterDbContext dbMaster     = new MasterDbContext(connString);
                var             doctorRoleId = (from master in dbMaster.EmployeeRole
                                                where master.EmployeeRoleName.ToLower() == "doctor"
                                                select master.EmployeeRoleId).FirstOrDefault();

                if (departmentName.ToLower() == "lab")
                {
                    filteredList = (from emp in empListFromCache
                                    join dept in deptList on emp.DepartmentId equals dept.DepartmentId
                                    where (dept.DepartmentName.ToLower() == "lab" || dept.DepartmentName.ToLower() == "pathology") &&
                                    emp.IsActive == true
                                    select emp).OrderBy(e => e.DisplaySequence).ToList();
                }
                else
                {
                    filteredList = (from emp in empListFromCache
                                    join dept in deptList on emp.DepartmentId equals dept.DepartmentId
                                    where dept.DepartmentName.ToLower() == departmentName.ToLower() && emp.EmployeeRoleId == doctorRoleId &&
                                    emp.IsActive == true  //sud:1Jun'19--take only active employees.
                                    select emp).OrderBy(e => e.DisplaySequence).ToList();
                }
                var formattedList = new DanpheHTTPResponse <List <EmployeeModel> >()
                {
                    Results = filteredList, Status = "OK"
                };
                returnValue = DanpheJSONConvert.SerializeObject(formattedList, true);
                return(returnValue);
            }
            else if (type == "icdcode")
            {
                //get the value from danphecache
                List <ICD10CodeModel> icdListFrmCache = (List <ICD10CodeModel>)DanpheCache.GetMasterData(MasterDataEnum.ICD10);

                //search in the departmentlist
                List <ICD10CodeModel> filteredList = new List <ICD10CodeModel>();
                if (string.IsNullOrEmpty(inputValue))
                {
                    filteredList = icdListFrmCache;
                }
                else
                {
                    filteredList = (from d in icdListFrmCache
                                    //add
                                    where d.ICD10Description.ToLower().Contains(inputValue.ToLower()) ||
                                    d.ICD10Code.ToLower().Contains(inputValue.ToLower())
                                    select d).ToList();
                }

                //add into DanpheHTTPResponse format.
                var formatedResult = new DanpheHTTPResponse <List <ICD10CodeModel> >()
                {
                    Results = filteredList, Status = "OK"
                };
                returnValue = DanpheJSONConvert.SerializeObject(formatedResult, true);
                return(returnValue);
            }

            else if (type == "employee")
            {
                //get the value from danphecache
                List <EmployeeModel> employeeFrmCache = (List <EmployeeModel>)DanpheCache.GetMasterData(MasterDataEnum.Employee);

                //search in the departmentlist
                List <EmployeeModel> filteredList = new List <EmployeeModel>();
                if (string.IsNullOrEmpty(inputValue))
                {
                    filteredList = employeeFrmCache;
                }
                else
                {
                    filteredList = (from e in employeeFrmCache
                                    //add
                                    where (e.FirstName.ToLower().Contains(inputValue.ToLower()) ||
                                           e.LastName.ToLower().Contains(inputValue.ToLower()))
                                    select e).ToList();
                }

                //add into DanpheHTTPResponse format.
                var formatedResult = new DanpheHTTPResponse <List <EmployeeModel> >()
                {
                    Results = filteredList, Status = "OK"
                };
                returnValue = DanpheJSONConvert.SerializeObject(formatedResult, true);
            }

            else if (type == "medicine")
            {
                //get the value from danphecache
                List <PHRMItemMasterModel> medicineFrmCache = (List <PHRMItemMasterModel>)DanpheCache.GetMasterData(MasterDataEnum.Medicine);

                //search in the departmentlist
                List <PHRMItemMasterModel> filteredList = new List <PHRMItemMasterModel>();
                if (string.IsNullOrEmpty(inputValue))
                {
                    filteredList = medicineFrmCache;
                }
                else
                {
                    filteredList = (from m in medicineFrmCache
                                    where m.ItemName.ToLower().Contains(inputValue.ToLower())
                                    select m).ToList();
                }

                //add into DanpheHTTPResponse format.
                var formatedResult = new DanpheHTTPResponse <List <PHRMItemMasterModel> >()
                {
                    Results = filteredList, Status = "OK"
                };
                returnValue = DanpheJSONConvert.SerializeObject(formatedResult, true);
            }

            else if (type == "reaction")
            {
                //get the value from danphecache
                List <ReactionModel> reactionFrmCache = (List <ReactionModel>)DanpheCache.GetMasterData(MasterDataEnum.Reaction);

                //search in the departmentlist
                List <ReactionModel> filteredList = new List <ReactionModel>();
                if (string.IsNullOrEmpty(inputValue))
                {
                    filteredList = reactionFrmCache;
                }
                else
                {
                    //search in both reactinname as well as reactioncode.
                    filteredList = (from r in reactionFrmCache
                                    where r.ReactionName.ToLower().Contains(inputValue.ToLower()) ||
                                    r.ReactionCode.ToLower().Contains(inputValue.ToLower())
                                    select r).ToList();
                }

                //add into DanpheHTTPResponse format.
                var formatedResult = new DanpheHTTPResponse <List <ReactionModel> >()
                {
                    Results = filteredList, Status = "OK"
                };
                returnValue = DanpheJSONConvert.SerializeObject(formatedResult, true);
            }
            else if (type == "imagingitem")
            {
                //get the value from danphecache
                List <RadiologyImagingItemModel> imagingitemFrmCache = (List <RadiologyImagingItemModel>)DanpheCache.GetMasterData(MasterDataEnum.ImagingItems);

                //search in the departmentlist
                List <RadiologyImagingItemModel> filteredList = new List <RadiologyImagingItemModel>();
                string status = string.Empty;
                if (string.IsNullOrEmpty(inputValue) || inputValue == "0")
                {
                    filteredList = imagingitemFrmCache;
                }
                else
                {
                    int typeId = 0;
                    if (int.TryParse(inputValue, out typeId))
                    {
                        filteredList = (from i in imagingitemFrmCache
                                        where (i.ImagingTypeId == typeId)
                                        select i).ToList();
                        status = "OK";
                    }
                    else
                    {
                        status = "Failed";
                    }
                }
                var formattedList = new DanpheHTTPResponse <List <RadiologyImagingItemModel> >()
                {
                    Results = filteredList, Status = status
                };
                returnValue = DanpheJSONConvert.SerializeObject(formattedList, true);
                return(returnValue);
            }
            else if (type == "GetWards")
            {
                MasterDbContext  dbMaster = new MasterDbContext(connString);
                List <WardModel> wardList = new List <WardModel>();

                wardList = (from ward in dbMaster.Ward
                            select ward).ToList();

                var formatedResult = new DanpheHTTPResponse <List <WardModel> >()
                {
                    Results = wardList, Status = "OK"
                };
                returnValue = DanpheJSONConvert.SerializeObject(formatedResult, true);
            }
            else if (type == "AllMasters")
            {
                List <ServiceDepartmentModel> srvDeptList = (List <ServiceDepartmentModel>)DanpheCache.GetMasterData(MasterDataEnum.ServiceDepartment);
                List <DepartmentModel>        departments = (List <DepartmentModel>)DanpheCache.GetMasterData(MasterDataEnum.Department);
                List <TaxModel>     taxes = (List <TaxModel>)DanpheCache.GetMasterData(MasterDataEnum.Taxes);
                UniquePastDataModel allPastPatUniqueData = (UniquePastDataModel)DanpheCache.GetMasterData(MasterDataEnum.PastUniqueData);
                //Add other master tables if they need to be loaded at the beginning

                var srvDpts = FormatServiceDepts(srvDeptList, departments);

                var masters = new { ServiceDepartments = srvDpts, Departments = departments, Taxes = taxes, UniqueDataList = allPastPatUniqueData };
                responseData.Results = masters;
                responseData.Status  = "OK";
                returnValue          = DanpheJSONConvert.SerializeObject(responseData, true);
            }



            //else if (type == "GetBedFeatures")
            //{
            //    MasterDbContext dbMaster = new MasterDbContext(connString);
            //    List<BedTypeModel> bedTypeList = new List<BedTypeModel>();
            //    if (wardId != 0)
            //    {
            //        bedTypeList = (from bedType in dbMaster.BedType
            //                       join bed in dbMaster.Bed on bedType.BedTypeId equals bed.BedTypeId
            //                       where bed.WardId == wardId
            //                       select bedType).Distinct().ToList();
            //    }
            //    var formatedResult = new DanpheHTTPResponse<List<BedTypeModel>>() { Results = bedTypeList, Status = "OK" };
            //    returnValue = DanpheJSONConvert.SerializeObject(formatedResult, true);
            //}
            //else if (type == "GetAvailableBeds")
            //{
            //    MasterDbContext dbMaster = new MasterDbContext(connString);
            //    List<BedModel> bedList = new List<BedModel>();
            //    if (wardId != 0 && bedTypeId != 0)
            //    {
            //        bedList = (from bed in dbMaster.Bed
            //                   where bed.BedTypeId == bedTypeId && bed.WardId == wardId && bed.IsOccupied == false
            //                   select bed).ToList();
            //    }
            //    var formatedResult = new DanpheHTTPResponse<List<BedModel>>() { Results = bedList, Status = "OK" };
            //    returnValue = DanpheJSONConvert.SerializeObject(formatedResult, true);
            //}

            return(returnValue);
        }