Exemple #1
0
        private static void GetMacroSource(string patid, string userid)
        {
            try
            {
                //取得地址的那个取值方式 add by ywk 2012年8月3日 13:47:33
                //string isreadaddress = GetConfigValueByKey("EmrInputConfig");
                //XmlDocument doc1 = new XmlDocument();
                //doc1.LoadXml(isreadaddress);
                //string ReadAddress = doc1.GetElementsByTagName("IsReadAddressInfo")[0].InnerText;

                _macroSource = new Dictionary <string, DataRow>();
                HFDate hf = new HFDate();
                foreach (DataRow row in Macros.Rows)
                {
                    Macro     mac  = new Macro(row);
                    DataTable data = null;
                    if (!_macroSource.ContainsKey(mac.D_Table))
                    {
                        //此处做一下特殊处理,如果是inpatient 表则传入病人首页序号
                        if (mac.D_Table.Equals("INPATIENT"))
                        {
                            SqlParameter para = new SqlParameter("@NoOfinpat", SqlDbType.VarChar);
                            para.Value = patid;

                            m_PatID = patid;

                            data = DataAccessFactory.DefaultDataAccess.ExecuteDataTable("USP_EMR_GETPATINFO", new SqlParameter[] { para }, CommandType.StoredProcedure);
                            DataTable newDT = new DataTable();
                            if (data.Rows.Count > 0 && data.Rows[0]["isbaby"].ToString() == "1") //如果是婴儿,就把住院号,换成他母亲的 eidt by ywk 2012年11月23日15:53:27
                            {
                                string mother = data.Rows[0]["mother"].ToString();               //取得母亲的首页序号
                                newDT = DataAccessFactory.DefaultDataAccess.ExecuteDataTable(string.Format(@"select patid from inpatient
                            where noofinpat='{0}'", mother), CommandType.Text);
                                if (newDT != null && newDT.Rows.Count > 0)
                                {
                                    data.Rows[0]["patid"] = newDT.Rows[0]["patid"].ToString();//值替换为他母亲的号!
                                }
                            }

                            if (data.Rows.Count > 0)
                            {
                                DateTime dt    = Convert.ToDateTime(data.Rows[0]["jieqi"].ToString());
                                string   jieqi = hf.GetSolarTermInfo(dt);
                                data.Rows[0]["jieqi"] = jieqi;
                                _macroSource.Add(mac.D_Table, data.Rows[0]);
                            }
                        }
                        else if (mac.D_Table.Equals("INPATIENT_CLINIC"))
                        {
                            SqlParameter para = new SqlParameter("@NoOfinpat", SqlDbType.VarChar);
                            para.Value = patid;

                            m_PatID = patid;

                            data = DataAccessFactory.DefaultDataAccess.ExecuteDataTable("PATIENT_INFO.USP_INPATIENT_CLINIC", new SqlParameter[] { para }, CommandType.StoredProcedure);
                            //data = DataAccessFactory.DefaultDataAccess.ExecuteDataTable("PATIENT_INFO.usp_xml_content", new SqlParameter[] { para }, CommandType.StoredProcedure);
                            if (data.Rows.Count > 0)
                            {
                                _macroSource.Add(mac.D_Table, data.Rows[0]);
                            }
                        }
                        else if (mac.D_Table.Equals("CURRENTUSER")) //得到当前用户信息的宏
                        {
                            string sqlGetUser = @"select users.id userid, (case b.name||'/' when  '/' then users.name  else  b.name||'/'||users.name end)  username,a.masterid,b.name||'/' mastername, users.deptid userdeptid, users.wardid userwardid, department.name userdeptname, ward.name userwardname
                                                from users
                                                left outer join department on department.id = users.deptid and department.valid = '1'
                                                left outer join ward on ward.id = users.wardid and ward.valid = '1'
                                                left join tempusers a on users.id=a.userid
                                                left join users b on a.masterid=b.id
                                                where users.id = '{0}' and users.valid = '1'";
                            data = DataAccessFactory.DefaultDataAccess.ExecuteDataTable(string.Format(sqlGetUser, userid));
                            if (data.Rows.Count > 0)
                            {
                                _macroSource.Add(mac.D_Table, data.Rows[0]);
                            }
                        }
                        else
                        {
                            if (string.IsNullOrEmpty(mac.D_Sql))
                            {
                                continue;
                            }
                            data = DataAccessFactory.DefaultDataAccess.ExecuteDataTable(mac.D_Sql);
                            if (data.Rows.Count > 0)
                            {
                                _macroSource.Add(mac.D_Table, data.Rows[0]);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MyMessageBox.Show("MacroUtil.GetMacroSource:" + ex.Message);
            }
        }