Пример #1
0
        /// <summary>
        /// hàm thực hiện việc in phiếu điều trị cần thiết
        /// </summary>
        private void INPHIEU_DIEUTRI()
        {
            try
            {
                if (!Utility.isValidGrid(grdList))
                {
                    Utility.ShowMsg("Bạn cần chọn ít nhất một phiếu điều trị để in ", "Thông báo", MessageBoxIcon.Information);
                    return;
                }

                if (grdList.GetCheckedRows().Length <= 0)
                {
                    grdList.CurrentRow.IsChecked = true;
                }
                var TreatmentId = new StringBuilder("-1");
                foreach (GridEXRow gridExRow in grdList.GetCheckedRows())
                {
                    TreatmentId.Append(",");
                    TreatmentId.Append(gridExRow.Cells[NoitruPhieudieutri.Columns.IdPhieudieutri].Value.ToString());
                    gridExRow.BeginEdit();
                    gridExRow.Cells[NoitruPhieudieutri.Columns.TthaiIn].Value = 1;
                    gridExRow.EndEdit();
                }
                grdList.UpdateData();
                m_dtPhieudieutri.AcceptChanges();
                DataSet dsPrint;
                dsPrint = new noitru_phieudieutri().NoitruLaythongtinphieudieutriIn(TreatmentId.ToString());
                DataTable mdtDataPhieuDieuTri;
                mdtDataPhieuDieuTri = dsPrint.Tables[0];
                THU_VIEN_CHUNG.CreateXML(mdtDataPhieuDieuTri, "noitru_phieudieutri");
                foreach (DataRow row in mdtDataPhieuDieuTri.Rows)
                {
                    var YLENH = new StringBuilder("");
                    if (chkInYLenhThuocCLS.Checked)
                    {
                        List<DataRow> query = (from chidinh in dsPrint.Tables[1].AsEnumerable()
                                               where
                                                   Utility.Int32Dbnull(chidinh["id_phieudieutri"]) ==
                                                   Utility.Int32Dbnull(row["id_phieudieutri"])
                                                   &&
                                                   Utility.Int32Dbnull(chidinh["id_loaithanhtoan"]) ==
                                                   Utility.Int32Dbnull(KieuLoaiThanhToan.CLS)
                                               select chidinh).ToList();
                        if (query.Any())
                        {
                            foreach (DataRow dr in query)
                            {
                                YLENH.Append("<p>");
                                YLENH.Append(string.Format("<b>{0}</b>", Utility.sDbnull(dr["TEN"])));
                                YLENH.Append(" , ");
                                YLENH.Append(Utility.sDbnull(dr["SOLUONG"]));
                                YLENH.Append("</p>");
                            }
                        }

                        query = (dsPrint.Tables[1].AsEnumerable().Where(
                            chidinh => Utility.Int32Dbnull(chidinh["id_phieudieutri"]) == Utility.Int32Dbnull(row["id_phieudieutri"])
                                       &&
                                       Utility.Int32Dbnull(chidinh["id_loaithanhtoan"]) ==
                                       Utility.Int32Dbnull(KieuLoaiThanhToan.Thuoc))).ToList();
                        if (query.Any())
                        {
                            YLENH.Append("</br>");
                            foreach (DataRow dr in query)
                            {
                                YLENH.Append("<p>");
                                YLENH.Append(string.Format("<b>{0}</b>", Utility.sDbnull(dr["TEN"])));
                                YLENH.Append("<span > X</span> ");
                                YLENH.Append(Utility.sDbnull(dr["SOLUONG"]));
                                YLENH.Append(" ");
                                YLENH.Append(Utility.sDbnull(dr["DONVI"]));
                                YLENH.Append("</br>");
                                YLENH.Append(string.Format("{0}", dr["sDesc"]));
                                YLENH.Append("</p>");
                            }
                        }

                        YLENH.Append("</br> ");
                        YLENH.Append("</br> ");
                        YLENH.Append(string.Format("Người lập y lệnh : {0}", Utility.sDbnull(row["ten_bacsidieutri"])));
                        YLENH.Append("</br> ");
                        row["YLENH"] = YLENH.ToString();
                    }
                    else
                    {
                        //var YLENH = new StringBuilder("");
                        YLENH.Append("</br> ");
                        YLENH.Append("</br> ");
                        YLENH.Append(string.Format("Người lập y lệnh {0}", Utility.sDbnull(row["ten_bacsidieutri"])));
                        YLENH.Append("</br> ");
                        row["YLENH"] = YLENH.ToString();
                    }
                }

                Utility.UpdateLogotoDatatable(ref mdtDataPhieuDieuTri);
                mdtDataPhieuDieuTri.AcceptChanges();

                InphieuDieuTri(mdtDataPhieuDieuTri, dtNgayInPhieu.Value);

                foreach (GridEXRow gridExRow in grdList.GetCheckedRows())
                {
                    gridExRow.BeginEdit();
                    gridExRow.Cells[NoitruPhieudieutri.Columns.TthaiIn].Value = 1;
                    gridExRow.EndEdit();
                }
                grdList.UpdateData();
            }
            catch (Exception ex)
            {
                Utility.CatchException(ex);

            }
        }
        private void XoaPhieuDieuTri(int IdPhieudieutri)
        {
            try
            {
                if (!IsValidBeforeDelete(IdPhieudieutri)) return;

                ActionResult act = new noitru_phieudieutri().Xoaphieudieutri(new List<int>() { IdPhieudieutri });
                switch (act)
                {
                    case ActionResult.Success:
                        grdPhieudieutri.CurrentRow.Delete();
                        grdPhieudieutri.UpdateData();
                        grdPhieudieutri.Refresh();
                        m_dtPhieudieutri.AcceptChanges();
                        Utility.SetMsg(lblMsg, "Xóa phiếu điều trị thành công", false);
                        if (!Utility.isValidGrid(grdPhieudieutri))
                        {
                            _CurIdPhieudieutri = -1;
                            objPhieudieutri = null;
                        }
                        break;
                    case ActionResult.Error:
                        Utility.ShowMsg("Lỗi trong quá trình xóa thông tin", "Thông báo", MessageBoxIcon.Error);
                        break;
                }

            }
            catch (Exception exception)
            {
                if (globalVariables.IsAdmin)
                {
                    Utility.CatchException(exception);
                }
            }
            finally
            {
                grdPhieudieutri_SelectionChanged(grdPhieudieutri, new EventArgs());
                ModifyCommandPhieudieutri();
                ModifyCommmands();
            }
        }
        private void XoaPhieudieutri()
        {
            try
            {
                List<int> lstIdPhieudieutri = new List<int>();
                if (grdPhieudieutri.GetCheckedRows().Length < 0)
                {
                    if (Utility.isValidGrid(grdPhieudieutri))
                    {
                        Utility.ShowMsg("Bạn phải thực hiện chọn một phiếu điều trị để xóa");
                        grdPhieudieutri.Focus();
                        return;
                    }
                }
                foreach (GridEXRow gridExRow in grdPhieudieutri.GetCheckedRows())
                {
                    int TreatId = Utility.Int32Dbnull(grdPhieudieutri.GetValue(NoitruPhieudieutri.Columns.IdPhieudieutri), -1);
                    if (!IsValidBeforeDelete(TreatId))
                    {
                        return;
                    }
                }
                lstIdPhieudieutri = (from p in grdPhieudieutri.GetCheckedRows()
                                     select Utility.Int32Dbnull(p.Cells[NoitruPhieudieutri.Columns.IdPhieudieutri].Value, -1)).ToList<int>();
                string _question = grdPhieudieutri.GetCheckedRows().Length > 0 ? "Bạn có chắc chắn muốn xóa các phiếu điều trị đang chọn hay không?"
                    : string.Format("Bạn có chắc chắn muốn xóa phiếu điều trị của ngày {0} hay không?", Utility.sDbnull(grdPhieudieutri.GetValue("sngay_dieutri")));
                if (Utility.AcceptQuestion(_question,
                                           "Thông báo", true))
                {
                    ActionResult actionResult = new noitru_phieudieutri().Xoaphieudieutri(lstIdPhieudieutri);
                    if (grdPhieudieutri.GetCheckedRows().Length > 0)
                    {
                        switch (actionResult)
                        {
                            case ActionResult.Success:
                                foreach (GridEXRow gridExRow in grdPhieudieutri.GetCheckedRows())
                                {
                                    gridExRow.Delete();
                                    grdPhieudieutri.UpdateData();
                                    grdPhieudieutri.Refresh();
                                    m_dtPhieudieutri.AcceptChanges();
                                }
                                Utility.SetMsg(lblMsg, "Xóa phiếu điều trị thành công", false);
                                break;
                            case ActionResult.Error:
                                Utility.ShowMsg("Lỗi trong quá trình xóa thông tin", "Thông báo", MessageBoxIcon.Error);
                                break;
                            case ActionResult.IsNotUserName:
                                Utility.ShowMsg("Phiếu chỉ định này không phải của bạn, Bạn không có quyền xóa",
                                                "Thông báo", MessageBoxIcon.Warning);
                                break;
                        }

                    }
                    else//Xóa dòng hiện tại
                    {
                        XoaPhieuDieuTri(Utility.Int32Dbnull(grdPhieudieutri.GetValue(NoitruPhieudieutri.Columns.IdPhieudieutri), -1));
                    }
                }
            }
            catch (Exception)
            {
                // Utility.ShowMsg("Lỗi trong quá trình xóa thông tin ","Thông báo lỗi",MessageBoxIcon.Error);
            }
            finally
            {
                grdPhieudieutri_SelectionChanged(grdPhieudieutri, new EventArgs());
                ModifyCommandPhieudieutri();
                ModifyCommmands();
            }
        }
Пример #4
0
        private void UpdatePhieuDieuTri()
        {
            objPhieudieutri.IdPhieudieutri = Utility.Int32Dbnull(txtTreat_ID.Text, -1);
            if (objPhieudieutri.IdPhieudieutri > 0)
            {
                objPhieudieutri.MarkOld();
                objPhieudieutri.IsLoaded = true;
                objPhieudieutri.IsNew = false;
                objPhieudieutri.IdPhieudieutri = Utility.Int32Dbnull(txtTreat_ID.Text, -1);
                objPhieudieutri.NguoiSua = globalVariables.UserName;
                objPhieudieutri.NgaySua = globalVariables.SysDate;
                objPhieudieutri.TenMaysua = globalVariables.gv_strComputerName;
                objPhieudieutri.IpMaysua = globalVariables.gv_strIPAddress;
            }
            else
            {
                objPhieudieutri.TthaiIn = 0;
                objPhieudieutri.TrangThai = 0;
                objPhieudieutri.TenMaytao = globalVariables.gv_strComputerName;
                objPhieudieutri.IpMaytao =globalVariables.gv_strIPAddress;
                objPhieudieutri.NguoiTao = globalVariables.UserName;
                objPhieudieutri.NgayTao = globalVariables.SysDate;
            }
            objPhieudieutri.ThongtinDieutri = Utility.DoTrim(txtBstheodoi.Text);
            objPhieudieutri.ThongtinTheodoi = Utility.DoTrim(txtDieuduongtheodoi.Text);
            objPhieudieutri.NgayDieutri = dtNgayLapPhieu.Value.Date;
            objPhieudieutri.GioDieutri = dtGioLapPhieu.Text;
            objPhieudieutri.Thu = Utility.ConvertDayVietnamese(dtNgayLapPhieu.Value.DayOfWeek.ToString());
            objPhieudieutri.MaLuotkham = Utility.sDbnull(objLuotkham.MaLuotkham, "");
            objPhieudieutri.IdBuongGiuong = objBuongGiuong != null ? Utility.Int32Dbnull(objBuongGiuong.Id) : -1;
            objPhieudieutri.IdBuong = objBuongGiuong != null ? Utility.Int32Dbnull(objBuongGiuong.IdBuong) : -1;
            objPhieudieutri.IdGiuong = objBuongGiuong != null ? Utility.Int32Dbnull(objBuongGiuong.IdGiuong) : -1;
            objPhieudieutri.IdKhoanoitru = objBuongGiuong.IdKhoanoitru;
            objPhieudieutri.IdBenhnhan = Utility.Int32Dbnull(objLuotkham.IdBenhnhan, -1);
            objPhieudieutri.TthaiBosung =Utility.Bool2byte( chkPhieuBoSung.Checked);
            if (cboBacSy.SelectedIndex > 0)
                objPhieudieutri.IdBacsi = Utility.Int16Dbnull(cboBacSy.SelectedValue);
            else
            {
                objPhieudieutri.IdBacsi = globalVariables.gv_intIDNhanvien;
            }
            ActionResult actionResult = new noitru_phieudieutri().ThemPhieudieutri(objPhieudieutri);
            switch (actionResult)
            {
                case ActionResult.Success:
                    DataRow drv = p_TreatMent.NewRow();

                    Utility.FromObjectToDatarow(objPhieudieutri, ref drv);
                    var query = from dt in p_TreatMent.AsEnumerable()
                        where
                            Utility.Int32Dbnull(dt[NoitruPhieudieutri.Columns.IdPhieudieutri]) ==
                            Utility.Int32Dbnull(txtTreat_ID.Text, -1)
                        select dt;

                    if (query.Any())
                    {
                        var firstrow = query.FirstOrDefault();
                        if(firstrow!=null)
                            firstrow.Delete();
                        p_TreatMent.AcceptChanges();
                    }
                    if (cboBacSy.SelectedIndex > 0)
                    {
                        if (p_TreatMent.Columns.Contains("ten_bacsidieutri"))drv["ten_bacsidieutri"] = cboBacSy.Text;
                    }

                    drv["sngay_dieutri"] = dtNgayLapPhieu.Value.ToString("dd/MM/yyyy");
                    p_TreatMent.Rows.Add(drv);
                    Utility.GotoNewRowJanus(grdList, NoitruPhieudieutri.Columns.IdPhieudieutri, objPhieudieutri.IdPhieudieutri.ToString());
                    //Utility.ShowMsg("Bạn sửa thông tin thành công", "Thông báo thành công");
                    //SaoChepDonThuoc();
                    b_Cancel = true;
                    Close();
                    break;
                case ActionResult.Error:
                    Utility.ShowMsg("Lỗi trong quá trình sửa phiếu điều trị", "Thông báo lỗi", MessageBoxIcon.Error);
                    break;
            }
        }
Пример #5
0
        private void ThemPhieuDieuTri()
        {
            if (objPhieudieutri == null) objPhieudieutri = new NoitruPhieudieutri();
            if (em_Action == action.Update)
            {
                objPhieudieutri.MarkOld();
                objPhieudieutri.IsLoaded = true;
                objPhieudieutri.IsNew = false;
                objPhieudieutri.IdPhieudieutri = Utility.Int32Dbnull(txtTreat_ID.Text, -1);
                objPhieudieutri.NguoiSua = globalVariables.UserName;
                objPhieudieutri.NgaySua =globalVariables.SysDate;
                objPhieudieutri.TenMaysua = globalVariables.gv_strComputerName;
                objPhieudieutri.IpMaysua = globalVariables.gv_strIPAddress;
            }
            else
            {
                objPhieudieutri.TrangThai = 0;
                objPhieudieutri.IsNew = true;
                objPhieudieutri.TenMaytao = globalVariables.gv_strComputerName;
                objPhieudieutri.IpMaytao = globalVariables.gv_strIPAddress;
                objPhieudieutri.NguoiTao = globalVariables.UserName;
                objPhieudieutri.NgayTao = globalVariables.SysDate;
                objPhieudieutri.TthaiIn = 0;
            }
            objPhieudieutri.TthaiBosung =Utility.Bool2byte( chkPhieuBoSung.Checked);
            objPhieudieutri.IdPhieudieutri = Utility.Int32Dbnull(txtTreat_ID.Text, -1);
            objPhieudieutri.ThongtinDieutri = Utility.DoTrim(txtBstheodoi.Text);
            objPhieudieutri.ThongtinTheodoi = Utility.DoTrim(txtDieuduongtheodoi.Text);
            objPhieudieutri.NgayDieutri = dtNgayLapPhieu.Value.Date;
            objPhieudieutri.GioDieutri = dtGioLapPhieu.Text;
            objPhieudieutri.Thu = Utility.ConvertDayVietnamese(dtNgayLapPhieu.Value.DayOfWeek.ToString());
            objPhieudieutri.MaLuotkham = Utility.sDbnull(objLuotkham.MaLuotkham, "");
            objPhieudieutri.IdKhoanoitru = objBuongGiuong.IdKhoanoitru;
            objPhieudieutri.IdBuongGiuong =objBuongGiuong!=null? Utility.Int32Dbnull(objBuongGiuong.Id):-1;
            objPhieudieutri.IdBuong = objBuongGiuong != null ? Utility.Int32Dbnull(objBuongGiuong.IdBuong) : -1;
            objPhieudieutri.IdGiuong = objBuongGiuong != null ? Utility.Int32Dbnull(objBuongGiuong.IdGiuong) : -1;
            objPhieudieutri.IdBenhnhan = Utility.Int32Dbnull(objLuotkham.IdBenhnhan, -1);
            objPhieudieutri.IdBuong = objLuotkham.IdBuong;
            objPhieudieutri.IdGiuong = objLuotkham.IdGiuong;
            if (cboBacSy.SelectedIndex > 0)
                objPhieudieutri.IdBacsi = Utility.Int16Dbnull(cboBacSy.SelectedValue);
            else
            {
                objPhieudieutri.IdBacsi = globalVariables.gv_intIDNhanvien;
            }
            ActionResult actionResult = new noitru_phieudieutri().ThemPhieudieutri(objPhieudieutri);
            switch (actionResult)
            {
                case ActionResult.Success:
                    txtTreat_ID.Text = Utility.sDbnull(objPhieudieutri.IdPhieudieutri, -1);
                    DataRow drv = p_TreatMent.NewRow();
                    Utility.FromObjectToDatarow(objPhieudieutri, ref drv);
                    drv["sngay_dieutri"] = dtNgayLapPhieu.Value.ToString("dd/MM/yyyy");
                    if (cboBacSy.SelectedIndex > 0)
                    {
                        drv["ten_bacsidieutri"] = cboBacSy.Text;
                    }

                    p_TreatMent.Rows.Add(drv);
                    Utility.GotoNewRowJanus(grdList, NoitruPhieudieutri.Columns.IdPhieudieutri, objPhieudieutri.IdPhieudieutri.ToString());
                    b_Cancel = true;
                    Close();
                    break;
                case ActionResult.Error:
                    Utility.ShowMsg("Lỗi trong quá trình thêm phiếu điều trị", "Thông báo lỗi", MessageBoxIcon.Error);
                    break;
            }
        }
        private void cmdSaoChepPhieu_Click(object sender, EventArgs e)
        {
            if (!Utility.isValidGrid(grdPhieudieutrigoc))
            {
                Utility.ShowMsg("Bạn cần chọn phiếu điều trị gốc để thực hiện sao chép", "Thông báo", MessageBoxIcon.Error);
                grdPhieudieutrigoc.Focus();
                return;

            }
            if (grdDichvuSaochep.GetCheckedRows().Length <= 0)
            {
                Utility.ShowMsg("Bạn cần chọn ít nhất 1 dịch vụ cần sao chép", "Thông báo", MessageBoxIcon.Error);
                grdDichvuSaochep.Focus();
                return;

            }
            if (Utility.Int16Dbnull(cboKhoaHientai.SelectedValue, -1) < 0)
            {
                Utility.ShowMsg("Bạn cần chọn khoa nội trú hiện tại đang lập phiếu điều trị cho bệnh nhân", "Thông báo", MessageBoxIcon.Error);
                cboKhoaHientai.Focus();
                return;
            }
            if (grdNgaysaochep.GetDataRows().Count() <= 0)
            {
                Utility.ShowMsg("Bạn cần chọn ít nhất một ngày cần sao chép", "Thông báo", MessageBoxIcon.Error);
                cmdAddNgay.Focus();
                return;
            }
            bool moreAsk = true;
            if (Utility.Int16Dbnull(cboKhoaHientai.SelectedValue, -1) != Utility.Int16Dbnull(objLuotkham.IdKhoanoitru, -1))
            {
                if (!Utility.AcceptQuestion("Bệnh nhân đang nằm ở khoa nội trú khác với khoa Hiện tại bạn đang chọn. Bạn có chắc chắn đang tạo các phiếu điều trị cho khoa " + cboKhoaHientai.Text + " hay không?", "Thông báo", true))
                {
                    moreAsk = false;
                    cboKhoaHientai.Focus();
                    return;
                }
            }
            if(moreAsk)
                if (!Utility.AcceptQuestion("Bạn đã chắc chắn muốn sao chép phiếu điều trị cho các ngày bạn đang chọn không?", "Thông báo", true))
                {
                    return;
                }
            NoitruPhieudieutri[] objPhieudieutri = TaoPhieudieutriNoitru();
            ActionResult actionResult = new noitru_phieudieutri().SaoChepPhieuDieuTri(objPhieudieutri, objLuotkham, CreateChiDinhCLS(), CreatePresDetail());
            switch (actionResult)
            {
                case ActionResult.Success:
                    b_Cancel = true;
                    if (_OnCopyComplete != null)
                    {
                        _OnCopyComplete();
                    }
                    Utility.ShowMsg("Bạn sao chép thành công. Nhấn OK để kết thúc", "Thông báo");
                    break;
                case ActionResult.Error:
                    Utility.ShowMsg("Lỗi trong quá trình sao chép", "Thông báo");
                    break;
            }
        }