private bool AddApplicationInfo() { bool ok = false; string sqlApp = "select * from Tb_Application where ApplicationID='" + ConfigHelper.AppId + "'"; DataTable dt = _sqlite.ExcuteSqlite(sqlApp); if (null != dt) { var lsp = new List <SQLiteParameter>(); if (dt.Rows.Count == 0) { sqlApp = "Insert into [Tb_Application](ApplicationID,PatientID,wardshipId,Mmol) Values(@ApplicationID,@PatientID,@wardshipId,@Mmol)"; lsp.Add(new SQLiteParameter("@ApplicationID", ConfigHelper.AppId)); lsp.Add(new SQLiteParameter("@PatientID", ConfigHelper.PatientId)); lsp.Add(new SQLiteParameter("@wardshipId", DateTime.Now.ToString("s"))); lsp.Add(new SQLiteParameter("@Mmol", lbMmol.Text.Trim())); ok = _sqlite.ExecuteSql(sqlApp, lsp.ToArray()) > 0; } else { sqlApp = "update Tb_Application set Mmol=@Mmol where ApplicationID=@ApplicationID"; lsp.Add(new SQLiteParameter("@Mmol", lbMmol.Text.Trim())); lsp.Add(new SQLiteParameter("@ApplicationID", ConfigHelper.AppId)); ok = _sqlite.ExecuteSql(sqlApp, lsp.ToArray()) > 0; } lsp.Clear(); } return(ok); }
/// <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 bool AddApplicationInfo() { bool ok = false; string sqlApp = "select * from Tb_Application where ApplicationID='" + ConfigHelper.AppId + "'"; DataTable dt = _sqlite.ExcuteSqlite(sqlApp); if (null != dt) { var lsp = new List <SQLiteParameter>(); if (dt.Rows.Count == 0) { sqlApp = "Insert into [Tb_Application](ApplicationID,PatientID,wardshipId,LEU,NIT,UBG,PRO,PH,BLD,KET,BIL,GLU,VC,SG) Values(@ApplicationID,@PatientID,@wardshipId,@LEU,@NIT,@UBG,@PRO,@PH,@BLD,@KET,@BIL,@GLU,@VC,@SG)"; lsp.Add(new SQLiteParameter("@ApplicationID", ConfigHelper.AppId)); lsp.Add(new SQLiteParameter("@PatientID", ConfigHelper.PatientId)); lsp.Add(new SQLiteParameter("@wardshipId", DateTime.Now.ToString("s"))); lsp.Add(new SQLiteParameter("@LEU", lb_LEU.Text.Trim())); lsp.Add(new SQLiteParameter("@NIT", lb_NIT.Text.Trim())); lsp.Add(new SQLiteParameter("@UBG", lb_UBG.Text.Trim())); lsp.Add(new SQLiteParameter("@PRO", lb_PRO.Text.Trim())); lsp.Add(new SQLiteParameter("@PH", lb_PH.Text.Trim())); lsp.Add(new SQLiteParameter("@BLD", lb_BLD.Text.Trim())); lsp.Add(new SQLiteParameter("@KET", lb_KET.Text.Trim())); lsp.Add(new SQLiteParameter("@BIL", lb_BIL.Text.Trim())); lsp.Add(new SQLiteParameter("@GLU", lb_GLU.Text.Trim())); lsp.Add(new SQLiteParameter("@VC", lb_VC.Text.Trim())); lsp.Add(new SQLiteParameter("@SG", lb_SG.Text.Trim())); ok = _sqlite.ExecuteSql(sqlApp, lsp.ToArray()) > 0; } else { sqlApp = "update Tb_Application set LEU=@LEU,NIT=@NIT,UBG=@UBG,PRO=@PRO,PH=@PH,BLD=@BLD,KET=@KET,BIL=@BIL,GLU=@GLU,VC=@VC,SG=@SG where ApplicationID=@ApplicationID"; lsp.Add(new SQLiteParameter("@LEU", lb_LEU.Text.Trim())); lsp.Add(new SQLiteParameter("@NIT", lb_NIT.Text.Trim())); lsp.Add(new SQLiteParameter("@UBG", lb_UBG.Text.Trim())); lsp.Add(new SQLiteParameter("@PRO", lb_PRO.Text.Trim())); lsp.Add(new SQLiteParameter("@PH", lb_PH.Text.Trim())); lsp.Add(new SQLiteParameter("@BLD", lb_BLD.Text.Trim())); lsp.Add(new SQLiteParameter("@KET", lb_KET.Text.Trim())); lsp.Add(new SQLiteParameter("@BIL", lb_BIL.Text.Trim())); lsp.Add(new SQLiteParameter("@GLU", lb_GLU.Text.Trim())); lsp.Add(new SQLiteParameter("@VC", lb_VC.Text.Trim())); lsp.Add(new SQLiteParameter("@SG", lb_SG.Text.Trim())); lsp.Add(new SQLiteParameter("@ApplicationID", ConfigHelper.AppId)); ok = _sqlite.ExecuteSql(sqlApp, lsp.ToArray()) > 0; } lsp.Clear(); } return(ok); }
/// <summary> /// 添加患者和数据的中间表 /// </summary> private void AddApplationInfo() { string sqlApp = "select * from Tb_Application where ApplicationID='" + ConfigHelper.AppId + "'"; DataTable dt = _sqlite.ExcuteSqlite(sqlApp); if (null != dt && dt.Rows.Count == 0) { var lsp = new List <SQLiteParameter>(); sqlApp = "Insert into [Tb_Application](ApplicationID,PatientID,wardshipId,InterpretationStatus) Values(@ApplicationID,@PatientID,@wardshipId,@InterpretationStatus)"; lsp.Add(new SQLiteParameter("@ApplicationID", ConfigHelper.AppId)); lsp.Add(new SQLiteParameter("@PatientID", _patientId)); lsp.Add(new SQLiteParameter("@wardshipId", _wardshipId)); lsp.Add(new SQLiteParameter("@InterpretationStatus", "未判读")); _sqlite.ExecuteSql(sqlApp, lsp.ToArray()); lsp.Clear(); } }
//转换数据 public void TranslateData() { if (File.Exists(Application.StartupPath + "\\EcgView.dll") && File.Exists(Application.StartupPath + "\\EcgView2.dll")) { try { AccessOptions aoc = new AccessOptions(); DataTable patients = aoc.ExcuteSqlite("select * from Tb_PatientInfo"); SqliteOptions sq = new SqliteOptions(); DateTime defaultDate = new DateTime(2012, 2, 15); if (patients != null && patients.Rows.Count > 0) { foreach (DataRow dr in patients.Rows) { #region 插入患者 string CaseID = dr["CaseID"] != DBNull.Value ? dr["CaseID"].ToString() : ""; string RoomNum = dr["RoomNum"] != DBNull.Value ? dr["RoomNum"].ToString() : ""; string PBedNum = dr["PBedNum"] != DBNull.Value ? dr["PBedNum"].ToString() : ""; string cd = dr["CreateDate"] != DBNull.Value ? Convert.ToDateTime(dr["CreateDate"]).ToString("s") : defaultDate.ToString("s"); sq.SqliteAdd("INSERT INTO [Tb_PatientInfo]([ID],[PatientName],[Gender],[Birthday],[PatientID],[PatientIdType],[Remark],[CreateDate],[P_Id],[Area],CaseID,RoomNum,PBedNum)VALUES('" + dr["ID"].ToString() + "','" + dr["PatientName"].ToString() + "','" + dr["Gender"].ToString() + "','" + dr["Birthday"].ToString() + "','" + dr["PatientID"].ToString() + "','" + dr["PatientIdType"].ToString() + "','" + dr["Remark"].ToString() + "','" + cd + "','" + dr["P_Id"].ToString() + "','" + dr["Area"].ToString() + "','" + CaseID + "','" + RoomNum + "','" + PBedNum + "')"); #endregion #region 插入合同与数据、快照、自动分析、远程报告名称 DataTable apps = aoc.ExcuteSqlite("Select distinct WardshipId,PatientID,ApplicationID,Status,CreateDate,InterpretationStatus from data_packs where PatientID='" + dr["PatientID"].ToString() + "'"); if (apps != null && apps.Rows.Count > 0) { foreach (DataRow app in apps.Rows) { string cdate = app["CreateDate"] != DBNull.Value ? Convert.ToDateTime(app["CreateDate"]).ToString("s") : defaultDate.ToString("s"); sq.SqliteAdd("insert into tb_application(ApplicationID,PatientID,Status,InterpretationStatus,CreateDate,wardshipId) values('" + app["ApplicationID"].ToString() + "','" + app["PatientID"].ToString() + "','" + app["Status"].ToString() + "','" + app["InterpretationStatus"].ToString() + "','" + cdate + "','" + app["wardshipId"].ToString() + "')"); //以上是申请,一下是心电数据 DataTable dps = aoc.ExcuteSqlite("Select ApplicationID,beginTime,pureData,dataSizePerLead,EcgFilter from data_packs where PatientID='" + app["PatientID"].ToString() + "' and ApplicationID='" + app["ApplicationID"].ToString() + "'"); if (dps != null && dps.Rows.Count > 0) { foreach (DataRow dp in dps.Rows) { SQLiteParameter sqp = new SQLiteParameter("@Hospita", DbType.Binary); sqp.Value = (byte[])dp["pureData"]; sq.ExecuteSql("insert into data_packs(ApplicationID,beginTime,pureData,dataSizePerLead,EcgFilter) values('" + dp["ApplicationID"].ToString() + "','" + Convert.ToDateTime(dp["beginTime"]).ToString("s") + "',@Hospita,'" + dp["dataSizePerLead"].ToString() + "','" + dp["EcgFilter"].ToString() + "')", new SQLiteParameter[] { sqp }); } } #region 插入快照 DataTable snapshots = aoc.ExcuteSqlite("Select * from Tb_Snapshot where PatientID='" + app["PatientID"].ToString() + "' and wardshipId='" + app["wardshipId"].ToString() + "'"); if (snapshots != null && snapshots.Rows.Count > 0) { foreach (DataRow s in snapshots.Rows) { string strType = string.Empty; try { strType = s["Type"].ToString(); } catch { } sq.SqliteAdd("insert into tb_snapshot(ID,ApplicationID,SnapshotTime,Diagnosis,Type) values('" + s["ID"].ToString() + "','" + app["ApplicationID"].ToString() + "','" + Convert.ToDateTime(s["SnapshotTime"]).ToString("s") + "','" + s["Diagnosis"].ToString() + "','" + strType + "')"); } } #endregion #region 插入自动分析 DataTable autoDiagnosis = aoc.ExcuteSqlite("Select ID,wardshipId,PatientID,SnapshotTime,P,P_R,QRS,QT_QTC,QRSDZ,RV5_SV1,BMP from AutoDiagnosis where PatientID='" + app["PatientID"].ToString() + "' and wardshipId='" + app["wardshipId"].ToString() + "'"); if (autoDiagnosis != null && autoDiagnosis.Rows.Count > 0) { foreach (DataRow ad in autoDiagnosis.Rows) { sq.SqliteAdd("INSERT INTO [AutoDiagnosis]([ID],[ApplicationID],[SnapshotTime],[P],[P_R],[QRS],[QT_QTC],[QRSDZ],[RV5_SV1],[BMP]) VALUES('" + ad["ID"].ToString() + "','" + app["ApplicationID"].ToString() + "','" + Convert.ToDateTime(ad["SnapshotTime"]).ToString("s") + "','" + ad["P"].ToString() + "','" + ad["P_R"].ToString() + "','" + ad["QRS"].ToString() + "','" + ad["QT_QTC"].ToString() + "','" + ad["QRSDZ"].ToString() + "','" + ad["RV5_SV1"].ToString() + "','" + ad["BMP"].ToString() + "')"); } } #endregion #region 插入报告名称 DataTable rts = aoc.ExcuteSqlite("Select * from Tb_ReportTitle where PatientID='" + app["PatientID"].ToString() + "' and wardshipId='" + app["wardshipId"].ToString() + "'"); if (rts != null && rts.Rows.Count > 0) { foreach (DataRow rt in rts.Rows) { string ldept = string.Empty; string sdept = string.Empty; try { ldept = rt["LastDept"].ToString(); sdept = rt["SecondDept"].ToString(); } catch { } sq.SqliteAdd("insert into Tb_ReportTitle (ID,ReportTitleName,CreateTime,[ApplicationID],[FirstUser],[SecondUser],[LastUser],[LastDept],[SecondDept]) values ('" + rt["ID"].ToString() + "','" + rt["ReportTitleName"].ToString() + "','" + Convert.ToDateTime(rt["CreateTime"]).ToString("s") + "','" + app["ApplicationID"].ToString() + "','" + rt["FirstUser"].ToString() + "','" + rt["SecondUser"].ToString() + "','" + rt["LastUser"].ToString() + "','" + ldept + "','" + sdept + "')"); } } #endregion } } #endregion } #region 插入病房和病室 DataTable rooms = aoc.ExcuteSqlite("select ID,PatientRoomName from PatientRooms"); if (rooms != null && rooms.Rows.Count > 0) { foreach (DataRow r in rooms.Rows) { if (!IsDataExists("PatientRooms", "PatientRoomName='" + r["PatientRoomName"].ToString() + "'")) { sq.SqliteAdd("insert into PatientRooms(ID,PatientRoomName) values('" + r["ID"].ToString() + "','" + r["PatientRoomName"].ToString() + "')"); } } } DataTable beds = aoc.ExcuteSqlite("select ID,PatientBedName from PatientBeds"); if (beds != null && beds.Rows.Count > 0) { foreach (DataRow b in beds.Rows) { if (!IsDataExists("PatientBeds", "PatientBedName='" + b["PatientBedName"].ToString() + "'")) { sq.SqliteAdd("insert into PatientBeds(ID,PatientBedName) values('" + b["ID"].ToString() + "','" + b["PatientBedName"].ToString() + "')"); } } } #endregion #region 插入科室和默认报告名称、医生 DataTable depts = aoc.ExcuteSqlite("Select ID,SectionName,ActiveSection,CreateDateTime from Tb_Section"); if (depts != null && depts.Rows.Count > 0) { foreach (DataRow d in depts.Rows) { if (!IsDataExists("Tb_Section", "SectionName='" + d["SectionName"].ToString() + "'")) { sq.SqliteAdd("insert into Tb_Section(ID,SectionName,ActiveSection,CreateDateTime) values('" + d["ID"].ToString() + "','" + d["SectionName"].ToString() + "','" + d["ActiveSection"].ToString() + "','" + Convert.ToDateTime(d["CreateDateTime"]).ToString("s") + "')"); } } } DataTable doctors = aoc.ExcuteSqlite("Select ID,DoctorName,ActiveDoctor,CreateDateTime from Tb_Doctor"); if (doctors != null && doctors.Rows.Count > 0) { foreach (DataRow d in doctors.Rows) { if (!IsDataExists("Tb_Doctor", "DoctorName='" + d["DoctorName"].ToString() + "'")) { sq.SqliteAdd("insert into Tb_Doctor(ID,DoctorName,ActiveDoctor,CreateDateTime) values('" + d["ID"].ToString() + "','" + d["DoctorName"].ToString() + "','" + d["ActiveDoctor"].ToString() + "','" + Convert.ToDateTime(d["CreateDateTime"]).ToString("s") + "')"); } } } string sql = "select count(1) from Tb_ReportTitle where ApplicationID is null"; DataTable dt = sq.ExcuteSqlite(sql); if (dt != null && dt.Rows.Count > 0) { DataTable titles = aoc.ExcuteSqlite("Select * from Tb_ReportTitle where PatientID is null"); if (titles != null && titles.Rows.Count > 0) { int count = Convert.ToInt32(dt.Rows[0][0]); if (count == 0) { foreach (DataRow rt in titles.Rows) { sq.SqliteAdd("insert into Tb_ReportTitle (ID,ReportTitleName,CreateTime) values ('" + rt["ID"].ToString() + "','" + rt["ReportTitleName"].ToString() + "','" + Convert.ToDateTime(rt["CreateTime"]).ToString("s") + "')"); } } } } #endregion try { File.Delete(Application.StartupPath + "\\EcgView.dll"); } catch { } } } catch (Exception ex) { FileInfo info = new FileInfo(Application.StartupPath + "\\EcgView.dll"); try { info.MoveTo(Application.StartupPath + "\\EcgView20130722.dll"); } catch { } } } }