Exemple #1
0
        public IActionResult DrugStoreNurseRegister_pvDoctorInfo(int doctorId)
        {
            var doc          = _db.vwCHIS_Code_Doctor.AsNoTracking().FirstOrDefault(m => m.DoctorId == doctorId);
            var cus          = _db.CHIS_Code_Customer.AsNoTracking().FirstOrDefault(m => m.CustomerID == doc.CustomerId);
            var dep          = _db.vwCHIS_Code_Rel_DoctorDeparts.AsNoTracking().Where(m => m.DoctorId == doc.DoctorId).OrderBy(m => m.StationID).ToList();
            var stationRoles = _db.CHIS_Sys_Rel_DoctorStationRoles.AsNoTracking().Where(m => m.DoctorId == doc.DoctorId).OrderBy(m => m.StationId).ToList();

            var roleids = stationRoles.Select(m => m.RoleId.Value).Distinct().ToList();
            var roles   = _db.CHIS_SYS_Role.AsNoTracking().Where(m => roleids.Contains(m.RoleID)).Select(m => new RoleItem
            {
                RoleId   = m.RoleID,
                RoleKey  = m.RoleKey,
                RoleName = m.RoleName
            }).ToList();

            var stationids = stationRoles.Where(m => m.MyStationIsEnable == true).Select(m => m.StationId.Value).Distinct().ToList();

            //stationids.AddRange(stationRoles.Select(m => m.StationId.Value).Distinct());
            stationids = stationids.Distinct().ToList();
            var stations = _db.CHIS_Code_WorkStation.AsNoTracking().Where(m => stationids.Contains(m.StationID)).ToList();

            var model = new Models.ViewModel.DoctorInfo
            {
                Doctor   = doc,
                Customer = cus
            };

            model.InitialStationInfo(dep, stationRoles, roles, stations);
            return(PartialView("DrugStoreNurseRegister_pvDoctorInfo", model));
        }
        private IEnumerable <Models.ViewModel.DoctorStationInfo> GetDoctorStationInfo(int doctorId, int rootStationId)
        {
            var doc          = _db.vwCHIS_Code_Doctor.AsNoTracking().FirstOrDefault(m => m.DoctorId == doctorId);
            var cus          = _db.CHIS_Code_Customer.AsNoTracking().FirstOrDefault(m => m.CustomerID == doc.CustomerId);
            var dep          = _db.vwCHIS_Code_Rel_DoctorDeparts.AsNoTracking().Where(m => m.DoctorId == doc.DoctorId).OrderBy(m => m.StationID).ToList();
            var stationRoles = _db.CHIS_Sys_Rel_DoctorStationRoles.AsNoTracking().Where(m => m.DoctorId == doc.DoctorId).OrderBy(m => m.StationId).ToList();

            var roleids = stationRoles.Select(m => m.RoleId.Value).Distinct().ToList();
            var roles   = _db.CHIS_SYS_Role.AsNoTracking().Where(m => roleids.Contains(m.RoleID)).Select(m => new RoleItem
            {
                RoleId   = m.RoleID,
                RoleKey  = m.RoleKey,
                RoleName = m.RoleName
            }).ToList();

            var allowStations = UserMgr.GetAllowedStationsAndSubStationsQuery(_db, doctorId, rootStationId).ToList();
            var stationids    = stationRoles.Where(m => m.MyStationIsEnable == true).Select(m => m.StationId.Value).Distinct().ToList();

            //  stationids.AddRange(stationRoles.Select(m => m.StationId.Value).Distinct());
            stationids = (from item in stationids.Distinct()
                          where allowStations.Contains(item)
                          select item).ToList();
            var stations = _db.CHIS_Code_WorkStation.AsNoTracking().Where(m => stationids.Contains(m.StationID)).ToList();

            var model = new Models.ViewModel.DoctorInfo
            {
                Doctor   = doc,
                Customer = cus
            };

            model.InitialStationInfo(dep, stationRoles, roles, stations);
            return(model.StationInfos);
        }