void ShortCut2AddProc(string ACODE, string PCODE, bool AutoSelectNotDone, ref int _detailId) { try { using (frm_Choose_Anotomy_Projection _Choose_Anotomy_Projection = new frm_Choose_Anotomy_Projection(-1)) { _Choose_Anotomy_Projection.InitComponents(); bool _Success = false; _Choose_Anotomy_Projection.AutoSelectAnatomy(ACODE, PCODE, ref _Success); if (_Success) { if (m_dtAcquisitionDataSource == null || m_dtAcquisitionDataSource.Columns.Count <= 0 || m_dtAcquisitionDataSource.Rows.Count <= 0) { m_dtAcquisitionDataSource = new RegDetailController().GetAllData(-1).Tables[0]; } DataRow dr; if (m_dtAcquisitionDataSource.Rows.Count > 0) { dr = m_dtAcquisitionDataSource.Rows[0]; if (dr["reg_id"].ToString() == "-1") dr["REG_ID"] = currREGID; } else { dr = m_dtAcquisitionDataSource.NewRow(); dr["UsingGrid"] = 0; dr["STATUS"] = 0; dr["IMGNAME"] = ""; dr["PRINTCOUNT"] = 0; dr["EXPOSURECOUNT"] = 0; dr["HOST"] = "127.0.0.1"; dr["IMGDATA"] = DBNull.Value; dr["REG_NUMBER"] = txtRegNumber2.Text.Trim(); dr["REG_ID"] = currREGID; } DataTable dtAP = _Choose_Anotomy_Projection.AP_DataSource.Select("CHON=1").CopyToDataTable(); DataRow newdr = m_dtAcquisitionDataSource.NewRow(); Utility.CopyData(dr, ref newdr); if (dtAP != null) { string SeriesInstanceUID = ""; foreach (DataRow drAP in dtAP.Rows) { RegDetailInfor infor = new RegDetailInfor(); int NextSeriesInstanceUID = MaxSeriesInstanceUID + 1; SeriesInstanceUID = CurrStudyInstanceUID + "." + NextSeriesInstanceUID.ToString(); MaxSeriesInstanceUID = NextSeriesInstanceUID; newdr["DETAIL_ID"] = -1; newdr["StudyInstanceUID"] = CurrStudyInstanceUID; //SeriesInstanceUID=StudyInstanceUID+Số thứ tự dịch vụ trong lần đăng ký đó newdr["SeriesInstanceUID"] = SeriesInstanceUID; //SOPInstanceUID=SeriesInstanceUID+Số lần chụp của dịch vụ đó. //SOPInstanceUID chỉ thay đổi khi dịch vụ này đang có ảnh và lại được chụp lại newdr["SOPInstanceUID"] = SeriesInstanceUID + ".1"; newdr["REG_ID"] = dr["REG_ID"]; newdr["ANATOMY_CODE"] = drAP["ANATOMY_CODE"]; newdr["BODYSIZE_CODE"] = _Choose_Anotomy_Projection.BODYSIZE_CODE; newdr["UsingGrid"] = 0; newdr["PROJECTION_CODE"] = drAP["PROJECTION_CODE"]; newdr["DISPLAY_NAME"] = drAP["ANATOMY_CODE"]; newdr["STANDARD_NAME"] = drAP["ANATOMY_CODE"]; newdr["DirectionCapture"] = 0; newdr["STATUS"] = 0; newdr["STATUS_NAME"] = ""; Utility.MapValueFromEntityIntoObjectInfor(infor, newdr); if (new RegDetailController(infor).Insert() == ActionResult.Success) { newdr["DETAIL_ID"] = infor.DETAIL_ID; _detailId = Convert.ToInt32(infor.DETAIL_ID); decimal _kVp = 0M; int _mA = 0; int _mAs = 0; GetAPParams(_Choose_Anotomy_Projection.APParams_DataSource, infor.ANATOMY_CODE, infor.PROJECTION_CODE, infor.BODYSIZE_CODE, ref _kVp, ref _mA, ref _mAs); //Add new Scheduled Control ScheduledControl _Scheduled = new ScheduledControl(txtImgDir.Text.Trim() + @"\" + txtRegNumber2.Text.Trim() + "_" + infor.DETAIL_ID.ToString(), (int)infor.REG_ID, (int)infor.DETAIL_ID, CurrStudyInstanceUID, SeriesInstanceUID, newdr["SOPInstanceUID"].ToString(), infor.ANATOMY_CODE, infor.PROJECTION_CODE, infor.BODYSIZE_CODE, Utility.sDbnull(drAP["VN_ANATOMY_NAME"], ""), Utility.sDbnull(drAP["EN_ANATOMY_NAME"], ""), Utility.sDbnull(drAP["VN_PROJECTION_NAME"], ""), Utility.sDbnull(drAP["EN_PROJECTION_NAME"], ""), _Choose_Anotomy_Projection.BODYSIZE_NAME, _Choose_Anotomy_Projection.BODYSIZE_NAME, _kVp, _mA, _mAs, Utility.Int32Dbnull(drAP["A_STT"], 0), Utility.Int32Dbnull(drAP["P_STT"], 0), 0, 0); Size originalSize = _Scheduled.Size; _Scheduled._OnClick += new ScheduledControl.OnClick(_ScheduledControl__OnClick); _Scheduled.ContextMenuStrip = ctx; _Scheduled._OnNewScheduleClick += new ScheduledControl.OnNewScheduleClick(_ScheduledControl__OnNewScheduleClick); _Scheduled._OnRejectScheduleClick += new ScheduledControl.OnRejectScheduleClick(_ScheduledControl__OnRejectScheduleClick); _Scheduled._OnDelScheduleClick += new ScheduledControl.OnDelScheduleClick(_ScheduledControl__OnDelScheduleClick); _Scheduled._OnNewScheduleDoubleClick += new ScheduledControl.OnNewScheduleDoubleClick(_ScheduledControl__OnNewScheduleDoubleClick); _Scheduled._OnRejectScheduleDoubleClick += new ScheduledControl.OnRejectScheduleDoubleClick(_ScheduledControl__OnRejectScheduleDoubleClick); _Scheduled._OnDelScheduleDoubleClick += new ScheduledControl.OnDelScheduleDoubleClick(_ScheduledControl__OnDelScheduleDoubleClick); _Scheduled._OnKeyDown += new ScheduledControl.OnKeyDown(_ScheduledControl__OnKeyDown); AutoAddNewSchedule(_Scheduled); //pnlScheduled.Controls.Add(_Scheduled); _Scheduled.Size = new Size(124, 71); if (_Scheduled != null) { //Nếu chưa có kết quả thì tự động chọn và scroll tới AutoScroll2NewSchedule(_Scheduled); //pnlScheduled.ScrollControlIntoView(_Scheduled); _Scheduled._AnatomyObject.PerformClick(); } } m_dtAcquisitionDataSource.Rows.Add(newdr); m_dtAcquisitionDataSource.AcceptChanges(); newdr = m_dtAcquisitionDataSource.NewRow(); } } if (!AcquisitionFromWL) { //string[] Img = Utility.sDbnull(currentStudyRow["Img"]).Split('/'); //currentStudyRow["Img"] = Img[0] + "/" + (Convert.ToInt64(Img[1]) + _newForm.arrProc.Count).ToString(); //currentStudyRow["Img1"] = currentStudyRow["Img"]; } //Update Procedure List to DB and Datasource string ProcedureList = GetProcedureList(); new RegDetailController().UpdateProcedureList(Convert.ToInt64(dr["REG_ID"]), ProcedureList); //Update Dataset DataRow[] drWL = m_dtWLDataSource.Select("Reg_ID=" + Convert.ToInt64(dr["REG_ID"])); DataRow[] drST = m_dtStudyListDataSource.Select("Reg_ID=" + Convert.ToInt64(dr["REG_ID"])); if (drWL.Length > 0) drWL[0]["ProcedureList"] = ProcedureList; if (drST.Length > 0) drST[0]["ProcedureList"] = ProcedureList; m_dtWLDataSource.AcceptChanges(); m_dtStudyListDataSource.AcceptChanges(); } } } catch (Exception ex) { AppLogger.LogAction.AddLog2List(lstFPD560, "Action: Lỗi khi tạo DV mới-->" + ex.Message); } finally { if (AutoSelectNotDone) { ScheduledControl _reObj = GetSelectedScheduled_NOTDONE(); if (_reObj != null) { //Nếu chưa có kết quả thì tự động _reObj._AnatomyObject.PerformClick(); } } } }
private void cmdFindPro_Click(object sender, EventArgs e) { //frm_ChooseProcedureList _newForm = new frm_ChooseProcedureList(); //_newForm.arrProc = arrProc; //_newForm.ShowDialog(); //if (!_newForm.m_blnCancel) // txtProcedure.Text = _newForm.ProList; //arrProc = _newForm.arrProc; frm_Choose_Anotomy_Projection _Choose_Anotomy_Projection = new frm_Choose_Anotomy_Projection(-1); if (_Choose_Anotomy_Projection.ShowDialog() == DialogResult.OK) { this.BODYSIZE_CODE = _Choose_Anotomy_Projection.BODYSIZE_CODE; this.BODYSIZE_NAME = _Choose_Anotomy_Projection.BODYSIZE_NAME; dtAP = _Choose_Anotomy_Projection.AP_DataSource.Select("CHON=1").CopyToDataTable(); txtProcedure.Text = GetProcedure(); } }
public void CreateEmerency() { try { action Act = action.Insert; DataTable dtPhysician = new DoctorController().GetAllData().Tables[0]; if (dtPhysician == null || dtPhysician.Rows.Count <= 0) { new frm_LargeMsgBoxOK(MultiLanguage.GetText(globalVariables.DisplayLanguage, "Thông báo", "Warning"), MultiLanguage.GetText(globalVariables.DisplayLanguage, "Đề nghị tạo danh mục bác sĩ trước khi thêm BN cấp cứu!", "Pls create Doctor list before add Emerency"), MultiLanguage.GetText(globalVariables.DisplayLanguage, "ĐỒNG Ý", "I see"), MultiLanguage.GetText(globalVariables.DisplayLanguage, "HỦY BỎ", "Cancel")).ShowDialog(); return; } DataSet dsEmerencyDataEntity = new DataSet(); DataTable EmerencyPatientEntity = new PatientEntity.PatientEntityDataTable(); DataTable EmerencyRegEntity = new RegEntity.RegEntityDataTable(); DataTable EmerencyRegDetailEntity = new RegDetailEntity.RegDetailEntityDataTable(); Utility.ResetEntity(ref dsEmerencyDataEntity); Utility.ResetEntity(ref EmerencyPatientEntity); Utility.ResetEntity(ref EmerencyRegDetailEntity); Utility.ResetEntity(ref EmerencyRegEntity); //Create new Row string PID = Utility.GetYYYYMMDDHHMMSS(DateTime.Now); DataRow dr0 = EmerencyPatientEntity.NewRow(); dr0["Patient_ID"] = -1; dr0["Age"] = 20; dr0["PATIENT_CODE"] = Utility.GetValue(PID, false); dr0["Patient_Name"] = "Bệnh nhân cấp cứu vào lúc " + PID; dr0["Birth_Date"] = DateTime.Now.AddYears(-20); dr0["sBirth_Date"] = DateTime.Now.AddYears(-20).ToString("dd/MM/yyyy"); //dr0["Doctor_Name"] = cboPhysician.Text; dr0["Sex"] = 0;//Mặc định là Male dr0["EMERGENCY"] = 1;//BN cấp cứu EmerencyPatientEntity.Rows.Add(dr0); EmerencyPatientEntity.AcceptChanges(); //Tao thong tin dang ky chup DataRow dr1 = EmerencyRegEntity.NewRow(); dr1["REG_ID"] = -1; //dr1["REGSTATUS"] = 1; dr1["REG_NUMBER"] = dr0["PATIENT_CODE"]; dr1["PATIENT_ID"] = dr0["Patient_ID"]; //dr1["DESC"] = Utility.GetValue("Bệnh nhân cấp cứu cần chụp ngay", false); DataTable dtAP = new ProcedureController().GetEmerencyData().Tables[0]; DataSet dsEmerencyDoctor = new DoctorController().GetEmerencyData(); ArrayList Emerency_arrProc = new ArrayList(); string ProcList = ""; int totalProc = 0; if (dtAP == null || dtAP.Rows.Count <= 0) { frm_Choose_Anotomy_Projection _Choose_Anotomy_Projection = new frm_Choose_Anotomy_Projection(-1); if (_Choose_Anotomy_Projection.ShowDialog() == DialogResult.OK) { dtAP = _Choose_Anotomy_Projection.AP_DataSource.Select("CHON=1").CopyToDataTable(); ProcList = GetProcedureEmerency(dtAP); dr1["PROCEDURELIST"] = ProcList; } } else { //Update Procedure List to DB and Datasource ProcList = GetProcedureEmerency(dtAP); dr1["PROCEDURELIST"] = ProcList; } //Tự động gán bác sĩ cấp cứu if (dsEmerencyDoctor != null && dsEmerencyDoctor.Tables.Count > 0 && dsEmerencyDoctor.Tables[0].Rows.Count > 0) dr1["PHYSICIAN"] = dsEmerencyDoctor.Tables[0].Rows[0]["DOCTOR_CODE"].ToString(); else dr1["PHYSICIAN"] = dtPhysician.Rows[0]["DOCTOR_CODE"].ToString(); dr1["CREATED_DATE"] = DateTime.Now; EmerencyRegEntity.Rows.Add(dr1); EmerencyRegEntity.AcceptChanges(); //Tao thong tin dang ky chup chi tiet if (dtAP != null) { foreach (DataRow drAP in dtAP.Rows) { DataRow dr2 = EmerencyRegDetailEntity.NewRow(); dr2["DETAIL_ID"] = -1; dr2["REG_ID"] = dr1["REG_ID"]; dr2["ANATOMY_CODE"] = drAP["ANATOMY_CODE"]; dr2["PROJECTION_CODE"] = drAP["PROJECTION_CODE"]; dr2["STATUS"] = 0; totalProc += 1; EmerencyRegDetailEntity.Rows.Add(dr2); EmerencyRegDetailEntity.AcceptChanges(); } } dsEmerencyDataEntity.Tables.Add(EmerencyPatientEntity); dsEmerencyDataEntity.Tables.Add(EmerencyRegEntity); dsEmerencyDataEntity.Tables.Add(EmerencyRegDetailEntity); //Now AutoSave Emerency Patient WLRules _BusRule = new WLRules(); //Gọi nghiệp vụ Insert dữ liệu PatientInfor _PatientInfor = new PatientInfor(); RegInfor _RegInfor = new RegInfor(); ActionResult InsertResult = _BusRule.Insert(dsEmerencyDataEntity, _PatientInfor, _RegInfor); if (InsertResult == ActionResult.Success)//Nếu thành công { //Thêm mới một dòng vào Datasource để cập nhật lại dữ liệu trên DataGridView //phải đảm bảo Datasource và RoomEntity có cấu trúc giống nhau mới dùng hàm này DataRow newRow = m_dtWLDataSource.NewRow(); newRow["Patient_ID"] = _PatientInfor.Patient_ID; newRow["PATIENT_CODE"] = Utility.GetValue(PID, false); newRow["Patient_Name"] = "Bệnh nhân cấp cứu vào lúc " + PID; newRow["Birth_Date"] = DateTime.Now.AddYears(-20); newRow["sBirth_Date"] = DateTime.Now.AddYears(-20).ToShortDateString(); newRow["Sex"] = 0; newRow["Age"] = 0; newRow["EMERGENCY"] = 20; newRow["REG_ID"] = _RegInfor.REG_ID; newRow["REG_NUMBER"] = newRow["PATIENT_CODE"]; newRow["REGSTATUS"] = 1; newRow["PROCEDURELIST"] = ProcList; if (dsEmerencyDoctor != null && dsEmerencyDoctor.Tables.Count > 0 && dsEmerencyDoctor.Tables[0].Rows.Count > 0) { newRow["PHYSICIAN"] = dsEmerencyDoctor.Tables[0].Rows[0]["DOCTOR_CODE"].ToString(); newRow["Doctor_Name"] = dsEmerencyDoctor.Tables[0].Rows[0]["DOCTOR_Name"].ToString(); } else { newRow["PHYSICIAN"] = dtPhysician.Rows[0]["DOCTOR_CODE"].ToString(); newRow["Doctor_Name"] = dtPhysician.Rows[0]["DOCTOR_Name"].ToString(); } newRow["CREATED_DATE"] = DateTime.Now; newRow["sCREATED_DATE"] = DateTime.Now.ToShortDateString(); newRow["SEX_NAME"] = "Male"; newRow["CanDel"] = 1; newRow["HasProcessed"] = 0; newRow["NoneProcessed"] = 1; newRow["TotalProc"] = totalProc; if (newRow != null)//99.99% là sẽ !=null { m_dtWLDataSource.Rows.Add(newRow); m_dtWLDataSource.AcceptChanges(); } //Return to the InitialStatus Act = action.FirstOrFinished; //Tự động Suspending Bệnh nhân đang được chọn ở mục Acquisition SuspendCurrentPatient(); //Nhảy đến bản ghi vừa thêm mới trên lưới. Do txtID chưa bị reset nên dùng luôn Utility.GotoNewRow(grdWorkList, "colPatient_ID", _PatientInfor.Patient_ID.ToString()); //Tự động chuyển BN cấp cứu vào phần Acquisition BeginExam(); } else//Có lỗi xảy ra { switch (InsertResult) { case ActionResult.ExistedRecord: mdlStatic.SetMsg(lblMsg, "Lỗi trong khi tạo Bệnh nhân cấp cứu!\nĐã tồn tại Bệnh nhân có mã: " + _PatientInfor.Patient_Code + ". Đề nghị bạn xem lại", true); //Utility.FocusAndSelectAll(txtID); break; default: mdlStatic.SetMsg(lblMsg, "Lỗi trong quá trình thêm mới Bệnh nhân cấp cứu. Liên hệ với VBIT", true); break; } } } catch (Exception ex) { Utility.ShowMsg(ex.Message); } }