Ejemplo n.º 1
0
        public short Insert(RecPack RecPack)
        {
            if (RecPack == null)
            {
                LogManager.Instance.WriteLog("", new string[] { "" }
                                             , new object[] { RecPack }, "参数不能为空");
                return(SystemData.ReturnValue.PARAM_ERROR);
            }
            if (RecPack.PACK_ID == string.Empty)
            {
                return(SystemData.ReturnValue.EXCEPTION);
            }
            StringBuilder sbField = new StringBuilder();
            StringBuilder sbValue = new StringBuilder();

            sbField.AppendFormat("{0},", SystemData.RecPackTable.CASE_NO);
            sbValue.AppendFormat("'{0}',", RecPack.CASE_NO);
            sbField.AppendFormat("{0},", SystemData.RecPackTable.DISCHARGE_TIME);
            sbValue.AppendFormat("{0},", base.MedQCAccess.GetSqlTimeFormat(RecPack.DISCHARGE_TIME));
            sbField.AppendFormat("{0},", SystemData.RecPackTable.HOSPITAL_DISTRICT);
            sbValue.AppendFormat("'{0}',", RecPack.HOSPITAL_DISTRICT);
            sbField.AppendFormat("{0},", SystemData.RecPackTable.PACKER);
            sbValue.AppendFormat("'{0}',", RecPack.PACKER);
            sbField.AppendFormat("{0},", SystemData.RecPackTable.PACKER_ID);
            sbValue.AppendFormat("'{0}',", RecPack.PACKER_ID);
            sbField.AppendFormat("{0},", SystemData.RecPackTable.PACK_ID);
            sbValue.AppendFormat("{0},", RecPack.PACK_ID);
            sbField.AppendFormat("{0},", SystemData.RecPackTable.PACK_NO);
            sbValue.AppendFormat("'{0}',", RecPack.PACK_NO);
            sbField.AppendFormat("{0},", SystemData.RecPackTable.PACK_TIME);
            sbValue.AppendFormat("{0},", base.MedQCAccess.GetSqlTimeFormat(RecPack.PACK_TIME));
            sbField.AppendFormat("{0},", SystemData.RecPackTable.PAPER_NUMBER);
            sbValue.AppendFormat("{0},", RecPack.PAPER_NUMBER);
            sbField.AppendFormat("{0},", SystemData.RecPackTable.PATIENT_ID);
            sbValue.AppendFormat("'{0}',", RecPack.PATIENT_ID);
            sbField.AppendFormat("{0},", SystemData.RecPackTable.PATIENT_NAME);
            sbValue.AppendFormat("'{0}',", RecPack.PATIENT_NAME);
            sbField.AppendFormat("{0},", SystemData.RecPackTable.VISIT_ID);
            sbValue.AppendFormat("'{0}',", RecPack.VISIT_ID);
            sbField.AppendFormat("{0}", SystemData.RecPackTable.VISIT_NO);
            sbValue.AppendFormat("'{0}'", RecPack.VISIT_NO);
            string szSQL  = string.Format(SystemData.SQL.INSERT, SystemData.DataTable.REC_PACK, sbField.ToString(), sbValue.ToString());
            int    nCount = 0;

            try
            {
                nCount = base.MedQCAccess.ExecuteNonQuery(szSQL, CommandType.Text);
            }
            catch (Exception ex)
            {
                LogManager.Instance.WriteLog("", new string[] { "szSQL" }, new object[] { szSQL }, ex);
                return(SystemData.ReturnValue.EXCEPTION);
            }
            if (nCount <= 0)
            {
                LogManager.Instance.WriteLog("", new string[] { "szSQL" }, new object[] { szSQL }, "SQL语句执行后返回0!");
                return(SystemData.ReturnValue.EXCEPTION);
            }
            return(SystemData.ReturnValue.OK);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 生成包号
        /// </summary>
        /// <returns></returns>
        public string MakePackNo()
        {
            //取工号,每个工号起始数字不同
            int nBegin = 0;

#if DEBUG
            nBegin = 1000;
#endif
            string szUserID = SystemParam.Instance.UserInfo.USER_ID;
            //从数据库获得最新包号,然后加1
            List <RecPack> lstRecPacks = new List <RecPack>();
            short          shRet       = RecPackAccess.Instance.GetRecPacks(szUserID, ref lstRecPacks);
            if (lstRecPacks != null && lstRecPacks.Count > 0)
            {
                RecPack recPack = lstRecPacks.OrderByDescending(m => m.PACK_NO).First();
                nBegin = int.Parse(recPack.PACK_NO) + 1;
                return(nBegin.ToString());
            }
            return(nBegin.ToString());
        }
Ejemplo n.º 3
0
        public short GetRecPacks(string szPatientID, string szVisitNo, ref List <RecPack> lstRecPacks)
        {
            if (base.MedQCAccess == null)
            {
                return(SystemData.ReturnValue.PARAM_ERROR);
            }
            StringBuilder sbField = new StringBuilder();

            sbField.AppendFormat("{0},", SystemData.RecPackTable.CASE_NO);
            sbField.AppendFormat("{0},", SystemData.RecPackTable.DISCHARGE_TIME);
            sbField.AppendFormat("{0},", SystemData.RecPackTable.HOSPITAL_DISTRICT);
            sbField.AppendFormat("{0},", SystemData.RecPackTable.PACKER);
            sbField.AppendFormat("{0},", SystemData.RecPackTable.PACKER_ID);
            sbField.AppendFormat("{0},", SystemData.RecPackTable.PACK_NO);
            sbField.AppendFormat("{0},", SystemData.RecPackTable.PACK_ID);
            sbField.AppendFormat("{0},", SystemData.RecPackTable.PACK_TIME);
            sbField.AppendFormat("{0},", SystemData.RecPackTable.PATIENT_ID);
            sbField.AppendFormat("{0},", SystemData.RecPackTable.PATIENT_NAME);
            sbField.AppendFormat("{0},", SystemData.RecPackTable.VISIT_ID);
            sbField.AppendFormat("{0},", SystemData.RecPackTable.VISIT_NO);
            sbField.AppendFormat("{0}", SystemData.RecPackTable.PAPER_NUMBER);
            string szCondition = string.Format("1=1");

            szCondition = string.Format("{0} AND {1} = '{2}' AND {3} = '{4}'"
                                        , szCondition
                                        , SystemData.RecPackTable.PATIENT_ID, szPatientID
                                        , SystemData.RecPackTable.VISIT_NO, szVisitNo);
            string szSQL = string.Format(SystemData.SQL.SELECT_WHERE
                                         , sbField.ToString(), SystemData.DataTable.REC_PAPER, szCondition);

            IDataReader dataReader = null;

            try
            {
                dataReader = base.MedQCAccess.ExecuteReader(szSQL, CommandType.Text);
                if (dataReader == null || dataReader.IsClosed || !dataReader.Read())
                {
                    return(SystemData.ReturnValue.RES_NO_FOUND);
                }
                if (lstRecPacks == null)
                {
                    lstRecPacks = new List <RecPack>();
                }
                do
                {
                    RecPack RecPack = new RecPack();
                    for (int i = 0; i < dataReader.FieldCount; i++)
                    {
                        if (dataReader.IsDBNull(i))
                        {
                            continue;
                        }
                        switch (dataReader.GetName(i))
                        {
                        case SystemData.RecPackTable.CASE_NO:
                            RecPack.CASE_NO = dataReader.GetString(i);
                            break;

                        case SystemData.RecPackTable.DISCHARGE_TIME:
                            RecPack.DISCHARGE_TIME = dataReader.GetDateTime(i);
                            break;

                        case SystemData.RecPackTable.HOSPITAL_DISTRICT:
                            RecPack.HOSPITAL_DISTRICT = dataReader.GetString(i);
                            break;

                        case SystemData.RecPackTable.PACKER:
                            RecPack.PACKER = dataReader.GetString(i);
                            break;

                        case SystemData.RecPackTable.PACKER_ID:
                            RecPack.PACKER_ID = dataReader.GetString(i);
                            break;

                        case SystemData.RecPackTable.PACK_ID:
                            RecPack.PACK_ID = dataReader.GetString(i);
                            break;

                        case SystemData.RecPackTable.PATIENT_ID:
                            RecPack.PATIENT_ID = dataReader.GetString(i);
                            break;

                        case SystemData.RecPackTable.VISIT_ID:
                            RecPack.VISIT_ID = dataReader.GetString(i);
                            break;

                        case SystemData.RecPackTable.VISIT_NO:
                            RecPack.VISIT_NO = dataReader.GetString(i);
                            break;

                        case SystemData.RecPackTable.PACK_NO:
                            RecPack.PACK_NO = dataReader.GetString(i);
                            break;

                        case SystemData.RecPackTable.PACK_TIME:
                            RecPack.PACK_TIME = dataReader.GetDateTime(i);
                            break;

                        case SystemData.RecPackTable.PAPER_NUMBER:
                            RecPack.PAPER_NUMBER = int.Parse(dataReader.GetValue(i).ToString());
                            break;

                        case SystemData.RecPackTable.PATIENT_NAME:
                            RecPack.PATIENT_NAME = dataReader.GetString(i);
                            break;
                        }
                    }
                    lstRecPacks.Add(RecPack);
                } while (dataReader.Read());
                return(SystemData.ReturnValue.OK);
            }
            catch (Exception ex)
            {
                LogManager.Instance.WriteLog("", new string[] { "szSQL" }, new object[] { szSQL }, ex);
                return(SystemData.ReturnValue.EXCEPTION);
            }
            finally { base.MedQCAccess.CloseConnnection(false); }
        }
Ejemplo n.º 4
0
        private void txtDocID_TextChanged(object sender, EventArgs e)
        {
            string       szDocID      = this.txtDocID.Text;
            MedDocInfo   docInfo      = null;
            short        shRet        = EmrDocAccess.Instance.GetDocInfo(szDocID, ref docInfo);
            PatVisitInfo patVisitInfo = null;

            if (docInfo == null)
            {
                string szPatientID = this.txtDocID.Text.Trim();
                List <PatVisitInfo> lstPatVisitInfo = null;
                PatVisitAccess.Instance.GetPatVisitInfos(szPatientID, ref lstPatVisitInfo);
                if (lstPatVisitInfo == null)
                {
                    return;
                }
                patVisitInfo = lstPatVisitInfo.LastOrDefault();
            }
            else
            {
                string szPatientID = docInfo.PATIENT_ID;
                string szVisitNo   = docInfo.VISIT_ID;//文书VisitID存了 VisitNo
                shRet = PatVisitAccess.Instance.GetPatVisit(szPatientID, szVisitNo, ref patVisitInfo);
            }
            if (patVisitInfo == null)
            {
                return;
            }
            if (patVisitInfo != null && patVisitInfo.DISCHARGE_TIME != patVisitInfo.DefaultTime)
            {
                this.txt_DISCHARGE_TIME.Text = patVisitInfo.DISCHARGE_TIME.ToShortDateString();
            }
            this.txt_PATIENT_ID.Text   = docInfo.PATIENT_ID;
            this.txt_PATIENT_NAME.Text = docInfo.PATIENT_NAME;
            this.txt_DEPT_NAME.Text    = docInfo.DEPT_NAME;
            //显示纸质病历列表
            List <MedDocInfo> lstMedDocInfos = null;

            shRet = EmrDocAccess.Instance.GetDocList(patVisitInfo.PATIENT_ID, patVisitInfo.VISIT_NO, ref lstMedDocInfos);
            if (lstMedDocInfos == null)
            {
                return;
            }
            List <RecPaper> lstRecPapers = new List <RecPaper>();

            shRet = RecPaperAccess.Instance.GetRecPapers(patVisitInfo.PATIENT_ID, patVisitInfo.VISIT_NO, ref lstRecPapers);
            string[] arrSignKeyName = DataCache.Instance.DicHdpParameter[SystemData.ConfigKey.SignKeyName].Split('|');
            int      rowIndex       = 0;

            this.dataGridView1.Rows.Clear();
            //张数
            int paperNumber = 0;

            foreach (var item in arrSignKeyName)
            {
                foreach (var doc in lstMedDocInfos)
                {
                    if (doc.DOC_TITLE.Contains(item))
                    {
                        rowIndex = this.dataGridView1.Rows.Add();
                        DataGridViewRow row = this.dataGridView1.Rows[rowIndex];
                        row.Cells[this.colDocTitle.Index].Value   = doc.DOC_TITLE;
                        row.Cells[this.colRecordTime.Index].Value = doc.RECORD_TIME.ToString("yyyy-MM-dd HH:mm");
                        row.Tag = doc;
                        if (lstRecPapers != null && lstRecPapers.Count > 0)
                        {
                            var recPaper = lstRecPapers.Where(m => m.DOC_ID == doc.DOC_ID).FirstOrDefault();
                            if (recPaper != null)
                            {
                                //病历确认接收后才算一张
                                paperNumber++;
                                if (recPaper.PAPER_STATE == SystemData.PaperState.Receive)
                                {
                                    row.Cells[this.colCheckBox.Index].Value = true;
                                }
                                if (!string.IsNullOrEmpty(recPaper.IMAGE_FRONTAGE))
                                {
                                    row.Cells[this.col_IMAGE_FRONTAGE.Index].Value = MedQC.MedRecord.Properties.Resources.docuemt;
                                    row.Cells[this.col_IMAGE_FRONTAGE.Index].Tag   = recPaper.IMAGE_FRONTAGE;
                                }
                                if (!string.IsNullOrEmpty(recPaper.IMAGE_OPPOSITE))
                                {
                                    row.Cells[this.col_IMAGE_OPPOSITE.Index].Value = MedQC.MedRecord.Properties.Resources.docuemt;
                                    row.Cells[this.col_IMAGE_OPPOSITE.Index].Tag   = recPaper.IMAGE_OPPOSITE;
                                }

                                row.Cells[this.colCheckBox.Index].Tag = recPaper;
                            }
                        }
                    }
                }
            }
            //查询是否已存在打包信息
            RecPack recPack = null;

            shRet = RecPackAccess.Instance.GetRecPack(patVisitInfo.PATIENT_ID, patVisitInfo.VISIT_NO, ref recPack);
            if (recPack == null)
            {
                if (this.txt_PACK_NO.Text == string.Empty)
                {
                    MessageBoxEx.ShowMessage("包号未设置");
                    return;
                }
                recPack                   = new RecPack();
                recPack.CASE_NO           = string.Empty;
                recPack.DISCHARGE_TIME    = patVisitInfo.DISCHARGE_TIME;
                recPack.HOSPITAL_DISTRICT = string.Empty;//院区字段不明
                recPack.PACKER            = SystemParam.Instance.UserInfo.USER_NAME;
                recPack.PACKER_ID         = SystemParam.Instance.UserInfo.USER_ID;
                recPack.PACK_ID           = recPack.MakeID();
                recPack.PACK_NO           = this.txt_PACK_NO.Text;
                recPack.PACK_TIME         = SysTimeHelper.Instance.Now;
                recPack.PAPER_NUMBER      = paperNumber;
                recPack.PATIENT_ID        = patVisitInfo.PATIENT_ID;
                recPack.PATIENT_NAME      = patVisitInfo.PATIENT_NAME;
                recPack.VISIT_ID          = patVisitInfo.VISIT_ID;
                recPack.VISIT_NO          = patVisitInfo.VISIT_NO;
                shRet = RecPackAccess.Instance.Insert(recPack);
            }
            else
            {
                recPack.PACK_TIME    = SysTimeHelper.Instance.Now;
                recPack.PACKER       = SystemParam.Instance.UserInfo.USER_NAME;
                recPack.PACKER_ID    = SystemParam.Instance.UserInfo.USER_ID;
                recPack.PAPER_NUMBER = paperNumber;
                shRet = RecPackAccess.Instance.Update(recPack);
                this.txt_PACK_NO.Text = recPack.PACK_NO;
            }
            if (shRet != SystemData.ReturnValue.OK)
            {
                MessageBoxEx.ShowMessage("打包失败");
                return;
            }
            this.lbl_PackResult.Text        = "打包成功";
            this.txt_PACKER.Text            = recPack.PACKER;
            this.lbl_PaperCount.Text        = paperNumber.ToString();
            this.txt_HOSPITAL_DISTRICT.Text = recPack.HOSPITAL_DISTRICT;
            this.CalPaperCount(recPack.PACK_NO);
        }