private TTestInfo CreateTestInfoDetail(DataRow dataRow) { var testInforDetail = new TTestInfo(); if (dataRow["IsNew"].ToString() == "0") { testInforDetail.TestId = Utility.Int32Dbnull(dataRow[TTestInfo.Columns.TestId], -1); } testInforDetail.TestTypeId = Utility.Int32Dbnull(dataRow[TTestInfo.Columns.TestTypeId], -1); testInforDetail.Barcode = Utility.sDbnull(dataRow[TTestInfo.Columns.Barcode], ""); testInforDetail.TestSeq = Utility.sDbnull(dataRow[TTestInfo.Columns.TestSeq], ""); testInforDetail.PatientId = Utility.Int32Dbnull(dataRow[TTestInfo.Columns.PatientId], -1); testInforDetail.TestDate = globalVariables.SysDate; //testInforDetail.RequireDate = globalVariables.SysDate; testInforDetail.AssignId = Utility.Int32Dbnull(dataRow[TTestInfo.Columns.AssignId], -1); testInforDetail.DiagnosticianId = Utility.Int32Dbnull(dataRow[TTestInfo.Columns.DiagnosticianId], -1); testInforDetail.ReceiverId = Utility.Int32Dbnull(dataRow[TTestInfo.Columns.ReceiverId], -1); testInforDetail.TestStatus = 90; testInforDetail.DiagResult = Utility.sDbnull(dataRow[TTestInfo.Columns.DiagResult], ""); testInforDetail.DeviceId = Utility.Int32Dbnull(dataRow[TTestInfo.Columns.DeviceId], -1); testInforDetail.ParaId = Utility.Int32Dbnull(dataRow[TTestInfo.Columns.ParaId], -1); testInforDetail.Printstatus = true; testInforDetail.UpdateDate = globalVariables.SysDate; testInforDetail.UpdateUser = Utility.Int32Dbnull(dataRow[TTestInfo.Columns.UpdateUser], -1); testInforDetail.HisAssignId = Utility.Int32Dbnull(dataRow[TTestInfo.Columns.HisAssignId], -1); return(testInforDetail); }
private bool Invalidata() { string BarCode = globalVariables.SysDate.Year + globalVariables.SysDate.Month.ToString() + globalVariables.SysDate.Date + txtBarcode.Text; Utility.ResetMessageError(errorProvider1); if (!string.IsNullOrEmpty(txtBarcode.Text)) { if (Utility.Int32Dbnull(txtBarcode.Text, 0) < SystemParaBarcode.ParaBacode) { Utility.SetMessageError(errorProvider1, txtBarcode, "Số thứ tự của barcode không nhỏ hơn " + SystemParaBarcode.ParaBacode); txtBarcode.Focus(); return(false); } TTestInfoCollection testInfoCollection = new TTestInfoController().FetchByQuery(TTestInfo.CreateQuery().AddWhere(TTestInfo.Columns.Barcode, Comparison.Equals, txtBarcode.Text.Trim())); if (testInfoCollection.Count > 0) { Utility.SetMessageError(errorProvider1, txtBarcode, "Tồn tại " + SystemParaBarcode.ParaBacode); txtBarcode.Focus(); return(false); } } return(true); }
public static void DeleteTesInfor(int test_Id) { if (TTestInfo.FetchByID(test_Id) != null) { TTestInfo.Delete(test_Id); } }
private void DeleteAllTestId(Int32 Test_ID) { try { if (!Utility.AcceptQuestion("Thực hiện xóa", "Thông báo", true)) { return; } Query myQuery; myQuery = TResultDetail.CreateQuery().WHERE(TTestInfo.Columns.TestId, Test_ID); myQuery.QueryType = QueryType.Delete; myQuery.Execute(); myQuery = TTestInfo.CreateQuery().WHERE(TTestInfo.Columns.TestId, Test_ID); myQuery.QueryType = QueryType.Delete; myQuery.Execute(); grdTestInfo.CurrentRow.Delete(); } catch (Exception ex) { Utility.ShowMsg(ex.Message); } }
public ActionResult UpdateTestInfor(ref DataTable testInfoDetail, int testInfo) { Query query = TTestInfo.CreateQuery(); try { using (var scope = new TransactionScope()) { using (new SharedDbConnectionScope()) { SqlQuery sqlQuery = new Select().From(TResultDetail.Schema) .Where(TResultDetail.Columns.TestId).IsEqualTo(testInfo); if (sqlQuery.GetRecordCount() > 0) { new Update(TTestInfo.Schema) .Set(TTestInfo.Columns.TestStatus).EqualTo(90) .Where(TTestInfo.Columns.TestId).IsEqualTo(testInfo).Execute(); } foreach (DataRow dr in testInfoDetail.Rows) { if (dr["CHON"].ToString() == "1") { if (dr["IsNew"].ToString() == "1") { TTestInfo objTestInfor = CreateTestInfoDetail(dr); if (objTestInfor != null) { objTestInfor.IsNew = true; objTestInfor.Save(); int testId = Convert.ToInt32(query.GetMax(TTestInfo.Columns.TestId)); dr[TTestInfo.Columns.TestId] = testId; } } else { TTestInfo objTestInfor = CreateTestInfoDetail(dr); UpdateTestInfor(objTestInfor); } } } testInfoDetail.AcceptChanges(); } scope.Complete(); return(ActionResult.Success); } } catch (Exception exception) { return(ActionResult.Error); } }
private void ActionDoctor(action vAction) { try { if (grdDoctor.CurrentRow == null && (vAction == action.Update || vAction == action.Delete)) { return; } switch (vAction) { case action.Normal: dtDoctor = new Select().From(LUser.Schema.Name).ExecuteDataSet().Tables[0]; grdDoctor.DataSource = dtDoctor; break; case action.Delete: if (TTestInfo.CreateQuery().WHERE(TTestInfo.Columns.DiagnosticianId, Utility.Int32Dbnull(grdDoctor.GetValue("User_ID"))). OR(TTestInfo.Columns.AssignId, Utility.Int32Dbnull(grdDoctor.GetValue("User_ID"))).GetRecordCount() > 0) { Utility.ShowMsg("Danh mục đang được sử dụng. Không được xóa"); return; } if (Utility.AcceptQuestion("Thực hiện xóa " + grdDoctor.GetValue("User_Name"), "Thông báo", true)) { new Delete().From(LUser.Schema.Name).Where(LUser.Columns.UserId). IsEqualTo(Utility.Int32Dbnull(grdDoctor.GetValue("User_ID"))). Execute(); grdDoctor.CurrentRow.Delete(); grdDoctor.UpdateData(); dtDoctor.AcceptChanges(); } break; default: var oForm = new frmDoctorList_AU(); oForm.vAction = vAction; oForm.drList = Utility.GetDataRow(dtDoctor, LUser.Columns.UserId, grdDoctor.GetValue("User_ID")); oForm.dtList = dtDoctor; oForm.ShowDialog(); break; } } catch (Exception ex) { Utility.ShowMsg(ex.Message); } }
public ActionResult UpdateDeviceTestInfor(ref DataTable testInfoDetail, int v_TestInfo) { int Test_Id = -1; Query _Query = TTestInfo.CreateQuery(); try { using (var scope = new TransactionScope()) { using (var sp = new SharedDbConnectionScope()) { new Update(TTestInfo.Schema) .Set(TTestInfo.Columns.TestStatus).EqualTo(90) .Where(TTestInfo.Columns.TestId).IsEqualTo(v_TestInfo).Execute(); foreach (DataRow dr in testInfoDetail.Rows) { if (dr["CHON"].ToString() == "1") { if (dr["IsNew"].ToString() == "1") { TTestInfo ObjTestInfor = CreateTestInfoDetail(dr); if (ObjTestInfor != null) { ObjTestInfor.IsNew = true; ObjTestInfor.Save(); Test_Id = Convert.ToInt32(_Query.GetMax(TTestInfo.Columns.TestId)); dr[TTestInfo.Columns.TestId] = Test_Id; } //dr["IsNew"] = 0; } else { TTestInfo ObjTestInforV = CreateDeviceInfor(dr); UpdateTestInfor(ObjTestInforV); } } } testInfoDetail.AcceptChanges(); } scope.Complete(); return(ActionResult.Success); } } catch (Exception exception) { return(ActionResult.Error); } }
private TTestInfo CreateDeviceInfor(DataRow dataRow) { var testInforDetail = new TTestInfo(); if (dataRow["IsNew"].ToString() == "0") { testInforDetail.TestId = Utility.Int32Dbnull(dataRow[TTestInfo.Columns.TestId], -1); } testInforDetail.TestTypeId = Utility.Int32Dbnull(dataRow[TTestInfo.Columns.TestTypeId], -1); testInforDetail.Barcode = Utility.sDbnull(dataRow[TTestInfo.Columns.Barcode], ""); testInforDetail.TestSeq = Utility.sDbnull(dataRow[TTestInfo.Columns.TestSeq], ""); testInforDetail.PatientId = Utility.Int32Dbnull(dataRow[TTestInfo.Columns.PatientId], -1); testInforDetail.DeviceId = Utility.Int32Dbnull(dataRow[TTestInfo.Columns.DeviceId], -1); return(testInforDetail); }
private bool InValiData() { v_patientId = Utility.Int32Dbnull(grdPatients.CurrentRow.Cells["colPatient_ID"].Value, -1); TTestInfoCollection testInfoCollection = new TTestInfoController().FetchByQuery(TTestInfo.CreateQuery().AND(TTestInfo.Columns.TestTypeId, Comparison.Equals, v_TestTypeInfo).AND( TTestInfo.Columns.PatientId, Comparison.Equals, v_patientId)); if (testInfoCollection.Count > 0) { return(true); } return(false); }
public static string InsertTestInfo(TTestInfo pitems) { try { using (var scope = new TransactionScope()) { using (var sp = new SharedDbConnectionScope()) { if (pitems.TestDate == null) { pitems.TestDate = DateTime.Now; } if (pitems.RequireDate == null) { pitems.RequireDate = DateTime.Now; } if (pitems.TestStatus == null) { pitems.TestStatus = 0; } int i = 0; Query _QueryRS = TTestInfo.CreateQuery(); TTestInfoCollection testInfoCollection = new TTestInfoController().FetchByQuery( TTestInfo.CreateQuery().AddWhere(TTestInfo.Columns.PatientId, Comparison.Equals, pitems.PatientId)); if (testInfoCollection.Count > 0) { pitems.ParaId = testInfoCollection[0].ParaId; } pitems.IsNew = true; pitems.Save(i); scope.Complete(); return(_QueryRS.GetMax(TTestInfo.Columns.TestId).ToString()); } } } catch (Exception ex) { throw ex; } }
public static string BarCodeTestInfo(int vPatient_ID, int testTyeId, int Para_ID) { var dataTable = new DataTable(); string sBarcode = ""; TTestInfoCollection testInfoController = new TTestInfoController().FetchByQuery(TTestInfo.CreateQuery().AddWhere(TTestInfo.Columns.PatientId, Comparison.Equals, vPatient_ID)); if (testInfoController.Count > 0) { sBarcode = testInfoController[0].Barcode; } else { dataTable = SPs.SpGetNewTestSID(globalVariables.SysDate, testTyeId, Para_ID).GetDataSet().Tables[0]; if (dataTable.Rows.Count > 0) { sBarcode = dataTable.Rows[0][0].ToString(); } } return(sBarcode); }
public void UpdateTestInfor(TTestInfo testInfor) { int record = -1; Query _Query = TTestInfo.CreateQuery(); if (TTestInfo.FetchByID(testInfor.TestId) != null) { new Update(TTestInfo.Schema) .Set(TTestInfo.Columns.Barcode).EqualTo(testInfor.Barcode) .Set(TTestInfo.Columns.TestTypeId).EqualTo(testInfor.TestTypeId) .Set(TTestInfo.Columns.TestSeq).EqualTo(testInfor.TestSeq) .Set(TTestInfo.Columns.PatientId).EqualTo(testInfor.PatientId) //.Set(TTestInfo.Columns.TestDate).EqualTo(testInfor.TestDate) //.Set(TTestInfo.Columns.RequireDate).EqualTo(testInfor.RequireDate) .Set(TTestInfo.Columns.TestStatus).EqualTo(testInfor.TestStatus) .Set(TTestInfo.Columns.DeviceId).EqualTo(testInfor.DeviceId) .Set(TTestInfo.Columns.ParaId).EqualTo(testInfor.ParaId) .Set(TTestInfo.Columns.Printstatus).EqualTo(testInfor.Printstatus) .Where(TTestInfo.Columns.TestId).IsEqualTo(testInfor.TestId).Execute(); } }
/// <summary> /// Hàm xử lý click vào nút đăng ký xn /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnTestTypeClick(object sender, EventArgs e) { try { int count; var btn = (UIButton)sender; int vTestTypeId = Utility.Int32Dbnull(btn.Tag); count = TTestInfo.CreateQuery().WHERE(TTestInfo.Columns.PatientId, patientId). WHERE(TTestInfo.Columns.TestTypeId, vTestTypeId).GetRecordCount(); if (count > 0) { //Utility.ShowMsg("Loại Xét Nghiệm đã được đăng ký"); //Todo: focus vào test đã đăng ký for (int i = 0; i < grdTestInfo.RowCount; i++) { if (Utility.sDbnull(grdTestInfo.GetRow(i).Cells["TestType_ID"].Value) == (string)btn.Tag) { grdTestInfo.MoveTo(i); break; } } return; } string vBarcode = ""; DataRow drTestType = Utility.GetDataRow(dtTestTypeList, TTestTypeList.Columns.TestTypeId, btn.Tag); if (SysPara.AutoGenerateBarcode == 2 | (SysPara.AutoGenerateBarcode == 0 & dtTestInfo.Rows.Count == 0)) { frmInput_Update_Barcode oForm = new frmInput_Update_Barcode(); if (dtTestInfo.Rows.Count > 0) { oForm.txtBarcode.Text = Utility.sDbnull(grdTestInfo.GetValue("Barcode")); oForm.txtBarcode.SelectAll(); } oForm.vTestType_ID = vTestTypeId; oForm.txtTestType_Name.Text = Utility.sDbnull(drTestType["TestType_Name"]); oForm.ShowDialog(); if (string.IsNullOrEmpty(oForm.txtBarcode.Text)) { return; } vBarcode = oForm.txtBarcode.Text; } else if (dtTestInfo.Rows.Count > 0) { vBarcode = Utility.sDbnull(grdTestInfo.GetValue("Barcode")).Trim(); //count = new Select().From(TTestInfo.Schema).Where(TTestInfo.Columns.TestTypeId).IsEqualTo(vTestTypeId). // And(TTestInfo.Columns.Barcode).IsEqualTo(vBarcode).GetRecordCount(); //if (count > 0) //{ // Utility.ShowMsg("Barcode tồn tại. Mời nhập lại."); // return; //} } else { vBarcode = BarcodeInfo.GetBarcodeForPatient(patientId, vTestTypeId, drTestType[TTestTypeList.Columns.IntOrder].ToString()); if (vBarcode == "-1") { Utility.ShowMsg("Không tìm được Barcode"); return; } } string canlamsangid; LPatientInfo lPatientInfo = new Select().From(LPatientInfo.Schema.Name).Where(LPatientInfo.Columns.PatientId).IsEqualTo(patientId).ExecuteSingle <LPatientInfo>(); canlamsangid = lPatientInfo.CanLamSangId; var obj = new TTestInfo(); obj.TestTypeId = vTestTypeId; obj.Barcode = vBarcode; obj.PatientId = patientId; obj.TestDate = DateTime.Now; obj.RequireDate = DateTime.Now; obj.AssignId = Utility.Int32Dbnull(cboAssignDoctor.SelectedValue); obj.CanLamSangId = "OO" + DateTime.Now.ToString("yyMMdd") + "." + canlamsangid; obj.IsNew = true; obj.Save(); DataRow dr = dtTestInfo.NewRow(); dr[TTestInfo.Columns.TestId] = TTestInfo.CreateQuery().WHERE(TTestInfo.Columns.PatientId, patientId). WHERE(TTestInfo.Columns.TestTypeId, vTestTypeId).GetMax(TTestInfo.Columns.TestId); dr[TTestInfo.Columns.TestDate] = obj.TestDate; dr[TTestInfo.Columns.Barcode] = obj.Barcode; dr[TTestInfo.Columns.PatientId] = obj.PatientId; dr[TTestInfo.Columns.TestTypeId] = obj.TestTypeId; dr[TTestTypeList.Columns.TestTypeName] = drTestType[TTestTypeList.Columns.TestTypeName].ToString(); dr[TTestInfo.Columns.AssignId] = obj.AssignId; dr["AssignDoctor_Name"] = Utility.Int32Dbnull(cboAssignDoctor.SelectedValue) == -1 ? "" : cboAssignDoctor.Text; dtTestInfo.Rows.InsertAt(dr, 0); grdTestInfo.SelectionChanged -= grdTestInfo_SelectionChanged; dtTestInfo.AcceptChanges(); grdTestInfo.SelectionChanged += grdTestInfo_SelectionChanged; grdTestInfo.MoveFirst(); // Todo: xử lý sau khi nhấn nút đăng ký //Nếu ô đăng ký test có dl thì chuyển sang //if (flpTestGroup.Controls.Count > 0) flpTestGroup.Focus(); //else flpStandardTest.Focus(); } catch (Exception ex) { Utility.ShowMsg(ex.Message); } finally { FocusButtonDetail(); } }
private void AddTestType(object sender, EventArgs e) { if (!Invalidata()) { return; } if (grdPatientList.CurrentRow != null) { int rowIndex = grdPatientList.CurrentRow.Index; var btni = (ButtonItem)sender; var pItem = new TTestInfo(); pItem.TestTypeId = Convert.ToDecimal(btni.Name); int test = 0; if (string.IsNullOrEmpty(txtBarcode.Text)) { pItem.Barcode = PatientBusiness.GetBarCodeTestInfo( Convert.ToInt32(Utility.GetValueFromGridColumn(grdPatientList, "colPatient_ID", grdPatientList.CurrentRow.Index)), SystemParaBarcode.ParaBacode, 0); } else { pItem.Barcode = PatientBusiness.GetBarCodeTestInfo( Convert.ToInt32(Utility.GetValueFromGridColumn(grdPatientList, "colPatient_ID", grdPatientList.CurrentRow.Index)), Utility.Int32Dbnull(txtBarcode.Text, 0), 1); } barcode = PatientBusiness.GetBarCodeTestInfo( Convert.ToInt32(Utility.GetValueFromGridColumn(grdPatientList, "colPatient_ID", grdPatientList.CurrentRow.Index)), SystemParaBarcode.ParaBacode, 0); if (!_lstBarcode.Contains(barcode)) { _lstBarcode.Add(barcode); } barcode1.Data = barcode; barcode2.Data = barcode; //barcode2.Data = barcode; //pItem.Barcode = txtSid == null ? string.Empty : txtSid.Text; pItem.PatientId = Convert.ToInt32(dtPatientList.Rows[rowIndex][LPatientInfo.Columns.PatientId]); //pItem.AssignId = Convert.ToInt32(cboAssignDoctor.SelectedValue); //pItem.DiagnosticianId = Convert.ToInt32(cboDiagnoseDoctor.SelectedValue); pItem.AssignId = Convert.ToInt32(-1); pItem.DiagnosticianId = Convert.ToInt32(-1); pItem.ParaId = string.IsNullOrEmpty(txtBarcode.Text) ? 0 : 1; string testID = TestInfoBusiness.InsertTestInfo(pItem); DataRow dr = dtRegisteredTestType.NewRow(); dr[TTestInfo.Columns.TestId] = testID; dr[TTestInfo.Columns.Barcode] = pItem.Barcode; dr[TTestInfo.Columns.TestTypeId] = btni.Name; dr[TTestTypeList.Columns.TestTypeName] = btni.Text; dr[TTestInfo.Columns.TestStatus] = 0; dr[TTestInfo.Columns.PatientId] = pItem.PatientId; dr[TTestInfo.Columns.AssignId] = pItem.AssignId; dr[TTestInfo.Columns.DiagnosticianId] = pItem.DiagnosticianId; dr[LTestStatus.Columns.TestStatusName] = dtTestStatus.Rows[0][LTestStatus.Columns.TestStatusName].ToString(); //dr[TTestTypeList.Columns.TestTypeName] = btni.Text; dtRegisteredTestType.Rows.Add(dr); dtRegisteredTestType.AcceptChanges(); grdTestType.Focus(); //grdTestType.DataSource = dtRegisteredTestType; } }
private void grdTestInfoModification_CellUpdated(object sender, ColumnActionEventArgs e) { if (grdTestInfoModification.CurrentColumn.Key == "Barcode") { bool bSuccess = false; string vBarcode = Utility.sDbnull(grdTestInfoModification.GetValue("Barcode")); try { //Tim Patient_ID moi cho test_ID dang dc chon if (vBarcode.Length <= 4) vBarcode = DateTime.Now.ToString("yyMMdd") + vBarcode.PadLeft(4, '0'); DataTable dtPatientModified = TTestInfo.CreateQuery().WHERE(TTestInfo.Columns.Barcode, vBarcode).AND( TTestInfo.Columns.PatientId, Comparison.GreaterThan, 0).ExecuteDataSet().Tables[0]; //Neu ko tim thay if ( (from drCount in dtPatientModified.AsEnumerable() select drCount["Patient_ID"]).Distinct().Count () != 1) { Utility.ShowMsg( string.Format( "Không tìm thấy bệnh nhân có barcode {0} hoặc tìm thấy nhiều hơn 1 bệnh nhân. Đề nghị thực hiện lại.", vBarcode)); grdTestInfoModification.CurrentRow.Cells["Barcode"].Value = CurrentRowBarcode; return; } //Neu tim thay int newPatientID = Utility.Int32Dbnull(dtPatientModified.Rows[0]["Patient_ID"]); int oldPatientID = Utility.Int32Dbnull(grdTestInfoModification.GetValue("Patient_ID")); int oldTestID = Utility.Int32Dbnull(grdTestInfoModification.GetValue("Test_ID")); int vTestType_ID = Utility.Int32Dbnull(grdTestInfoModification.GetValue("TestType_ID")); LPatientInfo obj = LPatientInfo.FetchByID(newPatientID); if (obj == null) { Utility.ShowMsg("Không tồn tại bệnh nhân !"); return; } if ( !Utility.AcceptQuestion( string.Format("Thực hiện chuyển sang bệnh nhận {0} có barcode {1} ?", obj.PatientName, vBarcode), "Thông báo", true)) return; DataRow dr = Utility.GetDataRow(dtPatientModified, "TestType_ID", vTestType_ID); DataRow drPatient = Utility.GetDataRow(dtResultModification, new[] {"Patient_ID", "Test_ID"}, new object[] {oldPatientID, oldTestID}); if (drPatient == null) { Utility.ShowMsg("Không tìm thấy thông tin trên lưới"); return; } int newTest_ID = oldTestID; if (oldTestID > 0) { if (dr == null) { newTest_ID = oldTestID; new Update(TTestInfo.Schema.Name). //Set(TTestInfo.Columns.Barcode).EqualTo(vBarcode). Set(TTestInfo.Columns.PatientId).EqualTo(newPatientID). Set(TTestInfo.Columns.Barcode).EqualTo(vBarcode). Where(TTestInfo.Columns.TestId).IsEqualTo(oldTestID). Execute(); //Utility.ShowMsg(string.Format("Tìm thấy bệnh nhân {0}, chưa đăng ký {1}. Đề nghị thực hiện lại.", // obj.PatientName, grdResultModification.GetValue("TestType_Name"))); //return; } else if (oldPatientID > 0) { if ( !Utility.AcceptQuestion( string.Format( "Giữ đăng ký của bệnh nhân cũ và chỉ thực hiện chuyển kết quả sang bệnh nhận {0} có barcode {1} ?", obj.PatientName, dr["Barcode"]), "Thông báo", true)) { //Update PatientID cho T_Test_Info new Update(TTestInfo.Schema.Name). //Set(TTestInfo.Columns.Barcode).EqualTo(vBarcode). Set(TTestInfo.Columns.PatientId).EqualTo(newPatientID). Set(TTestInfo.Columns.Barcode).EqualTo(vBarcode). Where(TTestInfo.Columns.TestId).IsEqualTo(oldTestID). Execute(); } else newTest_ID = Utility.Int32Dbnull(dr["Test_ID"]); } else newTest_ID = Utility.Int32Dbnull(dr["Test_ID"]); } else { //Utility.ShowMsg(string.Format("Tìm thấy bệnh nhân {0}, chưa đăng ký {1}. Đề nghị thực hiện lại.", // obj.PatientName, grdResultModification.GetValue("TestType_Name"))); //return; TTestInfo objTestInfo = new TTestInfo(); objTestInfo.DeviceId = -1; objTestInfo.PatientId = newPatientID; objTestInfo.Barcode = vBarcode; objTestInfo.TestDate = DateTime.Now; objTestInfo.RequireDate = DateTime.Now; objTestInfo.TestTypeId = Utility.Int32Dbnull(grdTestInfoModification.GetValue("TestType_ID")); objTestInfo.TestStatus = 0; objTestInfo.PrintStatus = 0; objTestInfo.IsNew = true; objTestInfo.Save(); newTest_ID = Utility.Int32Dbnull(objTestInfo.TestId); } //Update PatientID,TestID,Barcode cho T_Result_Detail new Update(TResultDetail.Schema.Name).Set(TResultDetail.Columns.PatientId).EqualTo(newPatientID). Set(TResultDetail.Columns.Barcode).EqualTo(vBarcode). Set(TResultDetail.Columns.TestId).EqualTo(newTest_ID). Set(TResultDetail.Columns.TestDate).EqualTo(DateTime.Now.ToString()). Where(TResultDetail.Columns.TestId).IsEqualTo(oldTestID). And(TResultDetail.Columns.PatientId).IsEqualTo(oldPatientID). And(TResultDetail.Columns.Barcode).IsEqualTo(CurrentRowBarcode). Execute(); //Sửa trạng thái Has_Result của những test có kết quả var dtTestHasResult = new Select(TResultDetail.Columns.TestDataId).From(TResultDetail.Schema.Name).Where( TResultDetail.Columns.Barcode).IsEqualTo(vBarcode).And(TResultDetail.Columns.TestId). IsEqualTo(newTest_ID).ExecuteDataSet().Tables[0]; var listTestHasResult = (from d in dtTestHasResult.AsEnumerable() select d["TestData_ID"]).ToList(); new Update(TRegList.Schema.Name).Set(TRegList.Columns.HasResult).EqualTo(1).Where( TRegList.Columns.Barcode).IsEqualTo(vBarcode).And(TResultDetail.Columns.TestDataId).In(listTestHasResult).Execute(); if (oldTestID > 0 & oldPatientID <= 0 & dr != null) new Delete().From(TTestInfo.Schema.Name).Where(TTestInfo.Columns.TestId).IsEqualTo(oldTestID). Execute(); else if ( TResultDetail.CreateQuery().WHERE(TResultDetail.Columns.TestId, oldTestID).GetRecordCount() <= 0) { if ( Utility.AcceptQuestion( string.Format("Đăng ký {0} của bệnh nhân {1} không còn kết quả. Thực hiện xóa ?", drPatient["TestType_Name"], drPatient["Patient_Name"]), "Thông báo", true)) { new Delete().From(TTestInfo.Schema.Name).Where(TTestInfo.Columns.TestId).IsEqualTo( oldTestID).Execute(); } } if (oldPatientID > 0 & TTestInfo.CreateQuery().WHERE(TTestInfo.Columns.PatientId, oldPatientID).GetRecordCount() <= 0) if ( Utility.AcceptQuestion( string.Format("Bệnh nhận {0} không còn đăng ký. Thực hiện xóa ?", grdTestInfoModification.GetValue("Patient_Name")), "Thông báo", true)) { new Delete().From(LPatientInfo.Schema.Name).Where(LPatientInfo.Columns.PatientId).IsEqualTo( oldPatientID).Execute(); } //Cap nhan thong tin BN tren luoi if (newTest_ID == oldTestID) { Utility.FromObjectToDatarow(obj, ref drPatient); if (obj.YearBirth != null) drPatient["Age"] = DateTime.Now.Year - obj.YearBirth; drPatient["SexName"] = obj.Sex == true ? "Nam" : "Nữ"; dtResultModification.AcceptChanges(); } else { //grdTestInfoModification.CurrentRow.Delete(); //grdTestInfoModification.Refresh(); grdTestInfoModification.UpdateData(); dtResultModification.AcceptChanges(); btnSearchModification.PerformClick(); } bSuccess = true; } catch (Exception ex) { Utility.ShowMsg(ex.Message); } finally { if (!bSuccess) { grdTestInfoModification.CurrentRow.Cells["Barcode"].Value = CurrentRowBarcode; grdTestInfoModification.UpdateData(); dtResultModification.AcceptChanges(); } } } }
/// <summary> /// Hàm xử lý click vào nút đăng ký xn /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnTestTypeClick(object sender, EventArgs e) { try { int count; var btn = (UIButton) sender; int vTestTypeId = Utility.Int32Dbnull(btn.Tag); count = TTestInfo.CreateQuery().WHERE(TTestInfo.Columns.PatientId, patientId). WHERE(TTestInfo.Columns.TestTypeId, vTestTypeId).GetRecordCount(); if (count > 0) { //Utility.ShowMsg("Loại Xét Nghiệm đã được đăng ký"); //Todo: focus vào test đã đăng ký for (int i = 0; i < grdTestInfo.RowCount; i++) { if (Utility.sDbnull(grdTestInfo.GetRow(i).Cells["TestType_ID"].Value) == (string)btn.Tag) { grdTestInfo.MoveTo(i); break; } } return; } string vBarcode = ""; DataRow drTestType = Utility.GetDataRow(dtTestTypeList, TTestTypeList.Columns.TestTypeId, btn.Tag); if (SysPara.AutoGenerateBarcode == 2 | (SysPara.AutoGenerateBarcode == 0 & dtTestInfo.Rows.Count == 0)) { frmInput_Update_Barcode oForm = new frmInput_Update_Barcode(); if (dtTestInfo.Rows.Count > 0) { oForm.txtBarcode.Text = Utility.sDbnull(grdTestInfo.GetValue("Barcode")); oForm.txtBarcode.SelectAll(); } oForm.vTestType_ID = vTestTypeId; oForm.txtTestType_Name.Text = Utility.sDbnull(drTestType["TestType_Name"]); oForm.ShowDialog(); if (string.IsNullOrEmpty(oForm.txtBarcode.Text)) return; vBarcode = oForm.txtBarcode.Text; } else if (dtTestInfo.Rows.Count > 0) { vBarcode = Utility.sDbnull(grdTestInfo.GetValue("Barcode")).Trim(); //count = new Select().From(TTestInfo.Schema).Where(TTestInfo.Columns.TestTypeId).IsEqualTo(vTestTypeId). // And(TTestInfo.Columns.Barcode).IsEqualTo(vBarcode).GetRecordCount(); //if (count > 0) //{ // Utility.ShowMsg("Barcode tồn tại. Mời nhập lại."); // return; //} } else { vBarcode = BarcodeInfo.GetBarcodeForPatient(patientId, vTestTypeId, drTestType[TTestTypeList.Columns.IntOrder].ToString()); if (vBarcode == "-1") { Utility.ShowMsg("Không tìm được Barcode"); return; } } string canlamsangid; LPatientInfo lPatientInfo = new Select().From(LPatientInfo.Schema.Name).Where(LPatientInfo.Columns.PatientId).IsEqualTo(patientId).ExecuteSingle<LPatientInfo>(); canlamsangid=lPatientInfo.CanLamSangId; var obj = new TTestInfo(); obj.TestTypeId = vTestTypeId; obj.Barcode = vBarcode; obj.PatientId = patientId; obj.TestDate = DateTime.Now; obj.RequireDate = DateTime.Now; obj.AssignId = Utility.Int32Dbnull(cboAssignDoctor.SelectedValue); obj.CanLamSangId = "OO" + DateTime.Now.ToString("yyMMdd")+"."+canlamsangid; obj.IsNew = true; obj.Save(); DataRow dr = dtTestInfo.NewRow(); dr[TTestInfo.Columns.TestId] = TTestInfo.CreateQuery().WHERE(TTestInfo.Columns.PatientId, patientId). WHERE(TTestInfo.Columns.TestTypeId, vTestTypeId).GetMax(TTestInfo.Columns.TestId); dr[TTestInfo.Columns.TestDate] = obj.TestDate; dr[TTestInfo.Columns.Barcode] = obj.Barcode; dr[TTestInfo.Columns.PatientId] = obj.PatientId; dr[TTestInfo.Columns.TestTypeId] = obj.TestTypeId; dr[TTestTypeList.Columns.TestTypeName] = drTestType[TTestTypeList.Columns.TestTypeName].ToString(); dr[TTestInfo.Columns.AssignId] = obj.AssignId; dr["AssignDoctor_Name"] = Utility.Int32Dbnull(cboAssignDoctor.SelectedValue) == -1 ? "" : cboAssignDoctor.Text; dtTestInfo.Rows.InsertAt(dr, 0); grdTestInfo.SelectionChanged -= grdTestInfo_SelectionChanged; dtTestInfo.AcceptChanges(); grdTestInfo.SelectionChanged += grdTestInfo_SelectionChanged; grdTestInfo.MoveFirst(); // Todo: xử lý sau khi nhấn nút đăng ký //Nếu ô đăng ký test có dl thì chuyển sang //if (flpTestGroup.Controls.Count > 0) flpTestGroup.Focus(); //else flpStandardTest.Focus(); } catch (Exception ex) { Utility.ShowMsg(ex.Message); } finally {FocusButtonDetail();} }
public void Insert(decimal? TestTypeId,string Barcode,string TestSeq,decimal? PatientId,DateTime? TestDate,DateTime? RequireDate,decimal? AssignId,decimal? DiagnosticianId,string ReceiverId,short? TestStatus,string DiagResult,string UpdateUser,DateTime? UpdateDate,string Lam,string CanLamSangId,decimal? DeviceId,int? PrintStatus,int? ResultCount,int? RegCount,int? RegNoResultCount,int? SentStatus) { TTestInfo item = new TTestInfo(); item.TestTypeId = TestTypeId; item.Barcode = Barcode; item.TestSeq = TestSeq; item.PatientId = PatientId; item.TestDate = TestDate; item.RequireDate = RequireDate; item.AssignId = AssignId; item.DiagnosticianId = DiagnosticianId; item.ReceiverId = ReceiverId; item.TestStatus = TestStatus; item.DiagResult = DiagResult; item.UpdateUser = UpdateUser; item.UpdateDate = UpdateDate; item.Lam = Lam; item.CanLamSangId = CanLamSangId; item.DeviceId = DeviceId; item.PrintStatus = PrintStatus; item.ResultCount = ResultCount; item.RegCount = RegCount; item.RegNoResultCount = RegNoResultCount; item.SentStatus = SentStatus; item.Save(UserName); }