Ejemplo n.º 1
0
        private void ExecuteAction()
        {
            try
            {
                //Kiểm tra tính hợp lệ của dữ liệu trước khi thêm mới
                if (!IsValidData())
                {
                    return;
                }
                //Gán RoomEntity vào DataEntity
                SetValueforEntity();
                WLRules _BusRule = new WLRules();
                switch (Act)
                {
                    case action.Insert:
                        //Gọi nghiệp vụ Insert dữ liệu
                        PatientInfor _PatientInfor = new PatientInfor();
                        RegInfor _RegInfor = new RegInfor();
                        ActionResult InsertResult = _BusRule.Insert(DataEntity, _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 = WLDataSource.NewRow();
                            newRow["Patient_ID"] = _PatientInfor.Patient_ID;
                            newRow["PATIENT_CODE"] = AutoGenPID ? Utility.GetValue(txtID.Text, false) : Utility.GetValue(txtID.Text, false) + "_" + Utility.GetValue(txtRegID.Text, false);
                            newRow["Patient_Name"] = Utility.GetValue(txtPName.Text, false).Replace(txtAge.Text.Trim(),"").Trim();
                            newRow["PATIENT_NAME_UNSIGNED"] = Bodau(newRow["Patient_Name"].ToString());
                            newRow["PATIENT_NAME_NOSPACE"] = newRow["PATIENT_NAME_UNSIGNED"].ToString().Replace(" ", "");
                            //------------------------------------------------------------------------------
                            newRow["Birth_Date"] = dtpBirthday.Value;
                            newRow["Age"] = Convert.ToInt32(txtAge.Text.Trim());
                            newRow["sBirth_Date"] = dtpBirthday.Value.ToString("dd/MM/yyyy");
                            newRow["Sex"] = chkNam.ImageIndex == 0 ? 0 : (chkNu.ImageIndex == 0 ? 1 : 2);
                            newRow["EMERGENCY"] = EMERGENCY ? 1 : 0;
                            newRow["REG_ID"] = _RegInfor.REG_ID;
                            newRow["COMPANY_NAME"] = "VIETBAIT DROC";
                            newRow["REG_NUMBER"] = Utility.GetValue(txtRegID.Text, false);
                            //newRow["DESC"] = Utility.GetValue(txtDesc.Text, false);
                            newRow["PROCEDURELIST"] = Utility.GetValue(txtProcedure.Text, false);
                            newRow["PHYSICIAN"] = cboPhysician.SelectedValue.ToString();
                            newRow["Doctor_Name"] = cboPhysician.Text;
                            newRow["CREATED_DATE"] = dtpRegDate.Value;
                            newRow["REGSTATUS"] = 0;
                            newRow["sCREATED_DATE"] = dtpRegDate.Value.ToString("dd/MM/yyyy");
                            newRow["SEX_NAME"] = chkNam.ImageIndex == 0 ? MultiLanguage.GetText(globalVariables.DisplayLanguage, "NAM", "MALE") : (chkNu.ImageIndex == 0 ? MultiLanguage.GetText(globalVariables.DisplayLanguage, "NỮ", "FEMALE") : MultiLanguage.GetText(globalVariables.DisplayLanguage, "OTHER", ""));
                            newRow["CanDel"] = 1;
                            newRow["HasProcessed"] = 0;
                            newRow["NoneProcessed"] = 1;
                            newRow["TotalProc"] = 1;

                            if (newRow != null)//99.99% là sẽ !=null
                            {
                                WLDataSource.Rows.Add(newRow);
                                WLDataSource.AcceptChanges();
                            }
                            //Return to the InitialStatus
                            Act = action.FirstOrFinished;
                            //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(grdList, "colPatient_ID", _PatientInfor.Patient_ID.ToString());
                            mdlStatic.SetMsg(lblMsg, "Thêm mới dữ liệu thành công!", false);
                            blnRegOK = true;
                            this.Close();
                        }
                        else//Có lỗi xảy ra
                        {
                            blnRegOK = false;
                            switch (InsertResult)
                            {
                                case ActionResult.ExistedRecord:
                                    mdlStatic.SetMsg(lblMsg, "Đã 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. Liên hệ với VBIT", true);
                                    break;
                            }
                        }
                        break;
                    case action.Update:

                        //Gọi Business cập nhật dữ liệu
                        ActionResult UpdateResult = _BusRule.Update(DataEntity, Hasresult);
                        if (UpdateResult == ActionResult.Success)//Nếu thành công
                        {
                            newFolderName = ImgPath + @"\" + SubDirLv1() + @"\" + SubDirLv2_Patient();
                            Try2RenameFolderAndFileName();
                            dr["PATIENT_CODE"] = AutoGenPID ? Utility.GetValue(txtID.Text, false) : Utility.GetValue(txtID.Text, false) + "_" + Utility.GetValue(txtRegID.Text, false);
                            dr["Patient_Name"] = Utility.GetValue(txtPName.Text, false).Replace(txtAge.Text.Trim(), "").Trim();
                            dr["PATIENT_NAME_UNSIGNED"] = Bodau(dr["Patient_Name"].ToString());
                            dr["PATIENT_NAME_NOSPACE"] = dr["PATIENT_NAME_UNSIGNED"].ToString().Replace(" ", "");
                            //------------------------------------------------------------------------------
                            dr["Birth_Date"] = dtpBirthday.Value;
                            dr["sBirth_Date"] = dtpBirthday.Value.ToString("dd/MM/yyyy");
                            dr["Age"] = Convert.ToInt32(txtAge.Text.Trim());
                            dr["Sex"] = chkNam.ImageIndex == 0 ? 0 : (chkNu.ImageIndex == 0 ? 1 : 2);
                            dr["PROCEDURELIST"] = Utility.GetValue(txtProcedure.Text, false);
                            dr["PHYSICIAN"] = cboPhysician.SelectedValue.ToString();
                            //dr["DESC"] = Utility.GetValue(txtDesc.Text, false);
                            dr["Doctor_Name"] = cboPhysician.Text;
                            dr["CREATED_DATE"] = dtpRegDate.Value;
                            dr["sCREATED_DATE"] = dtpRegDate.Text;
                            NewPID = dr["PATIENT_CODE"].ToString();
                            dr["SEX_NAME"] = chkNam.ImageIndex == 0 ? MultiLanguage.GetText(globalVariables.DisplayLanguage, "NAM", "MALE") : (chkNu.ImageIndex == 0 ? MultiLanguage.GetText(globalVariables.DisplayLanguage, "NỮ", "FEMALE") : MultiLanguage.GetText(globalVariables.DisplayLanguage, "OTHER", ""));
                            WLDataSource.AcceptChanges();
                            //Return to the InitialStatus
                            Act = action.FirstOrFinished;
                            //Nhảy đến bản ghi vừa cập nhật trên lưới. Do txtID chưa bị reset nên dùng luôn
                            Utility.GotoNewRow(grdList, "colPatient_ID", Utility.sDbnull(dr["Patient_ID"]));
                            mdlStatic.SetMsg(lblMsg, "Cập nhật dữ liệu thành công.", false);
                            blnRegOK = true;
                            this.Close();
                        }
                        else//Có lỗi xảy ra
                        {
                            blnRegOK = false;
                            switch (UpdateResult)
                            {
                                case ActionResult.Error:
                                    mdlStatic.SetMsg(lblMsg, "Lỗi khi cập nhật Bệnh nhân. Liên hệ với VBIT", true);
                                    break;
                                default:
                                    mdlStatic.SetMsg(lblMsg, "Lỗi khi cập nhật Bệnh nhân. Liên hệ với VBIT", true);
                                    break;
                            }
                        }
                        break;

                    case action.Delete:

                        break;
                    default:
                        break;
                }
            }
            catch(Exception ex)
            {
                new frm_LargeMsgBoxOK(MultiLanguage.GetText(globalVariables.DisplayLanguage,"Lỗi khi tạo bệnh nhân mới","Error when creating a new patient"),  ex.ToString(), "ĐÃ HIỂU", "NO").ShowDialog();
            }
        }
Ejemplo n.º 2
0
        private void ExecuteSavingAction(DataRow drPInfor, DataTable dtAP)
        {
            try
            {

                //Gán RoomEntity vào DataEntity
                SetValueforEntity(drPInfor, dtAP);
                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(DataEntity, _PatientInfor, _RegInfor);
                if (InsertResult == ActionResult.Success)//Nếu thành công
                {
                    currREGID = _RegInfor.REG_ID;
                    //Thêm dịch vụ đăng ký
                    AddProcSearchedFromMWL(_PatientInfor.Patient_Code);
                    //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[] _arrDR = m_dtWLDataSource.Select("PATIENT_CODE='" + _PatientInfor.Patient_Code + "'");
                    if (_arrDR.Length > 0)
                    {
                        _arrDR[0]["Patient_ID"] = _PatientInfor.Patient_ID;
                        drPInfor["Patient_ID"] = _PatientInfor.Patient_ID;
                        _arrDR[0]["REG_ID"] = _RegInfor.REG_ID;




                        _arrDR[0]["HasProcessed"] = 0;
                        _arrDR[0]["NoneProcessed"] = 1;
                        _arrDR[0]["TotalProc"] = 1;


                        m_dtWLDataSource.AcceptChanges();


                    }
                }
                else//Có lỗi xảy ra
                {

                    switch (InsertResult)
                    {
                        case ActionResult.ExistedRecord:
                            mdlStatic.SetMsg(lblMsg, "Đã tồn tại Bệnh nhân có mã: " + _PatientInfor.Patient_Code + ". Đề nghị bạn xem lại", true);

                            break;
                        default:
                            mdlStatic.SetMsg(lblMsg, "Lỗi trong quá trình thêm mới Bệnh nhân. Liên hệ với VBIT", true);
                            break;
                    }
                }
            }
            catch
            {
            }
        }
Ejemplo n.º 3
0
        private void cmdImport_Click(object sender, EventArgs e)
        {
            try
            {
                if (dsExcelData == null || dsExcelData.Tables.Count <= 0 || dsExcelData.Tables[0].Select("CHON='T'").Length <= 0) return;
                using (frm_LargeMsgBox MsgBox = new frm_LargeMsgBox(globalVariables.DisplayLanguage == "VN" ? "Xác nhận nhập dữ liệu vào DROC từ file " : "Import Data from Excel file Confirm", globalVariables.DisplayLanguage == "VN" ? "Bạn có muốn nhập các Bệnh nhân đang chọn trên lưới vào hệ thống dữ liệu DROC hay không?" : "Do you want to import selected data on the Grid into DROC DataBase?", globalVariables.DisplayLanguage == "VN" ? "ĐỒNG Ý" : "ACCEPT", globalVariables.DisplayLanguage == "VN" ? "HỦY BỎ" : "CANCEL"))
                {
                    if (MsgBox.ShowDialog() == DialogResult.OK)
                    {
                        prgImportExcel.Visible = true;
                        prgImportExcel.Minimum = 0;
                        prgImportExcel.Maximum = dsExcelData.Tables[0].Rows.Count;
                        prgImportExcel.Value = 0;
                        foreach (DataRow drExcel in dsExcelData.Tables[0].Rows)
                        {
                            prgImportExcel.Value += 1;
                            if (drExcel["CHON"].ToString() == "T")
                            {
                                try
                                {

                                    //Gán RoomEntity vào DataEntity
                                    Utility.ResetEntity(ref DataEntity);
                                    Utility.ResetEntity(ref PatientEntity);

                                    Utility.ResetEntity(ref RegEntity);
                                    //Create new Row
                                    DataRow dr0 = PatientEntity.NewRow();
                                    dr0["Patient_ID"] = -1;
                                    dr0["PATIENT_CODE"] = Utility.sDbnull(drExcel["MA_BN"], "").Trim() == "" ? Utility.GetYYYYMMDDHHMMSS(DateTime.Now) : drExcel["MA_BN"].ToString();
                                    dr0["Patient_Name"] = Utility.GetValue(Utility.sDbnull(drExcel["TEN_BN"], "No Excel Name"), false);
                                    //Ngày tháng năm sinh
                                    if (Utility.sDbnull(drExcel["NGAY_SINH"], "").Trim().Length > 4 && Utility.sDbnull(drExcel["NGAY_SINH"], "").Contains("/"))
                                    {
                                        string[] birthdateOfPatient = Utility.sDbnull(drExcel["NGAY_SINH"], DateTime.Now.ToString("dd/MM/yyyy")).Split('/');
                                        dr0["Birth_Date"] = new DateTime(Convert.ToInt32(birthdateOfPatient[2]), Convert.ToInt32(birthdateOfPatient[1]), Convert.ToInt32(birthdateOfPatient[0]));
                                        dr0["sBirth_Date"] = Utility.sDbnull(drExcel["NGAY_SINH"], DateTime.Now.ToString("dd/MM/yyyy"));

                                        dr0["Age"] = DateTime.Now.AddYears(-1 * Convert.ToInt32(birthdateOfPatient[2])).Year;
                                    }
                                    //Năm sinh
                                    else if (Utility.sDbnull(drExcel["NGAY_SINH"], "").Trim().Length == 4 && !Utility.sDbnull(drExcel["NGAY_SINH"], "").Contains("/"))
                                    {
                                        dr0["Birth_Date"] = new DateTime(Convert.ToInt32(Utility.sDbnull(drExcel["NGAY_SINH"], "0")), 1, 1);
                                        dr0["sBirth_Date"] = new DateTime(Convert.ToInt32(Utility.sDbnull(drExcel["NGAY_SINH"], "0")), 1, 1).ToString("dd/MM/yyyy");

                                        dr0["Age"] = DateTime.Now.AddYears(-1 * Convert.ToInt32(Convert.ToInt32(Utility.sDbnull(drExcel["NGAY_SINH"], "0")))).Year;
                                    }
                                    else//Tuổi
                                    {
                                        dr0["Age"] = Convert.ToInt32(Convert.ToInt32(Utility.sDbnull(drExcel["NGAY_SINH"], "0")));
                                        dr0["Birth_Date"] = new DateTime(DateTime.Now.AddYears(-1 * Convert.ToInt32(dr0["Age"])).Year, 1, 1);
                                        dr0["sBirth_Date"] = new DateTime(DateTime.Now.AddYears(-1 * Convert.ToInt32(dr0["Age"])).Year, 1, 1).ToString("dd/MM/yyyy");

                                    }
                                    dr0["Sex"] = GioiTinh(drExcel["GIOI_TINH"].ToString().ToUpper());
                                    dr0["EMERGENCY"] = 0;

                                    PatientEntity.Rows.Add(dr0);
                                    PatientEntity.AcceptChanges();
                                    //Tao thong tin dang ky chup
                                    DataRow dr1 = RegEntity.NewRow();
                                    dr1["REG_ID"] = -1;

                                    dr1["REG_NUMBER"] = dr0["PATIENT_CODE"];
                                    dr1["PATIENT_ID"] = dr0["Patient_ID"];
                                    dr1["DESC"] = "";

                                    dr1["PROCEDURELIST"] = "";
                                    dr1["PHYSICIAN"] = "";
                                    dr1["CREATED_DATE"] = DateTime.Now;

                                    RegEntity.Rows.Add(dr1);
                                    RegEntity.AcceptChanges();


                                    DataEntity.Tables.Add(PatientEntity);
                                    DataEntity.Tables.Add(RegEntity);
                                    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(DataEntity, _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"] = dr0["PATIENT_CODE"];
                                        newRow["Patient_Name"] = dr0["Patient_Name"];
                                        newRow["Birth_Date"] = dr0["Birth_Date"];
                                        newRow["sBirth_Date"] = dr0["sBirth_Date"];
                                        newRow["Sex"] = dr0["Sex"];
                                        newRow["Age"] = dr0["Age"];
                                        newRow["EMERGENCY"] = 0;
                                        newRow["REG_ID"] = _RegInfor.REG_ID;
                                        newRow["REG_NUMBER"] = dr1["REG_NUMBER"];
                                        //newRow["DESC"] = Utility.GetValue(txtDesc.Text, false);
                                        newRow["PROCEDURELIST"] = "";
                                        newRow["PHYSICIAN"] = "";
                                        newRow["Doctor_Name"] = "";
                                        newRow["CREATED_DATE"] = DateTime.Now;
                                        newRow["REGSTATUS"] = 0;
                                        newRow["sCREATED_DATE"] = DateTime.Now.ToString("dd/MM/yyyy");
                                        newRow["SEX_NAME"] = drExcel["GIOI_TINH"].ToString();
                                        newRow["CanDel"] = 1;
                                        newRow["HasProcessed"] = 0;
                                        newRow["NoneProcessed"] = 0;
                                        newRow["TotalProc"] = 0;

                                        if (newRow != null)//99.99% là sẽ !=null
                                        {
                                            m_dtWLDataSource.Rows.Add(newRow);
                                            m_dtWLDataSource.AcceptChanges();
                                        }





                                    }
                                    else//Có lỗi xảy ra
                                    {

                                        switch (InsertResult)
                                        {
                                            case ActionResult.ExistedRecord:
                                                Utility.ShowMsg("Đã tồn tại Bệnh nhân có mã: " + _PatientInfor.Patient_Code + ". Đề nghị bạn xem lại", "Thông báo");

                                                break;
                                            default:
                                                mdlStatic.SetMsg(lblMsg, "Lỗi trong quá trình thêm mới Bệnh nhân. Liên hệ với VBIT", true);
                                                break;
                                        }
                                    }
                                }
                                catch
                                {
                                    prgImportExcel.Visible = false;
                                }
                            }
                            prgImportExcel.Visible = false;
                        }
                    }
                }
            }
            catch
            {
            }
            finally
            {
                prgImportExcel.Visible = false;
            }
        }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
 public RegController(RegInfor Infor)
 {
     this.Infor = Infor;
 }