public static void WriteSaveFail(CD1800Result re) { LogProgram.WriteLog("***Fail", "Save SpecimenID: " + re.SpecimenID + "; Patient: " + re.Patient + "; Sequence: " + re.Sequence, true); }
private void DataReceive(object obj, SerialDataReceivedEventArgs e) { try { tem = port.ReadExisting(); index++; InputData += tem; //InputDataHuyetHoc += tem; if (tem.StartsWith("")) { LogProgram.WriteBeginTranfer(); frmMain.formMain.m_notifyicon.ShowBalloonTip(3, "MKV", "Đang nhận kết quả từ máy cd 1800", System.Windows.Forms.ToolTipIcon.Info); } #region Sinh Hoa Mr Khoe //if (InputData.Contains(" E0 ") && tem.EndsWith("")) //{ // bool kt = LuuKetQuaSinhHoa(InputData); // if (kt) // { // frmMain.formMain.m_notifyicon.ShowBalloonTip(3, "MKV", "Đã lưu kết quả từ máy EBLX200 " + InputData, System.Windows.Forms.ToolTipIcon.Info); // } // LogProgram.WriteEndTranfer(); // tem = ""; // InputData = ""; //} #endregion //LogProgram.WriteEndTranfer(); //} #region Huyết học Mr Khanh if (tem.EndsWith("")) { InputData = InputData.TrimStart('').TrimEnd(''); CD1800Result re = new CD1800Result(InputData); if (UpdateToSQL(re) == false) { LogProgram.WriteSaveFail(re); frmMain.formMain.m_notifyicon.ShowBalloonTip(3, "mkv", "lưu kết quả '" + re.SpecimenID + "' từ máy cd 1800 không thành công", System.Windows.Forms.ToolTipIcon.Error); } else { LogProgram.WriteSaveSucess(re); frmMain.formMain.m_notifyicon.ShowBalloonTip(3, "mkv", "đã lưu kết quả '" + re.SpecimenID + "' từ máy cd 1800", System.Windows.Forms.ToolTipIcon.Info); } LogProgram.WriteEndTranfer(); tem = ""; InputData = ""; } #endregion #region Huyết học Mr Khoe //if(tem.StartsWith("03")) //{ // LogProgram.WriteBeginTranfer(); // frmMain.formMain.m_notifyicon.ShowBalloonTip(3, "MKV", "Đang nhận kết quả từ máy Huyet Hoc LH500", System.Windows.Forms.ToolTipIcon.Info); //} //if(tem.EndsWith("")) //{ // bool okHH = LuKetQuaHuyetHoc(InputDataHuyetHoc); // if (okHH == false) // { // LogProgram.WriteLog("***Fail", "Save Huyet Hoc LH500 Error: " + InputDataHuyetHoc, true); // frmMain.formMain.m_notifyicon.ShowBalloonTip(3, "mkv", "lưu kết quả từ máy Huyet Hoc LH500 không thành công", System.Windows.Forms.ToolTipIcon.Error); // } // else // { // LogProgram.WriteLog("Success", "Save Huyet Hoc LH500 Success"); // frmMain.formMain.m_notifyicon.ShowBalloonTip(3, "mkv", "đã lưu kết quả từ máy Huyet Hoc LH500", System.Windows.Forms.ToolTipIcon.Info); // } // LogProgram.WriteEndTranfer(); // tem = ""; // InputDataHuyetHoc = ""; //} #endregion } catch (Exception ex) { LogProgram.WriteLog("[CD1800]:", ex.ToString()); } }
public static void WriteSaveSucess(CD1800Result re) { LogProgram.WriteLog("Success", "Save SpecimenID: " + re.SpecimenID + "; Patient: " + re.Patient + "; Sequence: " + re.Sequence); }
private bool UpdateToSQL(CD1800Result result) { try { string idKetQuaTuMayCLS = GetIdKetQuaTuMayCLS(result.SpecimenID); List <string> paramName = new List <string>(); List <object> values = new List <object>(); List <SqlDbType> sqlTypes = new List <SqlDbType>(); #region thamso if (result.WBC != null) { paramName.Add("@WBC"); values.Add(result.WBC); sqlTypes.Add(SqlDbType.Float); } if (result.LYM != null) { paramName.Add("@LYM"); values.Add(result.LYM); sqlTypes.Add(SqlDbType.Float); } if (result.MID != null) { paramName.Add("@MID"); values.Add(result.MID); sqlTypes.Add(SqlDbType.Float); } if (result.GRAN != null) { paramName.Add("@GRAN"); values.Add(result.GRAN); sqlTypes.Add(SqlDbType.Float); } if (result.RBC != null) { paramName.Add("@RBC"); values.Add(result.RBC); sqlTypes.Add(SqlDbType.Float); } if (result.HGB != null) { paramName.Add("@HGB"); values.Add(result.HGB); sqlTypes.Add(SqlDbType.Float); } if (result.HCT != null) { paramName.Add("@HCT"); values.Add(result.HCT); sqlTypes.Add(SqlDbType.Float); } if (result.MCV != null) { paramName.Add("@MCV"); values.Add(result.MCV); sqlTypes.Add(SqlDbType.Float); } if (result.MCH != null) { paramName.Add("@MCH"); values.Add(result.MCH); sqlTypes.Add(SqlDbType.Float); } if (result.MCHC != null) { paramName.Add("@MCHC"); values.Add(result.MCHC); sqlTypes.Add(SqlDbType.Float); } if (result.RDW != null) { paramName.Add("@RDW"); values.Add(result.RDW); sqlTypes.Add(SqlDbType.Float); } if (result.PLT != null) { paramName.Add("@PLT"); values.Add(result.PLT); sqlTypes.Add(SqlDbType.Float); } if (result.MPV != null) { paramName.Add("@MPV"); values.Add(result.MPV); sqlTypes.Add(SqlDbType.Float); } if (result.PCT != null) { paramName.Add("@PCT"); values.Add(result.PCT); sqlTypes.Add(SqlDbType.Float); } if (result.PDW != null) { paramName.Add("@PDW"); values.Add(result.PDW); sqlTypes.Add(SqlDbType.Float); } if (result.LYM_PER != null) { paramName.Add("@LYM_PER"); values.Add(result.LYM_PER); sqlTypes.Add(SqlDbType.Float); } if (result.MID_PER != null) { paramName.Add("@MID_PER"); values.Add(result.MID_PER); sqlTypes.Add(SqlDbType.Float); } if (result.GRAN_PER != null) { paramName.Add("@GRAN_PER"); values.Add(result.GRAN_PER); sqlTypes.Add(SqlDbType.Float); } #endregion if (idKetQuaTuMayCLS == "-1")//thêm mới { string sql = string.Format(@"INSERT INTO dbo.KetQuaTuMayCLS( mabenhnhan ,TenBenhNhan ,ngaythuchien , maketqua ,loaimay , STT , mota ) VALUES( '{0}' ,N'{1}' ,'{2}' ,'{3}' ,'{4}' , '{5}' , N'{6}' )", " ", result.Patient, result.Analyzed, result.SpecimenID, AppParams.cd1800Config.MaMayCLS, result.Sequence, ""); ServerConnect.I.BeginTran(); if (ServerConnect.I.ExecSQL(sql) == false) { ServerConnect.I.RollBack(); return(false); } idKetQuaTuMayCLS = GetIdKetQuaTuMayCLS(result.SpecimenID); string sqlCT = string.Format(@" INSERT INTO dbo.KetQuaTuMayCLS_CT ( idKetQuaTuMayCLS , tenthongso , giatri) VALUES ( {0} , N'{1}' , {2})", idKetQuaTuMayCLS, AppParams.cd1800Config.WBC, result.WBC == null ? "NULL" : "@WBC"); sqlCT += Environment.NewLine + string.Format(@"INSERT INTO dbo.KetQuaTuMayCLS_CT ( idKetQuaTuMayCLS , tenthongso , giatri) VALUES ( {0} , N'{1}' ,{2})", idKetQuaTuMayCLS, AppParams.cd1800Config.LYM, result.LYM == null ? "NULL" : "@LYM"); sqlCT += Environment.NewLine + string.Format(@"INSERT INTO dbo.KetQuaTuMayCLS_CT ( idKetQuaTuMayCLS , tenthongso , giatri) VALUES ( {0} , N'{1}' ,{2} )", idKetQuaTuMayCLS, AppParams.cd1800Config.MID, result.MID == null ? "NULL" : "@MID"); sqlCT += Environment.NewLine + string.Format(@"INSERT INTO dbo.KetQuaTuMayCLS_CT ( idKetQuaTuMayCLS , tenthongso , giatri) VALUES ( {0} , N'{1}' ,{2} )", idKetQuaTuMayCLS, AppParams.cd1800Config.GRAN, result.GRAN == null ? "NULL" : "@GRAN"); sqlCT += Environment.NewLine + string.Format(@"INSERT INTO dbo.KetQuaTuMayCLS_CT ( idKetQuaTuMayCLS , tenthongso , giatri) VALUES ( {0} , N'{1}' ,{2} )", idKetQuaTuMayCLS, AppParams.cd1800Config.RBC, result.RBC == null ? "NULL" : "@RBC"); sqlCT += Environment.NewLine + string.Format(@"INSERT INTO dbo.KetQuaTuMayCLS_CT ( idKetQuaTuMayCLS , tenthongso , giatri) VALUES ( {0} , N'{1}' ,{2} )", idKetQuaTuMayCLS, AppParams.cd1800Config.HGB, result.HGB == null ? "NULL" : "@HGB"); sqlCT += Environment.NewLine + string.Format(@"INSERT INTO dbo.KetQuaTuMayCLS_CT ( idKetQuaTuMayCLS , tenthongso , giatri) VALUES ( {0} , N'{1}' ,{2} )", idKetQuaTuMayCLS, AppParams.cd1800Config.HCT, result.HCT == null ? "NULL" : "@HCT"); sqlCT += Environment.NewLine + string.Format(@"INSERT INTO dbo.KetQuaTuMayCLS_CT ( idKetQuaTuMayCLS , tenthongso , giatri) VALUES ( {0} , N'{1}' ,{2} )", idKetQuaTuMayCLS, AppParams.cd1800Config.MCV, result.MCV == null ? "NULL" : "@MCV"); sqlCT += Environment.NewLine + string.Format(@"INSERT INTO dbo.KetQuaTuMayCLS_CT ( idKetQuaTuMayCLS , tenthongso , giatri) VALUES ( {0} , N'{1}' ,{2} )", idKetQuaTuMayCLS, AppParams.cd1800Config.MCH, result.MCH == null ? "NULL" : "@MCH"); sqlCT += Environment.NewLine + string.Format(@"INSERT INTO dbo.KetQuaTuMayCLS_CT ( idKetQuaTuMayCLS , tenthongso , giatri) VALUES ( {0} , N'{1}' ,{2} )", idKetQuaTuMayCLS, AppParams.cd1800Config.MCHC, result.MCHC == null ? "NULL" : "@MCHC"); sqlCT += Environment.NewLine + string.Format(@"INSERT INTO dbo.KetQuaTuMayCLS_CT ( idKetQuaTuMayCLS , tenthongso , giatri) VALUES ( {0} , N'{1}' ,{2} )", idKetQuaTuMayCLS, AppParams.cd1800Config.RDW, result.RDW == null ? "NULL" : "@RDW"); sqlCT += Environment.NewLine + string.Format(@"INSERT INTO dbo.KetQuaTuMayCLS_CT ( idKetQuaTuMayCLS , tenthongso , giatri) VALUES ( {0} , N'{1}' ,{2} )", idKetQuaTuMayCLS, AppParams.cd1800Config.PLT, result.PLT == null ? "NULL" : "@PLT"); sqlCT += Environment.NewLine + string.Format(@"INSERT INTO dbo.KetQuaTuMayCLS_CT ( idKetQuaTuMayCLS , tenthongso , giatri) VALUES ( {0} , N'{1}' ,{2} )", idKetQuaTuMayCLS, AppParams.cd1800Config.MPV, result.MPV == null ? "NULL" : "@MPV"); sqlCT += Environment.NewLine + string.Format(@"INSERT INTO dbo.KetQuaTuMayCLS_CT ( idKetQuaTuMayCLS , tenthongso , giatri) VALUES ( {0} , N'{1}' ,{2} )", idKetQuaTuMayCLS, AppParams.cd1800Config.PCT, result.PCT == null ? "NULL" : "@PCT"); sqlCT += Environment.NewLine + string.Format(@"INSERT INTO dbo.KetQuaTuMayCLS_CT ( idKetQuaTuMayCLS , tenthongso , giatri) VALUES ( {0} , N'{1}' ,{2} )", idKetQuaTuMayCLS, AppParams.cd1800Config.PDW, result.PDW == null ? "NULL" : "@PDW"); sqlCT += Environment.NewLine + string.Format(@"INSERT INTO dbo.KetQuaTuMayCLS_CT ( idKetQuaTuMayCLS , tenthongso , giatri) VALUES ( {0} , N'{1}' ,{2} )", idKetQuaTuMayCLS, AppParams.cd1800Config.LYMPer, result.LYM_PER == null ? "NULL" : "@LYM_PER"); sqlCT += Environment.NewLine + string.Format(@"INSERT INTO dbo.KetQuaTuMayCLS_CT ( idKetQuaTuMayCLS , tenthongso , giatri) VALUES ( {0} , N'{1}' ,{2} )", idKetQuaTuMayCLS, AppParams.cd1800Config.MIDPer, result.MID_PER == null ? "NULL" : "@MID_PER"); sqlCT += Environment.NewLine + string.Format(@"INSERT INTO dbo.KetQuaTuMayCLS_CT ( idKetQuaTuMayCLS , tenthongso , giatri) VALUES ( {0} , N'{1}' ,{2} )", idKetQuaTuMayCLS, AppParams.cd1800Config.GRANPer, result.GRAN_PER == null ? "NULL" : "@GRAN_PER"); if (ServerConnect.I.Exec(sqlCT, paramName.ToArray(), values.ToArray(), sqlTypes.ToArray()) <= 0) { ServerConnect.I.RollBack(); return(false); } ServerConnect.I.Commit(); } else { string sql = string.Format(@"UPDATE dbo.KetQuaTuMayCLS_CT SET giatri={0} WHERE idKetQuaTuMayCLS={1} AND tenthongso='{2}'", result.WBC == null ? "NULL" : "@WBC", idKetQuaTuMayCLS, AppParams.cd1800Config.WBC); sql += Environment.NewLine + string.Format(@"UPDATE dbo.KetQuaTuMayCLS_CT SET giatri={0} WHERE idKetQuaTuMayCLS={1} AND tenthongso='{2}'", result.LYM == null ? "NULL" : "@LYM", idKetQuaTuMayCLS, AppParams.cd1800Config.LYM); sql += Environment.NewLine + string.Format(@"UPDATE dbo.KetQuaTuMayCLS_CT SET giatri={0} WHERE idKetQuaTuMayCLS={1} AND tenthongso='{2}'", result.MID == null ? "NULL" : "@MID", idKetQuaTuMayCLS, AppParams.cd1800Config.MID); sql += Environment.NewLine + string.Format(@"UPDATE dbo.KetQuaTuMayCLS_CT SET giatri={0} WHERE idKetQuaTuMayCLS={1} AND tenthongso='{2}'", result.GRAN == null ? "NULL" : "@GRAN", idKetQuaTuMayCLS, AppParams.cd1800Config.GRAN); sql += Environment.NewLine + string.Format(@"UPDATE dbo.KetQuaTuMayCLS_CT SET giatri={0} WHERE idKetQuaTuMayCLS={1} AND tenthongso='{2}'", result.RBC == null ? "NULL" : "@RBC", idKetQuaTuMayCLS, AppParams.cd1800Config.RBC); sql += Environment.NewLine + string.Format(@"UPDATE dbo.KetQuaTuMayCLS_CT SET giatri={0} WHERE idKetQuaTuMayCLS={1} AND tenthongso='{2}'", result.HGB == null ? "NULL" : "@HGB", idKetQuaTuMayCLS, AppParams.cd1800Config.HGB); sql += Environment.NewLine + string.Format(@"UPDATE dbo.KetQuaTuMayCLS_CT SET giatri={0} WHERE idKetQuaTuMayCLS={1} AND tenthongso='{2}'", result.HCT == null ? "NULL" : "@HCT", idKetQuaTuMayCLS, AppParams.cd1800Config.HCT); sql += Environment.NewLine + string.Format(@"UPDATE dbo.KetQuaTuMayCLS_CT SET giatri={0} WHERE idKetQuaTuMayCLS={1} AND tenthongso='{2}'", result.MCV == null ? "NULL" : "@MCV", idKetQuaTuMayCLS, AppParams.cd1800Config.MCV); sql += Environment.NewLine + string.Format(@"UPDATE dbo.KetQuaTuMayCLS_CT SET giatri={0} WHERE idKetQuaTuMayCLS={1} AND tenthongso='{2}'", result.MCH == null ? "NULL" : "@MCH", idKetQuaTuMayCLS, AppParams.cd1800Config.MCH); sql += Environment.NewLine + string.Format(@"UPDATE dbo.KetQuaTuMayCLS_CT SET giatri={0} WHERE idKetQuaTuMayCLS={1} AND tenthongso='{2}'", result.MCHC == null ? "NULL" : "@MCHC", idKetQuaTuMayCLS, AppParams.cd1800Config.MCHC); sql += Environment.NewLine + string.Format(@"UPDATE dbo.KetQuaTuMayCLS_CT SET giatri={0} WHERE idKetQuaTuMayCLS={1} AND tenthongso='{2}'", result.RDW == null ? "NULL" : "@RDW", idKetQuaTuMayCLS, AppParams.cd1800Config.RDW); sql += Environment.NewLine + string.Format(@"UPDATE dbo.KetQuaTuMayCLS_CT SET giatri={0} WHERE idKetQuaTuMayCLS={1} AND tenthongso='{2}'", result.PLT == null ? "NULL" : "@PLT", idKetQuaTuMayCLS, AppParams.cd1800Config.PLT); sql += Environment.NewLine + string.Format(@"UPDATE dbo.KetQuaTuMayCLS_CT SET giatri={0} WHERE idKetQuaTuMayCLS={1} AND tenthongso='{2}'", result.MPV == null ? "NULL" : "@MPV", idKetQuaTuMayCLS, AppParams.cd1800Config.MPV); sql += Environment.NewLine + string.Format(@"UPDATE dbo.KetQuaTuMayCLS_CT SET giatri={0} WHERE idKetQuaTuMayCLS={1} AND tenthongso='{2}'", result.PCT == null ? "NULL" : "@PCT", idKetQuaTuMayCLS, AppParams.cd1800Config.PCT); sql += Environment.NewLine + string.Format(@"UPDATE dbo.KetQuaTuMayCLS_CT SET giatri={0} WHERE idKetQuaTuMayCLS={1} AND tenthongso='{2}'", result.PDW == null ? "NULL" : "@PDW", idKetQuaTuMayCLS, AppParams.cd1800Config.PDW); sql += Environment.NewLine + string.Format(@"UPDATE dbo.KetQuaTuMayCLS_CT SET giatri={0} WHERE idKetQuaTuMayCLS={1} AND tenthongso='{2}'", result.LYM_PER == null ? "NULL" : "@LYM_PER", idKetQuaTuMayCLS, AppParams.cd1800Config.LYMPer); sql += Environment.NewLine + string.Format(@"UPDATE dbo.KetQuaTuMayCLS_CT SET giatri={0} WHERE idKetQuaTuMayCLS={1} AND tenthongso='{2}'", result.MID_PER == null ? "NULL" : "@MID_PER", idKetQuaTuMayCLS, AppParams.cd1800Config.MIDPer); sql += Environment.NewLine + string.Format(@"UPDATE dbo.KetQuaTuMayCLS_CT SET giatri={0} WHERE idKetQuaTuMayCLS={1} AND tenthongso='{2}'", result.GRAN_PER == null ? "NULL" : "@GRAN_PER", idKetQuaTuMayCLS, AppParams.cd1800Config.GRANPer); if (ServerConnect.I.Exec(sql, paramName.ToArray(), values.ToArray(), sqlTypes.ToArray()) <= 0) { return(false); } } return(true); } catch { return(false); } }