/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtBoxID.Text.Trim())) { XtraMessageBox.Show(@"请先读取身份信息,再保存信息!", @"提示:", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (PatientInfo_IsExsist(_code.ToString().Trim())) { XtraMessageBox.Show(@"此身份证已存在,请重新填写!", @"提示:", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } var pmMd = new PatientMd { PatientName = txtBoxName.Text.Trim(), PatientID = Guid.NewGuid().ToString(), Gender = (rbtnSexM.Checked?"男":"女"), Birthday = _birDay, Folk = cBoxNational.Text, P_Id = txtBoxID.Text, ExpireStart = _exStart, ExpireEnd = _exEnd, WorkUnits = txtBoxWorkUnits.Text.Trim(), Phone = txtBoxPhone.Text.Trim(), Address = txtBoxRegistrationAddress.Text.Trim(), Levelofeducation = cBoxLevelofeducation.Text, Marriage = cBoxMarriage.Text, PermanentType = cBoxPermanentType.Text, BloodType = cBoxBloodType.Text, SleepStatus = cBoxSleepStatus.Text, PhysicalExercise = cBoxPhysicalExercise.Text, Drinking = cBoxDrinking.Text, Professional = cBoxProfessional.Text, Height = txtBoxHeight.Text.Trim(), Waistline = txtBoxWaistline.Text.Trim(), Hipline = txtBoxHipline.Text.Trim(), Weight = txtBoxWeight.Text.Trim(), DisabilityStatus = (rbtnDisabilityStatusNo.Checked ? "无&" : "有&" + txtBoxDisabilityStatus.Text.Trim()), Allergy = (rbtnAllergyNo.Checked ? "无&" : "有&" + txtBoxAllergy.Text.Trim()), ExposureHistory = (rbtnExposureHistoryNo.Checked ? "无&" : "有&" + txtBoxrExposureHistory.Text.Trim()), DiseasesHistory = (rbtnDiseasesHistoryNo.Checked ? "无&" : "有&" + txtBoxDiseasesHistory.Text.Trim()), OperationHistory = (rbtnOperationHistoryNo.Checked ? "无&" : "有&" + txtBoxOperationHistory.Text.Trim()), RtaumaHistory = (rbtnRtaumaHistoryNo.Checked ? "无&" : "有&" + txtBoxRtaumaHistory.Text.Trim()), TransfusionHistory = (rbtnTransfusionHistoryNo.Checked ? "无&" : "有&" + txtBoxTransfusionHistory.Text.Trim()) }; bool ok = PatientInfo_Add(pmMd); if (ok) { ConfigHelper.PatientId = pmMd.PatientID; ConfigHelper.PatientName = pmMd.PatientName; ConfigHelper.IP = pmMd.P_Id; ConfigHelper.PatientGender = pmMd.Gender; ConfigHelper.PatientAge = (DateTime.Now.Year - DateTime.Parse(_birDay).Year).ToString(); ConfigHelper.AppId = Guid.NewGuid().ToString(); ResetPatientInfo(); DisableControls(true); XtraMessageBox.Show(@"添加成功!", @"提示:", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private PatientMd GetFilterContidition() { var pm = new PatientMd { P_Id = txtID.Text.Trim().Replace("'", "''") }; if (comboBox1.SelectedIndex != 0) { pm.Gender = comboBox1.Text.Trim(); } pm.PatientName = textBox1.Text.Trim().Replace("'", "''"); pm.AgeStart = tbAgeStart.Text; pm.AgeEnd = tbAgeEnd.Text; if (string.IsNullOrEmpty(pm.PatientName)) { pm.CollectionStartDate = dateTimePicker1.Value.ToShortDateString(); pm.ConllectionEndDate = dateTimePicker2.Value.ToShortDateString(); } else { pm.CollectionStartDate = new DateTime(1900, 1, 1).ToShortDateString(); pm.ConllectionEndDate = DateTime.Now.ToShortDateString(); } return(pm); }
/// <summary> /// 添加患者信息 /// </summary> /// <param name="patientMd"></param> /// <returns></returns> public bool PatientInfo_Add(PatientMd patientMd) { try { const string sql = "insert into Tb_PatientInfo (ID,PatientID,PatientName,Gender,Birthday,P_Id,CreateDate,Folk,Address,Agency,ExpireStart,ExpireEnd,DoctorId,WorkUnits,Phone,Levelofeducation,Marriage,PermanentType,BloodType,SleepStatus,Drinking,Professional,PhysicalExercise,Height,Waistline,Hipline,Weight,DisabilityStatus,Allergy,ExposureHistory,DiseasesHistory,OperationHistory,RtaumaHistory,TransfusionHistory)" + "Values(@ID,@PatientID,@PatientName,@Gender,@Birthday,@P_Id,datetime('now', 'localtime'),@Folk,@Address,@Agency,@ExpireStart,@ExpireEnd,@DoctorId,@WorkUnits,@Phone,@Levelofeducation,@Marriage,@PermanentType,@BloodType,@SleepStatus,@Drinking,@Professional,@PhysicalExercise,@Height,@Waistline,@Hipline,@Weight,@DisabilityStatus,@Allergy,@ExposureHistory,@DiseasesHistory,@OperationHistory,@RtaumaHistory,@TransfusionHistory)"; var ls = new List <SQLiteParameter> { new SQLiteParameter("@ID", Guid.NewGuid().ToString()), new SQLiteParameter("@PatientID", patientMd.PatientID), new SQLiteParameter("@PatientName", patientMd.PatientName), new SQLiteParameter("@Gender", patientMd.Gender), new SQLiteParameter("@Birthday", patientMd.Birthday), new SQLiteParameter("@P_Id", patientMd.P_Id), new SQLiteParameter("@Folk", patientMd.Folk), new SQLiteParameter("@Address", patientMd.Address), new SQLiteParameter("@Agency", patientMd.Agency), new SQLiteParameter("@ExpireStart", patientMd.ExpireStart), new SQLiteParameter("@ExpireEnd", patientMd.ExpireEnd), new SQLiteParameter("@DoctorId", ConfigHelper.LoginId), new SQLiteParameter("@WorkUnits", patientMd.WorkUnits), new SQLiteParameter("@Phone", patientMd.Phone), new SQLiteParameter("@Levelofeducation", patientMd.Levelofeducation), new SQLiteParameter("@Marriage", patientMd.Marriage), new SQLiteParameter("@PermanentType", patientMd.PermanentType), new SQLiteParameter("@BloodType", patientMd.BloodType), new SQLiteParameter("@SleepStatus", patientMd.SleepStatus), new SQLiteParameter("@Drinking", patientMd.Drinking), new SQLiteParameter("@Professional", patientMd.Professional), new SQLiteParameter("@PhysicalExercise", patientMd.PhysicalExercise), new SQLiteParameter("@Height", patientMd.Height), new SQLiteParameter("@Waistline", patientMd.Waistline), new SQLiteParameter("@Hipline", patientMd.Hipline), new SQLiteParameter("@Weight", patientMd.Weight), new SQLiteParameter("@DisabilityStatus", patientMd.DisabilityStatus), new SQLiteParameter("@Allergy", patientMd.Allergy), new SQLiteParameter("@ExposureHistory", patientMd.ExposureHistory), new SQLiteParameter("@DiseasesHistory", patientMd.DiseasesHistory), new SQLiteParameter("@OperationHistory", patientMd.OperationHistory), new SQLiteParameter("@RtaumaHistory", patientMd.RtaumaHistory), new SQLiteParameter("@TransfusionHistory", patientMd.TransfusionHistory) }; WatchDog.WriteMsg(DateTime.Now + "==添加患者:" + patientMd.PatientName); _sqlite.ExecuteSql(sql, ls.ToArray()); ls.Clear(); return(true); } catch (Exception ex) { WatchDog.WriteMsg(DateTime.Now + "==添加患者失败:" + patientMd.PatientName + ex.StackTrace); return(false); } }
private void BindPagedData(int index, PatientMd p) { int account = 0; wp.PageIndex = index; DataTable dt = QueryPatients(p, wp.PageSize, wp.PageIndex, ref account); wp.TotalRows = _recordCount; gc_PatientManage.DataSource = dt; _recordCount = account; if (gc_PatientManage.RowCount > 0) { gc_PatientManage.CurrentCell = gc_PatientManage.Rows[_rowIndex].Cells[0]; } }
/// <summary> /// 修改信息 /// </summary> /// <param name="patientMd"></param> /// <returns></returns> public bool PatientInfo_Mod(PatientMd patientMd) { try { const string sql = "update Tb_PatientInfo set WorkUnits=@WorkUnits,Phone=@Phone,Levelofeducation=@Levelofeducation,Marriage=@Marriage,PermanentType=@PermanentType,BloodType=@BloodType,SleepStatus=@SleepStatus,Drinking=@Drinking,Professional=@Professional,PhysicalExercise=@PhysicalExercise,Height=@Height,Waistline=@Waistline,Hipline=@Hipline,Weight=@Weight,DisabilityStatus=@DisabilityStatus,Allergy=@Allergy,ExposureHistory=@ExposureHistory,DiseasesHistory=@DiseasesHistory,OperationHistory=@OperationHistory,RtaumaHistory=@RtaumaHistory,TransfusionHistory=@TransfusionHistory where PatientID=@PatientID"; var ls = new List <SQLiteParameter> { new SQLiteParameter("@PatientID", patientMd.PatientID), new SQLiteParameter("@WorkUnits", patientMd.WorkUnits), new SQLiteParameter("@Phone", patientMd.Phone), new SQLiteParameter("@Levelofeducation", patientMd.Levelofeducation), new SQLiteParameter("@Marriage", patientMd.Marriage), new SQLiteParameter("@PermanentType", patientMd.PermanentType), new SQLiteParameter("@BloodType", patientMd.BloodType), new SQLiteParameter("@SleepStatus", patientMd.SleepStatus), new SQLiteParameter("@Drinking", patientMd.Drinking), new SQLiteParameter("@Professional", patientMd.Professional), new SQLiteParameter("@PhysicalExercise", patientMd.PhysicalExercise), new SQLiteParameter("@Height", patientMd.Height), new SQLiteParameter("@Waistline", patientMd.Waistline), new SQLiteParameter("@Hipline", patientMd.Hipline), new SQLiteParameter("@Weight", patientMd.Weight), new SQLiteParameter("@DisabilityStatus", patientMd.DisabilityStatus), new SQLiteParameter("@Allergy", patientMd.Allergy), new SQLiteParameter("@ExposureHistory", patientMd.ExposureHistory), new SQLiteParameter("@DiseasesHistory", patientMd.DiseasesHistory), new SQLiteParameter("@OperationHistory", patientMd.OperationHistory), new SQLiteParameter("@RtaumaHistory", patientMd.RtaumaHistory), new SQLiteParameter("@TransfusionHistory", patientMd.TransfusionHistory) }; WatchDog.WriteMsg(DateTime.Now + "==修改患者:" + patientMd.PatientName); _sqlite.ExecuteSql(sql, ls.ToArray()); ls.Clear(); return(true); } catch (Exception ex) { WatchDog.WriteMsg(DateTime.Now + "==修改患者失败:" + patientMd.PatientName + ex.StackTrace); return(false); } }
/// <summary> /// 修改信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnMod_Click(object sender, EventArgs e) { var pmMd = new PatientMd { PatientID = _patientId, WorkUnits = txtBoxWorkUnits.Text.Trim(), Phone = txtBoxPhone.Text.Trim(), Address = txtBoxRegistrationAddress.Text.Trim(), Levelofeducation = cBoxLevelofeducation.Text, Marriage = cBoxMarriage.Text, PermanentType = cBoxPermanentType.Text, BloodType = cBoxBloodType.Text, SleepStatus = cBoxSleepStatus.Text, PhysicalExercise = cBoxPhysicalExercise.Text, Drinking = cBoxDrinking.Text, Professional = cBoxProfessional.Text, Height = txtBoxHeight.Text.Trim(), Waistline = txtBoxWaistline.Text.Trim(), Hipline = txtBoxHipline.Text.Trim(), Weight = txtBoxWeight.Text.Trim(), DisabilityStatus = (rbtnDisabilityStatusNo.Checked ? "无&" : "有&" + txtBoxDisabilityStatus.Text.Trim()), Allergy = (rbtnAllergyNo.Checked ? "无&" : "有&" + txtBoxAllergy.Text.Trim()), ExposureHistory = (rbtnExposureHistoryNo.Checked ? "无&" : "有&" + txtBoxrExposureHistory.Text.Trim()), DiseasesHistory = (rbtnDiseasesHistoryNo.Checked ? "无&" : "有&" + txtBoxDiseasesHistory.Text.Trim()), OperationHistory = (rbtnOperationHistoryNo.Checked ? "无&" : "有&" + txtBoxOperationHistory.Text.Trim()), RtaumaHistory = (rbtnRtaumaHistoryNo.Checked ? "无&" : "有&" + txtBoxRtaumaHistory.Text.Trim()), TransfusionHistory = (rbtnTransfusionHistoryNo.Checked ? "无&" : "有&" + txtBoxTransfusionHistory.Text.Trim()) }; bool ok = PatientInfo_Mod(pmMd); if (ok) { XtraMessageBox.Show(@"修改成功!", @"提示:", MessageBoxButtons.OK, MessageBoxIcon.Information); Close(); } }
/// <summary> /// 构造函数 /// </summary> /// <param name="pmd"> /// </param> /// <param name="isPrint">是否为快速打印</param> /// <param name="strQiBo"></param> /// <param name="isApped"></param> /// <param name="errorLead"></param> public EcgViewFrm(PatientMd pmd, bool isPrint, string strQiBo, bool isApped, string errorLead) { InitializeComponent(); lb_Time.Parent = pictureEdit3; _patientId = pmd.PatientID; _patientName = pmd.PatientName; _gender = pmd.Gender; _age = pmd.AgeStart; _idStr = pmd.P_Id; _pdStatus = pmd.Pdstatus; label2.Text = _patientName; label13.Text = _gender; _isQiBo = strQiBo; #region 尿常规、血糖、血氧、血压、体温 lb_LEU.Text = pmd.LEU; lb_BIL.Text = pmd.BIL; lb_BLD.Text = pmd.BLD; lb_DIA.Text = pmd.DIA + @" mmHg"; lb_GLU.Text = pmd.GLU; lb_KET.Text = pmd.KET; lb_Mmol.Text = pmd.Mmol + @" mmol/L"; lb_NIT.Text = pmd.NIT; lb_PH.Text = pmd.PH; lb_PRO.Text = pmd.PRO; lb_SG.Text = pmd.SG; lb_Spo2.Text = pmd.Spo2 + @" %"; lb_SYS.Text = pmd.SYS + @" mmHg"; lb_TEMP.Text = pmd.Temperature + @" ℃"; lb_UBG.Text = pmd.UBG; lb_VC.Text = pmd.VC; #endregion label19.Text = ((_age == @"0") ? " " : (_age + @" 岁")); _isApped = isApped; _applicationId = pmd.AppId; ErrorLead = errorLead; _dt1 = new DataTable(); string sqlite = "SELECT beginTime,LeadEndTime,LeadType,InterpretationStatus FROM data_packs inner join tb_Application on data_packs.ApplicationID=tb_Application.ApplicationID WHERE data_packs.applicationID='" + _applicationId + "' and isLead='" + StrIsLead + "' order by beginTime asc limit 1 offset 0"; DataTable dtBeginTime = _sqHelper.ExcuteSqlite(sqlite); if (dtBeginTime.Rows.Count == 1) { _applicationInterpretationStatus = dtBeginTime.Rows[0]["InterpretationStatus"].ToString(); _currentTime = Convert.ToDateTime(dtBeginTime.Rows[0]["beginTime"].ToString().Trim()); _beginTime = _currentTime; } sqlite = "select * from data_packs WHERE applicationID='" + _applicationId + "' and isLead='" + StrIsLead + "' order by beginTime asc"; _dt1 = _sqHelper.ExcuteSqlite(sqlite); if (_dt1.Rows.Count > 0) { if (_dt1.Rows[0]["pureData"] == DBNull.Value) { string ednPathDir = Application.StartupPath + "\\ECG_DATA_NEW" + "\\" + _applicationId + "_" + StrIsLead; if (File.Exists(ednPathDir)) { var fs = new FileStream(ednPathDir, FileMode.Open, FileAccess.Read); var br = new BinaryReader(fs, Encoding.UTF8); _dt1.Rows[0]["pureData"] = br.ReadBytes((int)fs.Length); br.Close(); //fs.Close(); } } if (!string.IsNullOrEmpty(_dt1.Rows[0]["paceLocs"].ToString())) { string[] pL = _dt1.Rows[0]["paceLocs"].ToString().Split(','); foreach (string t in pL) { PLocsView.Add(Convert.ToInt32(t)); } } } _ecgDataDicAfterFilter.Clear(); GetEcgData(_dt1); //获取原始心电数据 if (_ecgDataDicAfterFilter.Count > 0) { hScrollBar_Lead.Maximum = _ecgDataDicAfterFilter[0].Count / 1000; //hScrollBar_Lead.Maximum = GetMaximun(EcgData_Dic_AfterFilter[0].Count) / 1000; //if (hScrollBar_Lead.Maximum <= 0) //{ // hScrollBar_Lead.Maximum = 1; //} //shortLeadRemove = GetMaximun(EcgData_Dic_AfterFilter[0].Count) % 1000; } if (_applicationInterpretationStatus != "未判读" && _applicationInterpretationStatus != "已作废") { _isFastPrint = isPrint; BindSnapInfo(); // 加载患者心电图快照的时间 if (isPrint) { if (listBox1.Items.Count > 0) { EcgView_Frm_Load(null, null); } else { XtraMessageBox.Show(@"请添加参考记录,再做打印!", @"提示:", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); // lblMsg.Text = "提示:" + "请添加参考记录,再做打印!"; } } } else { if (isPrint) { XtraMessageBox.Show(@"请添加参考记录,再做打印!", @"提示:", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); //lblMsg.Text = "提示:" + "请添加参考记录,再做打印!!"; } } }
private void gc_EcgList_CellClick(object sender, DataGridViewCellEventArgs e) { if (_dtEcgDataList.Rows.Count <= 0 || gc_PatientManage.Rows.Count <= 0) { return; } if (gc_EcgList.CurrentRow != null) { int index = gc_EcgList.CurrentRow.Index; if (gc_PatientManage.CurrentRow != null) { DataRow dr = ((DataRowView)gc_PatientManage.CurrentRow.DataBoundItem).Row; string appId = gc_EcgList.Rows[index].Cells["ApplicationID"].Value.ToString(); var pmd = new PatientMd(); #region 心电图分析 //心电图分析 if (gc_EcgList.Columns[e.ColumnIndex] == EcgAnalisis) { string isQiBo = dr["IsQiBo"].ToString(); string errorLead = _dtEcgDataList.Rows[index]["errorLead"].ToString(); pmd.WardshipId = _dtEcgDataList.Rows[index]["wardshipId"].ToString(); pmd.PatientID = dr["PatientID"].ToString(); pmd.PatientName = dr["PatientName"].ToString(); pmd.Gender = dr["Gender"].ToString(); pmd.AgeStart = string.Empty; if (string.IsNullOrEmpty(dr["Birthday"].ToString().Trim())) { pmd.AgeStart = "0"; } else { pmd.AgeStart = (Convert.ToDateTime(pmd.WardshipId).Year - Convert.ToDateTime(dr["Birthday"].ToString().Trim()).Year).ToString(); } pmd.P_Id = dr["P_Id"].ToString(); pmd.AppId = appId; pmd.Pdstatus = _dtEcgDataList.Rows[index]["InterpretationStatus"].ToString(); string status = _dtEcgDataList.Rows[index]["status"].ToString(); bool isApped = true; pmd.LEU = _dtEcgDataList.Rows[index]["LEU"].ToString(); pmd.NIT = _dtEcgDataList.Rows[index]["NIT"].ToString(); pmd.UBG = _dtEcgDataList.Rows[index]["UBG"].ToString(); pmd.PRO = _dtEcgDataList.Rows[index]["PRO"].ToString(); pmd.PH = _dtEcgDataList.Rows[index]["PH"].ToString(); pmd.BLD = _dtEcgDataList.Rows[index]["BLD"].ToString(); pmd.KET = _dtEcgDataList.Rows[index]["KET"].ToString(); pmd.BIL = _dtEcgDataList.Rows[index]["BIL"].ToString(); pmd.GLU = _dtEcgDataList.Rows[index]["GLU"].ToString(); pmd.VC = _dtEcgDataList.Rows[index]["VC"].ToString(); pmd.SG = _dtEcgDataList.Rows[index]["SG"].ToString(); pmd.Mmol = _dtEcgDataList.Rows[index]["Mmol"].ToString(); pmd.Spo2 = _dtEcgDataList.Rows[index]["Spo2"].ToString(); pmd.DIA = _dtEcgDataList.Rows[index]["DIA"].ToString(); pmd.SYS = _dtEcgDataList.Rows[index]["SYS"].ToString(); pmd.Temperature = _dtEcgDataList.Rows[index]["Temperature"].ToString(); if (status == "1") { isApped = false; } var evf = new EcgViewFrm(pmd, false, isQiBo, isApped, errorLead) { FormBorderStyle = FormBorderStyle.None, WindowState = FormWindowState.Maximized }; evf.ShowDialog(); } #endregion #region 远程申请 if (gc_EcgList.Columns[e.ColumnIndex] == LongConnect) { var extContract = new ExtContract { Data = new EcgData[1] }; var combination = new Combination { LEU = _dtEcgDataList.Rows[index]["LEU"].ToString(), NIT = _dtEcgDataList.Rows[index]["NIT"].ToString(), UBG = _dtEcgDataList.Rows[index]["UBG"].ToString(), PRO = _dtEcgDataList.Rows[index]["PRO"].ToString(), PH = _dtEcgDataList.Rows[index]["PH"].ToString(), BLD = _dtEcgDataList.Rows[index]["BLD"].ToString(), KET = _dtEcgDataList.Rows[index]["KET"].ToString(), BIL = _dtEcgDataList.Rows[index]["BIL"].ToString(), GLU = _dtEcgDataList.Rows[index]["GLU"].ToString(), VC = _dtEcgDataList.Rows[index]["VC"].ToString(), SG = _dtEcgDataList.Rows[index]["SG"].ToString(), Mmol = _dtEcgDataList.Rows[index]["Mmol"].ToString(), Spo2 = _dtEcgDataList.Rows[index]["Spo2"].ToString(), DIA = _dtEcgDataList.Rows[index]["DIA"].ToString(), SYS = _dtEcgDataList.Rows[index]["SYS"].ToString(), Temperature = _dtEcgDataList.Rows[index]["Temperature"].ToString() }; extContract.Others = combination; var patient = new Patient { PatientID = dr["PatientID"].ToString(), PatientName = dr["PatientName"].ToString(), NewId = dr["P_Id"].ToString(), IsQiBo = dr["IsQiBo"].ToString(), Status = "1" }; extContract.God = patient; var ecgData = new EcgData(); string sqli = "SELECT data_packs.beginTime,pureData,LeadEndTime,data_packs.EcgFilter,data_packs.IsLead,data_packs.PaceLocs FROM data_packs inner join tb_Application on data_packs.ApplicationID=tb_Application.ApplicationID WHERE data_packs.applicationID='" + appId + "' and isLead='0' order by beginTime asc limit 1 offset 0"; DataTable dtBeginTime = _sqlite.ExcuteSqlite(sqli); if (null != dtBeginTime && dtBeginTime.Rows.Count == 1) { ecgData.BeginTime = dtBeginTime.Rows[0]["beginTime"].ToString(); ecgData.EcgFilter = dtBeginTime.Rows[0]["EcgFilter"].ToString(); ecgData.IsLead = "0"; ecgData.PaceLocs = ""; if (dtBeginTime.Rows[0]["pureData"] == DBNull.Value) { string ednPathDir = Application.StartupPath + "\\ECG_DATA_NEW" + "\\" + appId + "_" + ecgData.IsLead; if (File.Exists(ednPathDir)) { var fs = new FileStream(ednPathDir, FileMode.Open, FileAccess.Read); var br = new BinaryReader(fs, Encoding.UTF8); ecgData.PureData = Convert.ToBase64String(br.ReadBytes((int)fs.Length)); br.Close(); //fs.Close(); } } } else { ecgData.BeginTime = DateTime.Now.ToString(); ecgData.EcgFilter = "低通:75Hz"; ecgData.IsLead = "0"; ecgData.PaceLocs = ""; ecgData.PureData = null; } extContract.Data[0] = ecgData; var transition = new Transition { ApplicationID = appId, InptLevel = ConfigHelper.InterpretationLevel, CommunityOrgID = ConfigHelper.ORGID }; if (null != dtBeginTime && dtBeginTime.Rows.Count == 1) { transition.CheckDate = dtBeginTime.Rows[0]["beginTime"].ToString(); transition.GatherCompletionTime = dtBeginTime.Rows[0]["LeadEndTime"].ToString(); } else { transition.CheckDate = DateTime.Now.ToString(); transition.GatherCompletionTime = DateTime.Now.ToString(); } extContract.Trans = transition; var contract = new Contract { ApplicationDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), ApplicationUserID = ConfigHelper.LoginId }; switch (ConfigHelper.InterpretationLevel) { case "2": contract.Status = "4"; break; case "3": contract.Status = "5"; break; default: contract.Status = "3"; break; } extContract.Contr = contract; ThreadPool.QueueUserWorkItem(WaitAppData, extContract); UpdateApplicationStatus(appId, "4"); SelEcgList(extContract.God.PatientID); } #endregion } } }
/// <summary> /// 根据条件分页查询患者 /// </summary> /// <param name="pm">患者对象(检索条件)</param> /// <param name="pageSize">每页显示记录数</param> /// <param name="pageIndex">第几页(从第一页开始)</param> /// <param name="rowsCount">返回总记录数</param> /// <returns></returns> private DataTable QueryPatients(PatientMd pm, int pageSize, int pageIndex, ref int rowsCount) { DateTime startDate = Convert.ToDateTime(pm.CollectionStartDate); DateTime endDate = Convert.ToDateTime(pm.ConllectionEndDate); if (startDate > endDate) { string dtTmp = pm.CollectionStartDate; pm.CollectionStartDate = pm.ConllectionEndDate; pm.ConllectionEndDate = dtTmp; } int start = (pageIndex - 1) * pageSize; //从第N条开始取数据 var dt = new DataTable(); //存储分页数据 var tbl = new DataTable(); //存储行数 const string of = " CreateDate desc"; #region SQLITE 分页语句 const string strPdzt = " InterpretationStatus as PDZT,"; string sql = @"select ifnull(b.[wardshipId],a.CreateDate)- Birthday as Birthday2,IsQiBo,Folk,[Gender],Birthday,[P_Id],[PatientName],(case when( select count(1) as SumEcg from Tb_Application d where d.PatientID=a.PatientID)>0 then '有' else '无' end) as EcgDataState,(case when( select count(1) as SumStatus from Tb_Application dp where dp.PatientID=a.PatientID and Status='3') >0 then '有' else '无' end) as OpeartionState," + strPdzt + "ifnull(b.[wardshipId],a.CreateDate) as CreateDate2,a.CreateDate,a.PatientID,ID,b.CompressType from tb_patientinfo a left join tb_application b on a.[PatientID]=b.[PatientID] WHERE 1=1 "; var sbQuery = new StringBuilder(sql); var sbCount = new StringBuilder("SELECT COUNT(*) FROM(select a.[PatientID]," + strPdzt + "ifnull(b.[wardshipId],a.CreateDate) as CreateDate2,a.PatientID,ID from tb_patientinfo a left join tb_application b on a.[PatientID]=b.[PatientID] WHERE 1=1 "); var sbFilter = new StringBuilder(); if (ConfigHelper.LoginName != "admin") { sbFilter.Append(" and DoctorId = '").Append(ConfigHelper.LoginId).Append("' "); } if (!string.IsNullOrEmpty(pm.P_Id)) { sbFilter.Append(" and P_ID like '%").Append(pm.P_Id).Append("%' "); } if (!string.IsNullOrEmpty(pm.PatientName)) { sbFilter.Append(" and PatientName like '%").Append(pm.PatientName).Append("%' "); } if (!string.IsNullOrEmpty(pm.Gender) && pm.Gender != "0") { sbFilter.Append(" and Gender= '").Append(pm.Gender).Append("' "); } if (!string.IsNullOrEmpty(pm.AgeStart)) { var startTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); sbFilter.Append(" and Birthday <='").Append(startTime.AddYears(-Convert.ToInt32(tbAgeStart.Text) + 1).ToString("yyyy-MM-dd")).Append("' "); } if (!string.IsNullOrEmpty(pm.AgeEnd)) { var date = new DateTime(DateTime.Now.Year, 1, 1); sbFilter.Append(" and Birthday >='").Append(date.AddYears(-Convert.ToInt32(tbAgeEnd.Text)).ToString("yyyy-MM-dd")).Append("' "); } var sbCjsj = new StringBuilder(); bool canCancel = !string.IsNullOrEmpty(pm.P_Id); if (!canCancel) { sbCjsj.Append(" and createdate2 >='").Append(Convert.ToDateTime(pm.CollectionStartDate).ToString("yyyy-MM-dd")).Append("'").Append(" and createdate2 <'").Append(Convert.ToDateTime(pm.ConllectionEndDate).AddDays(1).ToString("yyyy-MM-dd")).Append("'"); } if (sbFilter.Length > 0) { sbQuery.Append(sbFilter); sbCount.Append(sbFilter); } sbQuery.Append(sbCjsj); sbQuery.Append(") as t "); sbCount.Append(sbCjsj); string s = "select Birthday2,IsQiBo,Folk,[Gender],Birthday,[P_Id],strftime('%Y-%m-%d'," + of.Replace(" desc", "") + ") as CreateDate,[PatientName],[PatientID],[ID],CompressType,EcgDataState,OpeartionState,PDZT,'查阅与诊断' as EcgAnalisis,'采集' as EcgGather ,'修改' as EditPatient,'删除' as DeletePatient from ("; var sbUnion = new StringBuilder(s); sbUnion.Append(sbQuery).Append(" group by [PatientID] order by ").Append(" strftime('%Y-%m-%d %H:%M:%S', CreateDate2) desc ").Append(" limit ").Append(pageSize.ToString()).Append(" offset ").Append(start.ToString()); try { sql = sbUnion.ToString(); dt = _sqlite.ExcuteSqlite(sql); sbCount.Append(" group by a.[PatientID])"); sql = sbCount.ToString(); tbl = _sqlite.ExcuteSqlite(sql); } catch { } #endregion if (tbl != null && tbl.Rows.Count > 0) { rowsCount = Convert.ToInt32(tbl.Rows[0][0]); } if (dt != null && dt.Rows.Count > 0) { var dcFlag = new DataColumn("flag", typeof(bool)); dt.Columns.Add(dcFlag); for (int i = 0; i < dt.Rows.Count; i++) { dt.Rows[i]["flag"] = false; } } return(dt); }