private void Create_ChandoanKetluan()
        {
            if (((Utility.DoTrim(txtTenBenhChinh.Text) != "") || (grd_ICD.GetDataRows().Length > 0)) ||
                (Utility.DoTrim(txtchandoan_new.Text) != ""))
            {
                SqlQuery sqlkt =
                    new Select().From(KcbChandoanKetluan.Schema)
                    .Where(KcbChandoanKetluan.Columns.IdKham)
                    .IsEqualTo(Utility.Int64Dbnull(id_kham));
                if (KcbChandoanKetluan == null || sqlkt.GetRecordCount() <= 0)
                {
                    KcbChandoanKetluan = new KcbChandoanKetluan();
                }
                KcbChandoanKetluan.IdKham        = id_kham;
                KcbChandoanKetluan.MaLuotkham    = objLuotkham.MaLuotkham;
                KcbChandoanKetluan.IdBenhnhan    = objLuotkham.IdBenhnhan;
                KcbChandoanKetluan.MotaBenhchinh = Utility.sDbnull(txtTenBenhChinh.Text);
                KcbChandoanKetluan.MabenhChinh   = Utility.sDbnull(txtMaBenhChinh.Text, "");
                if (Utility.Int16Dbnull(globalVariables.gv_intIDNhanvien, -1) > 0)
                {
                    KcbChandoanKetluan.IdBacsikham = Utility.Int16Dbnull(globalVariables.gv_intIDNhanvien, -1);
                }
                else
                {
                    KcbChandoanKetluan.IdBacsikham = globalVariables.gv_intIDNhanvien;
                }
                KcbChandoanKetluan.MabenhPhu = Utility.sDbnull(GetDanhsachBenhphu(), "");
                if (KcbChandoanKetluan.IsNew)
                {
                    KcbChandoanKetluan.NgayTao  = ngaykedon;
                    KcbChandoanKetluan.NguoiTao = globalVariables.UserName;

                    KcbChandoanKetluan.IpMaytao  = globalVariables.gv_strIPAddress;
                    KcbChandoanKetluan.TenMaytao = globalVariables.gv_strComputerName;
                }
                else
                {
                    KcbChandoanKetluan.NgaySua  = ngaykedon;
                    KcbChandoanKetluan.NguoiSua = globalVariables.UserName;

                    KcbChandoanKetluan.IpMaysua  = globalVariables.gv_strIPAddress;
                    KcbChandoanKetluan.TenMaysua = globalVariables.gv_strComputerName;
                }
                KcbChandoanKetluan.NgayChandoan = ngaykedon;
                KcbChandoanKetluan.IdBacsikham  = globalVariables.gv_intIDNhanvien;
                KcbChandoanKetluan.Chandoan     = Utility.ReplaceString(txtChanDoan.Text);
                if (objLuotkham.Noitru != null)
                {
                    KcbChandoanKetluan.Noitru = (byte)objLuotkham.Noitru;
                }
            }
        }
Example #2
0
        public ActionResult CapnhatDonthuoc(KcbLuotkham objLuotkham, KcbDonthuoc objDonthuoc, KcbDonthuocChitiet[] arrDonthuocChitiet,KcbChandoanKetluan  _KcbChandoanKetluan,ref int p_intIdDonthuoc, ref Dictionary<long, long> lstChitietDonthuoc)
        {
            try
             {
                 using (TransactionScope scope = new TransactionScope())
                 {
                     using (SharedDbConnectionScope sh = new SharedDbConnectionScope())
                     {
                         //KcbDonthuoc objDonthuoc = KcbDonthuoc.FetchByID(objDonthuoc.IdDonthuoc);
                         p_intIdDonthuoc = objDonthuoc.IdDonthuoc;
                         new Update(KcbDonthuoc.Schema)
                             .Set(KcbDonthuoc.Columns.TaiKham).EqualTo(objDonthuoc.TaiKham)
                             .Set(KcbDonthuoc.Columns.NgayTaikham).EqualTo(objDonthuoc.NgayTaikham)
                             .Set(KcbDonthuoc.Columns.LoidanBacsi).EqualTo(objDonthuoc.LoidanBacsi)
                             .Set(KcbDonthuoc.Columns.IdPhongkham).EqualTo(objDonthuoc.IdPhongkham)
                             .Set(KcbDonthuoc.Columns.NgaySua).EqualTo(globalVariables.SysDate)
                             .Set(KcbDonthuoc.Columns.NguoiSua).EqualTo(globalVariables.UserName)
                             .Set(KcbDonthuoc.Columns.IpMaysua).EqualTo(objDonthuoc.IpMaysua)
                             .Set(KcbDonthuoc.Columns.TenMaysua).EqualTo(objDonthuoc.TenMaysua)
                             .Where(KcbDonthuoc.Columns.IdDonthuoc).IsEqualTo(objDonthuoc.IdDonthuoc).Execute();
                         if (Utility.Int32Dbnull(objDonthuoc.IdKham) > 0)
                         {
                             new Update(KcbDangkyKcb.Schema)
                          .Set(KcbDangkyKcb.Columns.IdBacsikham).EqualTo(globalVariables.gv_intIDNhanvien)
                          .Where(KcbDangkyKcb.Columns.IdKham).IsEqualTo(objDonthuoc.IdKham).Execute();
                         }
                         decimal PtramBH = Utility.DecimaltoDbnull(objLuotkham.PtramBhyt, 0);

                         foreach (KcbDonthuocChitiet objDonthuocChitiet in arrDonthuocChitiet)
                         {
                             objDonthuocChitiet.IdDonthuoc = objDonthuoc.IdDonthuoc;
                         }
                         if (objLuotkham.TrangthaiNoitru <= 0) CapnhatChandoan(_KcbChandoanKetluan);
                         foreach (KcbDonthuocChitiet objDonthuocChitiet in arrDonthuocChitiet)
                         {

                             if (objDonthuocChitiet.IdChitietdonthuoc == -1)
                             {
                                 objDonthuocChitiet.IdKham = objDonthuoc.IdKham;
                                 objDonthuocChitiet.IsNew = true;
                                 objDonthuocChitiet.SluongLinh = 0;
                                 objDonthuocChitiet.SluongSua = 0;
                                 objDonthuocChitiet.TrangThai = 0;

                                 objDonthuocChitiet.IdThanhtoan = -1;
                                 objDonthuocChitiet.MaLuotkham = objDonthuoc.MaLuotkham;
                                 objDonthuocChitiet.IdBenhnhan = objDonthuoc.IdBenhnhan;
                                 objDonthuocChitiet.IdDonthuoc = objDonthuoc.IdDonthuoc;
                                 objDonthuocChitiet.CachDung = objDonthuocChitiet.MotaThem;
                                 ThemChitiet(objDonthuoc, objDonthuocChitiet, PtramBH, objLuotkham);
                                 if (!lstChitietDonthuoc.ContainsKey(objDonthuocChitiet.IdThuockho.Value))
                                     lstChitietDonthuoc.Add(objDonthuocChitiet.IdThuockho.Value, objDonthuocChitiet.IdChitietdonthuoc);
                             }
                             else
                             {
                                 if (!lstChitietDonthuoc.ContainsKey(objDonthuocChitiet.IdThuockho.Value))
                                     lstChitietDonthuoc.Add(objDonthuocChitiet.IdThuockho.Value, objDonthuocChitiet.IdChitietdonthuoc);
                                 new Update(KcbDonthuocChitiet.Schema)
                                     .Set(KcbDonthuocChitiet.SoLuongColumn).EqualTo(objDonthuocChitiet.SoLuong)
                                     .Set(KcbDonthuocChitiet.NgaySuaColumn).EqualTo(objDonthuocChitiet.NgaySua)
                                     .Set(KcbDonthuocChitiet.NguoiSuaColumn).EqualTo(objDonthuocChitiet.NguoiSua)
                                     .Set(KcbDonthuocChitiet.Columns.IpMaysua).EqualTo(objDonthuocChitiet.IpMaysua)
                                     .Set(KcbDonthuocChitiet.Columns.TenMaysua).EqualTo(objDonthuocChitiet.TenMaysua)
                                     .Where(KcbDonthuocChitiet.IdChitietdonthuocColumn).IsEqualTo(objDonthuocChitiet.IdChitietdonthuoc).Execute();
                             }
                         }
                     }
                     scope.Complete();
                     return ActionResult.Success;
                 }
             }
             catch (Exception exception)
             {
                 log.Error("Loi trong qua trinh luu don thuoc", exception);
                 return ActionResult.Error;
             }
        }
        private void frm_KCB_KeVacxin_Tiemchung_Load(object sender, EventArgs e)
        {
            try
            {
                chkAdditional.Checked = forced2Add;
                chkAdditional.Visible = !forced2Add && objLuotkham.TrangthaiNoitru>0;

                txtptramdauthe.Visible = objLuotkham.IdLoaidoituongKcb == 0;
                lblphantramdauthe.Visible = objLuotkham.IdLoaidoituongKcb == 0;
                pnlChandoanNgoaitru.Visible = objLuotkham.TrangthaiNoitru <= 0;
                m_dtDulieuTiemchungBN = KCB_KEDONTHUOC.KcbThamkhamDulieuTiemchungTheoBenhnhan(objLuotkham.IdBenhnhan);
                m_dtqheCamchidinhChungphieu = new Select().From(QheCamchidinhChungphieu.Schema).Where(QheCamchidinhChungphieu.Columns.Loai).IsEqualTo(1).ExecuteDataSet().Tables[0];
                BHYT_PTRAM_TRAITUYENNOITRU = Utility.DecimaltoDbnull(THU_VIEN_CHUNG.Laygiatrithamsohethong("BHYT_PTRAM_TRAITUYENNOITRU", "0", false), 0m);
                m_intKieudonthuoc = KIEU_THUOC_VT == "THUOC" ? 2 : 1;
                txtCachDung.LOAI_DANHMUC = KIEU_THUOC_VT == "THUOC" ? "CDDT" :"CHIDAN_KEVATTU";
                this.AutoloadSaveAndPrintConfig();
                this.LayDanhsachBSKham();
                this.LayDanhsachKhoVacxin();
                this.LoadLaserPrinters();
                this.txtCachDung.Init();
                txtLydotiem.Init();
                LayCongtiem();
                this.GetData();
                this.GetDataPresDetail();
                this.txtChanDoan.Init();
                this.LoadBenh();
                mnuThuoctutuc.Visible = THU_VIEN_CHUNG.IsBaoHiem(objLuotkham.IdLoaidoituongKcb);
                chkTutuc.Visible = THU_VIEN_CHUNG.IsBaoHiem(objLuotkham.IdLoaidoituongKcb);
                if (!chkTutuc.Visible) chkTutuc.Checked = false;
                this.MaDoiTuong = objLuotkham.MaDoituongKcb;
                if (this._KcbChandoanKetluan == null)
                {
                    this._KcbChandoanKetluan = new KcbChandoanKetluan();
                    this._KcbChandoanKetluan.IsNew = true;
                }
                else
                {
                    this._KcbChandoanKetluan.IsNew = false;
                    this._KcbChandoanKetluan.MarkOld();
                }
                bool gridView = Utility.Int32Dbnull(THU_VIEN_CHUNG.Laygiatrithamsohethong("KEDONTHUOC_SUDUNGLUOI", "0", true), 0) == 1;
                if (!gridView)
                {
                    gridView = PropertyLib._AppProperties.GridView;
                }
                this.txtdrug.GridView = gridView;
                this.isLoaded = true;
                this.AllowTextChanged = true;
                this.blnHasLoaded = true;
                if (KIEU_THUOC_VT == "THUOC")
                    globalVariables.KHOKEDON = PropertyLib._ThamKhamProperties.IDKho;
                else
                    globalVariables.KHOKEDON = PropertyLib._ThamKhamProperties.IDKhoVT;

                if (this.dtStockList.Select(TDmucKho.Columns.IdKho + "= " + globalVariables.KHOKEDON).Length > 0)
                {
                    this.cboStock.SelectedIndex = Utility.GetSelectedIndex(this.cboStock, globalVariables.KHOKEDON.ToString());
                    this.cboStock_SelectedIndexChanged(this.cboStock, new EventArgs());
                }
                else
                {
                    this.cboStock.SelectedIndex = -1;
                }
                if (this.cboStock.Items.Count == 0)
                {
                    Utility.ShowMsg(string.Format("Bệnh nhân {0} thuộc đối tượng {1} chưa Có kho " + (KIEU_THUOC_VT == "THUOC" ? "thuốc" : "vật tư") + " để kê đơn", this.txtPatientName.Text.Trim(), this.txtObjectName.Text.Trim()));
                    base.Close();
                }
                this.grdPresDetail.RootTable.Groups.Clear();
                if (this.chkHienthithuoctheonhom.Checked)
                {
                    GridEXColumn column = this.grdPresDetail.RootTable.Columns["ma_loaithuoc"];
                    GridEXGroup group = new GridEXGroup(column)
                    {
                        GroupPrefix = "Loại " + KIEU_THUOC_VT == "THUOC" ? "thuốc" : "vật tư" + " : "
                    };
                    this.grdPresDetail.RootTable.Groups.Add(group);
                }
                this.txtdrug.Focus();
                this.txtdrug.Select();
            }
            catch(Exception ex)
            {
                Utility.CatchException(ex);
            }
            finally
            {
            }
        }
        public ActionResult ThemDonThuoc(KcbLuotkham objLuotkham, KcbDonthuoc objDonthuoc, KcbDonthuocChitiet[] arrDonthuocChitiet, KcbChandoanKetluan _KcbChandoanKetluan, ref long p_intIdDonthuoc, ref Dictionary<long, long> lstChitietDonthuoc)
        {
            // Query _Query = KcbDonthuoc.CreateQuery();
             try
             {
                 using (TransactionScope scope = new TransactionScope())
                 {
                     using (SharedDbConnectionScope sh = new SharedDbConnectionScope())
                     {
                         if (objLuotkham != null)
                         {
                             if (objDonthuoc.NgayKedon <= Convert.ToDateTime("01/01/1900"))
                                 objDonthuoc.NgayKedon = globalVariables.SysDate;

                             objDonthuoc.IsNew = true;
                             objDonthuoc.TenDonthuoc = THU_VIEN_CHUNG.TaoTenDonthuoc(objLuotkham.MaLuotkham,
                                                                                        Utility.Int32Dbnull(
                                                                                            objLuotkham.IdBenhnhan,
                                                                                            -1));

                             objDonthuoc.Save();

                             KcbDangkyKcb objKCB = KcbDangkyKcb.FetchByID(objDonthuoc.IdKham);
                             if (objKCB != null)
                             {
                                 objKCB.DakeDonthuoc = 1;
                                 objKCB.IdBacsikham = objDonthuoc.IdBacsiChidinh;
                                 objKCB.IsNew = false;
                                 objKCB.Save();
                             }

                             if (!Utility.Byte2Bool(objDonthuoc.Noitru))
                                 CapnhatChandoan(_KcbChandoanKetluan);
                             p_intIdDonthuoc = objDonthuoc.IdDonthuoc;
                             decimal PtramBH = Utility.DecimaltoDbnull(objLuotkham.PtramBhyt, 0);
                             bool TUDONGDANHDAU_TRANGTHAISUDUNG = THU_VIEN_CHUNG.Laygiatrithamsohethong("KCB_TIEMCHUNG_TUDONGDANHDAU_TRANGTHAISUDUNG", "0", false) == "1";
                             foreach (KcbDonthuocChitiet objDonthuocChitiet in arrDonthuocChitiet)
                             {
                                 objDonthuocChitiet.IdKham = objDonthuoc.IdKham;
                                 objDonthuocChitiet.MaLuotkham = objDonthuoc.MaLuotkham;
                                 objDonthuocChitiet.IdBenhnhan = objDonthuoc.IdBenhnhan;
                                 objDonthuocChitiet.IdDonthuoc = objDonthuoc.IdDonthuoc;
                                 objDonthuocChitiet.NgaySudung = objDonthuoc.NgayKedon;
                                 objDonthuocChitiet.DaDung=Utility.Bool2byte(TUDONGDANHDAU_TRANGTHAISUDUNG);
                                 ThemChitiet(objDonthuoc, objDonthuocChitiet, PtramBH, objLuotkham);
                                 //Tạo mới dòng dữ liệu tempt để kiểm tra tồn kho theo ngày
                                 TblKedonthuocTempt newItem = new TblKedonthuocTempt();
                                 newItem.IdChitietdonthuoc = objDonthuocChitiet.IdChitietdonthuoc;
                                 newItem.IdDonthuoc = objDonthuocChitiet.IdDonthuoc;
                                 newItem.IdKho =Utility.Int32Dbnull( objDonthuocChitiet.IdKho,-1);
                                 newItem.IdThuoc = objDonthuocChitiet.IdThuoc;
                                 newItem.IdThuockho =Utility.Int64Dbnull( objDonthuocChitiet.IdThuockho,-1);
                                 newItem.NgayKedon = objDonthuoc.NgayKedon;
                                 newItem.SoLuong = objDonthuocChitiet.SoLuong;
                                 newItem.TrangThai = Utility.ByteDbnull(objDonthuocChitiet.TrangThai, 0);
                                 newItem.IsNew = true;
                                 newItem.Save();
                                 if (!lstChitietDonthuoc.ContainsKey(objDonthuocChitiet.IdThuockho.Value))
                                     lstChitietDonthuoc.Add(objDonthuocChitiet.IdThuockho.Value, objDonthuocChitiet.IdChitietdonthuoc);
                             }

                         }

                     }
                     scope.Complete();
                     return ActionResult.Success;
                 }
             }
             catch (Exception exception)
             {

                 log.Error("Loi trong qua trinh luu don thuoc {0}", exception);
                 return ActionResult.Error;
             }
        }
Example #5
0
        public ActionResult LuuHoibenhvaChandoan(KcbChandoanKetluan objDiagInfo)
        {
            try
            {
                using (var scope = new TransactionScope())
                {
                    using (var sh = new SharedDbConnectionScope())
                    {

                        if (objDiagInfo.IsNew)
                        {
                            objDiagInfo.Save();
                        }
                        else
                        {
                            objDiagInfo.MarkOld();
                            objDiagInfo.Save();
                        }

                    }

                    scope.Complete();
                    //  Reg_ID = Utility.Int32Dbnull(objRegExam.IdKham, -1);
                    return ActionResult.Success;
                }
            }
            catch (Exception exception)
            {
                log.Error("Loi trong qua trinh chuyen vien khoi noi tru {0}", exception);
                return ActionResult.Error;
            }
        }
        void cmdGhichandoan_Click(object sender, EventArgs e)
        {
            try
            {
                if (!isValidChandoan()) return;
                KcbChandoanKetluan objKcbChandoanKetluan = new KcbChandoanKetluan();
                if (m_enActChandoan == action.Update)
                {
                    objKcbChandoanKetluan = KcbChandoanKetluan.FetchByID(Utility.Int32Dbnull(txtIdChandoan.Text, -1));
                    objKcbChandoanKetluan.MarkOld();
                    objKcbChandoanKetluan.IsNew = false;
                }
                else
                {
                    objKcbChandoanKetluan = new KcbChandoanKetluan();
                    objKcbChandoanKetluan.IsNew = true;
                }
                objKcbChandoanKetluan.MaLuotkham = objLuotkham.MaLuotkham;
                objKcbChandoanKetluan.IdBenhnhan = objLuotkham.IdBenhnhan;
                objKcbChandoanKetluan.MabenhChinh = Utility.sDbnull(txtMaBenhChinh.Text, "");
                objKcbChandoanKetluan.Nhommau = txtNhommau.Text;
                objKcbChandoanKetluan.Nhietdo = Utility.sDbnull(txtNhietDo.Text);
                objKcbChandoanKetluan.Huyetap = txtHa.Text;
                objKcbChandoanKetluan.Mach = txtMach.Text;
                objKcbChandoanKetluan.Nhiptim = Utility.sDbnull(txtNhipTim.Text);
                objKcbChandoanKetluan.Nhiptho = Utility.sDbnull(txtNhipTho.Text);
                objKcbChandoanKetluan.Chieucao = Utility.sDbnull(txtChieucao.Text);
                objKcbChandoanKetluan.Cannang = Utility.sDbnull(txtCannang.Text);
                objKcbChandoanKetluan.HuongDieutri = "";
                objKcbChandoanKetluan.SongayDieutri = 0;

                if (cboBSDieutri.SelectedIndex > 0)
                    objKcbChandoanKetluan.IdBacsikham = Utility.Int16Dbnull(cboBSDieutri.SelectedValue, -1);
                else
                {
                    objKcbChandoanKetluan.IdBacsikham = globalVariables.gv_intIDNhanvien;
                }
                string sMaICDPHU = GetDanhsachBenhphu();
                objKcbChandoanKetluan.MabenhPhu = Utility.sDbnull(sMaICDPHU.ToString(), "");
                objKcbChandoanKetluan.IdKhoanoitru = objLuotkham.IdKhoanoitru;
                objKcbChandoanKetluan.IdBuongNoitru = objLuotkham.IdBuong;
                objKcbChandoanKetluan.IdGiuongNoitru = objLuotkham.IdGiuong;
                objKcbChandoanKetluan.IdBuongGiuong = objLuotkham.IdRavien;

                objKcbChandoanKetluan.IdKham = objPhieudieutri == null ? -1 : objPhieudieutri.IdPhieudieutri;
                objKcbChandoanKetluan.NgayTao = dtpCreatedDate.Value;
                objKcbChandoanKetluan.NguoiTao = globalVariables.UserName;
                objKcbChandoanKetluan.NgayChandoan = dtpNgaychandoan.Value;
                objKcbChandoanKetluan.Ketluan = "";
                objKcbChandoanKetluan.Chandoan = Utility.ReplaceString(txtChanDoan.Text);
                objKcbChandoanKetluan.ChandoanKemtheo = Utility.sDbnull(txtChanDoanKemTheo.Text);
                objKcbChandoanKetluan.IdPhieudieutri = objPhieudieutri == null ? -1 : objPhieudieutri.IdPhieudieutri;
                objKcbChandoanKetluan.Noitru = 1;
                objKcbChandoanKetluan.Save();
                DataRow[] arrDr = m_dtChandoanKCB.Select(KcbChandoanKetluan.Columns.IdChandoan + "=" + objKcbChandoanKetluan.IdChandoan.ToString());
                if (arrDr.Length > 0)
                {
                    Utility.FromObjectToDatarow(objKcbChandoanKetluan, ref arrDr[0]);
                    arrDr[0]["sNgay_chandoan"] = dtpNgaychandoan.Text;
                    Utility.GotoNewRowJanus(grdChandoan, KcbChandoanKetluan.Columns.IdChandoan, objKcbChandoanKetluan.IdChandoan.ToString());
                    m_dtChandoanKCB.AcceptChanges();
                }
                else
                {
                    DataRow newDr = m_dtChandoanKCB.NewRow();
                    Utility.FromObjectToDatarow(objKcbChandoanKetluan, ref newDr);
                    newDr["sNgay_chandoan"] = dtpNgaychandoan.Text;
                    m_dtChandoanKCB.Rows.Add(newDr);
                    m_dtChandoanKCB.AcceptChanges();
                    Utility.GotoNewRowJanus(grdChandoan, KcbChandoanKetluan.Columns.IdChandoan, objKcbChandoanKetluan.IdChandoan.ToString());
                }
                EnableChandoan(false);
                cmdGhichandoan.Enabled = cmdHuychandoan.Enabled = false;
                ModifyCommmands();
                grdChandoan_SelectionChanged(grdChandoan, e);
            }
            catch (Exception ex)
            {
                Utility.CatchException(ex);
            }
        }
 private void ThemphieuVattu_tronggoi()
 {
     try
     {
         // KeDonThuocTheoDoiTuong();
         frm_KCB_KE_DONTHUOC frm = new frm_KCB_KE_DONTHUOC("VT");
         frm.em_Action = action.Insert;
         frm.objLuotkham = CreatePatientExam();
         frm._KcbChandoanKetluan = _KcbChandoanKetluan;
         frm._MabenhChinh = txtMaBenhChinh.Text;
         frm._Chandoan = txtChanDoan.Text;
         if (objPhieudieutri != null)
             frm.forced2Add = Utility.Byte2Bool(objPhieudieutri.TthaiBosung);
         frm.dt_ICD = dt_ICD;
         frm.dt_ICD_PHU = dt_ICD_PHU;
         frm.id_kham = Utility.Int32Dbnull(txtExam_ID.Text);
         frm.objPhieudieutriNoitru = NoitruPhieudieutri.FetchByID(Utility.Int32Dbnull(txtIdPhieudieutri.Text));
         frm.txtPatientCode.Text = Utility.sDbnull(objLuotkham.MaLuotkham);
         frm.id_kham = -1;
         frm.id_goidv=Utility.Int32Dbnull(Utility.GetValueFromGridColumn(grdGoidichvu,KcbChidinhclsChitiet.Columns.IdChitietchidinh),-1) ;
         frm.trong_goi=1;
         frm.txtPatientID.Text = Utility.sDbnull(objLuotkham.IdBenhnhan);
         frm.txtPres_ID.Text = "-1";
         frm.noitru = 1;
         frm.CallActionKeDon = CallActionKieuKeDon.TheoDoiTuong;
         frm.ShowDialog();
         if (frm.b_Cancel)
         {
             txtMaBenhChinh.Text = frm._MabenhChinh;
             txtChanDoan._Text = frm._Chandoan;
             dt_ICD_PHU = frm.dt_ICD_PHU;
             if (frm._KcbChandoanKetluan != null) _KcbChandoanKetluan = frm._KcbChandoanKetluan;
             LaythongtinPhieudieutri();
             TinhtoanTongchiphi();
             Utility.GotoNewRowJanus(grdVTTH_tronggoi, KcbDonthuoc.Columns.IdDonthuoc,
                                     Utility.sDbnull(frm.txtPres_ID.Text));
             ModifyCommmands();
         }
     }
     catch (Exception exception)
     {
         if (globalVariables.IsAdmin)
         {
             Utility.ShowMsg(exception.ToString());
         }
     }
     finally
     {
         txtPatient_Code.Focus();
         txtPatient_Code.SelectAll();
     }
 }
Example #8
0
        /// <summary>
        /// hàm thực hiện việc update thông tin xác nhận gói
        /// </summary>
        /// <param name="objThongtinGoiDvuBnhan"></param>
        /// <returns></returns>


        public ActionResult UpdateExamInfo(KcbChandoanKetluan objDiagInfo, KcbDangkyKcb objRegExam,
                                           KcbLuotkham objPatientExam)
        {
            try
            {
                using (var scope = new TransactionScope())
                {
                    using (var sh = new SharedDbConnectionScope())
                    {
                        if (objDiagInfo != null)
                        {
                            log.Trace("1.1 Bat dau ket thuc benh nhan: " + objDiagInfo.MaLuotkham);
                            if (objDiagInfo.IsNew)
                            {
                                //  objDiagInfo.Save();
                                SPs.SpKcbThemmoiChandoanKetluan(objDiagInfo.IdChandoan, objDiagInfo.IdKham,
                                                                objDiagInfo.IdBenhnhan,
                                                                objDiagInfo.MaLuotkham, objDiagInfo.IdBacsikham, objDiagInfo.NgayChandoan,
                                                                objDiagInfo.NguoiTao,
                                                                objDiagInfo.NgayTao, objDiagInfo.IdKhoanoitru, objDiagInfo.IdBuonggiuong,
                                                                objDiagInfo.IdBuong, objDiagInfo.IdGiuong
                                                                , objDiagInfo.IdPhieudieutri, objDiagInfo.Noitru, objDiagInfo.IdPhongkham,
                                                                objDiagInfo.TenPhongkham, objDiagInfo.Mach, objDiagInfo.Nhietdo, objDiagInfo.Huyetap
                                                                , objDiagInfo.Nhiptim, objDiagInfo.Nhiptho, objDiagInfo.Cannang,
                                                                objDiagInfo.Chieucao, objDiagInfo.Nhommau, objDiagInfo.Ketluan, objDiagInfo.ChedoDinhduong,
                                                                objDiagInfo.HuongDieutri, objDiagInfo.SongayDieutri, objDiagInfo.TrieuchungBandau
                                                                , objDiagInfo.Chandoan, objDiagInfo.ChandoanKemtheo, objDiagInfo.MabenhChinh,
                                                                objDiagInfo.MabenhPhu, objDiagInfo.MotaBenhchinh, objDiagInfo.IpMaytao, objDiagInfo.TenMaytao,
                                                                objDiagInfo.PhanungSautiemchung, objDiagInfo.KPL1
                                                                , objDiagInfo.KPL2, objDiagInfo.KPL3, objDiagInfo.KPL4, objDiagInfo.KPL5,
                                                                objDiagInfo.KPL6, objDiagInfo.KPL7, objDiagInfo.KPL8, objDiagInfo.KL1,
                                                                objDiagInfo.KL2, objDiagInfo.KL3, objDiagInfo.KetluanNguyennhan, objDiagInfo.NhanXet
                                                                , objDiagInfo.ChongchidinhKhac, objDiagInfo.SoNgayhen, objDiagInfo.ChisoIbm, objDiagInfo.ThilucMp, objDiagInfo.ThilucMt, objDiagInfo.NhanapMp, objDiagInfo.NhanapMt
                                                                ).Execute();
                            }
                            else
                            {
                                SPs.SpKcbCapnhatChandoanKetluan(objDiagInfo.IdChandoan, objDiagInfo.IdBacsikham,
                                                                objDiagInfo.NgayChandoan, objDiagInfo.NguoiSua, objDiagInfo.NgaySua,
                                                                objDiagInfo.IdPhieudieutri
                                                                , objDiagInfo.Noitru, objDiagInfo.IdPhongkham, objDiagInfo.TenPhongkham,
                                                                objDiagInfo.Mach, objDiagInfo.Nhietdo, objDiagInfo.Huyetap, objDiagInfo.Nhiptim,
                                                                objDiagInfo.Nhiptho, objDiagInfo.Cannang, objDiagInfo.Chieucao
                                                                , objDiagInfo.Nhommau, objDiagInfo.Ketluan, objDiagInfo.ChedoDinhduong, objDiagInfo.HuongDieutri,
                                                                objDiagInfo.SongayDieutri, objDiagInfo.TrieuchungBandau, objDiagInfo.Chandoan,
                                                                objDiagInfo.ChandoanKemtheo, objDiagInfo.MabenhChinh
                                                                , objDiagInfo.MabenhPhu, objDiagInfo.MotaBenhchinh, objDiagInfo.IpMaysua, objDiagInfo.TenMaysua,
                                                                objDiagInfo.PhanungSautiemchung, objDiagInfo.KPL1
                                                                , objDiagInfo.KPL2, objDiagInfo.KPL3, objDiagInfo.KPL4, objDiagInfo.KPL5,
                                                                objDiagInfo.KPL6, objDiagInfo.KPL7, objDiagInfo.KPL8, objDiagInfo.KL1,
                                                                objDiagInfo.KL2, objDiagInfo.KL3, objDiagInfo.KetluanNguyennhan, objDiagInfo.NhanXet,
                                                                objDiagInfo.ChongchidinhKhac, objDiagInfo.SoNgayhen, objDiagInfo.ChisoIbm, objDiagInfo.ThilucMp, objDiagInfo.ThilucMt, objDiagInfo.NhanapMp, objDiagInfo.NhanapMt).Execute();
                            }
                        }
                        log.Trace("1.2 Luu xong chan doan cua benh nhan: " + objDiagInfo.MaLuotkham);
                        SqlQuery sqlQuery = new Select().From(
                            KcbChandoanKetluan.Schema)
                                            .Where(KcbChandoanKetluan.Columns.MaLuotkham).IsEqualTo(objPatientExam.MaLuotkham)
                                            .And(KcbChandoanKetluan.Columns.IdBenhnhan).IsEqualTo(objPatientExam.IdBenhnhan)
                                            .And(KcbChandoanKetluan.Columns.IdKham).IsEqualTo(objRegExam.IdKham).OrderAsc(
                            KcbChandoanKetluan.Columns.NgayChandoan);

                        KcbChandoanKetluanCollection objInfoCollection = sqlQuery.ExecuteAsCollection <KcbChandoanKetluanCollection>();

                        var query = (from chandoan in objInfoCollection.AsEnumerable()
                                     let y = Utility.sDbnull(chandoan.Chandoan)
                                             where (y != "")
                                             select y).ToArray();
                        string cdchinh = string.Join(";", query);
                        //KcbChandoanKetluanCollection objInfoCollection = sqlQuery.ExecuteAsCollection<KcbChandoanKetluanCollection>();
                        var querychandoanphu = (from chandoan in objInfoCollection.AsEnumerable()
                                                let y = Utility.sDbnull(chandoan.ChandoanKemtheo)
                                                        where (y != "")
                                                        select y).ToArray();
                        string cdphu          = string.Join(";", querychandoanphu);
                        var    querybenhchinh = (from benhchinh in objInfoCollection.AsEnumerable()
                                                 let y = Utility.sDbnull(benhchinh.MabenhChinh)
                                                         where (y != "")
                                                         select y).ToArray();
                        string mabenhchinh = string.Join(";", querybenhchinh);

                        var querybenhphu = (from benhphu in objInfoCollection.AsEnumerable()
                                            let y = Utility.sDbnull(benhphu.MabenhPhu)
                                                    where (y != "")
                                                    select y).ToArray();
                        string mabenhphu = string.Join(";", querybenhphu);
                        SPs.KcbLuotkhamTrangthaiketthuckham(objPatientExam.IdBenhnhan,
                                                            objPatientExam.MaLuotkham, objPatientExam.TrangthaiNgoaitru, objPatientExam.Noitru,
                                                            mabenhchinh, mabenhphu, objPatientExam.KetLuan, objPatientExam.HuongDieutri, cdchinh
                                                            , cdphu, objPatientExam.Locked, objPatientExam.SongayDieutri, objPatientExam.TrieuChung,
                                                            globalVariables.UserName, globalVariables.SysDate, globalVariables.gv_strIPAddress,
                                                            globalVariables.gv_strComputerName, objDiagInfo.IdBacsikham, objRegExam.TrangThai,
                                                            objRegExam.IdKham).Execute();

                        log.Trace("1.3 Update thanh cong trang thai cua benh nhan: " + objDiagInfo.MaLuotkham);

                        //new Update(KcbLuotkham.Schema)
                        //    .Set(KcbLuotkham.Columns.MabenhChinh).EqualTo(mabenhchinh)
                        //    .Set(KcbLuotkham.Columns.MabenhPhu).EqualTo(mabenhphu)
                        //    .Set(KcbLuotkham.Columns.KetLuan).EqualTo(objPatientExam.KetLuan)
                        //    .Set(KcbLuotkham.Columns.HuongDieutri).EqualTo(objPatientExam.HuongDieutri)
                        //    .Set(KcbLuotkham.Columns.ChanDoan).EqualTo(cdchinh)
                        //    .Set(KcbLuotkham.Columns.SongayDieutri).EqualTo(objPatientExam.SongayDieutri)
                        //    .Set(KcbLuotkham.Columns.ChandoanKemtheo).EqualTo(cdphu)
                        //    .Set(KcbLuotkham.Columns.TrieuChung).EqualTo(objPatientExam.TrieuChung)
                        //    .Set(KcbLuotkham.Columns.NguoiSua).EqualTo(globalVariables.UserName)
                        //    .Set(KcbLuotkham.Columns.NgaySua).EqualTo(globalVariables.SysDate)
                        //    .Set(KcbLuotkham.Columns.Locked).EqualTo(objPatientExam.Locked)
                        //    .Set(KcbLuotkham.Columns.NguoiKetthuc).EqualTo(objPatientExam.NguoiKetthuc)
                        //    .Set(KcbLuotkham.Columns.NgayKetthuc).EqualTo(objPatientExam.NgayKetthuc)
                        //    .Set(KcbLuotkham.Columns.TrangthaiNgoaitru).EqualTo(objPatientExam.TrangthaiNgoaitru)
                        //    .Where(KcbLuotkham.Columns.MaLuotkham).IsEqualTo(objPatientExam.MaLuotkham)
                        //    .And(KcbLuotkham.Columns.IdBenhnhan).IsEqualTo(objPatientExam.IdBenhnhan).Execute();
                        ////Tạm bỏ tránh việc bị cập nhật sai bác sĩ chỉ định nếu bác sĩ đó chỉ lưu thông tin kết luận
                        ////SPs.KcbThamkhamCappnhatBsyKham(Utility.Int32Dbnull(objRegExam.IdKham, -1), objPatientExam.MaLuotkham,
                        ////                            Utility.Int32Dbnull(objPatientExam.IdBenhnhan, -1),
                        ////                            Utility.Int32Dbnull(objDiagInfo.DoctorId, -1)).Execute();

                        //if (objRegExam != null)
                        //{
                        //    new Update(KcbDangkyKcb.Schema)
                        //        .Set(KcbDangkyKcb.Columns.NgaySua).EqualTo(globalVariables.SysDate)
                        //        .Set(KcbDangkyKcb.Columns.NguoiSua).EqualTo(globalVariables.UserName)
                        //        .Set(KcbDangkyKcb.Columns.IpMaysua).EqualTo(globalVariables.gv_strIPAddress)
                        //        .Set(KcbDangkyKcb.Columns.TenMaysua).EqualTo(globalVariables.gv_strComputerName)
                        //        .Set(KcbDangkyKcb.Columns.IdBacsikham).EqualTo(objDiagInfo.IdBacsikham)
                        //        .Set(KcbDangkyKcb.Columns.TrangThai).EqualTo(objRegExam.TrangThai)
                        //        .Where(KcbDangkyKcb.Columns.IdKham).IsEqualTo(Utility.Int32Dbnull(objRegExam.IdKham, -1)).
                        //        Execute();
                        //}
                        sh.Dispose();
                    }

                    scope.Complete();
                    //  Reg_ID = Utility.Int32Dbnull(objRegExam.IdKham, -1);
                    return(ActionResult.Success);
                }
            }
            catch (Exception exception)
            {
                log.Error("Loi trong qua trinh ket thuc benh nhan", exception);
                return(ActionResult.Error);
            }
        }
Example #9
0
        public ActionResult ThemDonThuoc(KcbLuotkham objLuotkham, KcbDonthuoc objDonthuoc, KcbDonthuocChitiet[] arrDonthuocChitiet, KcbChandoanKetluan _KcbChandoanKetluan, ref int p_intIdDonthuoc, ref Dictionary <long, long> lstChitietDonthuoc)
        {
            // Query _Query = KcbDonthuoc.CreateQuery();
            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    using (SharedDbConnectionScope sh = new SharedDbConnectionScope())
                    {
                        if (objLuotkham != null)
                        {
                            if (objDonthuoc.NgayKedon <= Convert.ToDateTime("01/01/1900"))
                            {
                                objDonthuoc.NgayKedon = globalVariables.SysDate;
                            }

                            objDonthuoc.IsNew       = true;
                            objDonthuoc.TenDonthuoc = THU_VIEN_CHUNG.TaoTenDonthuoc(objLuotkham.MaLuotkham,
                                                                                    Utility.Int32Dbnull(
                                                                                        objLuotkham.IdBenhnhan,
                                                                                        -1));

                            objDonthuoc.Save();
                            if (!Utility.Byte2Bool(objDonthuoc.Noitru))
                            {
                                CapnhatChandoan(_KcbChandoanKetluan);
                            }
                            p_intIdDonthuoc = objDonthuoc.IdDonthuoc;
                            decimal PtramBH = Utility.DecimaltoDbnull(objLuotkham.PtramBhyt, 0);

                            foreach (KcbDonthuocChitiet objDonthuocChitiet in arrDonthuocChitiet)
                            {
                                objDonthuocChitiet.IdKham     = objDonthuoc.IdKham;
                                objDonthuocChitiet.MaLuotkham = objDonthuoc.MaLuotkham;
                                objDonthuocChitiet.IdBenhnhan = objDonthuoc.IdBenhnhan;
                                objDonthuocChitiet.IdDonthuoc = objDonthuoc.IdDonthuoc;
                                ThemChitiet(objDonthuoc, objDonthuocChitiet, PtramBH, objLuotkham);
                                if (!lstChitietDonthuoc.ContainsKey(objDonthuocChitiet.IdThuockho.Value))
                                {
                                    lstChitietDonthuoc.Add(objDonthuocChitiet.IdThuockho.Value, objDonthuocChitiet.IdChitietdonthuoc);
                                }
                            }
                        }
                    }
                    scope.Complete();
                    return(ActionResult.Success);
                }
            }
            catch (Exception exception)
            {
                log.Error("Loi trong qua trinh luu don thuoc {0}", exception);
                return(ActionResult.Error);
            }
        }
Example #10
0
        public ActionResult CapnhatChandoan(KcbChandoanKetluan objKcbChandoanKetluan)
        {
            try
            {
                if (objKcbChandoanKetluan == null)
                {
                    return(ActionResult.Cancel);
                }
                using (TransactionScope scope = new TransactionScope())
                {
                    using (SharedDbConnectionScope sh = new SharedDbConnectionScope())
                    {
                        if (objKcbChandoanKetluan.IsNew)
                        {
                            objKcbChandoanKetluan.Save();
                        }
                        else
                        {
                            objKcbChandoanKetluan.MarkOld();
                            objKcbChandoanKetluan.Save();
                        }

                        SqlQuery sqlQuery = new Select().From(KcbChandoanKetluan.Schema)
                                            .Where(KcbChandoanKetluan.Columns.MaLuotkham).IsEqualTo(objKcbChandoanKetluan.MaLuotkham)
                                            .And(KcbChandoanKetluan.Columns.IdBenhnhan).IsEqualTo(objKcbChandoanKetluan.IdBenhnhan).OrderAsc(
                            KcbChandoanKetluan.Columns.NgayChandoan);
                        KcbChandoanKetluanCollection objInfoCollection = sqlQuery.ExecuteAsCollection <KcbChandoanKetluanCollection>();
                        var query = (from chandoan in objInfoCollection.AsEnumerable()
                                     let y = Utility.sDbnull(chandoan.Chandoan)
                                             where (y != "")
                                             select y).ToArray();
                        string cdchinh          = string.Join(";", query);
                        var    querychandoanphu = (from chandoan in objInfoCollection.AsEnumerable()
                                                   let y = Utility.sDbnull(chandoan.ChandoanKemtheo)
                                                           where (y != "")
                                                           select y).ToArray();
                        string cdphu          = string.Join(";", querychandoanphu);
                        var    querybenhchinh = (from benhchinh in objInfoCollection.AsEnumerable()
                                                 let y = Utility.sDbnull(benhchinh.MabenhChinh)
                                                         where (y != "")
                                                         select y).ToArray();
                        string mabenhchinh = string.Join(";", querybenhchinh);

                        var querybenhphu = (from benhphu in objInfoCollection.AsEnumerable()
                                            let y = Utility.sDbnull(benhphu.MabenhPhu)
                                                    where (y != "")
                                                    select y).ToArray();
                        string mabenhphu = string.Join(";", querybenhphu);
                        new Update(KcbLuotkham.Schema)
                        .Set(KcbLuotkham.Columns.MabenhChinh).EqualTo(mabenhchinh)
                        .Set(KcbLuotkham.Columns.MabenhPhu).EqualTo(mabenhphu)
                        .Set(KcbLuotkham.Columns.ChanDoan).EqualTo(cdchinh)
                        .Set(KcbLuotkham.Columns.NguoiSua).EqualTo(globalVariables.UserName)
                        .Set(KcbLuotkham.Columns.NgaySua).EqualTo(globalVariables.SysDate)
                        .Where(KcbLuotkham.Columns.MaLuotkham).IsEqualTo(objKcbChandoanKetluan.MaLuotkham)
                        .And(KcbLuotkham.Columns.IdBenhnhan).IsEqualTo(objKcbChandoanKetluan.IdBenhnhan).Execute();
                    }

                    scope.Complete();
                    //  Reg_ID = Utility.Int32Dbnull(objRegExam.IdKham, -1);
                    return(ActionResult.Success);
                }
            }
            catch (Exception exception)
            {
                log.Error("Loi trong qua trinh chuyen vien khoi noi tru {0}", exception);
                return(ActionResult.Error);
            }
        }
Example #11
0
        public ActionResult CapnhatDonthuoc(KcbLuotkham objLuotkham, KcbDonthuoc objDonthuoc, KcbDonthuocChitiet[] arrDonthuocChitiet, KcbChandoanKetluan _KcbChandoanKetluan, ref long p_intIdDonthuoc, ref Dictionary <long, long> lstChitietDonthuoc)
        {
            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    using (SharedDbConnectionScope sh = new SharedDbConnectionScope())
                    {
                        log.Trace("4. Bat dau cap nhat don thuoc");
                        p_intIdDonthuoc = objDonthuoc.IdDonthuoc;
                        SPs.SpKcbCapnhatDonthuoc(objDonthuoc.IdDonthuoc, globalVariables.UserName, globalVariables.SysDate, objDonthuoc.LoidanBacsi,
                                                 objDonthuoc.NgayTaikham, objDonthuoc.TaiKham, objDonthuoc.IpMaysua, objDonthuoc.TenMaysua).Execute();
                        log.Trace("4.1 Da cap nhat don thuoc");
                        if (Utility.Int32Dbnull(objDonthuoc.IdKham) > 0)
                        {
                            SPs.SpKcbCapnhatBacsiKham(objDonthuoc.IdKham, objDonthuoc.IdBacsiChidinh, 0).Execute();
                            log.Trace("4.2 Da cap nhat BS kham=BS ke don");
                        }
                        decimal PtramBH = Utility.DecimaltoDbnull(objLuotkham.PtramBhyt, 0);

                        foreach (KcbDonthuocChitiet objDonthuocChitiet in arrDonthuocChitiet)
                        {
                            objDonthuocChitiet.IdDonthuoc = objDonthuoc.IdDonthuoc;
                        }
                        if (objLuotkham.TrangthaiNoitru <= 0)
                        {
                            CapnhatChandoan(_KcbChandoanKetluan);
                        }
                        log.Trace("4.3 Da cap nhat thong tin chan doan ket luan");
                        foreach (KcbDonthuocChitiet objDonthuocChitiet in arrDonthuocChitiet)
                        {
                            if (objDonthuocChitiet.IdChitietdonthuoc == -1)
                            {
                                objDonthuocChitiet.IdKham     = objDonthuoc.IdKham;
                                objDonthuocChitiet.IsNew      = true;
                                objDonthuocChitiet.SluongLinh = 0;
                                objDonthuocChitiet.SluongSua  = 0;
                                objDonthuocChitiet.TrangThai  = 0;

                                objDonthuocChitiet.IdThanhtoan = -1;
                                objDonthuocChitiet.MaLuotkham  = objDonthuoc.MaLuotkham;
                                objDonthuocChitiet.IdBenhnhan  = objDonthuoc.IdBenhnhan;
                                objDonthuocChitiet.IdDonthuoc  = objDonthuoc.IdDonthuoc;
                                objDonthuocChitiet.CachDung    = objDonthuocChitiet.MotaThem;
                                ThemChitiet(objDonthuoc, objDonthuocChitiet, PtramBH, objLuotkham);
                                if (!lstChitietDonthuoc.ContainsKey(objDonthuocChitiet.IdThuockho.Value))
                                {
                                    lstChitietDonthuoc.Add(objDonthuocChitiet.IdThuockho.Value, objDonthuocChitiet.IdChitietdonthuoc);
                                }
                            }
                            else
                            {
                                if (!lstChitietDonthuoc.ContainsKey(objDonthuocChitiet.IdThuockho.Value))
                                {
                                    lstChitietDonthuoc.Add(objDonthuocChitiet.IdThuockho.Value, objDonthuocChitiet.IdChitietdonthuoc);
                                }
                                SPs.SpKcbCapnhatChitietDonthuoc(objDonthuocChitiet.IdChitietdonthuoc, objDonthuocChitiet.SoLuong, objDonthuocChitiet.NgaySua
                                                                , objDonthuocChitiet.NguoiSua, objDonthuocChitiet.IpMaysua, objDonthuocChitiet.TenMaysua).Execute();
                            }
                        }
                        log.Trace("4.4 Da cap nhat xong chi tiet don thuoc");
                    }
                    scope.Complete();
                    return(ActionResult.Success);
                }
            }
            catch (Exception exception)
            {
                log.Error(string.Format("Loi khi cap nhat don thuoc {0}", exception.Message));
                return(ActionResult.Error);
            }
        }
Example #12
0
        public ActionResult ThemDonThuoc(KcbLuotkham objLuotkham, KcbDonthuoc objDonthuoc, KcbDonthuocChitiet[] arrDonthuocChitiet, KcbChandoanKetluan _KcbChandoanKetluan, ref long p_intIdDonthuoc, ref Dictionary <long, long> lstChitietDonthuoc)
        {
            // Query _Query = KcbDonthuoc.CreateQuery();
            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    using (SharedDbConnectionScope sh = new SharedDbConnectionScope())
                    {
                        if (objLuotkham != null)
                        {
                            log.Trace("4. Bat dau luu thuoc vao CSDL");
                            if (objDonthuoc.NgayKedon <= Convert.ToDateTime("01/01/1900"))
                            {
                                objDonthuoc.NgayKedon = globalVariables.SysDate;
                            }

                            objDonthuoc.IsNew       = true;
                            objDonthuoc.TenDonthuoc = THU_VIEN_CHUNG.TaoTenDonthuoc(objLuotkham.MaLuotkham,
                                                                                    Utility.Int32Dbnull(
                                                                                        objLuotkham.IdBenhnhan,
                                                                                        -1));
                            var sp = SPs.SpKcbThemmoiDonthuoc(objDonthuoc.IdDonthuoc, objDonthuoc.IdPhieudieutri, objDonthuoc.IdKhoadieutri, objDonthuoc.IdDonthuocthaythe, objDonthuoc.IdKham
                                                              , objDonthuoc.IdBenhnhan, objDonthuoc.MaLuotkham, objDonthuoc.NgayKedon, objDonthuoc.IdBacsiChidinh, objDonthuoc.TrangThai, objDonthuoc.TthaiTonghop
                                                              , objDonthuoc.TrangthaiThanhtoan, objDonthuoc.NgayThanhtoan, objDonthuoc.IdGoi, objDonthuoc.TrongGoi, objDonthuoc.NguoiTao, objDonthuoc.NgayTao
                                                              , objDonthuoc.MotaThem, objDonthuoc.TenDonthuoc, objDonthuoc.MaDoituongKcb, objDonthuoc.Noitru, objDonthuoc.KieuDonthuoc, objDonthuoc.IdPhongkham
                                                              , objDonthuoc.IdBuongGiuong, objDonthuoc.IdBuongNoitru, objDonthuoc.IdGiuongNoitru, objDonthuoc.LoidanBacsi, objDonthuoc.NgayTaikham
                                                              , objDonthuoc.TaiKham, objDonthuoc.MaKhoaThuchien, objDonthuoc.NgayCapphat, objDonthuoc.KieuThuocvattu, objDonthuoc.NgayChot
                                                              , objDonthuoc.IdChot, objDonthuoc.NgayHuychot, objDonthuoc.NguoiHuychot, objDonthuoc.LydoHuychot, objDonthuoc.NgayHuyxacnhan, objDonthuoc.NguoiHuyxacnhan
                                                              , objDonthuoc.LydoHuyxacnhan, objDonthuoc.NgayXacnhan, objDonthuoc.NguoiXacnhan, objDonthuoc.IdLichsuDoituongKcb, objDonthuoc.MatheBhyt
                                                              , objDonthuoc.IpMaytao, objDonthuoc.TenMaytao, objDonthuoc.LastActionName);
                            sp.Execute();
                            objDonthuoc.IdDonthuoc = Utility.Int64Dbnull(sp.OutputValues[0]);
                            log.Trace("4.1 Da luu don thuoc CSDL");
                            SPs.SpKcbCapnhatBacsiKham(objDonthuoc.IdKham, objDonthuoc.IdBacsiChidinh, 0).Execute();
                            log.Trace("4.2 Cap nhat bac si kham = BS ke don");

                            if (!Utility.Byte2Bool(objDonthuoc.Noitru))
                            {
                                CapnhatChandoan(_KcbChandoanKetluan);
                            }
                            log.Trace("4.3 Da luu chan doan ket luan");
                            p_intIdDonthuoc = objDonthuoc.IdDonthuoc;
                            decimal PtramBH = Utility.DecimaltoDbnull(objLuotkham.PtramBhyt, 0);
                            bool    TUDONGDANHDAU_TRANGTHAISUDUNG = THU_VIEN_CHUNG.Laygiatrithamsohethong("KCB_TIEMCHUNG_TUDONGDANHDAU_TRANGTHAISUDUNG", "0", false) == "1";
                            foreach (KcbDonthuocChitiet objDonthuocChitiet in arrDonthuocChitiet)
                            {
                                objDonthuocChitiet.IdKham     = objDonthuoc.IdKham;
                                objDonthuocChitiet.MaLuotkham = objDonthuoc.MaLuotkham;
                                objDonthuocChitiet.IdBenhnhan = objDonthuoc.IdBenhnhan;
                                objDonthuocChitiet.IdDonthuoc = objDonthuoc.IdDonthuoc;
                                objDonthuocChitiet.NgaySudung = objDonthuoc.NgayKedon;
                                objDonthuocChitiet.DaDung     = Utility.Bool2byte(TUDONGDANHDAU_TRANGTHAISUDUNG);
                                ThemChitiet(objDonthuoc, objDonthuocChitiet, PtramBH, objLuotkham);
                                if (!lstChitietDonthuoc.ContainsKey(objDonthuocChitiet.IdThuockho.Value))
                                {
                                    lstChitietDonthuoc.Add(objDonthuocChitiet.IdThuockho.Value, objDonthuocChitiet.IdChitietdonthuoc);
                                }
                            }
                            log.Trace("4.4 Da luu xong chi tiet don thuoc");
                        }
                    }
                    scope.Complete();
                    return(ActionResult.Success);
                }
            }
            catch (Exception exception)
            {
                log.Error("Loi trong qua trinh luu don thuoc {0}", exception);
                return(ActionResult.Error);
            }
        }
Example #13
0
        public ActionResult CapnhatChandoan(KcbChandoanKetluan objKcbChandoanKetluan)
        {
            try
            {
                if (objKcbChandoanKetluan == null || objKcbChandoanKetluan.IdBenhnhan <= 0 || objKcbChandoanKetluan.IdKham <= 0)
                {
                    return(ActionResult.Cancel);
                }
                using (TransactionScope scope = new TransactionScope())
                {
                    using (SharedDbConnectionScope sh = new SharedDbConnectionScope())
                    {
                        SqlQuery sqlkt = new Select().From(KcbChandoanKetluan.Schema).Where(KcbChandoanKetluan.Columns.IdKham).IsEqualTo(objKcbChandoanKetluan.IdKham);
                        if (objKcbChandoanKetluan.IsNew || sqlkt.GetRecordCount() <= 0)
                        {
                            var sp = SPs.SpKcbThemmoiChandoanKetluan(objKcbChandoanKetluan.IdChandoan,
                                                                     objKcbChandoanKetluan.IdKham, objKcbChandoanKetluan.IdBenhnhan,
                                                                     objKcbChandoanKetluan.MaLuotkham
                                                                     , objKcbChandoanKetluan.IdBacsikham, objKcbChandoanKetluan.NgayChandoan,
                                                                     objKcbChandoanKetluan.NguoiTao, objKcbChandoanKetluan.NgayTao,
                                                                     objKcbChandoanKetluan.IdKhoanoitru
                                                                     , objKcbChandoanKetluan.IdBuonggiuong, objKcbChandoanKetluan.IdBuong,
                                                                     objKcbChandoanKetluan.IdGiuong, objKcbChandoanKetluan.IdPhieudieutri
                                                                     , objKcbChandoanKetluan.Noitru, objKcbChandoanKetluan.IdPhongkham,
                                                                     objKcbChandoanKetluan.TenPhongkham, objKcbChandoanKetluan.Mach
                                                                     , objKcbChandoanKetluan.Nhietdo, objKcbChandoanKetluan.Huyetap,
                                                                     objKcbChandoanKetluan.Nhiptim, objKcbChandoanKetluan.Nhiptho,
                                                                     objKcbChandoanKetluan.Cannang
                                                                     , objKcbChandoanKetluan.Chieucao, objKcbChandoanKetluan.Nhommau,
                                                                     objKcbChandoanKetluan.Ketluan, objKcbChandoanKetluan.ChedoDinhduong,
                                                                     objKcbChandoanKetluan.HuongDieutri, objKcbChandoanKetluan.SongayDieutri
                                                                     , objKcbChandoanKetluan.TrieuchungBandau, objKcbChandoanKetluan.Chandoan,
                                                                     objKcbChandoanKetluan.ChandoanKemtheo, objKcbChandoanKetluan.MabenhChinh,
                                                                     objKcbChandoanKetluan.MabenhPhu, objKcbChandoanKetluan.MotaBenhchinh
                                                                     , objKcbChandoanKetluan.IpMaytao, objKcbChandoanKetluan.TenMaytao,
                                                                     objKcbChandoanKetluan.PhanungSautiemchung, objKcbChandoanKetluan.KPL1
                                                                     , objKcbChandoanKetluan.KPL2, objKcbChandoanKetluan.KPL3, objKcbChandoanKetluan.KPL4,
                                                                     objKcbChandoanKetluan.KPL5, objKcbChandoanKetluan.KPL6
                                                                     , objKcbChandoanKetluan.KPL7, objKcbChandoanKetluan.KPL8, objKcbChandoanKetluan.KL1,
                                                                     objKcbChandoanKetluan.KL2, objKcbChandoanKetluan.KL3
                                                                     , objKcbChandoanKetluan.KetluanNguyennhan, objKcbChandoanKetluan.NhanXet,
                                                                     objKcbChandoanKetluan.ChongchidinhKhac, objKcbChandoanKetluan.SoNgayhen, objKcbChandoanKetluan.ChisoIbm, objKcbChandoanKetluan.ThilucMp, objKcbChandoanKetluan.ThilucMt, objKcbChandoanKetluan.NhanapMp, objKcbChandoanKetluan.NhanapMt);

                            sp.Execute();
                            objKcbChandoanKetluan.IdChandoan = Utility.Int64Dbnull(sp.OutputValues[0]);
                        }
                        else
                        {
                            SPs.SpKcbCapnhatChandoanKetluan(objKcbChandoanKetluan.IdChandoan
                                                            , objKcbChandoanKetluan.IdBacsikham, objKcbChandoanKetluan.NgayChandoan, objKcbChandoanKetluan.NguoiSua, objKcbChandoanKetluan.NgaySua, objKcbChandoanKetluan.IdPhieudieutri
                                                            , objKcbChandoanKetluan.Noitru, objKcbChandoanKetluan.IdPhongkham, objKcbChandoanKetluan.TenPhongkham, objKcbChandoanKetluan.Mach
                                                            , objKcbChandoanKetluan.Nhietdo, objKcbChandoanKetluan.Huyetap, objKcbChandoanKetluan.Nhiptim, objKcbChandoanKetluan.Nhiptho, objKcbChandoanKetluan.Cannang
                                                            , objKcbChandoanKetluan.Chieucao, objKcbChandoanKetluan.Nhommau, objKcbChandoanKetluan.Ketluan, objKcbChandoanKetluan.ChedoDinhduong, objKcbChandoanKetluan.HuongDieutri, objKcbChandoanKetluan.SongayDieutri
                                                            , objKcbChandoanKetluan.TrieuchungBandau, objKcbChandoanKetluan.Chandoan, objKcbChandoanKetluan.ChandoanKemtheo, objKcbChandoanKetluan.MabenhChinh, objKcbChandoanKetluan.MabenhPhu, objKcbChandoanKetluan.MotaBenhchinh
                                                            , objKcbChandoanKetluan.IpMaytao, objKcbChandoanKetluan.TenMaytao, objKcbChandoanKetluan.PhanungSautiemchung, objKcbChandoanKetluan.KPL1
                                                            , objKcbChandoanKetluan.KPL2, objKcbChandoanKetluan.KPL3, objKcbChandoanKetluan.KPL4, objKcbChandoanKetluan.KPL5, objKcbChandoanKetluan.KPL6
                                                            , objKcbChandoanKetluan.KPL7, objKcbChandoanKetluan.KPL8, objKcbChandoanKetluan.KL1, objKcbChandoanKetluan.KL2, objKcbChandoanKetluan.KL3
                                                            , objKcbChandoanKetluan.KetluanNguyennhan, objKcbChandoanKetluan.NhanXet, objKcbChandoanKetluan.ChongchidinhKhac, objKcbChandoanKetluan.SoNgayhen, objKcbChandoanKetluan.ChisoIbm, objKcbChandoanKetluan.ThilucMp, objKcbChandoanKetluan.ThilucMt, objKcbChandoanKetluan.NhanapMp, objKcbChandoanKetluan.NhanapMt).Execute();
                        }
                        DataTable dtData = SPs.SpKcbLaydulieuChandoanKetluanTheoluotkham(objKcbChandoanKetluan.IdBenhnhan, objKcbChandoanKetluan.MaLuotkham).GetDataSet().Tables[0];
                        var       query  = (from chandoan in dtData.AsEnumerable()
                                            let y = Utility.sDbnull(chandoan["Chandoan"])
                                                    where (y != "")
                                                    select y).ToArray();
                        string cdchinh          = string.Join(";", query);
                        var    querychandoanphu = (from chandoan in dtData.AsEnumerable()
                                                   let y = Utility.sDbnull(chandoan["chandoan_kemtheo"])
                                                           where (y != "")
                                                           select y).ToArray();
                        string cdphu          = string.Join(";", querychandoanphu);
                        var    querybenhchinh = (from benhchinh in dtData.AsEnumerable()
                                                 let y = Utility.sDbnull(benhchinh["mabenh_chinh"])
                                                         where (y != "")
                                                         select y).ToArray();
                        string mabenhchinh = string.Join(";", querybenhchinh);

                        var querybenhphu = (from benhphu in dtData.AsEnumerable()
                                            let y = Utility.sDbnull(benhphu["mabenh_phu"])
                                                    where (y != "")
                                                    select y).ToArray();
                        string mabenhphu = string.Join(";", querybenhphu);
                        SPs.SpKcbCapnhatMabenhChoLuotkham(objKcbChandoanKetluan.IdBenhnhan, objKcbChandoanKetluan.MaLuotkham,
                                                          mabenhchinh, mabenhphu, cdchinh, globalVariables.SysDate, globalVariables.UserName).Execute();
                    }

                    scope.Complete();
                    return(ActionResult.Success);
                }
            }
            catch (Exception exception)
            {
                log.Error("Loi trong qua trinh chuyen vien khoi noi tru {0}", exception);
                return(ActionResult.Error);
            }
        }
        public void Insert(long IdKham,long IdBenhnhan,string MaLuotkham,short IdBacsikham,DateTime NgayChandoan,string NguoiTao,DateTime NgayTao,string NguoiSua,DateTime? NgaySua,int? IdKhoanoitru,long? IdBuonggiuong,short? IdBuong,short? IdGiuong,long? IdPhieudieutri,byte Noitru,int? IdPhongkham,string TenPhongkham,string Mach,string Nhietdo,string Huyetap,string Nhiptim,string Nhiptho,string Cannang,string Chieucao,string Nhommau,string Ketluan,string HuongDieutri,short? SongayDieutri,string TrieuchungBandau,string Chandoan,string ChandoanKemtheo,string MabenhChinh,string MabenhPhu,string IpMaytao,string IpMaysua,string TenMaytao,string TenMaysua,string PhanungSautiemchung,byte? KPL1,byte? KPL2,byte? KPL3,byte? KPL4,byte? KPL5,byte? KPL6,byte? KPL7,byte? KPL8,byte? KL1,byte? KL2,byte? KL3,string KetluanNguyennhan,string NhanXet,string ChongchidinhKhac)
        {
            KcbChandoanKetluan item = new KcbChandoanKetluan();

            item.IdKham = IdKham;

            item.IdBenhnhan = IdBenhnhan;

            item.MaLuotkham = MaLuotkham;

            item.IdBacsikham = IdBacsikham;

            item.NgayChandoan = NgayChandoan;

            item.NguoiTao = NguoiTao;

            item.NgayTao = NgayTao;

            item.NguoiSua = NguoiSua;

            item.NgaySua = NgaySua;

            item.IdKhoanoitru = IdKhoanoitru;

            item.IdBuonggiuong = IdBuonggiuong;

            item.IdBuong = IdBuong;

            item.IdGiuong = IdGiuong;

            item.IdPhieudieutri = IdPhieudieutri;

            item.Noitru = Noitru;

            item.IdPhongkham = IdPhongkham;

            item.TenPhongkham = TenPhongkham;

            item.Mach = Mach;

            item.Nhietdo = Nhietdo;

            item.Huyetap = Huyetap;

            item.Nhiptim = Nhiptim;

            item.Nhiptho = Nhiptho;

            item.Cannang = Cannang;

            item.Chieucao = Chieucao;

            item.Nhommau = Nhommau;

            item.Ketluan = Ketluan;

            item.HuongDieutri = HuongDieutri;

            item.SongayDieutri = SongayDieutri;

            item.TrieuchungBandau = TrieuchungBandau;

            item.Chandoan = Chandoan;

            item.ChandoanKemtheo = ChandoanKemtheo;

            item.MabenhChinh = MabenhChinh;

            item.MabenhPhu = MabenhPhu;

            item.IpMaytao = IpMaytao;

            item.IpMaysua = IpMaysua;

            item.TenMaytao = TenMaytao;

            item.TenMaysua = TenMaysua;

            item.PhanungSautiemchung = PhanungSautiemchung;

            item.KPL1 = KPL1;

            item.KPL2 = KPL2;

            item.KPL3 = KPL3;

            item.KPL4 = KPL4;

            item.KPL5 = KPL5;

            item.KPL6 = KPL6;

            item.KPL7 = KPL7;

            item.KPL8 = KPL8;

            item.KL1 = KL1;

            item.KL2 = KL2;

            item.KL3 = KL3;

            item.KetluanNguyennhan = KetluanNguyennhan;

            item.NhanXet = NhanXet;

            item.ChongchidinhKhac = ChongchidinhKhac;

            item.Save(UserName);
        }
Example #15
0
        public ActionResult LuuHoibenhvaChandoan(KcbChandoanKetluan objDiagInfo, KcbDonthuocChitiet objChitiet, bool luudulieutiemchung)
        {
            try
            {
                using (var scope = new TransactionScope())
                {
                    using (var sh = new SharedDbConnectionScope())
                    {
                        if (objChitiet != null)
                        {
                            objChitiet.IsNew = false;
                            if (objDiagInfo != null)
                            {
                                objChitiet.PhanungSautiem    = objDiagInfo.PhanungSautiemchung;
                                objChitiet.Xutri             = objDiagInfo.HuongDieutri;
                                objChitiet.KetQua            = objDiagInfo.Ketluan;
                                objChitiet.KetluanNguyennhan = objDiagInfo.KetluanNguyennhan;
                            }
                            objChitiet.MarkOld();
                            objChitiet.Save();
                        }
                        if (objDiagInfo != null)
                        {
                            log.Trace("1. Bắt đầu lưu chẩn đoán của bệnh nhân: " + objDiagInfo.MaLuotkham);
                            if (objDiagInfo.IsNew)
                            {
                                //  objDiagInfo.Save();
                                SPs.SpKcbThemmoiChandoanKetluan(objDiagInfo.IdChandoan, objDiagInfo.IdKham,
                                                                objDiagInfo.IdBenhnhan,
                                                                objDiagInfo.MaLuotkham, objDiagInfo.IdBacsikham, objDiagInfo.NgayChandoan,
                                                                objDiagInfo.NguoiTao,
                                                                objDiagInfo.NgayTao, objDiagInfo.IdKhoanoitru, objDiagInfo.IdBuonggiuong,
                                                                objDiagInfo.IdBuong, objDiagInfo.IdGiuong
                                                                , objDiagInfo.IdPhieudieutri, objDiagInfo.Noitru, objDiagInfo.IdPhongkham,
                                                                objDiagInfo.TenPhongkham, objDiagInfo.Mach, objDiagInfo.Nhietdo, objDiagInfo.Huyetap
                                                                , objDiagInfo.Nhiptim, objDiagInfo.Nhiptho, objDiagInfo.Cannang,
                                                                objDiagInfo.Chieucao, objDiagInfo.Nhommau, objDiagInfo.Ketluan, objDiagInfo.ChedoDinhduong,
                                                                objDiagInfo.HuongDieutri, objDiagInfo.SongayDieutri, objDiagInfo.TrieuchungBandau
                                                                , objDiagInfo.Chandoan, objDiagInfo.ChandoanKemtheo, objDiagInfo.MabenhChinh,
                                                                objDiagInfo.MabenhPhu, objDiagInfo.MotaBenhchinh, objDiagInfo.IpMaytao, objDiagInfo.TenMaytao,
                                                                objDiagInfo.PhanungSautiemchung, objDiagInfo.KPL1
                                                                , objDiagInfo.KPL2, objDiagInfo.KPL3, objDiagInfo.KPL4, objDiagInfo.KPL5,
                                                                objDiagInfo.KPL6, objDiagInfo.KPL7, objDiagInfo.KPL8, objDiagInfo.KL1,
                                                                objDiagInfo.KL2, objDiagInfo.KL3, objDiagInfo.KetluanNguyennhan, objDiagInfo.NhanXet
                                                                , objDiagInfo.ChongchidinhKhac, objDiagInfo.SoNgayhen, objDiagInfo.ChisoIbm, objDiagInfo.ThilucMp, objDiagInfo.ThilucMt, objDiagInfo.NhanapMp, objDiagInfo.NhanapMt
                                                                ).Execute();
                                log.Trace("1.1 Thêm mới lưu chẩn đoán của bệnh nhân: " + objDiagInfo.MaLuotkham);
                            }
                            else
                            {
                                SPs.SpKcbCapnhatChandoanKetluan(objDiagInfo.IdChandoan, objDiagInfo.IdBacsikham,
                                                                objDiagInfo.NgayChandoan, objDiagInfo.NguoiSua, objDiagInfo.NgaySua,
                                                                objDiagInfo.IdPhieudieutri
                                                                , objDiagInfo.Noitru, objDiagInfo.IdPhongkham, objDiagInfo.TenPhongkham,
                                                                objDiagInfo.Mach, objDiagInfo.Nhietdo, objDiagInfo.Huyetap, objDiagInfo.Nhiptim,
                                                                objDiagInfo.Nhiptho, objDiagInfo.Cannang, objDiagInfo.Chieucao
                                                                , objDiagInfo.Nhommau, objDiagInfo.Ketluan, objDiagInfo.ChedoDinhduong, objDiagInfo.HuongDieutri,
                                                                objDiagInfo.SongayDieutri, objDiagInfo.TrieuchungBandau, objDiagInfo.Chandoan,
                                                                objDiagInfo.ChandoanKemtheo, objDiagInfo.MabenhChinh
                                                                , objDiagInfo.MabenhPhu, objDiagInfo.MotaBenhchinh, objDiagInfo.IpMaysua, objDiagInfo.TenMaysua,
                                                                objDiagInfo.PhanungSautiemchung, objDiagInfo.KPL1
                                                                , objDiagInfo.KPL2, objDiagInfo.KPL3, objDiagInfo.KPL4, objDiagInfo.KPL5,
                                                                objDiagInfo.KPL6, objDiagInfo.KPL7, objDiagInfo.KPL8, objDiagInfo.KL1,
                                                                objDiagInfo.KL2, objDiagInfo.KL3, objDiagInfo.KetluanNguyennhan, objDiagInfo.NhanXet,
                                                                objDiagInfo.ChongchidinhKhac, objDiagInfo.SoNgayhen, objDiagInfo.ChisoIbm, objDiagInfo.ThilucMp, objDiagInfo.ThilucMt, objDiagInfo.NhanapMp, objDiagInfo.NhanapMt).Execute();
                                log.Trace("1.2 Cập nhật chẩn đoán của bệnh nhân: " + objDiagInfo.MaLuotkham);
                                // objDiagInfo.MarkOld();

                                //  objDiagInfo.Save();
                            }
                            if (luudulieutiemchung && objChitiet == null)
                            {
                                new Update(KcbDonthuocChitiet.Schema)
                                .Set(KcbDonthuocChitiet.Columns.PhanungSautiem).EqualTo(objDiagInfo.PhanungSautiemchung)
                                .Set(KcbDonthuocChitiet.Columns.Xutri).EqualTo(objDiagInfo.HuongDieutri)
                                .Set(KcbDonthuocChitiet.Columns.KetQua).EqualTo(objDiagInfo.Ketluan)
                                .Set(KcbDonthuocChitiet.Columns.KetluanNguyennhan).EqualTo(objDiagInfo.KetluanNguyennhan)
                                .Where(KcbDonthuocChitiet.Columns.IdKham).IsEqualTo(objDiagInfo.IdKham)
                                .Execute();
                            }
                            log.Trace("2.Kết thúc lưu chẩn đoán của bệnh nhân: " + objDiagInfo.MaLuotkham);
                        }
                        log.Trace("");
                        sh.Dispose();
                    }

                    scope.Complete();
                    //  Reg_ID = Utility.Int32Dbnull(objRegExam.IdKham, -1);
                    return(ActionResult.Success);
                }
            }
            catch (Exception exception)
            {
                log.Error("Loi trong qua trinh chuyen vien khoi noi tru {0}", exception);
                return(ActionResult.Error);
            }
        }
Example #16
0
        public ActionResult ThemDonThuoc(KcbLuotkham objLuotkham, KcbDonthuoc objDonthuoc, KcbDonthuocChitiet[] arrDonthuocChitiet,KcbChandoanKetluan _KcbChandoanKetluan, ref int p_intIdDonthuoc, ref Dictionary<long, long> lstChitietDonthuoc)
        {
            // Query _Query = KcbDonthuoc.CreateQuery();
             try
             {
                 using (TransactionScope scope = new TransactionScope())
                 {
                     using (SharedDbConnectionScope sh = new SharedDbConnectionScope())
                     {
                         if (objLuotkham != null)
                         {
                             if (objDonthuoc.NgayKedon <= Convert.ToDateTime("01/01/1900"))
                                 objDonthuoc.NgayKedon = globalVariables.SysDate;

                             objDonthuoc.IsNew = true;
                             objDonthuoc.TenDonthuoc = THU_VIEN_CHUNG.TaoTenDonthuoc(objLuotkham.MaLuotkham,
                                                                                        Utility.Int32Dbnull(
                                                                                            objLuotkham.IdBenhnhan,
                                                                                            -1));

                             objDonthuoc.Save();
                             if (!Utility.Byte2Bool(objDonthuoc.Noitru))
                                 CapnhatChandoan(_KcbChandoanKetluan);
                             p_intIdDonthuoc = objDonthuoc.IdDonthuoc;
                             decimal PtramBH = Utility.DecimaltoDbnull(objLuotkham.PtramBhyt, 0);

                             foreach (KcbDonthuocChitiet objDonthuocChitiet in arrDonthuocChitiet)
                             {
                                 objDonthuocChitiet.IdKham = objDonthuoc.IdKham;
                                 objDonthuocChitiet.MaLuotkham = objDonthuoc.MaLuotkham;
                                 objDonthuocChitiet.IdBenhnhan = objDonthuoc.IdBenhnhan;
                                 objDonthuocChitiet.IdDonthuoc = objDonthuoc.IdDonthuoc;
                                 ThemChitiet(objDonthuoc, objDonthuocChitiet, PtramBH, objLuotkham);
                                 if (!lstChitietDonthuoc.ContainsKey(objDonthuocChitiet.IdThuockho.Value))
                                     lstChitietDonthuoc.Add(objDonthuocChitiet.IdThuockho.Value, objDonthuocChitiet.IdChitietdonthuoc);
                             }

                         }

                     }
                     scope.Complete();
                     return ActionResult.Success;
                 }
             }
             catch (Exception exception)
             {

                 log.Error("Loi trong qua trinh luu don thuoc {0}", exception);
                 return ActionResult.Error;
             }
        }
 public bool Destroy(object IdChandoan)
 {
     return(KcbChandoanKetluan.Destroy(IdChandoan) == 1);
 }
Example #18
0
        public ActionResult CapnhatDonthuoc(KcbLuotkham objLuotkham, KcbDonthuoc objDonthuoc, KcbDonthuocChitiet[] arrDonthuocChitiet, KcbChandoanKetluan _KcbChandoanKetluan, ref int p_intIdDonthuoc, ref Dictionary <long, long> lstChitietDonthuoc)
        {
            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    using (SharedDbConnectionScope sh = new SharedDbConnectionScope())
                    {
                        //KcbDonthuoc objDonthuoc = KcbDonthuoc.FetchByID(objDonthuoc.IdDonthuoc);
                        p_intIdDonthuoc = objDonthuoc.IdDonthuoc;
                        new Update(KcbDonthuoc.Schema)
                        .Set(KcbDonthuoc.Columns.TaiKham).EqualTo(objDonthuoc.TaiKham)
                        .Set(KcbDonthuoc.Columns.NgayTaikham).EqualTo(objDonthuoc.NgayTaikham)
                        .Set(KcbDonthuoc.Columns.LoidanBacsi).EqualTo(objDonthuoc.LoidanBacsi)
                        .Set(KcbDonthuoc.Columns.IdPhongkham).EqualTo(objDonthuoc.IdPhongkham)
                        .Set(KcbDonthuoc.Columns.NgaySua).EqualTo(globalVariables.SysDate)
                        .Set(KcbDonthuoc.Columns.NguoiSua).EqualTo(globalVariables.UserName)
                        .Set(KcbDonthuoc.Columns.IpMaysua).EqualTo(objDonthuoc.IpMaysua)
                        .Set(KcbDonthuoc.Columns.TenMaysua).EqualTo(objDonthuoc.TenMaysua)
                        .Where(KcbDonthuoc.Columns.IdDonthuoc).IsEqualTo(objDonthuoc.IdDonthuoc).Execute();
                        if (Utility.Int32Dbnull(objDonthuoc.IdKham) > 0)
                        {
                            new Update(KcbDangkyKcb.Schema)
                            .Set(KcbDangkyKcb.Columns.IdBacsikham).EqualTo(globalVariables.gv_intIDNhanvien)
                            .Where(KcbDangkyKcb.Columns.IdKham).IsEqualTo(objDonthuoc.IdKham).Execute();
                        }
                        decimal PtramBH = Utility.DecimaltoDbnull(objLuotkham.PtramBhyt, 0);

                        foreach (KcbDonthuocChitiet objDonthuocChitiet in arrDonthuocChitiet)
                        {
                            objDonthuocChitiet.IdDonthuoc = objDonthuoc.IdDonthuoc;
                        }
                        if (objLuotkham.TrangthaiNoitru <= 0)
                        {
                            CapnhatChandoan(_KcbChandoanKetluan);
                        }
                        foreach (KcbDonthuocChitiet objDonthuocChitiet in arrDonthuocChitiet)
                        {
                            if (objDonthuocChitiet.IdChitietdonthuoc == -1)
                            {
                                objDonthuocChitiet.IdKham     = objDonthuoc.IdKham;
                                objDonthuocChitiet.IsNew      = true;
                                objDonthuocChitiet.SluongLinh = 0;
                                objDonthuocChitiet.SluongSua  = 0;
                                objDonthuocChitiet.TrangThai  = 0;

                                objDonthuocChitiet.IdThanhtoan = -1;
                                objDonthuocChitiet.MaLuotkham  = objDonthuoc.MaLuotkham;
                                objDonthuocChitiet.IdBenhnhan  = objDonthuoc.IdBenhnhan;
                                objDonthuocChitiet.IdDonthuoc  = objDonthuoc.IdDonthuoc;
                                objDonthuocChitiet.CachDung    = objDonthuocChitiet.MotaThem;
                                ThemChitiet(objDonthuoc, objDonthuocChitiet, PtramBH, objLuotkham);
                                if (!lstChitietDonthuoc.ContainsKey(objDonthuocChitiet.IdThuockho.Value))
                                {
                                    lstChitietDonthuoc.Add(objDonthuocChitiet.IdThuockho.Value, objDonthuocChitiet.IdChitietdonthuoc);
                                }
                            }
                            else
                            {
                                if (!lstChitietDonthuoc.ContainsKey(objDonthuocChitiet.IdThuockho.Value))
                                {
                                    lstChitietDonthuoc.Add(objDonthuocChitiet.IdThuockho.Value, objDonthuocChitiet.IdChitietdonthuoc);
                                }
                                new Update(KcbDonthuocChitiet.Schema)
                                .Set(KcbDonthuocChitiet.SoLuongColumn).EqualTo(objDonthuocChitiet.SoLuong)
                                .Set(KcbDonthuocChitiet.NgaySuaColumn).EqualTo(objDonthuocChitiet.NgaySua)
                                .Set(KcbDonthuocChitiet.NguoiSuaColumn).EqualTo(objDonthuocChitiet.NguoiSua)
                                .Set(KcbDonthuocChitiet.Columns.IpMaysua).EqualTo(objDonthuocChitiet.IpMaysua)
                                .Set(KcbDonthuocChitiet.Columns.TenMaysua).EqualTo(objDonthuocChitiet.TenMaysua)
                                .Where(KcbDonthuocChitiet.IdChitietdonthuocColumn).IsEqualTo(objDonthuocChitiet.IdChitietdonthuoc).Execute();
                            }
                        }
                    }
                    scope.Complete();
                    return(ActionResult.Success);
                }
            }
            catch (Exception exception)
            {
                log.Error("Loi trong qua trinh luu don thuoc", exception);
                return(ActionResult.Error);
            }
        }
 private void SuaphieuVattu_tronggoi()
 {
     try
     {
         if (!CheckPatientSelected()) return;
         if (!Utility.isValidGrid(grdVTTH_tronggoi))
         {
             if (grdVTTH_tronggoi.GetDataRows().Length > 0)
                 grdVTTH_tronggoi.MoveFirst();
         }
         //Check lại cho chắc ăn
         if (!Utility.isValidGrid(grdVTTH_tronggoi))
         {
             return;
         }
         KcbLuotkham objPatientExam = CreatePatientExam();
         if (objPatientExam != null)
         {
             int Pres_ID = Utility.Int32Dbnull(grdVTTH.GetValue(KcbDonthuocChitiet.Columns.IdDonthuoc));
             if (Donthuoc_DangXacnhan(Pres_ID))
             {
                 Utility.ShowMsg(
                     "Phiếu vật tư này đang ở trạng thái đã duyệt cho Bệnh nhân nên không thể chỉnh sửa. Đề nghị quay lại hỏi bộ phận cấp phát vật tư để xác nhận");
                 return;
             }
             var v_collect = new Select().From(KcbDonthuocChitiet.Schema.TableName)
                 .Where(KcbDonthuocChitiet.TrangthaiThanhtoanColumn.ColumnName).IsEqualTo(1)
                 .And(KcbDonthuocChitiet.IdDonthuocColumn.ColumnName).IsEqualTo(Pres_ID)
                 .ExecuteAsCollection<KcbDonthuocChitietCollection>();
             if (v_collect.Count > 0)
             {
                 Utility.ShowMsg(
                     "Phiếu vật tư bạn đang chọn sửa đã được thanh toán. Muốn sửa lại Phiếu vật tư Bạn cần phải liên hệ với bộ phận Thanh toán để hủy thanh toán và Bộ phận cấp vật tư tiêu hao để hủy xác nhận Phiếu vật tư tại kho vật tư");
                 return;
             }
             KcbDonthuoc objPrescription = KcbDonthuoc.FetchByID(Pres_ID);
             if (objPrescription != null)
             {
                 frm_KCB_KE_DONTHUOC frm = new frm_KCB_KE_DONTHUOC("VT");
                 frm.em_Action = action.Update;
                 frm._KcbChandoanKetluan = _KcbChandoanKetluan;
                 frm._MabenhChinh = txtMaBenhChinh.Text;
                 frm._Chandoan = txtChanDoan.Text;
                 frm.dt_ICD = dt_ICD;
                 frm.dt_ICD_PHU = dt_ICD_PHU;
                 if (objPhieudieutri != null)
                     frm.forced2Add = Utility.Byte2Bool(objPhieudieutri.TthaiBosung);
                 frm.noitru = 1;
                 frm.id_goidv = Utility.Int32Dbnull(Utility.GetValueFromGridColumn(grdGoidichvu, KcbChidinhclsChitiet.Columns.IdChitietchidinh), -1);
                 frm.trong_goi = 1;
                 frm.objLuotkham = CreatePatientExam();
                 frm.id_kham = -1;
                 frm.objPhieudieutriNoitru = NoitruPhieudieutri.FetchByID(Utility.Int32Dbnull(txtIdPhieudieutri.Text));
                 frm.txtPatientCode.Text = Utility.sDbnull(objLuotkham.MaLuotkham);
                 frm.txtPatientID.Text = Utility.sDbnull(objLuotkham.IdBenhnhan);
                 frm.txtPres_ID.Text = Utility.sDbnull(objPrescription.IdDonthuoc);
                 frm.CallActionKeDon = CallActionKieuKeDon.TheoDoiTuong;
                 frm.ShowDialog();
                 if (frm.b_Cancel)
                 {
                     txtMaBenhChinh.Text = frm._MabenhChinh;
                     txtChanDoan._Text = frm._Chandoan;
                     dt_ICD_PHU = frm.dt_ICD_PHU;
                     if (frm._KcbChandoanKetluan != null) _KcbChandoanKetluan = frm._KcbChandoanKetluan;
                     LaythongtinPhieudieutri();
                     TinhtoanTongchiphi();
                     Utility.GotoNewRowJanus(grdVTTH_tronggoi, KcbDonthuocChitiet.Columns.IdDonthuoc,
                                             Utility.sDbnull(frm.txtPres_ID.Text));
                     ModifyCommmands();
                 }
             }
         }
     }
     catch
     {
     }
 }
Example #20
0
        void cmdChuyen_Click(object sender, EventArgs e)
        {
            Utility.SetMsg(lblMsg, "", false);
            if (txtNoichuyenden.MyCode == "-1")
            {
                Utility.SetMsg(lblMsg, "Bạn phải nhập thông tin nơi chuyển đến", true);
                txtNoichuyenden.Focus();
                return;
            }
            if (Utility.DoTrim(txtdauhieucls.Text) == "")
            {
                Utility.SetMsg(lblMsg, "Bạn phải nhập thông tin dấu hiệu lâm sàng", true);
                txtdauhieucls.Focus();
                return;
            }
            //if (Utility.DoTrim(txtketquaCls.Text) == "")
            //{
            //    Utility.SetMsg(lblMsg, "Bạn phải nhập thông tin kết quả xét nghiệm, cận lâm sàng", true);
            //    txtketquaCls.Focus();
            //    return;
            //}
            if (Utility.DoTrim(txtChandoan.Text) == "" && Utility.DoTrim(txtMaBenhChinh.Text) == "")
            {
                Utility.SetMsg(lblMsg, "Bạn phải nhập thông tin chẩn đoán", true);
                txtMaBenhChinh.Focus();
                return;
            }
            //if (Utility.DoTrim(txtThuocsudung.Text) == "")
            //{
            //    Utility.SetMsg(lblMsg, "Bạn phải nhập thông tin Phương pháp, thủ thuật, kỹ thuật, thuốc đã sử dụng trong điều trị:", true);
            //    txtThuocsudung.Focus();
            //    return;
            //}
            if (Utility.DoTrim(txtTrangthainguoibenh.Text) == "")
            {
                Utility.SetMsg(lblMsg, "Bạn phải nhập thông tin trạng thái người bệnh", true);
                txtTrangthainguoibenh.Focus();
                return;
            }
            if (Utility.DoTrim(txtHuongdieutri.Text) == "")
            {
                Utility.SetMsg(lblMsg, "Bạn phải nhập thông tin hướng điều trị", true);
                txtHuongdieutri.Focus();
                return;
            }
            //if (Utility.DoTrim(txtphuongtienvc.Text) == "")
            //{
            //    Utility.SetMsg(lblMsg, "Bạn phải nhập thông tin phương tiện vận chuyển", true);
            //    txtphuongtienvc.Focus();
            //    return;
            //}
            //if (Utility.DoTrim(txtNguoivanchuyen.Text) == "")
            //{
            //    Utility.SetMsg(lblMsg, "Bạn phải nhập thông tin người vận chuyển", true);
            //    txtNguoivanchuyen.Focus();
            //    return;
            //}

            try
            {
                KcbPhieuchuyenvien _phieuchuyenvien = null;
                SqlQuery           sqlkt            = new Select().From(KcbPhieuchuyenvien.Schema).Where(KcbPhieuchuyenvien.Columns.MaLuotkham).IsEqualTo(Utility.sDbnull(txtMaluotkham.Text));
                if (m_enAct == action.Insert && sqlkt.GetRecordCount() <= 0)
                {
                    _phieuchuyenvien               = new KcbPhieuchuyenvien();
                    _phieuchuyenvien.IsNew         = true;
                    _phieuchuyenvien.NgayTao       = globalVariables.SysDate;
                    _phieuchuyenvien.NguoiTao      = globalVariables.UserName;
                    _phieuchuyenvien.SoChuyentuyen = Utility.Int32Dbnull(GetmaxSoChuyenVien());
                }
                else
                {
                    _phieuchuyenvien       = KcbPhieuchuyenvien.FetchByID(Utility.Int32Dbnull(txtId.Text));
                    _phieuchuyenvien.IsNew = false;
                    _phieuchuyenvien.MarkOld();
                    _phieuchuyenvien.NguoiSua      = globalVariables.UserName;
                    _phieuchuyenvien.NgaySua       = globalVariables.SysDate;
                    _phieuchuyenvien.SoChuyentuyen = Utility.Int32Dbnull(txtsochuyenvien.Text, -1);
                }
                _phieuchuyenvien.IdBenhnhan          = objLuotkham.IdBenhnhan;
                _phieuchuyenvien.MaLuotkham          = objLuotkham.MaLuotkham;
                _phieuchuyenvien.IdBenhvienChuyenden = Utility.Int16Dbnull(txtNoichuyenden.MyID, -1);
                _phieuchuyenvien.DauhieuCls          = Utility.DoTrim(txtdauhieucls.Text);
                _phieuchuyenvien.KetquaXnCls         = Utility.DoTrim(txtketquaCls.Text);
                _phieuchuyenvien.ChanDoan            = Utility.DoTrim(txtChandoan.Text);
                _phieuchuyenvien.Mabenh            = Utility.DoTrim(txtMaBenhChinh.Text);
                _phieuchuyenvien.ThuocSudung       = Utility.DoTrim(txtThuocsudung.Text);
                _phieuchuyenvien.TrangthaiBenhnhan = Utility.DoTrim(txtTrangthainguoibenh.Text);
                _phieuchuyenvien.HuongDieutri      = Utility.DoTrim(txtHuongdieutri.Text);
                _phieuchuyenvien.LydoChuyen        = Utility.sDbnull(radDuDieukien.Checked ? "1" : "0");
                _phieuchuyenvien.PhuongtienChuyen  = Utility.DoTrim(txtphuongtienvc.Text);
                _phieuchuyenvien.NgayChuyenvien    = dtNgaychuyenvien.Value;
                _phieuchuyenvien.IdBacsiChuyenvien = Utility.Int16Dbnull(cboDoctorAssign.SelectedValue, -1);
                _phieuchuyenvien.TenNguoichuyen    = Utility.DoTrim(txtNguoivanchuyen.Text);
                _phieuchuyenvien.NoiTru            = noitru;
                _phieuchuyenvien.IdRavien          = Utility.Int32Dbnull(txtIdravien.Text, -1);
                _phieuchuyenvien.IdKhoanoitru      = Utility.Int32Dbnull(txtIdkhoanoitru.Text, -1);
                _phieuchuyenvien.IdBuong           = Utility.Int32Dbnull(txtidBuong.Text, -1);
                _phieuchuyenvien.IdGiuong          = Utility.Int32Dbnull(txtidgiuong.Text, -1);
                using (var scope = new TransactionScope())
                {
                    using (var dbscope = new SharedDbConnectionScope())
                    {
                        _phieuchuyenvien.Save();
                        objLuotkham.TthaiChuyendi     = 1;
                        objLuotkham.IdBacsiChuyenvien = _phieuchuyenvien.IdBacsiChuyenvien;
                        objLuotkham.MabenhChinh       = _phieuchuyenvien.Mabenh;
                        objLuotkham.NgayKetthuc       = _phieuchuyenvien.NgayChuyenvien;
                        objLuotkham.NguoiKetthuc      = _phieuchuyenvien.NguoiTao;
                        objLuotkham.NgayRavien        = _phieuchuyenvien.NgayChuyenvien;
                        objLuotkham.KetLuan           = "Chuyển viện";
                        objLuotkham.HuongDieutri      = "Chuyển viện";
                        objLuotkham.IdBenhvienDi      = Utility.Int16Dbnull(txtNoichuyenden.MyID, -1);
                        objLuotkham.IsNew             = false;
                        objLuotkham.MarkOld();
                        objLuotkham.Save();
                        KcbChandoanKetluan objChuandoanKetluan =
                            new Select().From(KcbChandoanKetluan.Schema).Where(KcbChandoanKetluan.Columns.MaLuotkham).
                            IsEqualTo(objLuotkham.MaLuotkham).And(KcbChandoanKetluan.Columns.IdBenhnhan).IsEqualTo(
                                objLuotkham.IdBenhnhan).ExecuteSingle <KcbChandoanKetluan>();
                        if (objChuandoanKetluan != null)
                        {
                            new Update(KcbChandoanKetluan.Schema)
                            .Set(KcbChandoanKetluan.Columns.MabenhChinh).EqualTo(objLuotkham.MabenhChinh)
                            .Where(KcbChandoanKetluan.Columns.IdBenhnhan).IsEqualTo(objLuotkham.IdBenhnhan)
                            .And(KcbChandoanKetluan.Columns.MaLuotkham).IsEqualTo(objLuotkham.MaLuotkham)
                            .And(KcbChandoanKetluan.Columns.Noitru).IsEqualTo(0)
                            .Execute();
                        }
                        else
                        {
                            objChuandoanKetluan               = new KcbChandoanKetluan();
                            objChuandoanKetluan.IdBenhnhan    = Utility.Int64Dbnull(objLuotkham.IdBenhnhan);
                            objChuandoanKetluan.MaLuotkham    = Utility.sDbnull(objLuotkham.MaLuotkham, "");
                            objChuandoanKetluan.SongayDieutri = 1;
                            objChuandoanKetluan.MabenhChinh   = objLuotkham.MabenhChinh;
                            objChuandoanKetluan.NgayChandoan  = globalVariables.SysDate;
                            objChuandoanKetluan.NguoiTao      = globalVariables.UserName;
                            objChuandoanKetluan.IdBacsikham   = globalVariables.gv_intIDNhanvien;
                            objChuandoanKetluan.IpMaytao      = globalVariables.gv_strIPAddress;
                            objChuandoanKetluan.Noitru        = 0;
                            objChuandoanKetluan.IsNew         = true;
                            objChuandoanKetluan.Save();
                        }
                        new Update(KcbDangkyKcb.Schema).Set(KcbDangkyKcb.Columns.TrangThai).EqualTo(1).Where(
                            KcbDangkyKcb.Columns.MaLuotkham).IsEqualTo(objLuotkham.MaLuotkham).And(
                            KcbDangkyKcb.Columns.IdBenhnhan).IsEqualTo(objLuotkham.IdBenhnhan).Execute();
                    }
                    scope.Complete();
                }
                Utility.SetMsg(lblMsg, "Cập nhật phiếu chuyển viện thành công", false);
                if (m_enAct == action.Insert)
                {
                    cmdPrint.Enabled = true;
                }
                m_enAct    = action.Update;
                txtId.Text = _phieuchuyenvien.IdPhieu.ToString();
            }
            catch (Exception ex)
            {
                Utility.CatchException(ex);
            }
        }
 private void UpdateDonThuoc()
 {
     try
     {
         if (grdPresDetail.CurrentRow != null && grdPresDetail.CurrentRow.RowType == RowType.Record)
         {
             KcbLuotkham objPatientExam = CreatePatientExam();
             if (objPatientExam != null)
             {
                 int Pres_ID = Utility.Int32Dbnull(grdPresDetail.GetValue(KcbDonthuocChitiet.Columns.IdDonthuoc));
                 if (Donthuoc_DangXacnhan(Pres_ID))
                 {
                     Utility.ShowMsg(
                         "Đơn thuốc này đang ở trạng thái đã duyệt cho Bệnh nhân nên không thể chỉnh sửa. Đề nghị quay lại hỏi bộ phận cấp phát thuốc tại phòng Dược");
                     return;
                 }
                 var v_collect = new Select().From(KcbDonthuocChitiet.Schema.TableName)
                     .Where(KcbDonthuocChitiet.TrangthaiThanhtoanColumn.ColumnName).IsEqualTo(1)
                     .And(KcbDonthuocChitiet.IdDonthuocColumn.ColumnName).IsEqualTo(Pres_ID)
                     .ExecuteAsCollection<KcbDonthuocChitietCollection>();
                 if (v_collect.Count > 0)
                 {
                     Utility.ShowMsg(
                         "Đơn thuốc bạn đang chọn sửa đã được thanh toán. Muốn sửa lại đơn thuốc Bạn cần phải liên hệ với bộ phận Thanh toán để hủy thanh toán và Bộ phận cấp thuốc để hủy xác nhận đơn thuốc tại kho thuốc");
                     return;
                 }
                 KcbDonthuoc objPrescription = KcbDonthuoc.FetchByID(Pres_ID);
                 if (objPrescription != null)
                 {
                     frm_KCB_KE_DONTHUOC frm = new frm_KCB_KE_DONTHUOC("THUOC");
                     frm.em_Action = action.Update;
                     frm._KcbChandoanKetluan = _KcbChandoanKetluan;
                     frm._MabenhChinh = txtMaBenhChinh.Text;
                     frm._Chandoan = txtChanDoan.Text;
                     frm.dt_ICD = dt_ICD;
                     if (objPhieudieutri != null)
                         frm.forced2Add = Utility.Byte2Bool(objPhieudieutri.TthaiBosung);
                     frm.dt_ICD_PHU = dt_ICD_PHU;
                     frm.noitru = 1;
                     frm.objLuotkham = CreatePatientExam();
                     frm.id_kham =-1;
                     frm.objPhieudieutriNoitru = NoitruPhieudieutri.FetchByID(Utility.Int32Dbnull(txtIdPhieudieutri.Text));
                     frm.txtPatientCode.Text = Utility.sDbnull(objLuotkham.MaLuotkham);
                     frm.txtPatientID.Text = Utility.sDbnull(objLuotkham.IdBenhnhan);
                     frm.txtPres_ID.Text = Utility.sDbnull(objPrescription.IdDonthuoc);
                     frm.CallActionKeDon = CallActionKieuKeDon.TheoDoiTuong;
                     frm.ShowDialog();
                     if (frm.b_Cancel)
                     {
                         txtMaBenhChinh.Text = frm._MabenhChinh;
                         txtChanDoan._Text = frm._Chandoan;
                         dt_ICD_PHU = frm.dt_ICD_PHU;
                         if (frm._KcbChandoanKetluan != null) _KcbChandoanKetluan = frm._KcbChandoanKetluan;
                         LaythongtinPhieudieutri();
                         TinhtoanTongchiphi();
                         Utility.GotoNewRowJanus(grdPresDetail, KcbDonthuocChitiet.Columns.IdDonthuoc,
                                                 Utility.sDbnull(frm.txtPres_ID.Text));
                         ModifyCommmands();
                     }
                 }
             }
         }
     }
     catch
     {
     }
 }
        /// <summary>
        /// Lấy về thông tin bệnh nhâ nội trú
        /// </summary>
        private void GetData()
        {
            try
            {
                Utility.SetMsg(lblMsg, "", false);
                if (!Utility.isValidGrid(grdList))
                {
                    return;
                }
                bool KHAMCHEO_CACKHOA = THU_VIEN_CHUNG.Laygiatrithamsohethong("KHAMCHEO_CACKHOA", "0", true) == "1";

                // Utility.SetMsg(lblMsg, "", false);
                string PatientCode = Utility.sDbnull(grdList.GetValue(KcbLuotkham.Columns.MaLuotkham), "");
                m_strMaLuotkham = PatientCode;
                if (!Utility.CheckLockObject(m_strMaLuotkham, "Thăm khám", "TK"))
                    return;

                int Id_Benhnhan = Utility.Int32Dbnull(grdList.GetValue(KcbLuotkham.Columns.IdBenhnhan), -1);
                objLuotkham = new Select().From(KcbLuotkham.Schema)
                    .Where(KcbLuotkham.Columns.MaLuotkham).IsEqualTo(PatientCode)
                    .And(KcbLuotkham.Columns.IdBenhnhan).IsEqualTo(Id_Benhnhan).ExecuteSingle<KcbLuotkham>();

                objBenhnhan = KcbDanhsachBenhnhan.FetchByID(objLuotkham.IdBenhnhan);

                isRoom = false;
                if (objLuotkham != null)
                {
                    string ten_khoaphong = Utility.sDbnull(grdList.GetValue("ten_khoaphong"), "");

                    cmdChuyenPhong.Visible = objLuotkham.TrangthaiNoitru == 0;
                    int hien_thi = Utility.Int32Dbnull(grdList.GetValue("hien_thi"), 0);
                    if (hien_thi == 0)
                    {
                        Utility.ShowMsg("Bệnh nhân " + objBenhnhan.TenBenhnhan +
                                        " CHƯA NỘP TIỀN KHÁM trong khi thuộc đối tượng khám chữa bệnh CẦN THANH TOÁN TRƯỚC KHI VÀO PHÒNG KHÁM.\nYêu cầu Bệnh nhân đi NỘP TIỀN KHÁM TRƯỚC");
                        objLuotkham = null;
                        objBenhnhan = null;
                        m_strMaLuotkham = "";
                        return;
                    }
                    if (!KHAMCHEO_CACKHOA && globalVariables.MA_KHOA_THIEN != objLuotkham.MaKhoaThuchien)
                    {
                        Utility.ShowMsg("Bệnh nhân này được tiếp đón và chỉ định khám cho khoa " + ten_khoaphong +
                                        ". Trong khi máy bạn đang cấu hình khám chữa bệnh cho khoa " +
                                        globalVariablesPrivate.objKhoaphong.TenKhoaphong +
                                        "\nHệ thống không cho phép khám chéo giữa các khoa. Đề nghị liên hệ Bộ phận IT trong đơn vị để được trợ giúp");
                        objLuotkham = null;
                        objBenhnhan = null;
                        m_strMaLuotkham = "";
                        return;
                    }
                    ClearControl();
                    lblSongaydieutri.ForeColor = THU_VIEN_CHUNG.IsBaoHiem(objLuotkham.IdLoaidoituongKcb)
                                                     ? lblKetluan.ForeColor
                                                     : lblBenhphu.ForeColor;
                    lblBenhchinh.ForeColor = lblSongaydieutri.ForeColor;
                    lblBANoitru.Text = Utility.Int32Dbnull(objLuotkham.SoBenhAn, -1) <= 0
                                           ? ""
                                           : "Số B.A Nội trú: " + objLuotkham.SoBenhAn;
                    txt_idchidinhphongkham.Text = Utility.sDbnull(grdList.GetValue(KcbDangkyKcb.Columns.IdKham));

                    objkcbdangky = KcbDangkyKcb.FetchByID(Utility.Int32Dbnull(txt_idchidinhphongkham.Text));
                    var objStaff =
                        new Select().From(DmucNhanvien.Schema).Where(DmucNhanvien.UserNameColumn).IsEqualTo(
                            Utility.sDbnull(objLuotkham.NguoiKetthuc, "")).ExecuteSingle<DmucNhanvien>();
                    string TenNhanvien = objLuotkham.NguoiKetthuc;
                    if (objStaff != null)
                        TenNhanvien = objStaff.TenNhanvien;
                    pnlCLS.Enabled = true;
                    pnlDonthuoc.Enabled = true;
                    pnlVTTH.Enabled = true;
                    if (objkcbdangky != null)
                    {
                        cmdUnlock.Visible = objLuotkham.TrangthaiNoitru == 0 && objLuotkham.Locked.ToString() == "1";
                        cmdUnlock.Enabled = cmdUnlock.Visible &&
                                            (Utility.Coquyen("quyen_mokhoa_tatca") ||
                                             objLuotkham.NguoiKetthuc == globalVariables.UserName);
                        if (!cmdUnlock.Enabled)
                            toolTip1.SetToolTip(cmdUnlock,
                                                "Bạn không có quyền mở khóa Bệnh nhân này. Đề nghị liên hệ " +
                                                TenNhanvien + "(" + objLuotkham.NguoiKetthuc +
                                                " - Là người khóa BN này) để được họ mở khóa. Hoặc liên hệ Quản trị hệ thống");
                        else
                            toolTip1.SetToolTip(cmdUnlock,
                                                "Nhấn vào đây để mở khóa cho bệnh nhân đang chọn(Phím tắt Ctrl+U). Điều kiện là chỉ mở khóa đối với đối tượng Dịch vụ. Muốn mở khóa đối tượng BHYT thì cần liên lạc với bộ phận thanh toán hủy in phôi BHYT");
                        cmdNhapVien.Enabled = objkcbdangky.TrangThai == 1;
                        cmdHuyNhapVien.Enabled = objLuotkham.TrangthaiNoitru >= 1;
                        cmdNhapVien.Tag = objLuotkham.TrangthaiNoitru == 0 ? "0" : "1";
                        cmdNhapVien.Text = objLuotkham.TrangthaiNoitru == 0 ? "Nhập viện" : "Cập nhật";

                        DataTable m_dtThongTin = _KCB_THAMKHAM.LayThongtinBenhnhanKCB(objLuotkham.MaLuotkham,
                                                                                      Utility.Int32Dbnull(
                                                                                          objLuotkham.IdBenhnhan,
                                                                                          -1),
                                                                                      Utility.Int32Dbnull(
                                                                                          txt_idchidinhphongkham.Text));

                        if (m_dtThongTin.Rows.Count > 0)
                        {
                            DataRow dr = m_dtThongTin.Rows[0];
                            if (dr != null)
                            {
                                dtInput_Date.Value = Convert.ToDateTime(dr[KcbLuotkham.Columns.NgayTiepdon]);
                                txtExam_ID.Text = Utility.sDbnull(grdList.GetValue(KcbDangkyKcb.Columns.IdKham));

                                txtGioitinh.Text =
                                    Utility.sDbnull(grdList.GetValue(KcbDanhsachBenhnhan.Columns.GioiTinh), "");
                                txt_idchidinhphongkham.Text =
                                    Utility.sDbnull(grdList.GetValue(KcbDangkyKcb.Columns.IdKham));
                                lblSOkham.Text = Utility.sDbnull(grdList.GetValue(KcbDangkyKcb.Columns.SttKham));
                                txtPatient_Name.Text = Utility.sDbnull(dr[KcbDanhsachBenhnhan.Columns.TenBenhnhan], "");
                                txtPatient_ID.Text = Utility.sDbnull(dr[KcbDanhsachBenhnhan.Columns.IdBenhnhan], "");
                                txtPatient_Code.Text = Utility.sDbnull(dr[KcbLuotkham.Columns.MaLuotkham], "");
                                barcode.Data = m_strMaLuotkham;
                                txtDiaChi.Text = Utility.sDbnull(dr[KcbDanhsachBenhnhan.Columns.DiaChi], "");
                                txtDiachiBHYT.Text = Utility.sDbnull(dr[KcbDanhsachBenhnhan.Columns.DiachiBhyt], "");
                                txtTrieuChungBD._Text = Utility.sDbnull(dr[KcbLuotkham.Columns.TrieuChung], "");
                                txtObjectType_Name.Text = Utility.sDbnull(dr[DmucDoituongkcb.Columns.TenDoituongKcb], "");
                                txtSoBHYT.Text = Utility.sDbnull(dr[KcbLuotkham.Columns.MatheBhyt], "");
                                txtBHTT.Text = Utility.sDbnull(dr[KcbLuotkham.Columns.PtramBhyt], "0");
                                //txtNgheNghiep.Text = Utility.sDbnull(dr[KcbDanhsachBenhnhan.Columns.NgheNghiep], "");
                                txtHanTheBHYT.Text = Utility.sDbnull(dr[KcbLuotkham.Columns.NgayketthucBhyt], "");
                                dtpNgayhethanBHYT.Text = Utility.sDbnull(dr[KcbLuotkham.Columns.NgayketthucBhyt],
                                                                         globalVariables.SysDate.ToString("dd/MM/yyyy"));
                                txtTuoi.Text = Utility.sDbnull(Utility.Int32Dbnull(globalVariables.SysDate.Year) -
                                                               objBenhnhan.NgaySinh.Value.Year);
                                ThongBaoBenhAn(txtPatient_ID.Text);

                                if (objkcbdangky != null)
                                {
                                    // txtSTTKhamBenh.Text = Utility.sDbnull(objkcbdangky.SoKham);
                                    txtReg_ID.Text = Utility.sDbnull(objkcbdangky.IdKham);
                                    dtpCreatedDate.Value = Convert.ToDateTime(objkcbdangky.NgayDangky);
                                    txtDepartment_ID.Text = Utility.sDbnull(objkcbdangky.IdPhongkham);
                                    var _department =
                                        new Select().From(DmucKhoaphong.Schema).Where(DmucKhoaphong.IdKhoaphongColumn).
                                            IsEqualTo(objkcbdangky.IdPhongkham).ExecuteSingle<DmucKhoaphong>();
                                    if (_department != null)
                                    {
                                        txtPhongkham.Text = Utility.sDbnull(_department.TenKhoaphong);
                                    }
                                    txtTenDvuKham.Text = Utility.sDbnull(objkcbdangky.TenDichvuKcb);
                                    txtNguoiTiepNhan.Text = Utility.sDbnull(objkcbdangky.NguoiTao);
                                    if (Utility.Int16Dbnull(objkcbdangky.IdBacsikham, -1) != -1)
                                    {
                                        txtBacsi.SetId(Utility.sDbnull(objkcbdangky.IdBacsikham, -1));
                                    }
                                    else
                                    {
                                        txtBacsi.SetId(globalVariables.gv_intIDNhanvien);
                                    }

                                    chkDaThucHien.Checked = Utility.Int32Dbnull(objkcbdangky.TrangThai) == 1;
                                }
                                _KcbChandoanKetluan = new Select().From(KcbChandoanKetluan.Schema)
                                    .Where(KcbChandoanKetluan.Columns.IdKham).IsEqualTo(objkcbdangky.IdKham).
                                    ExecuteSingle
                                    <KcbChandoanKetluan>();
                                if (_KcbChandoanKetluan != null)
                                {
                                    txtKet_Luan._Text = Utility.sDbnull(_KcbChandoanKetluan.Ketluan);
                                    // txtHuongdieutri.SetCode(_KcbChandoanKetluan.HuongDieutri);
                                    txtHuongdieutri._Text = _KcbChandoanKetluan.HuongDieutri;
                                    txtSongaydieutri.Text = Utility.sDbnull(_KcbChandoanKetluan.SongayDieutri, "0");
                                    txtHa.Text = Utility.sDbnull(_KcbChandoanKetluan.Huyetap);
                                    txtTrieuChungBD._Text = Utility.sDbnull(_KcbChandoanKetluan.TrieuchungBandau);
                                    txtMach.Text = Utility.sDbnull(_KcbChandoanKetluan.Mach);
                                    txtNhipTim.Text = Utility.sDbnull(_KcbChandoanKetluan.Nhiptim);
                                    txtNhipTho.Text = Utility.sDbnull(_KcbChandoanKetluan.Nhiptho);
                                    txtNhietDo.Text = Utility.sDbnull(_KcbChandoanKetluan.Nhietdo);
                                    txtCannang.Text = Utility.sDbnull(_KcbChandoanKetluan.Cannang);
                                    txtChieucao.Text = Utility.sDbnull(_KcbChandoanKetluan.Chieucao);
                                    txtNhanxet.Text = Utility.sDbnull(_KcbChandoanKetluan.NhanXet);
                                    if (!string.IsNullOrEmpty(Utility.sDbnull(_KcbChandoanKetluan.Nhommau)) &&
                                        Utility.sDbnull(_KcbChandoanKetluan.Nhommau) != "-1")
                                        txtNhommau._Text = Utility.sDbnull(_KcbChandoanKetluan.Nhommau);

                                    isLike = false;
                                    txtChanDoan._Text = Utility.sDbnull(_KcbChandoanKetluan.Chandoan);
                                    txtChanDoanKemTheo.Text = Utility.sDbnull(_KcbChandoanKetluan.ChandoanKemtheo);
                                    txtMaBenhChinh.Text = Utility.sDbnull(_KcbChandoanKetluan.MabenhChinh);
                                    string dataString = Utility.sDbnull(_KcbChandoanKetluan.MabenhPhu, "");
                                    isLike = true;
                                    dt_ICD_PHU.Clear();
                                    if (!string.IsNullOrEmpty(dataString))
                                    {
                                        string[] rows = dataString.Split(',');
                                        foreach (string row in rows)
                                        {
                                            if (!string.IsNullOrEmpty(row))
                                            {
                                                DataRow newDr = dt_ICD_PHU.NewRow();
                                                newDr[DmucBenh.Columns.MaBenh] = row;
                                                newDr[DmucBenh.Columns.TenBenh] = GetTenBenh(row);
                                                dt_ICD_PHU.Rows.Add(newDr);
                                                dt_ICD_PHU.AcceptChanges();
                                            }
                                        }
                                        grd_ICD.DataSource = dt_ICD_PHU;
                                    }
                                }
                                Laythongtinchidinhngoaitru();
                            }
                        }
                        //cmdKETTHUC.Visible = objLuotkham.Locked == 0 && objkcbdangky.TrangThai > 0;
                        cmdInTTDieuTri.Visible =
                            cmdInphieuhen.Visible = objkcbdangky.TrangThai != 0 && objLuotkham.TrangthaiNoitru == 0;
                        cboChonBenhAn.Visible = objkcbdangky.TrangThai != 0 &&
                                                THU_VIEN_CHUNG.Laygiatrithamsohethong("BENH_AN", "0", true) == "1" &&
                                                objLuotkham.TrangthaiNoitru == 0;
                        lblBenhan.Visible = cboChonBenhAn.Visible;
                        // cmdBenhAnNgoaiTru.Visible = objkcbdangky.TrangThai != 0;
                        cmdKETTHUC.Enabled = true;
                    }
                    else
                    {
                        ClearControl();
                        cmdKETTHUC.Enabled = false;
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg("Lỗi:" + ex.Message);
            }
            finally
            {
                ModifyCommmands();
                KiemTraDaInPhoiBHYT();
                getResult();
            }
        }
        public void Insert(long IdKham,long IdBenhnhan,string MaLuotkham,short IdBacsikham,DateTime NgayChandoan,string NguoiTao,DateTime? NgayTao,string NguoiSua,DateTime? NgaySua,int? IdKhoanoitru,int? IdBuongGiuong,short? IdBuongNoitru,short? IdGiuongNoitru,int? IdPhieudieutri,byte? Noitru,int? IdPhongkham,string TenPhongkham,string Mach,string Nhietdo,string Huyetap,string Nhiptim,string Nhiptho,string Cannang,string Chieucao,string Nhommau,string Ketluan,string HuongDieutri,short? SongayDieutri,string TrieuchungBandau,string Chandoan,string ChandoanKemtheo,string MabenhChinh,string MabenhPhu,string IpMaytao,string IpMaysua,string TenMaytao,string TenMaysua)
        {
            KcbChandoanKetluan item = new KcbChandoanKetluan();

            item.IdKham = IdKham;

            item.IdBenhnhan = IdBenhnhan;

            item.MaLuotkham = MaLuotkham;

            item.IdBacsikham = IdBacsikham;

            item.NgayChandoan = NgayChandoan;

            item.NguoiTao = NguoiTao;

            item.NgayTao = NgayTao;

            item.NguoiSua = NguoiSua;

            item.NgaySua = NgaySua;

            item.IdKhoanoitru = IdKhoanoitru;

            item.IdBuongGiuong = IdBuongGiuong;

            item.IdBuongNoitru = IdBuongNoitru;

            item.IdGiuongNoitru = IdGiuongNoitru;

            item.IdPhieudieutri = IdPhieudieutri;

            item.Noitru = Noitru;

            item.IdPhongkham = IdPhongkham;

            item.TenPhongkham = TenPhongkham;

            item.Mach = Mach;

            item.Nhietdo = Nhietdo;

            item.Huyetap = Huyetap;

            item.Nhiptim = Nhiptim;

            item.Nhiptho = Nhiptho;

            item.Cannang = Cannang;

            item.Chieucao = Chieucao;

            item.Nhommau = Nhommau;

            item.Ketluan = Ketluan;

            item.HuongDieutri = HuongDieutri;

            item.SongayDieutri = SongayDieutri;

            item.TrieuchungBandau = TrieuchungBandau;

            item.Chandoan = Chandoan;

            item.ChandoanKemtheo = ChandoanKemtheo;

            item.MabenhChinh = MabenhChinh;

            item.MabenhPhu = MabenhPhu;

            item.IpMaytao = IpMaytao;

            item.IpMaysua = IpMaysua;

            item.TenMaytao = TenMaytao;

            item.TenMaysua = TenMaysua;

            item.Save(UserName);
        }
        private void SuaphieuVattu()
        {
            try
            {
                if (!CheckPatientSelected()) return;
                if (!Utility.isValidGrid(grdVTTH)) return;

                KcbLuotkham objPatientExam = objLuotkham;
                if (objPatientExam != null)
                {
                    int Pres_ID = Utility.Int32Dbnull(grdVTTH.GetValue(KcbDonthuocChitiet.Columns.IdDonthuoc));
                    if (Donthuoc_DangXacnhan(Pres_ID))
                    {
                        Utility.ShowMsg(
                            "Phiếu vật tư này đang ở trạng thái đã duyệt cho Bệnh nhân nên không thể chỉnh sửa. Đề nghị quay lại hỏi bộ phận cấp phát vật tư tại phòng vật tư");
                        return;
                    }
                    var v_collect = new Select().From(KcbDonthuocChitiet.Schema.TableName)
                        .Where(KcbDonthuocChitiet.TrangthaiThanhtoanColumn.ColumnName).IsEqualTo(1)
                        .And(KcbDonthuocChitiet.IdDonthuocColumn.ColumnName).IsEqualTo(Pres_ID)
                        .ExecuteAsCollection<KcbDonthuocChitietCollection>();
                    if (v_collect.Count > 0)
                    {
                        Utility.ShowMsg(
                            "Phiếu vật tư bạn đang chọn sửa đã được thanh toán. Muốn sửa lại Phiếu vật tư Bạn cần phải liên hệ với bộ phận Thanh toán để hủy thanh toán và Bộ phận cấp vật tư để hủy xác nhận Phiếu vật tư tại kho vật tư");
                        return;
                    }
                    KcbDonthuoc objPrescription = KcbDonthuoc.FetchByID(Pres_ID);
                    if (objPrescription != null)
                    {
                        var frm = new frm_KCB_KE_DONTHUOC("VT");
                        frm.em_Action = action.Update;
                        frm._KcbChandoanKetluan = _KcbChandoanKetluan;
                        frm._MabenhChinh = txtMaBenhChinh.Text;
                        frm._Chandoan = txtChanDoan.Text;
                        frm.dt_ICD = dt_ICD;
                        frm.dt_ICD_PHU = dt_ICD_PHU;
                        frm.noitru = 0;
                        frm.objLuotkham = objLuotkham;
                        frm.id_kham = Utility.Int32Dbnull(txtExam_ID.Text);
                        frm.objPhieudieutriNoitru = null;
                        frm.txtPatientCode.Text = Utility.sDbnull(objLuotkham.MaLuotkham);
                        frm.txtPatientID.Text = Utility.sDbnull(objLuotkham.IdBenhnhan);
                        frm.txtPres_ID.Text = Utility.sDbnull(objPrescription.IdDonthuoc);
                        frm.CallActionKeDon = CallActionKieuKeDon.TheoDoiTuong;
                        frm.ShowDialog();
                        if (!frm.m_blnCancel)
                        {
                            txtMaBenhChinh.Text = frm._MabenhChinh;
                            txtChanDoan._Text = frm._Chandoan;
                            dt_ICD_PHU = frm.dt_ICD_PHU;
                            if (frm._KcbChandoanKetluan != null) _KcbChandoanKetluan = frm._KcbChandoanKetluan;
                            Laythongtinchidinhngoaitru();
                            Utility.GotoNewRowJanus(grdVTTH, KcbDonthuocChitiet.Columns.IdDonthuoc,
                                                    Utility.sDbnull(frm.txtPres_ID.Text));
                        }
                    }
                }
            }
            catch
            {
            }
            finally
            {
                ModifyCommmands();
            }
        }
Example #25
0
        /// <summary>
        /// hàm thực hiện việc update thông tin xác nhận gói
        /// </summary>
        /// <param name="objThongtinGoiDvuBnhan"></param>
        /// <returns></returns>
        public ActionResult UpdateExamInfo(KcbChandoanKetluan objDiagInfo, KcbDangkyKcb objRegExam,
                                           KcbLuotkham objPatientExam)
        {
            try
            {
                using (var scope = new TransactionScope())
                {
                    using (var sh = new SharedDbConnectionScope())
                    {

                        if (objDiagInfo.IsNew)
                        {
                            objDiagInfo.Save();
                        }
                        else
                        {
                            objDiagInfo.MarkOld();
                            objDiagInfo.Save();
                        }

                        SqlQuery sqlQuery = new Select().From(
                                                     KcbChandoanKetluan.Schema)
                               .Where(KcbChandoanKetluan.Columns.MaLuotkham).IsEqualTo(objPatientExam.MaLuotkham)
                               .And(KcbChandoanKetluan.Columns.IdBenhnhan).IsEqualTo(objPatientExam.IdBenhnhan).OrderAsc(
                                   KcbChandoanKetluan.Columns.NgayChandoan);
                        KcbChandoanKetluanCollection objInfoCollection = sqlQuery.ExecuteAsCollection<KcbChandoanKetluanCollection>();
                        var query = (from chandoan in objInfoCollection.AsEnumerable()
                                     let y = Utility.sDbnull(chandoan.Chandoan)
                                     where (y != "")
                                     select y).ToArray();
                        string cdchinh = string.Join(";", query);
                        //KcbChandoanKetluanCollection objInfoCollection = sqlQuery.ExecuteAsCollection<KcbChandoanKetluanCollection>();
                        var querychandoanphu = (from chandoan in objInfoCollection.AsEnumerable()
                                                let y = Utility.sDbnull(chandoan.ChandoanKemtheo)
                                                where (y != "")
                                                select y).ToArray();
                        string cdphu = string.Join(";", querychandoanphu);
                        var querybenhchinh = (from benhchinh in objInfoCollection.AsEnumerable()
                                              let y = Utility.sDbnull(benhchinh.MabenhChinh)
                                              where (y != "")
                                              select y).ToArray();
                        string mabenhchinh = string.Join(";", querybenhchinh);

                        var querybenhphu = (from benhphu in objInfoCollection.AsEnumerable()
                                            let y = Utility.sDbnull(benhphu.MabenhPhu)
                                            where (y != "")
                                            select y).ToArray();
                        string mabenhphu = string.Join(";", querybenhphu);
                        new Update(KcbLuotkham.Schema)
                            .Set(KcbLuotkham.Columns.MabenhChinh).EqualTo(mabenhchinh)
                            .Set(KcbLuotkham.Columns.MabenhPhu).EqualTo(mabenhphu)
                            .Set(KcbLuotkham.Columns.ChanDoan).EqualTo(cdchinh)
                            .Set(KcbLuotkham.Columns.ChandoanKemtheo).EqualTo(cdphu)
                            .Set(KcbLuotkham.Columns.TrieuChung).EqualTo(objPatientExam.TrieuChung)
                            .Set(KcbLuotkham.Columns.NguoiSua).EqualTo(globalVariables.UserName)
                            .Set(KcbLuotkham.Columns.NgaySua).EqualTo(globalVariables.SysDate)
                            .Set(KcbLuotkham.Columns.Locked).EqualTo(objPatientExam.Locked)
                            .Set(KcbLuotkham.Columns.NguoiKetthuc).EqualTo(objPatientExam.NguoiKetthuc)
                            .Set(KcbLuotkham.Columns.NgayKetthuc).EqualTo(objPatientExam.NgayKetthuc)
                            .Where(KcbLuotkham.Columns.MaLuotkham).IsEqualTo(objPatientExam.MaLuotkham)
                            .And(KcbLuotkham.Columns.IdBenhnhan).IsEqualTo(objPatientExam.IdBenhnhan).Execute();
                        //Tạm bỏ tránh việc bị cập nhật sai bác sĩ chỉ định nếu bác sĩ đó chỉ lưu thông tin kết luận
                        //SPs.KcbThamkhamCappnhatBsyKham(Utility.Int32Dbnull(objRegExam.IdKham, -1), objPatientExam.MaLuotkham,
                        //                            Utility.Int32Dbnull(objPatientExam.IdBenhnhan, -1),
                        //                            Utility.Int32Dbnull(objDiagInfo.DoctorId, -1)).Execute();

                        if (objRegExam != null)
                        {
                            new Update(KcbDangkyKcb.Schema)
                                .Set(KcbDangkyKcb.Columns.NgaySua).EqualTo(globalVariables.SysDate)
                                .Set(KcbDangkyKcb.Columns.NguoiSua).EqualTo(globalVariables.UserName)
                                .Set(KcbDangkyKcb.Columns.IpMaysua).EqualTo(globalVariables.gv_strIPAddress)
                                .Set(KcbDangkyKcb.Columns.TenMaysua).EqualTo(globalVariables.gv_strComputerName)
                                .Set(KcbDangkyKcb.Columns.IdBacsikham).EqualTo(objDiagInfo.IdBacsikham)
                                .Set(KcbDangkyKcb.Columns.TrangThai).EqualTo(objRegExam.TrangThai)
                                .Where(KcbDangkyKcb.Columns.IdKham).IsEqualTo(Utility.Int32Dbnull(objRegExam.IdKham, -1)).
                                Execute();
                        }

                    }

                    scope.Complete();
                    //  Reg_ID = Utility.Int32Dbnull(objRegExam.IdKham, -1);
                    return ActionResult.Success;
                }
            }
            catch (Exception exception)
            {
                log.Error("Loi trong qua trinh chuyen vien khoi noi tru {0}", exception);
                return ActionResult.Error;
            }
        }
 /// <summary>
 /// HÀM KHƠI TẠO PHẦN CHỈ ĐỊNH CHUẨN ĐOÁN
 /// </summary>
 /// <returns></returns>
 private KcbChandoanKetluan TaoDulieuChandoanKetluan()
 {
     try
     {
         if (_KcbChandoanKetluan == null)
         {
             _KcbChandoanKetluan = new KcbChandoanKetluan();
             _KcbChandoanKetluan.IsNew = true;
         }
         else
         {
             _KcbChandoanKetluan.IsNew = false;
             _KcbChandoanKetluan.MarkOld();
         }
         _KcbChandoanKetluan.IdKham = Utility.Int64Dbnull(txtExam_ID.Text, -1);
         _KcbChandoanKetluan.MaLuotkham = Utility.sDbnull(m_strMaLuotkham, "");
         _KcbChandoanKetluan.IdBenhnhan = Utility.Int64Dbnull(txtPatient_ID.Text, "-1");
         _KcbChandoanKetluan.MabenhChinh = Utility.sDbnull(txtMaBenhChinh.Text, "");
         _KcbChandoanKetluan.Nhommau = txtNhommau.Text;
         _KcbChandoanKetluan.Nhietdo = Utility.sDbnull(txtNhietDo.Text);
         _KcbChandoanKetluan.TrieuchungBandau = txtTrieuChungBD.Text;
         _KcbChandoanKetluan.Huyetap = txtHa.Text;
         _KcbChandoanKetluan.Mach = txtMach.Text;
         _KcbChandoanKetluan.Nhiptim = Utility.sDbnull(txtNhipTim.Text);
         _KcbChandoanKetluan.Nhiptho = Utility.sDbnull(txtNhipTho.Text);
         _KcbChandoanKetluan.Chieucao = Utility.sDbnull(txtChieucao.Text);
         _KcbChandoanKetluan.Cannang = Utility.sDbnull(txtCannang.Text);
         _KcbChandoanKetluan.HuongDieutri = txtHuongdieutri.Text; //.myCode.Trim();
         _KcbChandoanKetluan.SongayDieutri = (Int16) Utility.DecimaltoDbnull(txtSongaydieutri.Text, 0);
         _KcbChandoanKetluan.Ketluan = Utility.sDbnull(txtKet_Luan.Text, "");
         _KcbChandoanKetluan.NhanXet = Utility.sDbnull(txtNhanxet.Text, "");
         if (Utility.Int16Dbnull(txtBacsi.MyID, -1) > 0)
             _KcbChandoanKetluan.IdBacsikham = Utility.Int16Dbnull(txtBacsi.MyID);
         else
         {
             _KcbChandoanKetluan.IdBacsikham = globalVariables.gv_intIDNhanvien;
         }
         string sMaICDPHU = GetDanhsachBenhphu();
         _KcbChandoanKetluan.MabenhPhu = Utility.sDbnull(sMaICDPHU, "");
         if (objkcbdangky != null)
         {
             _KcbChandoanKetluan.IdKhoanoitru = Utility.Int32Dbnull(objkcbdangky.IdKhoakcb, -1);
             _KcbChandoanKetluan.IdPhongkham = Utility.Int32Dbnull(objkcbdangky.IdPhongkham, -1);
             DmucKhoaphong objDepartment =
                 DmucKhoaphong.FetchByID(Utility.Int32Dbnull(objkcbdangky.IdPhongkham, -1));
             if (objDepartment != null)
             {
                 _KcbChandoanKetluan.TenPhongkham = Utility.sDbnull(objDepartment.TenKhoaphong, "");
             }
         }
         else
         {
             _KcbChandoanKetluan.IdKhoanoitru = globalVariables.idKhoatheoMay;
             _KcbChandoanKetluan.IdPhongkham = globalVariables.idKhoatheoMay;
         }
         _KcbChandoanKetluan.IdKham = Utility.Int32Dbnull(txt_idchidinhphongkham.Text, -1);
         _KcbChandoanKetluan.NgayTao = dtpCreatedDate.Value;
         _KcbChandoanKetluan.NguoiTao = globalVariables.UserName;
         _KcbChandoanKetluan.NgayChandoan = dtpCreatedDate.Value;
         _KcbChandoanKetluan.Ketluan = Utility.sDbnull(txtKet_Luan.Text);
         _KcbChandoanKetluan.Chandoan = Utility.ReplaceString(txtChanDoan.Text);
         _KcbChandoanKetluan.ChandoanKemtheo = Utility.sDbnull(txtChanDoanKemTheo.Text);
         _KcbChandoanKetluan.IdPhieudieutri = -1;
         _KcbChandoanKetluan.Noitru = 0;
         return _KcbChandoanKetluan;
     }
     catch (Exception ex)
     {
         return null;
     }
 }
        private void Create_ChandoanKetluan()
        {
            if (((Utility.DoTrim(this.txtTenBenhChinh.Text) != "") || (this.grd_ICD.GetDataRows().Length > 0)) || (Utility.DoTrim(this.txtChanDoan.Text) != ""))
            {
                if (this._KcbChandoanKetluan == null) this._KcbChandoanKetluan = new KcbChandoanKetluan();
                this._KcbChandoanKetluan.IdKham = this.id_kham;
                this._KcbChandoanKetluan.MaLuotkham = this.objLuotkham.MaLuotkham;
                this._KcbChandoanKetluan.IdBenhnhan = this.objLuotkham.IdBenhnhan;
                this._KcbChandoanKetluan.MabenhChinh = Utility.sDbnull(this.txtMaBenhChinh.Text, "");
                if (Utility.Int16Dbnull(txtBacsi.MyID, -1) > 0)
                {
                    this._KcbChandoanKetluan.IdBacsikham = Utility.Int16Dbnull(txtBacsi.MyID, -1);
                }
                else
                {
                    this._KcbChandoanKetluan.IdBacsikham = globalVariables.gv_intIDNhanvien;
                }
                this._KcbChandoanKetluan.MabenhPhu = Utility.sDbnull(this.GetDanhsachBenhphu().ToString(), "");
                if (this._KcbChandoanKetluan.IsNew)
                {
                    this._KcbChandoanKetluan.NgayTao = this.dtpCreatedDate.Value;
                    this._KcbChandoanKetluan.NguoiTao = globalVariables.UserName;

                    this._KcbChandoanKetluan.IpMaytao = globalVariables.gv_strIPAddress;
                    this._KcbChandoanKetluan.TenMaytao = globalVariables.gv_strComputerName;

                }
                else
                {
                    this._KcbChandoanKetluan.NgaySua = new DateTime?(this.dtpCreatedDate.Value);
                    this._KcbChandoanKetluan.NguoiSua = globalVariables.UserName;

                    this._KcbChandoanKetluan.IpMaysua = globalVariables.gv_strIPAddress;
                    this._KcbChandoanKetluan.TenMaysua = globalVariables.gv_strComputerName;
                }
                this._KcbChandoanKetluan.NgayChandoan = this.dtpCreatedDate.Value;
                this._KcbChandoanKetluan.IdBacsikham = globalVariables.gv_intIDNhanvien;
                this._KcbChandoanKetluan.Chandoan = Utility.ReplaceString(this.txtChanDoan.Text);
                this._KcbChandoanKetluan.Noitru =(byte)noitru;
            }
            else
            {
                this._KcbChandoanKetluan = null;
            }
        }
 private void ThemphieuVattu()
 {
     try
     {
         // KeDonThuocTheoDoiTuong();
         var frm = new frm_KCB_KE_DONTHUOC("VT");
         frm.em_Action = action.Insert;
         frm.objLuotkham = objLuotkham;
         frm._KcbChandoanKetluan = _KcbChandoanKetluan;
         frm._MabenhChinh = txtMaBenhChinh.Text;
         frm._Chandoan = txtChanDoan.Text;
         frm.dt_ICD = dt_ICD;
         frm.dt_ICD_PHU = dt_ICD_PHU;
         frm.id_kham = Utility.Int32Dbnull(txtExam_ID.Text);
         frm.objPhieudieutriNoitru = null;
         frm.txtPatientCode.Text = Utility.sDbnull(objLuotkham.MaLuotkham);
         frm.txtPatientID.Text = Utility.sDbnull(objLuotkham.IdBenhnhan);
         frm.txtPres_ID.Text = "-1";
         frm.noitru = 0;
         frm.CallActionKeDon = CallActionKieuKeDon.TheoDoiTuong;
         frm.ShowDialog();
         if (!frm.m_blnCancel)
         {
             txtMaBenhChinh.Text = frm._MabenhChinh;
             txtChanDoan._Text = frm._Chandoan;
             dt_ICD_PHU = frm.dt_ICD_PHU;
             if (frm._KcbChandoanKetluan != null) _KcbChandoanKetluan = frm._KcbChandoanKetluan;
             Laythongtinchidinhngoaitru();
             Utility.GotoNewRowJanus(grdVTTH, KcbDonthuoc.Columns.IdDonthuoc,
                                     Utility.sDbnull(frm.txtPres_ID.Text));
         }
     }
     catch (Exception exception)
     {
         if (globalVariables.IsAdmin)
         {
             Utility.ShowMsg(exception.ToString());
         }
     }
     finally
     {
         ModifyCommmands();
         txtPatient_Code.Focus();
         txtPatient_Code.SelectAll();
     }
 }
        /// <summary>
        ///     Lấy về thông tin bệnh nhâ nội trú
        /// </summary>
        private void GetData()
        {
            try
            {
                // Utility.SetMsg(lblMsg, "", false);
                string patientCode = Utility.sDbnull(grdLuotkham.GetValue(KcbLuotkham.Columns.MaLuotkham), "");
                _malankham = patientCode;
                int patientId = Utility.Int32Dbnull(grdList.GetValue(KcbLuotkham.Columns.IdBenhnhan), -1);
                ObjLuotkham = new Select().From(KcbLuotkham.Schema)
                              .Where(KcbLuotkham.Columns.MaLuotkham).IsEqualTo(patientCode)
                              .And(KcbLuotkham.Columns.IdBenhnhan).IsEqualTo(patientId).ExecuteSingle <KcbLuotkham>();

                ObjBenhnhan = KcbDanhsachBenhnhan.FetchByID(ObjLuotkham.IdBenhnhan);

                if (ObjLuotkham != null)
                {
                    ClearControl();
                    txt_idchidinhphongkham.Text = Utility.sDbnull(grdRegExam.GetValue(KcbDangkyKcb.Columns.IdKham));

                    _objkcbdangky = KcbDangkyKcb.FetchByID(Utility.Int32Dbnull(txt_idchidinhphongkham.Text));
                    if (_objkcbdangky != null)
                    {
                        DataTable mDtThongTin = _kcbThamkham.LayThongtinBenhnhanKCB(ObjLuotkham.MaLuotkham,
                                                                                    Utility.Int32Dbnull(ObjLuotkham.IdBenhnhan,
                                                                                                        -1),
                                                                                    Utility.Int32Dbnull(txt_idchidinhphongkham.Text));
                        if (mDtThongTin.Rows.Count > 0)
                        {
                            DataRow dr = mDtThongTin.Rows[0];
                            if (dr != null)
                            {
                                dtInput_Date.Value = Convert.ToDateTime(dr[KcbLuotkham.Columns.NgayTiepdon]);
                                txtExam_ID.Text    = Utility.sDbnull(grdRegExam.GetValue(KcbDangkyKcb.Columns.IdKham));

                                txtKhoaDieuTri.Text = Utility.sDbnull(grdLuotkham.GetValue("ten_khoanoitru"));
                                txtBuong.Text       = Utility.sDbnull(grdLuotkham.GetValue("ten_buong"));
                                txtGiuong.Text      = Utility.sDbnull(grdLuotkham.GetValue("ten_giuong"));

                                txtTrangthaiNgoaitru.Text =
                                    Utility.sDbnull(grdLuotkham.GetValue("trangthai_ngoaitru")) == "0"
                                        ? "Đang khám"
                                        : "Đã khám xong";
                                txtTrangthaiNoitru.Text = Utility.sDbnull(grdLuotkham.GetValue("ten_trangthai_noitru"));

                                Utility.Int32Dbnull(txtExam_ID.Text, -1);
                                txtGioitinh.Text =
                                    Utility.sDbnull(grdList.GetValue(KcbDanhsachBenhnhan.Columns.GioiTinh), "");
                                txt_idchidinhphongkham.Text =
                                    Utility.sDbnull(grdRegExam.GetValue(KcbDangkyKcb.Columns.IdKham));
                                lblSOkham.Text       = Utility.sDbnull(grdRegExam.GetValue(KcbDangkyKcb.Columns.SttKham));
                                txtPatient_Name.Text = Utility.sDbnull(dr[KcbDanhsachBenhnhan.Columns.TenBenhnhan], "");
                                txtPatient_ID.Text   = Utility.sDbnull(dr[KcbDanhsachBenhnhan.Columns.IdBenhnhan], "");
                                txtPatient_Code.Text = Utility.sDbnull(dr[KcbLuotkham.Columns.MaLuotkham], "");
                                barcode.Data         = _malankham;
                                txtDiaChi.Text       = Utility.sDbnull(dr[KcbDanhsachBenhnhan.Columns.DiaChi], "");
                                txtDiachiBHYT.Text   = Utility.sDbnull(dr[KcbDanhsachBenhnhan.Columns.DiachiBhyt], "");

                                txtObjectType_Name.Text = Utility.sDbnull(dr[DmucDoituongkcb.Columns.TenDoituongKcb], "");
                                txtSoBHYT.Text          = Utility.sDbnull(dr[KcbLuotkham.Columns.MatheBhyt], "");
                                txtBHTT.Text            = Utility.sDbnull(dr[KcbLuotkham.Columns.PtramBhyt], "0");
                                txtNgheNghiep.Text      = Utility.sDbnull(dr[KcbDanhsachBenhnhan.Columns.NgheNghiep], "");
                                txtHanTheBHYT.Text      = Utility.sDbnull(dr[KcbLuotkham.Columns.NgayketthucBhyt], "");
                                dtpNgayhethanBHYT.Text  = Utility.sDbnull(dr[KcbLuotkham.Columns.NgayketthucBhyt],
                                                                          globalVariables.SysDate.ToString("dd/MM/yyyy"));
                                var sqlbenhan =
                                    new Select().From(KcbBenhAn.Schema)
                                    .Where(KcbBenhAn.Columns.IdBnhan)
                                    .IsEqualTo(ObjLuotkham.IdBenhnhan)
                                    .ExecuteSingle <KcbBenhAn>();
                                txtSoBa.Text = sqlbenhan != null?string.Format("{0}-{1}", sqlbenhan.LoaiBa, sqlbenhan.SoBenhAn) : "";

                                if (ObjBenhnhan.NgaySinh != null)
                                {
                                    txtTuoi.Text = Utility.sDbnull(Utility.Int32Dbnull(globalVariables.SysDate.Year) -
                                                                   ObjBenhnhan.NgaySinh.Value.Year);
                                }
                                //ThongBaoBenhAn(txtPatient_ID.Text);

                                if (_objkcbdangky != null)
                                {
                                    txtReg_ID.Text        = Utility.sDbnull(_objkcbdangky.IdKham);
                                    dtpCreatedDate.Value  = Convert.ToDateTime(_objkcbdangky.NgayDangky);
                                    txtDepartment_ID.Text = Utility.sDbnull(_objkcbdangky.IdPhongkham);
                                    var department = (from p in globalVariables.gv_dtDmucPhongban.AsEnumerable()
                                                      where p[DmucKhoaphong.Columns.IdKhoaphong].Equals(_objkcbdangky.IdPhongkham)
                                                      select p).FirstOrDefault();
                                    if (department != null)
                                    {
                                        txtPhongkham.Text = Utility.sDbnull(department["ten_khoaphong"], "");
                                    }
                                    txtTenDvuKham.Text    = Utility.sDbnull(_objkcbdangky.TenDichvuKcb);
                                    txtNguoiTiepNhan.Text = Utility.sDbnull(_objkcbdangky.NguoiTao);
                                    try
                                    {
                                        cboDoctorAssign.SelectedIndex =
                                            Utility.GetSelectedIndex(cboDoctorAssign,
                                                                     Utility.sDbnull(
                                                                         _objkcbdangky.IdBacsikham, -1));
                                    }
                                    catch (Exception exception)
                                    {
                                        if (globalVariables.IsAdmin)
                                        {
                                            Utility.ShowMsg(exception.ToString());
                                        }
                                    }
                                }
                                _kcbChandoanKetluan = new Select().From(KcbChandoanKetluan.Schema)
                                                      .Where(KcbChandoanKetluan.Columns.IdKham)
                                                      .IsEqualTo(_objkcbdangky.IdKham)
                                                      .ExecuteSingle
                                                      <KcbChandoanKetluan>();
                                if (_kcbChandoanKetluan != null)
                                {
                                    txtKet_Luan._Text     = Utility.sDbnull(_kcbChandoanKetluan.Ketluan);
                                    txtHuongdieutri._Text = _kcbChandoanKetluan.HuongDieutri;
                                    nmrSongayDT.Value     = Utility.DecimaltoDbnull(_kcbChandoanKetluan.SongayDieutri, 0);
                                    txtHa.Text            = Utility.sDbnull(_kcbChandoanKetluan.Huyetap);
                                    txtMach.Text          = Utility.sDbnull(_kcbChandoanKetluan.Mach);
                                    txtNhipTim.Text       = Utility.sDbnull(_kcbChandoanKetluan.Nhiptim);
                                    txtNhipTho.Text       = Utility.sDbnull(_kcbChandoanKetluan.Nhiptho);
                                    txtNhietDo.Text       = Utility.sDbnull(_kcbChandoanKetluan.Nhietdo);
                                    txtCannang.Text       = Utility.sDbnull(_kcbChandoanKetluan.Cannang);
                                    txtSoNgayHen.Text     = Utility.sDbnull(_kcbChandoanKetluan.SoNgayhen);
                                    txtChieucao.Text      = Utility.sDbnull(_kcbChandoanKetluan.Chieucao);
                                    if (!string.IsNullOrEmpty(Utility.sDbnull(_kcbChandoanKetluan.Nhommau)) &&
                                        Utility.sDbnull(_kcbChandoanKetluan.Nhommau) != "-1")
                                    {
                                        txtNhommau._Text = Utility.sDbnull(_kcbChandoanKetluan.Nhommau);
                                    }


                                    AllowTextChanged        = true;
                                    _isLike                 = false;
                                    txtChanDoan._Text       = Utility.sDbnull(_kcbChandoanKetluan.Chandoan);
                                    txtChanDoanKemTheo.Text = Utility.sDbnull(_kcbChandoanKetluan.ChandoanKemtheo);
                                    txtMaBenhChinh.Text     = Utility.sDbnull(_kcbChandoanKetluan.MabenhChinh);
                                    string dataString = Utility.sDbnull(_kcbChandoanKetluan.MabenhPhu, "");
                                    _isLike          = true;
                                    AllowTextChanged = false;
                                    _dtIcdPhu.Clear();
                                    if (!string.IsNullOrEmpty(dataString))
                                    {
                                        string[] rows = dataString.Split(',');
                                        foreach (string row in rows)
                                        {
                                            if (!string.IsNullOrEmpty(row))
                                            {
                                                DataRow newDr = _dtIcdPhu.NewRow();
                                                newDr[DmucBenh.Columns.MaBenh]  = row;
                                                newDr[DmucBenh.Columns.TenBenh] = GetTenBenh(row);
                                                _dtIcdPhu.Rows.Add(newDr);
                                                _dtIcdPhu.AcceptChanges();
                                            }
                                        }
                                        grd_ICD.DataSource = _dtIcdPhu;
                                    }
                                }

                                GetDataChiDinh();
                            }
                        }
                    }
                    else
                    {
                        ClearControl();
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg("Lỗi: " + ex.Message);
            }
            finally
            {
                KiemTraDaInPhoiBhyt();
            }
        }
        /// <summary>
        /// Lấy về thông tin bệnh nhâ nội trú
        /// </summary>
        private void GetData()
        {
            try
            {
                // Utility.SetMsg(lblMsg, "", false);
                string PatientCode = Utility.sDbnull(grdLuotkham.GetValue(KcbLuotkham.Columns.MaLuotkham), "");
                malankham = PatientCode;
                int Patient_ID = Utility.Int32Dbnull(grdList.GetValue(KcbLuotkham.Columns.IdBenhnhan), -1);
                objLuotkham = new Select().From(KcbLuotkham.Schema)
                    .Where(KcbLuotkham.Columns.MaLuotkham).IsEqualTo(PatientCode)
                    .And(KcbLuotkham.Columns.IdBenhnhan).IsEqualTo(Patient_ID).ExecuteSingle<KcbLuotkham>();

                objBenhnhan = KcbDanhsachBenhnhan.FetchByID(objLuotkham.IdBenhnhan);

                isRoom = false;
                if (objLuotkham != null)
                {
                    ClearControl();
                    txt_idchidinhphongkham.Text = Utility.sDbnull(grdRegExam.GetValue(KcbDangkyKcb.Columns.IdKham));

                    objkcbdangky = KcbDangkyKcb.FetchByID(Utility.Int32Dbnull(txt_idchidinhphongkham.Text));
                    DmucNhanvien objStaff = new Select().From(DmucNhanvien.Schema).Where(DmucNhanvien.UserNameColumn).IsEqualTo(Utility.sDbnull(objLuotkham.NguoiKetthuc, "")).ExecuteSingle<DmucNhanvien>();
                    string TenNhanvien = objLuotkham.NguoiKetthuc;
                    if (objStaff != null)
                        TenNhanvien = objStaff.TenNhanvien;
                    if (objkcbdangky != null)
                    {
                        DataTable m_dtThongTin = _KCB_THAMKHAM.LayThongtinBenhnhanKCB(objLuotkham.MaLuotkham,
                                                                          Utility.Int32Dbnull(objLuotkham.IdBenhnhan,
                                                                                              -1),
                                                                          Utility.Int32Dbnull(txt_idchidinhphongkham.Text));
                        if (m_dtThongTin.Rows.Count > 0)
                        {
                            DataRow dr = m_dtThongTin.Rows[0];
                            if (dr != null)
                            {

                                dtInput_Date.Value = Convert.ToDateTime(dr[KcbLuotkham.Columns.NgayTiepdon]);
                                txtExam_ID.Text = Utility.sDbnull(grdRegExam.GetValue(KcbDangkyKcb.Columns.IdKham));

                                txtKhoaDieuTri.Text = Utility.sDbnull(grdLuotkham.GetValue("ten_khoanoitru"));
                                txtBuong.Text = Utility.sDbnull(grdLuotkham.GetValue("ten_buong"));
                                txtGiuong.Text = Utility.sDbnull(grdLuotkham.GetValue("ten_giuong"));

                                txtTrangthaiNgoaitru.Text = Utility.sDbnull(grdLuotkham.GetValue("trangthai_ngoaitru"))=="0"?"Đang khám":"Đã khám xong";
                                txtTrangthaiNoitru.Text = Utility.sDbnull(grdLuotkham.GetValue("ten_trangthai_noitru"));

                                Exam_ID = Utility.Int32Dbnull(txtExam_ID.Text, -1);
                                txtGioitinh.Text =
                                    Utility.sDbnull(grdList.GetValue(KcbDanhsachBenhnhan.Columns.GioiTinh), "");
                                txt_idchidinhphongkham.Text = Utility.sDbnull(grdRegExam.GetValue(KcbDangkyKcb.Columns.IdKham));
                                lblSOkham.Text = Utility.sDbnull(grdRegExam.GetValue(KcbDangkyKcb.Columns.SttKham));
                                txtPatient_Name.Text = Utility.sDbnull(dr[KcbDanhsachBenhnhan.Columns.TenBenhnhan], "");
                                txtPatient_ID.Text = Utility.sDbnull(dr[KcbDanhsachBenhnhan.Columns.IdBenhnhan], "");
                                txtPatient_Code.Text = Utility.sDbnull(dr[KcbLuotkham.Columns.MaLuotkham], "");
                                barcode.Data = malankham;
                                txtDiaChi.Text = Utility.sDbnull(dr[KcbDanhsachBenhnhan.Columns.DiaChi], "");
                                txtDiachiBHYT.Text = Utility.sDbnull(dr[KcbDanhsachBenhnhan.Columns.DiachiBhyt], "");

                                txtObjectType_Name.Text = Utility.sDbnull(dr[DmucDoituongkcb.Columns.TenDoituongKcb], "");
                                txtSoBHYT.Text = Utility.sDbnull(dr[KcbLuotkham.Columns.MatheBhyt], "");
                                txtBHTT.Text = Utility.sDbnull(dr[KcbLuotkham.Columns.PtramBhyt], "0");
                                txtNgheNghiep.Text = Utility.sDbnull(dr[KcbDanhsachBenhnhan.Columns.NgheNghiep], "");
                                txtHanTheBHYT.Text = Utility.sDbnull(dr[KcbLuotkham.Columns.NgayketthucBhyt], "");
                                dtpNgayhethanBHYT.Text = Utility.sDbnull(dr[KcbLuotkham.Columns.NgayketthucBhyt], globalVariables.SysDate.ToString("dd/MM/yyyy"));
                                txtTuoi.Text = Utility.sDbnull(Utility.Int32Dbnull(globalVariables.SysDate.Year) -
                                                               objBenhnhan.NgaySinh.Value.Year);
                                //ThongBaoBenhAn(txtPatient_ID.Text);

                                if (objkcbdangky != null)
                                {
                                    txtReg_ID.Text = Utility.sDbnull(objkcbdangky.IdKham);
                                    dtpCreatedDate.Value = Convert.ToDateTime(objkcbdangky.NgayDangky);
                                    txtDepartment_ID.Text = Utility.sDbnull(objkcbdangky.IdPhongkham);
                                    DmucKhoaphong _department = new Select().From(DmucKhoaphong.Schema).Where(DmucKhoaphong.IdKhoaphongColumn).IsEqualTo(objkcbdangky.IdPhongkham).ExecuteSingle<DmucKhoaphong>();
                                    if (_department != null)
                                    {
                                        txtPhongkham.Text = Utility.sDbnull(_department.TenKhoaphong);
                                    }
                                    txtTenDvuKham.Text = Utility.sDbnull(objkcbdangky.TenDichvuKcb);
                                    txtNguoiTiepNhan.Text = Utility.sDbnull(objkcbdangky.NguoiTao);
                                    try
                                    {
                                        cboDoctorAssign.SelectedIndex =
                                                           Utility.GetSelectedIndex(cboDoctorAssign,
                                                                                    Utility.sDbnull(
                                                                                        objkcbdangky.IdBacsikham, -1));

                                    }
                                    catch (Exception)
                                    {
                                    }
                                }
                                _KcbChandoanKetluan = new Select().From(KcbChandoanKetluan.Schema)
                                        .Where(KcbChandoanKetluan.Columns.IdKham).IsEqualTo(objkcbdangky.IdKham).ExecuteSingle
                                        <KcbChandoanKetluan>();
                                if (_KcbChandoanKetluan != null)
                                {
                                    txtKet_Luan._Text = Utility.sDbnull(_KcbChandoanKetluan.Ketluan);
                                    txtHuongdieutri._Text = _KcbChandoanKetluan.HuongDieutri;
                                    nmrSongayDT.Value = Utility.DecimaltoDbnull(_KcbChandoanKetluan.SongayDieutri, 0);
                                    txtHa.Text = Utility.sDbnull(_KcbChandoanKetluan.Huyetap);
                                    txtMach.Text = Utility.sDbnull(_KcbChandoanKetluan.Mach);
                                    txtNhipTim.Text = Utility.sDbnull(_KcbChandoanKetluan.Nhiptim);
                                    txtNhipTho.Text = Utility.sDbnull(_KcbChandoanKetluan.Nhiptho);
                                    txtNhietDo.Text = Utility.sDbnull(_KcbChandoanKetluan.Nhietdo);
                                    txtCannang.Text = Utility.sDbnull(_KcbChandoanKetluan.Cannang);
                                    txtChieucao.Text = Utility.sDbnull(_KcbChandoanKetluan.Chieucao);
                                    if (!string.IsNullOrEmpty(Utility.sDbnull(_KcbChandoanKetluan.Nhommau)) &&
                                        Utility.sDbnull(_KcbChandoanKetluan.Nhommau) != "-1")
                                        txtNhommau._Text = Utility.sDbnull(_KcbChandoanKetluan.Nhommau);

                                    AllowTextChanged = true;
                                    isLike = false;
                                    txtChanDoan._Text = Utility.sDbnull(_KcbChandoanKetluan.Chandoan);
                                    txtChanDoanKemTheo.Text = Utility.sDbnull(_KcbChandoanKetluan.ChandoanKemtheo);
                                    txtMaBenhChinh.Text = Utility.sDbnull(_KcbChandoanKetluan.MabenhChinh);
                                    string dataString = Utility.sDbnull(_KcbChandoanKetluan.MabenhPhu, "");
                                    isLike = true;
                                    AllowTextChanged = false;
                                    dt_ICD_PHU.Clear();
                                    if (!string.IsNullOrEmpty(dataString))
                                    {
                                        string[] rows = dataString.Split(',');
                                        foreach (string row in rows)
                                        {
                                            if (!string.IsNullOrEmpty(row))
                                            {
                                                DataRow newDr = dt_ICD_PHU.NewRow();
                                                newDr[DmucBenh.Columns.MaBenh] = row;
                                                newDr[DmucBenh.Columns.TenBenh] = GetTenBenh(row);
                                                dt_ICD_PHU.Rows.Add(newDr);
                                                dt_ICD_PHU.AcceptChanges();
                                            }
                                        }
                                        grd_ICD.DataSource = dt_ICD_PHU;
                                    }
                                }

                                GetDataChiDinh();
                            }
                        }

                    }
                    else
                    {
                        ClearControl();

                    }
                }

            }
            catch
            {
            }
            finally
            {
                KiemTraDaInPhoiBHYT();
                getResult();
            }
        }
Example #31
0
        public ActionResult CapnhatChandoan(KcbChandoanKetluan objKcbChandoanKetluan)
        {
            try
             {
                 if (objKcbChandoanKetluan == null) return ActionResult.Cancel;
                 using (TransactionScope scope = new TransactionScope())
                 {
                     using (SharedDbConnectionScope sh = new SharedDbConnectionScope())
                     {
                         if (objKcbChandoanKetluan.IsNew )
                         {
                             objKcbChandoanKetluan.Save();
                         }
                         else
                         {
                             objKcbChandoanKetluan.MarkOld();
                             objKcbChandoanKetluan.Save();
                         }

                         SqlQuery sqlQuery = new Select().From( KcbChandoanKetluan.Schema)
                                .Where(KcbChandoanKetluan.Columns.MaLuotkham).IsEqualTo(objKcbChandoanKetluan.MaLuotkham)
                                .And(KcbChandoanKetluan.Columns.IdBenhnhan).IsEqualTo(objKcbChandoanKetluan.IdBenhnhan).OrderAsc(
                                    KcbChandoanKetluan.Columns.NgayChandoan);
                         KcbChandoanKetluanCollection objInfoCollection = sqlQuery.ExecuteAsCollection<KcbChandoanKetluanCollection>();
                         var query = (from chandoan in objInfoCollection.AsEnumerable()
                                      let y = Utility.sDbnull(chandoan.Chandoan)
                                      where (y != "")
                                      select y).ToArray();
                         string cdchinh = string.Join(";", query);
                         var querychandoanphu = (from chandoan in objInfoCollection.AsEnumerable()
                                                 let y = Utility.sDbnull(chandoan.ChandoanKemtheo)
                                                 where (y != "")
                                                 select y).ToArray();
                         string cdphu = string.Join(";", querychandoanphu);
                         var querybenhchinh = (from benhchinh in objInfoCollection.AsEnumerable()
                                               let y = Utility.sDbnull(benhchinh.MabenhChinh)
                                               where (y != "")
                                               select y).ToArray();
                         string mabenhchinh = string.Join(";", querybenhchinh);

                         var querybenhphu = (from benhphu in objInfoCollection.AsEnumerable()
                                             let y = Utility.sDbnull(benhphu.MabenhPhu)
                                             where (y != "")
                                             select y).ToArray();
                         string mabenhphu = string.Join(";", querybenhphu);
                         new Update(KcbLuotkham.Schema)
                             .Set(KcbLuotkham.Columns.MabenhChinh).EqualTo(mabenhchinh)
                             .Set(KcbLuotkham.Columns.MabenhPhu).EqualTo(mabenhphu)
                             .Set(KcbLuotkham.Columns.ChanDoan).EqualTo(cdchinh)
                             .Set(KcbLuotkham.Columns.NguoiSua).EqualTo(globalVariables.UserName)
                             .Set(KcbLuotkham.Columns.NgaySua).EqualTo(globalVariables.SysDate)
                             .Where(KcbLuotkham.Columns.MaLuotkham).IsEqualTo(objKcbChandoanKetluan.MaLuotkham)
                             .And(KcbLuotkham.Columns.IdBenhnhan).IsEqualTo(objKcbChandoanKetluan.IdBenhnhan).Execute();

                     }

                     scope.Complete();
                     //  Reg_ID = Utility.Int32Dbnull(objRegExam.IdKham, -1);
                     return ActionResult.Success;
                 }
             }
             catch (Exception exception)
             {
                 log.Error("Loi trong qua trinh chuyen vien khoi noi tru {0}", exception);
                 return ActionResult.Error;
             }
        }
Example #32
0
        /// <summary>
        /// hàm thực hiện việc update thông tin xác nhận gói
        /// </summary>
        /// <param name="objThongtinGoiDvuBnhan"></param>
        /// <returns></returns>


        public ActionResult UpdateExamInfo(KcbChandoanKetluan objDiagInfo, KcbDangkyKcb objRegExam,
                                           KcbLuotkham objPatientExam)
        {
            try
            {
                using (var scope = new TransactionScope())
                {
                    using (var sh = new SharedDbConnectionScope())
                    {
                        if (objDiagInfo.IsNew)
                        {
                            objDiagInfo.Save();
                        }
                        else
                        {
                            objDiagInfo.MarkOld();
                            objDiagInfo.Save();
                        }

                        SqlQuery sqlQuery = new Select().From(
                            KcbChandoanKetluan.Schema)
                                            .Where(KcbChandoanKetluan.Columns.MaLuotkham).IsEqualTo(objPatientExam.MaLuotkham)
                                            .And(KcbChandoanKetluan.Columns.IdBenhnhan).IsEqualTo(objPatientExam.IdBenhnhan).OrderAsc(
                            KcbChandoanKetluan.Columns.NgayChandoan);
                        KcbChandoanKetluanCollection objInfoCollection = sqlQuery.ExecuteAsCollection <KcbChandoanKetluanCollection>();
                        var query = (from chandoan in objInfoCollection.AsEnumerable()
                                     let y = Utility.sDbnull(chandoan.Chandoan)
                                             where (y != "")
                                             select y).ToArray();
                        string cdchinh = string.Join(";", query);
                        //KcbChandoanKetluanCollection objInfoCollection = sqlQuery.ExecuteAsCollection<KcbChandoanKetluanCollection>();
                        var querychandoanphu = (from chandoan in objInfoCollection.AsEnumerable()
                                                let y = Utility.sDbnull(chandoan.ChandoanKemtheo)
                                                        where (y != "")
                                                        select y).ToArray();
                        string cdphu          = string.Join(";", querychandoanphu);
                        var    querybenhchinh = (from benhchinh in objInfoCollection.AsEnumerable()
                                                 let y = Utility.sDbnull(benhchinh.MabenhChinh)
                                                         where (y != "")
                                                         select y).ToArray();
                        string mabenhchinh = string.Join(";", querybenhchinh);

                        var querybenhphu = (from benhphu in objInfoCollection.AsEnumerable()
                                            let y = Utility.sDbnull(benhphu.MabenhPhu)
                                                    where (y != "")
                                                    select y).ToArray();
                        string mabenhphu = string.Join(";", querybenhphu);
                        new Update(KcbLuotkham.Schema)
                        .Set(KcbLuotkham.Columns.MabenhChinh).EqualTo(mabenhchinh)
                        .Set(KcbLuotkham.Columns.MabenhPhu).EqualTo(mabenhphu)
                        .Set(KcbLuotkham.Columns.ChanDoan).EqualTo(cdchinh)
                        .Set(KcbLuotkham.Columns.ChandoanKemtheo).EqualTo(cdphu)
                        .Set(KcbLuotkham.Columns.TrieuChung).EqualTo(objPatientExam.TrieuChung)
                        .Set(KcbLuotkham.Columns.NguoiSua).EqualTo(globalVariables.UserName)
                        .Set(KcbLuotkham.Columns.NgaySua).EqualTo(globalVariables.SysDate)
                        .Set(KcbLuotkham.Columns.Locked).EqualTo(objPatientExam.Locked)
                        .Set(KcbLuotkham.Columns.NguoiKetthuc).EqualTo(objPatientExam.NguoiKetthuc)
                        .Set(KcbLuotkham.Columns.NgayKetthuc).EqualTo(objPatientExam.NgayKetthuc)
                        .Where(KcbLuotkham.Columns.MaLuotkham).IsEqualTo(objPatientExam.MaLuotkham)
                        .And(KcbLuotkham.Columns.IdBenhnhan).IsEqualTo(objPatientExam.IdBenhnhan).Execute();
                        //Tạm bỏ tránh việc bị cập nhật sai bác sĩ chỉ định nếu bác sĩ đó chỉ lưu thông tin kết luận
                        //SPs.KcbThamkhamCappnhatBsyKham(Utility.Int32Dbnull(objRegExam.IdKham, -1), objPatientExam.MaLuotkham,
                        //                            Utility.Int32Dbnull(objPatientExam.IdBenhnhan, -1),
                        //                            Utility.Int32Dbnull(objDiagInfo.DoctorId, -1)).Execute();

                        if (objRegExam != null)
                        {
                            new Update(KcbDangkyKcb.Schema)
                            .Set(KcbDangkyKcb.Columns.NgaySua).EqualTo(globalVariables.SysDate)
                            .Set(KcbDangkyKcb.Columns.NguoiSua).EqualTo(globalVariables.UserName)
                            //.Set(KcbDangkyKcb.Columns.IpMacSua).EqualTo(BusinessHelper.GetMACAddress())
                            //.Set(KcbDangkyKcb.Columns.IpMaySua).EqualTo(BusinessHelper.GetIP4Address())
                            .Set(KcbDangkyKcb.Columns.IdBacsikham).EqualTo(objDiagInfo.IdBacsikham)
                            .Set(KcbDangkyKcb.Columns.TrangThai).EqualTo(objRegExam.TrangThai)
                            .Where(KcbDangkyKcb.Columns.IdKham).IsEqualTo(Utility.Int32Dbnull(objRegExam.IdKham, -1)).
                            Execute();
                        }
                    }

                    scope.Complete();
                    //  Reg_ID = Utility.Int32Dbnull(objRegExam.IdKham, -1);
                    return(ActionResult.Success);
                }
            }
            catch (Exception exception)
            {
                log.Error("Loi trong qua trinh chuyen vien khoi noi tru {0}", exception);
                return(ActionResult.Error);
            }
        }
 public bool Delete(object IdChandoan)
 {
     return(KcbChandoanKetluan.Delete(IdChandoan) == 1);
 }
Example #34
0
        public ActionResult LuuHoibenhvaChandoan(KcbChandoanKetluan objDiagInfo,KcbDonthuocChitiet objChitiet,bool Luudulieutiemchung)
        {
            try
            {
                using (var scope = new TransactionScope())
                {
                    using (var sh = new SharedDbConnectionScope())
                    {

                        if (objChitiet != null)
                        {
                            objChitiet.IsNew = false;
                            if (objDiagInfo != null)
                            {
                                objChitiet.PhanungSautiem = objDiagInfo.PhanungSautiemchung;
                                objChitiet.Xutri = objDiagInfo.HuongDieutri;
                                objChitiet.KetQua = objDiagInfo.Ketluan;
                                objChitiet.KetluanNguyennhan = objDiagInfo.KetluanNguyennhan;
                            }
                            objChitiet.MarkOld();
                            objChitiet.Save();
                        }
                        if (objDiagInfo != null)
                        {
                            if (objDiagInfo.IsNew)
                            {
                                objDiagInfo.Save();
                            }
                            else
                            {
                                objDiagInfo.MarkOld();
                                objDiagInfo.Save();
                            }
                            if (Luudulieutiemchung && objChitiet == null)
                            {
                                new Update(KcbDonthuocChitiet.Schema)
                                    .Set(KcbDonthuocChitiet.Columns.PhanungSautiem).EqualTo(objDiagInfo.PhanungSautiemchung)
                                    .Set(KcbDonthuocChitiet.Columns.Xutri).EqualTo(objDiagInfo.HuongDieutri)
                                    .Set(KcbDonthuocChitiet.Columns.KetQua).EqualTo(objDiagInfo.Ketluan)
                                    .Set(KcbDonthuocChitiet.Columns.KetluanNguyennhan).EqualTo(objDiagInfo.KetluanNguyennhan)
                                    .Where(KcbDonthuocChitiet.Columns.IdKham).IsEqualTo(objDiagInfo.IdKham)
                                    .Execute();
                            }
                        }
                    }

                    scope.Complete();
                    //  Reg_ID = Utility.Int32Dbnull(objRegExam.IdKham, -1);
                    return ActionResult.Success;
                }
            }
            catch (Exception exception)
            {
                log.Error("Loi trong qua trinh chuyen vien khoi noi tru {0}", exception);
                return ActionResult.Error;
            }
        }
        public void Insert(long IdKham, long IdBenhnhan, string MaLuotkham, short IdBacsikham, DateTime NgayChandoan, string NguoiTao, DateTime NgayTao, string NguoiSua, DateTime?NgaySua, int?IdKhoanoitru, long?IdBuonggiuong, short?IdBuong, short?IdGiuong, long?IdPhieudieutri, byte Noitru, int?IdPhongkham, string TenPhongkham, string Mach, string Nhietdo, string Huyetap, string Nhiptim, string Nhiptho, string Cannang, string Chieucao, string Nhommau, string Ketluan, string HuongDieutri, short?SongayDieutri, short?SoNgayhen, string TrieuchungBandau, string Chandoan, string ChandoanKemtheo, string MabenhChinh, string MabenhPhu, string IpMaytao, string IpMaysua, string TenMaytao, string TenMaysua, string PhanungSautiemchung, byte?KPL1, byte?KPL2, byte?KPL3, byte?KPL4, byte?KPL5, byte?KPL6, byte?KPL7, byte?KPL8, byte?KL1, byte?KL2, byte?KL3, string KetluanNguyennhan, string NhanXet, string ChongchidinhKhac, string ChedoDinhduong, string MotaBenhchinh, decimal?ChisoIbm, string NhanapMp, string NhanapMt, string ThilucMp, string ThilucMt)
        {
            KcbChandoanKetluan item = new KcbChandoanKetluan();

            item.IdKham = IdKham;

            item.IdBenhnhan = IdBenhnhan;

            item.MaLuotkham = MaLuotkham;

            item.IdBacsikham = IdBacsikham;

            item.NgayChandoan = NgayChandoan;

            item.NguoiTao = NguoiTao;

            item.NgayTao = NgayTao;

            item.NguoiSua = NguoiSua;

            item.NgaySua = NgaySua;

            item.IdKhoanoitru = IdKhoanoitru;

            item.IdBuonggiuong = IdBuonggiuong;

            item.IdBuong = IdBuong;

            item.IdGiuong = IdGiuong;

            item.IdPhieudieutri = IdPhieudieutri;

            item.Noitru = Noitru;

            item.IdPhongkham = IdPhongkham;

            item.TenPhongkham = TenPhongkham;

            item.Mach = Mach;

            item.Nhietdo = Nhietdo;

            item.Huyetap = Huyetap;

            item.Nhiptim = Nhiptim;

            item.Nhiptho = Nhiptho;

            item.Cannang = Cannang;

            item.Chieucao = Chieucao;

            item.Nhommau = Nhommau;

            item.Ketluan = Ketluan;

            item.HuongDieutri = HuongDieutri;

            item.SongayDieutri = SongayDieutri;

            item.SoNgayhen = SoNgayhen;

            item.TrieuchungBandau = TrieuchungBandau;

            item.Chandoan = Chandoan;

            item.ChandoanKemtheo = ChandoanKemtheo;

            item.MabenhChinh = MabenhChinh;

            item.MabenhPhu = MabenhPhu;

            item.IpMaytao = IpMaytao;

            item.IpMaysua = IpMaysua;

            item.TenMaytao = TenMaytao;

            item.TenMaysua = TenMaysua;

            item.PhanungSautiemchung = PhanungSautiemchung;

            item.KPL1 = KPL1;

            item.KPL2 = KPL2;

            item.KPL3 = KPL3;

            item.KPL4 = KPL4;

            item.KPL5 = KPL5;

            item.KPL6 = KPL6;

            item.KPL7 = KPL7;

            item.KPL8 = KPL8;

            item.KL1 = KL1;

            item.KL2 = KL2;

            item.KL3 = KL3;

            item.KetluanNguyennhan = KetluanNguyennhan;

            item.NhanXet = NhanXet;

            item.ChongchidinhKhac = ChongchidinhKhac;

            item.ChedoDinhduong = ChedoDinhduong;

            item.MotaBenhchinh = MotaBenhchinh;

            item.ChisoIbm = ChisoIbm;

            item.NhanapMp = NhanapMp;

            item.NhanapMt = NhanapMt;

            item.ThilucMp = ThilucMp;

            item.ThilucMt = ThilucMt;


            item.Save(UserName);
        }
        /// <summary>
        /// HÀM KHƠI TẠO PHẦN CHỈ ĐỊNH CHUẨN ĐOÁN
        /// </summary>
        /// <returns></returns>
        private KcbChandoanKetluan CreateDiagInfo()
        {
            if (_KcbChandoanKetluan == null)
            {
                _KcbChandoanKetluan = new KcbChandoanKetluan();
                _KcbChandoanKetluan.IsNew = true;
            }
            else
            {
                _KcbChandoanKetluan.IsNew = false;
                _KcbChandoanKetluan.MarkOld();
            }
            _KcbChandoanKetluan.IdKham = Utility.Int64Dbnull(txtExam_ID.Text, -1);
            _KcbChandoanKetluan.MaLuotkham = Utility.sDbnull(malankham, "");
            _KcbChandoanKetluan.IdBenhnhan = Utility.Int64Dbnull(txtPatient_ID.Text, "-1");
            _KcbChandoanKetluan.MabenhChinh = Utility.sDbnull(txtMaBenhChinh.Text, "");
            _KcbChandoanKetluan.Nhommau = txtNhommau.Text;
            _KcbChandoanKetluan.Nhietdo = Utility.sDbnull(txtNhietDo.Text);
            _KcbChandoanKetluan.Huyetap = txtHa.Text;
            _KcbChandoanKetluan.Mach = txtMach.Text;
            _KcbChandoanKetluan.Nhiptim = Utility.sDbnull(txtNhipTim.Text);
            _KcbChandoanKetluan.Nhiptho = Utility.sDbnull(txtNhipTho.Text);
            _KcbChandoanKetluan.Chieucao = Utility.sDbnull(txtChieucao.Text);
            _KcbChandoanKetluan.Cannang = Utility.sDbnull(txtCannang.Text);
            _KcbChandoanKetluan.HuongDieutri = "";
            _KcbChandoanKetluan.SongayDieutri = 0;
            _KcbChandoanKetluan.Ketluan = "";
            if (cboBSDieutri.SelectedIndex > 0)
                _KcbChandoanKetluan.IdBacsikham = Utility.Int16Dbnull(cboBSDieutri.SelectedValue, -1);
            else
            {
                _KcbChandoanKetluan.IdBacsikham = globalVariables.gv_intIDNhanvien;
            }
            string sMaICDPHU = GetDanhsachBenhphu();
            _KcbChandoanKetluan.MabenhPhu = Utility.sDbnull(sMaICDPHU.ToString(), "");
            if (objPhieudieutri != null)
            {
                _KcbChandoanKetluan.IdPhongkham = Utility.Int32Dbnull(objPhieudieutri.IdKhoanoitru, -1);
                DmucKhoaphong objDepartment = DmucKhoaphong.FetchByID(Utility.Int32Dbnull(objPhieudieutri.IdKhoanoitru, -1));
                if (objDepartment != null)
                {
                    _KcbChandoanKetluan.TenPhongkham = Utility.sDbnull(objDepartment.TenKhoaphong, "");
                }
                _KcbChandoanKetluan.IdPhongkham = Utility.Int32Dbnull(objPhieudieutri.IdKhoanoitru);
            }
            else
            {
                _KcbChandoanKetluan.IdPhongkham = globalVariables.idKhoatheoMay;
            }
            _KcbChandoanKetluan.IdKham = Utility.Int32Dbnull(txtIdPhieudieutri.Text, -1);
            _KcbChandoanKetluan.NgayTao = dtpCreatedDate.Value;
            _KcbChandoanKetluan.NguoiTao = globalVariables.UserName;
            _KcbChandoanKetluan.NgayChandoan = dtpCreatedDate.Value;
            _KcbChandoanKetluan.Ketluan = "";
            _KcbChandoanKetluan.Chandoan = Utility.ReplaceString(txtChanDoan.Text);
            _KcbChandoanKetluan.ChandoanKemtheo = Utility.sDbnull(txtChanDoanKemTheo.Text);

            _KcbChandoanKetluan.Noitru = (byte)1;
            return _KcbChandoanKetluan;
        }