Ejemplo n.º 1
0
        /// <summary>
        /// 根据登陆人科室权限查询未归档病人
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>
        public static string GetAllUnRebackRecordsByDeptRights(string userid)
        {
            try
            {
                if (string.IsNullOrEmpty(userid))
                {
                    return("");
                }
                string deptStr = string.Empty;
                if (userid != "00")
                {
                    List <string[]> list = DS_BaseService.GetDeptAndWardInRight(userid);
                    if (null != list && list.Count() > 0)
                    {
                        deptStr = DS_Common.CombineSQLStringByList(list.Select(p => p[0]).ToList());
                    }
                }
                //修改语句 更据病人表查询未归档病人 无需更据病历表
                string sqlStr = @"select distinct a.patid, a.noofinpat, a.NAME patname, a.PY, a.WB, a.sexid sex,a.agestr, b.NAME sexname, a.outbed bedid, trim(c.Name) admitdeptname, trim(d.name) outdeptname, substr(a.admitdate, 1, 16) as admitdate,substr(a.inwarddate, 1, 16) as inwarddate
   from inpatient a  LEFT JOIN inpatientchangeinfo i on i.noofinpat = a.noofinpat  LEFT JOIN dictionary_detail b   ON b.detailid = a.sexid and b.categoryid = '3'
  LEFT JOIN department c  ON a.admitdept = c.id
  LEFT JOIN department d ON a.outhosdept = d.id
 where (a.islock=4700 or a.islock=4702 or a.islock is null) ";

                deptStr = string.IsNullOrEmpty(deptStr) ? ("'" + DS_Common.currentUser.CurrentDeptId + "'") : deptStr;
                List <string> jobList = DS_BaseService.GetRolesByUserID(userid);
                if (null == jobList || jobList.Count() == 0 || (!jobList.Contains("66") && !jobList.Contains("111")))
                {
                    sqlStr += " and (i.newdeptid in(" + deptStr + ") or a.outhosdept in(" + deptStr + ")) ";// " and a.outhosdept in(" + (string.IsNullOrEmpty(deptStr) ? YD_Common.currentUser.CurrentDeptId : deptStr) + ") ";
                }
                sqlStr += " order by admitdeptname asc,admitdate desc,inwarddate desc ";

                return(sqlStr);
            }
            catch (Exception ex)
            {
                throw new Exception("GetAllUnRebackRecordsByDeptRights" + ex.Message);
            }
        }
Ejemplo n.º 2
0
        private void InitForm()
        {
            try
            {
                ///是否为补写病历入口且为补写管理员
                bool IsWriteAdmin = false;
                if (floaderState == FloderState.NoneAudit)
                {
                    List <string> jobList = DS_BaseService.GetRolesByUserID(DS_Common.currentUser.Id);
                    IsWriteAdmin = jobList.Contains("00") || jobList.Contains("111");
                }

                //通过首页序号获得病人所待过的科室
                DataTable dt = GetDeptByNoofinpat(m_Noofinpat);
                //获取当前登录人有权限的科室
                DataTable dtUser2Dept = GetUser2Dept();

                if (m_IsNeedFilter && !IsWriteAdmin)
                {
                    //保留登录人当前科室和登录人有权限的科室
                    var dtRows = dt.AsEnumerable().Where(dr =>
                    {
                        string deptid        = dr["deptid"].ToString();
                        string wardid        = dr["wardid"].ToString();
                        string currentDeptID = DS_Common.currentUser.CurrentDeptId;
                        string currentWardID = DS_Common.currentUser.CurrentWardId;
                        if (currentDeptID == deptid && currentWardID == wardid)
                        {
                            return(true);
                        }
                        if (dtUser2Dept.Rows.Cast <DataRow>().Where(drUser2Dept =>
                        {
                            string drDeptid = drUser2Dept["deptid"].ToString();
                            string drWardid = drUser2Dept["wardid"].ToString();
                            if (deptid == drDeptid && wardid == drWardid)
                            {
                                return(true);
                            }
                            return(false);
                        }).Count() > 0)
                        {
                            return(true);
                        }
                        return(false);
                    });
                    if (null != dtRows && dtRows.Count() > 0)
                    {
                        dt = dtRows.CopyToDataTable();
                    }
                    else
                    {
                        dt = dt.Clone();
                    }
                }

                ///如果左侧菜单科室没显示,则选择框也不显示
                if (null != m_DeptModelList && m_DeptModelList.Count > 0)
                {
                    var changIDs = m_DeptModelList.Select(p => p.ChangeID);
                    var newRows  = dt.AsEnumerable().Where(p => changIDs.Contains(p["id"].ToString()));
                    dt = (null != newRows && newRows.Count() > 0) ? newRows.CopyToDataTable() : dt.Clone();
                }
                gridControlDept.DataSource = dt;

                gridViewDept.FocusedRowHandle = dt.Rows.Count - 1;
                if (dt.Rows.Count == 1)
                {
                    Commit();
                    IsNeedShow        = false;
                    this.DialogResult = DialogResult.Yes;
                }
                else if (dt.Rows.Count == 0)
                {
                    this.DialogResult = DialogResult.No;
                    return;
                }
            }
            catch (Exception ex)
            {
                MyMessageBox.Show(1, ex);
            }
        }