Exemplo n.º 1
0
 public bool IsBaohiem(TPatientExam objPatientExam)
 {
     LObjectType objObjectType = LObjectType.FetchByID(objPatientExam.ObjectTypeId);
     if (objObjectType.ObjectTypeType == 0) return true;
     else
     {
         return false;
     }
 }
Exemplo n.º 2
0
        public bool IsBaohiem(TPatientExam objPatientExam)
        {
            LObjectType objObjectType = LObjectType.FetchByID(objPatientExam.ObjectTypeId);

            if (objObjectType.ObjectTypeType == 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 3
0
        private void grdListPatientExam_SelectionChanged(object sender, EventArgs e)
        {
            try
            {
                if (grdListPatientExam.CurrentRow != null)
                {
                    string PatientCode = Utility.sDbnull(grdListPatientExam.GetValue(TPatientExam.Columns.PatientCode), "");
                    ObjPatientExam = new Select().From(TPatientExam.Schema).Where(TPatientExam.Columns.PatientCode).IsEqualTo(PatientCode)
                                     .And(TPatientExam.Columns.PatientId).IsEqualTo(PatientId).ExecuteSingle <TPatientExam>();
                    if (ObjPatientExam != null)
                    {
                        txtPatient_Code.Text = Utility.sDbnull(ObjPatientExam.PatientCode, "");
                        barcode.Data         = Utility.sDbnull(ObjPatientExam.PatientCode, "");

                        txtObjectType_Name.Text = BusinessHelper.GetObjectTypeName(ObjPatientExam.ObjectTypeId);
                        txtObjectType_Code.Text = Utility.sDbnull(ObjPatientExam.MaDoiTuong, "");
                        txtSoBHYT.Text          = Utility.sDbnull(ObjPatientExam.InsuranceNum, "");
                        txtBHTT.Text            = Utility.sDbnull(ObjPatientExam.DiscountRate, "0");
                        txtHanTheBHYT.Text      = Utility.sDbnull(ObjPatientExam.InsuranceFromDate, "");
                        Load_Trieuchung_LanKham(ObjPatientExam.PatientCode, PatientId);
                        DataTable dt_TRegExam = new Select().From(TRegExam.Schema)
                                                .Where(TRegExam.Columns.PatientCode).IsEqualTo(ObjPatientExam.PatientCode)
                                                .And(TRegExam.Columns.PatientId).IsEqualTo(ObjPatientExam.PatientId).ExecuteDataSet().Tables[0];
                        if (dt_TRegExam.Rows.Count > 0)
                        {
                            cboRegExam.DataSource    = dt_TRegExam;
                            cboRegExam.ValueMember   = TRegExam.Columns.RegId;
                            cboRegExam.DisplayMember = TRegExam.Columns.KieuKhambenh;
                            cboRegExam.SelectedIndex = 0;
                            if (dt_TRegExam.Rows.Count > 1)
                            {
                                cboRegExam.Enabled = true;
                            }
                            else
                            {
                                cboRegExam.Enabled = false;
                            }
                        }
                    }
                    else
                    {
                        ClearControl();
                    }
                }
            }
            catch (Exception)
            {
                Utility.ShowMsg("Có lỗi trong quá trình lấy thông tin lấy khám");
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// hàm thực hiện thanh toán xử lý thông tin của phần 
        /// </summary>
        /// <param name="v_decTotalPrice"></param>
        /// <param name="v_decDiscountRate"></param>
        /// <param name="vDiscountType"></param>
        /// <param name="v_SalaryBasic"></param>
        /// <param name="vClinicCode"></param>
        /// <param name="IsSpecialDiscount"></param>
        /// <returns></returns>
        public decimal LayThongPtramBHYT(decimal v_decTotalPrice, TPatientExam objPatientExam)
        {
            decimal decDiscountTotalMoney = 0;
            if (!string.IsNullOrEmpty(objPatientExam.InsClinicCode))
            {
                ///thực hiện xem có đúng tuyến không
                if (objPatientExam.CorrectLine == 1)
                {
                    if (objPatientExam.InsObjectCodeNumber.ToString() == "1" || objPatientExam.InsObjectCodeNumber.ToString() == "2")
                    {
                        decDiscountTotalMoney = 0;
                    }
                    else
                    {
                        if (v_decTotalPrice > objPatientExam.SalaryBasic * 15 / 100)
                        {
                            decDiscountTotalMoney = v_decTotalPrice * (Utility.DecimaltoDbnull(objPatientExam.DiscountRate) / 100);
                        }
                        else
                        {
                            decDiscountTotalMoney = 0;
                        }
                    }
                }
                else
                {
                    decDiscountTotalMoney = v_decTotalPrice * (Utility.DecimaltoDbnull(objPatientExam.DiscountRate) / 100);

                }

            }
            else
            {
                decDiscountTotalMoney = v_decTotalPrice * (Utility.DecimaltoDbnull(objPatientExam.DiscountRate) / 100); ;
            }

            return decDiscountTotalMoney;
        }
Exemplo n.º 5
0
        /// <summary>
        /// hàm thực hiện thanh toán xử lý thông tin của phần
        /// </summary>
        /// <param name="v_decTotalPrice"></param>
        /// <param name="v_decDiscountRate"></param>
        /// <param name="vDiscountType"></param>
        /// <param name="v_SalaryBasic"></param>
        /// <param name="vClinicCode"></param>
        /// <param name="IsSpecialDiscount"></param>
        /// <returns></returns>
        public decimal LayThongPtramBHYT(decimal v_decTotalPrice, TPatientExam objPatientExam)
        {
            decimal decDiscountTotalMoney = 0;

            if (!string.IsNullOrEmpty(objPatientExam.InsClinicCode))
            {
                ///thực hiện xem có đúng tuyến không
                if (objPatientExam.CorrectLine == 1)
                {
                    if (objPatientExam.InsObjectCodeNumber.ToString() == "1" || objPatientExam.InsObjectCodeNumber.ToString() == "2")
                    {
                        decDiscountTotalMoney = 0;
                    }
                    else
                    {
                        if (v_decTotalPrice > objPatientExam.SalaryBasic * 15 / 100)
                        {
                            decDiscountTotalMoney = v_decTotalPrice * (Utility.DecimaltoDbnull(objPatientExam.DiscountRate) / 100);
                        }
                        else
                        {
                            decDiscountTotalMoney = 0;
                        }
                    }
                }
                else
                {
                    decDiscountTotalMoney = v_decTotalPrice * (Utility.DecimaltoDbnull(objPatientExam.DiscountRate) / 100);
                }
            }
            else
            {
                decDiscountTotalMoney = v_decTotalPrice * (Utility.DecimaltoDbnull(objPatientExam.DiscountRate) / 100);;
            }

            return(decDiscountTotalMoney);
        }
Exemplo n.º 6
0
 public static TThongtinGoiDvuBnhan LayThongTinGoiNgoaiTru(TPatientExam objPatientExam)
 {
     SqlQuery sqlQuery = new Select().From(TThongtinGoiDvuBnhan.Schema)
         .Where(TThongtinGoiDvuBnhan.Columns.PatientCode).IsEqualTo(objPatientExam.PatientCode)
         .And(TThongtinGoiDvuBnhan.Columns.PatientId).IsEqualTo(objPatientExam.PatientId)
         .And(TThongtinGoiDvuBnhan.Columns.NoiTru).IsEqualTo(0);
     TThongtinGoiDvuBnhan objThongtinGoiDvuBnhan = sqlQuery.ExecuteSingle<TThongtinGoiDvuBnhan>();
     return objThongtinGoiDvuBnhan;
 }
Exemplo n.º 7
0
        /// <summary>
        /// hàm thực hiện việc tính phần trăm của bảo hiểm y tế
        /// </summary>
        /// <param name="objPatientExam"></param>
        /// <param name="objRegExam"></param>
        public static void TinhToanKhamPtramBHYT(TPatientExam objPatientExam, TRegExam objRegExam)
        {
            decimal PTramBHYT = Utility.DecimaltoDbnull(objPatientExam.DiscountRate, 0);
            objRegExam.MaKhoaThien = globalVariables.MA_KHOA_THIEN;
            if (Utility.Int32Dbnull(objRegExam.TrongGoi, 0) == 1)
            {
                objRegExam.GiaBhytCt = 0;
                objRegExam.GiaBnct = 0;
            }
            else
            {
                objRegExam.GiaBhytCt = Utility.DecimaltoDbnull(objRegExam.RegFee) *
                                            Utility.DecimaltoDbnull(PTramBHYT) / 100;

                objRegExam.GiaBnct = Utility.DecimaltoDbnull(objRegExam.RegFee, 0) -
                                          Utility.DecimaltoDbnull(objRegExam.GiaBhytCt, 0);
            }
        }
Exemplo n.º 8
0
        public static decimal TinhPtramBHYT(TPatientExam ObjPatientExam)
        {
            decimal ptramBhyt = 0;
            try
            {
                if (string.IsNullOrEmpty(ObjPatientExam.InsuranceNum)) return ptramBhyt;
                LObjectType objObjectType = LObjectType.FetchByID(ObjPatientExam.ObjectTypeId);
                if (!string.IsNullOrEmpty(ObjPatientExam.InsClinicCode))
                {
                    if (ObjPatientExam.CorrectLine == 1)//Đúng tuyến
                    {
                        if (objObjectType != null)
                        {
                            if (ObjPatientExam.InsObjectCodeNumber == 1 || ObjPatientExam.InsObjectCodeNumber == 2)//Đối tượng 1,2 hưởng 100%
                            {
                                ptramBhyt = 100;
                            }
                            else
                            {
                                SqlQuery sqlQuery = new Select(LInsuranceObject.Columns.Percent).From(LInsuranceObject.Schema)
                                .Where(LInsuranceObject.Columns.InsObjectCode).IsEqualTo(
                                    Utility.sDbnull(ObjPatientExam.InsObjectCode));
                                LInsuranceObject objInsuranceObject = sqlQuery.ExecuteSingle<LInsuranceObject>();
                                if (objInsuranceObject != null)
                                {
                                    ptramBhyt = Utility.DecimaltoDbnull(objInsuranceObject.Percent, 0);
                                }
                                else
                                {
                                    ptramBhyt = 100;
                                }
                            }

                        }
                    }
                    else//Trái tuyến
                    {
                        if (objObjectType != null)
                        {
                            ptramBhyt = Utility.DecimaltoDbnull(objObjectType.DiscountDiscorrectLine, 0);
                        }
                    }
                }
                else//Dịch vụ
                {
                    SqlQuery sqlQuery =
                        new Select().From(LObjectType.Schema).Where(LObjectType.Columns.ObjectTypeCode).IsEqualTo("DV");
                    objObjectType = sqlQuery.ExecuteSingle<LObjectType>();
                    if (objObjectType != null) ptramBhyt = Utility.DecimaltoDbnull(objObjectType.DiscountCorrectLine);
                    else ptramBhyt = 0;
                    // ptramBhyt = objObjectType.DiscountCorrectLine;
                }

            }
            catch (Exception exception)
            {
                ptramBhyt = 0;
            }
            return ptramBhyt;
        }
Exemplo n.º 9
0
        public static TPaymentDetail[] TinhPhamTramBHYT(TPaymentDetail[] arrPaymentDetail, TPatientExam objPatientExam, decimal v_DiscountRate)
        {
            string IsDungTuyen = "DT";
            LObjectType objectType = LObjectType.FetchByID(objPatientExam.ObjectTypeId);
            if (objectType != null)
            {
                switch (objectType.ObjectTypeCode)
                {
                    case "BHYT":
                        if (Utility.Int32Dbnull(objPatientExam.CorrectLine, "0") == 1) IsDungTuyen = "DT";
                        else
                        {
                            IsDungTuyen = "TT";
                        }
                        break;
                    default:
                        IsDungTuyen = "KHAC";
                        break;
                }

            }
            foreach (TPaymentDetail objPaymentDetail in arrPaymentDetail)
            {
                if (objPaymentDetail.IsPayment == 0)//Có thể tính cho BHYT
                {
                    SqlQuery sqlQuery = new Select().From(LInsDetailDiscountRate.Schema)
                        .Where(LInsDetailDiscountRate.Columns.ServiceDetailId).IsEqualTo(objPaymentDetail.ServiceDetailId)
                        .And(LInsDetailDiscountRate.Columns.PaymentTypeId).IsEqualTo(objPaymentDetail.PaymentTypeId)
                        .And(LInsDetailDiscountRate.Columns.InsType).IsEqualTo(IsDungTuyen)
                        .And(LInsDetailDiscountRate.Columns.ObjectTypeCode).IsEqualTo(objPatientExam.MaDoiTuong);
                    LInsDetailDiscountRate objDetailDiscountRate = sqlQuery.ExecuteSingle<LInsDetailDiscountRate>();
                    if (objDetailDiscountRate != null)
                    {
                        objPaymentDetail.MaDv = Utility.sDbnull(objPatientExam.MaDoiTuong);
                        objPaymentDetail.PTramBh = (int?)objDetailDiscountRate.DiscountRate;
                        objPaymentDetail.DiscountRate = DiscountRate(objDetailDiscountRate.DiscountRate,
                                                      Utility.DecimaltoDbnull(
                                                          objPaymentDetail.OriginPrice, 0));
                        objPaymentDetail.DiscountPrice = DiscountPrice(objDetailDiscountRate.DiscountRate,
                                                                 Utility.DecimaltoDbnull(
                                                                     objPaymentDetail.OriginPrice, 0));
                    }
                    else
                    {
                        objPaymentDetail.MaDv = Utility.sDbnull(objPatientExam.MaDoiTuong);
                        objPaymentDetail.PTramBh = (int?)v_DiscountRate;
                        objPaymentDetail.DiscountRate = DiscountRate(v_DiscountRate,
                                                       Utility.DecimaltoDbnull(
                                                           objPaymentDetail.OriginPrice, 0));
                        objPaymentDetail.DiscountPrice = DiscountPrice(v_DiscountRate,
                                                                 Utility.DecimaltoDbnull(
                                                                     objPaymentDetail.OriginPrice, 0));
                    }

                }
                else
                {
                    objPaymentDetail.MaDv = "DV";
                    objPaymentDetail.DiscountRate = 0;
                    objPaymentDetail.DiscountPrice = objPaymentDetail.OriginPrice;
                }

            }
            return arrPaymentDetail;
        }
Exemplo n.º 10
0
        private void ImportData()
        {
            TAssignDetail objAssignDetail = null;
            TAssignInfo objAsignInfo = null;
            TPatientExam objPatientExam = null;
            TPatientInfo objPatientInfo = null;
            string SoCMND = "";
            string sNgaySinh = "";
            string sGioiTinh = "";
            string sCoQuan = "";
            string sChucVu = "";
            byte btGioitinh = 0;
            string sDiaChi = "";
            string sSDT = "";
            string sMaNV = "";
            var dtNgaySinh = new DateTime();
            _lstAssignDetail.Clear();
            if (!chkGhepLo.Checked) LaySoLoImportExcel();
            int iSTT = 1;
            _Value = 0;
            try
            {
                DateTime sysdate = BusinessHelper.GetSysDateTime();

                #region Get AssignInfo

                objAsignInfo = new TAssignInfo();
                objAsignInfo.ExamId = -1;
                objAsignInfo.TreatId = -1;
                objAsignInfo.PatientDeptId = -1;
                objAsignInfo.PatientCode = SoCMND;
                objAsignInfo.ServiceId = -1;
                objAsignInfo.ServiceTypeId = -1;
                objAsignInfo.RegDate = dtNgayNhap.Value;
                objAsignInfo.PaymentStatus = 0;
                objAsignInfo.CreatedBy = globalVariables.UserName;
                objAsignInfo.CreateDate = sysdate;
                objAsignInfo.ObjectTypeId = -1;
                objAsignInfo.MaKhoaThien = "KSK";
                objAsignInfo.Actived = 0;
                objAsignInfo.NoiTru = 0;

                objAsignInfo.IsPHIDvuKtheo = 0;

                #endregion

                #region Get AssignDetail

                foreach (DataRow dr in m_dtAssignDetail.Rows)
                {
                    objAssignDetail = new TAssignDetail();
                    objAssignDetail.ExamId = -1;
                    objAssignDetail.ServiceId = Convert.ToInt16(dr["Service_Id"]);
                    objAssignDetail.ServiceDetailId = Convert.ToInt16(dr["ServiceDetail_Id"]);
                    objAssignDetail.DiagPerson = Convert.ToInt16(dr["Diag_Person"]);
                    objAssignDetail.DiscountRate = Convert.ToDecimal(Utility.DecimaltoDbnull(dr["Discount_Rate"], 0));
                    objAssignDetail.DiscountType = Convert.ToByte(Utility.ByteDbnull(dr["Discount_Type"], 0));
                    objAssignDetail.OriginPrice = Convert.ToDecimal(Utility.DecimaltoDbnull(dr["Origin_Price"], 0));
                    objAssignDetail.DiscountPrice = Convert.ToDecimal(Utility.DecimaltoDbnull(dr["Discount_Price"], 0));
                    objAssignDetail.SurchargePrice = Convert.ToDecimal(Utility.DecimaltoDbnull(dr["Surcharge_Price"], 0));
                    objAssignDetail.UserId = globalVariables.UserName;
                    if (!string.IsNullOrEmpty(dr["Assign_Type_Id"].ToString()))
                        objAssignDetail.AssignTypeId = Convert.ToByte(Utility.ByteDbnull(dr["Assign_Type_Id"], 0));
                    else
                        objAssignDetail.AssignTypeId = 0;
                    objAssignDetail.InputDate = dtNgayNhap.Value;
                    objAssignDetail.PaymentStatus = 0;
                    objAssignDetail.IsCancel = 0;
                    objAssignDetail.IsPayment = 0;
                    objAssignDetail.ObjectTypeId = 1;
                    objAssignDetail.Quantity = Convert.ToInt32(dr["Quantity"]);
                    objAssignDetail.AssignDetailStatus = 0;
                    objAssignDetail.BhytStatus = 0;
                    objAssignDetail.DisplayOnReport = 0;
                    objAssignDetail.GiaBhytCt = 0;
                    objAssignDetail.PaymentId = 0;
                    objAssignDetail.ChoPhepIn = 0;
                    _lstAssignDetail.Add(objAssignDetail);
                }

                foreach (GridEXRow row in grdData.GetCheckedRows())
                {
                    string patient_code = Utility.sDbnull(row.Cells["patient_code"].Value, "");
                    if (patient_code == "")
                    {
                        _BussinessImportExcel = new BussinessImportExcel();

                        #region Get PatientInfo

                        SoCMND = ChuanHoaChuoi(row.Cells["CMT"].Value.ToString());
                        sNgaySinh = ChuanHoaChuoi(row.Cells["NGAY_SINH"].Value.ToString());
                        sGioiTinh = ChuanHoaChuoi(row.Cells["GIOI_TINH"].Value.ToString());
                        sCoQuan = ChuanHoaChuoi(row.Cells["CO_QUAN"].Value.ToString());
                        sChucVu = ChuanHoaChuoi(row.Cells["CHUC_VU"].Value.ToString());
                        sSDT = ChuanHoaChuoi(row.Cells["SDT"].Value.ToString());
                        sMaNV = ChuanHoaChuoi(row.Cells["Ma_NV"].Value.ToString());
                        // sDiaChi = ChuanHoaChuoi(row.Cells["DIA_CHI"].Value.ToString());
                        sDiaChi = ChuanHoaChuoi(row.Cells["DIACHI"].Value.ToString());
                        if (sGioiTinh.ToLower().Equals("m")) btGioitinh = 0;
                        else if (sGioiTinh.ToLower().Equals("f")) btGioitinh = 1;
                        else if (sGioiTinh.ToLower().Equals("nam")) btGioitinh = 0;
                        else if (sGioiTinh.ToLower().Equals("nữ")) btGioitinh = 1;
                        else btGioitinh = 2;

                        if (string.IsNullOrEmpty(SoCMND)) SoCMND = dtNgayNhap.Value.ToString("yyyyMMdd") + "@" + iSTT;
                        objPatientInfo = new TPatientInfo();
                        objPatientInfo.CountryId = 1;
                        objPatientInfo.DanToc = 1;
                        objPatientInfo.IdentifyNum = SoCMND;
                        objPatientInfo.InputDate = dtNgayNhap.Value;
                        objPatientInfo.Locked = 0;
                        objPatientInfo.PatientJob = sChucVu;
                        objPatientInfo.PatientName = ChuanHoaChuoi(row.Cells["HO_TEN"].Value.ToString());
                        objPatientInfo.PatientEmail = sMaNV;
                        objPatientInfo.PatientPhone = sSDT;
                        objPatientInfo.PatientAddr = sDiaChi;
                        objPatientInfo.PatientSex = btGioitinh;
                        objPatientInfo.Offices = sCoQuan;
                        objPatientInfo.UserId = globalVariables.UserName;
                        objPatientInfo.NgayTao = sysdate;
                        int namsinh = DateTime.Now.Year;
                        DateTime ngay_sinh = DateTime.Now;
                        if (!string.IsNullOrEmpty(sNgaySinh))
                        {
                            try
                            {
                                if (sNgaySinh.TrimStart().TrimEnd() == "")
                                {
                                    namsinh = BusinessHelper.GetSysDateTime().Year;
                                    ngay_sinh = new DateTime(namsinh, 1, 1);
                                }
                                if (sNgaySinh.TrimStart().TrimEnd().Length == 4)
                                {
                                    namsinh = Utility.Int32Dbnull(sNgaySinh, BusinessHelper.GetSysDateTime().Year);
                                    ngay_sinh = new DateTime(namsinh, 1, 1);
                                }
                                else
                                {
                                    ngay_sinh = Convert.ToDateTime(sNgaySinh);
                                    namsinh = ngay_sinh.Year;
                                }
                            }
                            catch
                            {
                            }
                            objPatientInfo.PatientBirth = ngay_sinh;
                            objPatientInfo.YearOfBirth = (Int16) namsinh;
                        }
                        objPatientInfo.SoLo = Convert.ToInt32(txtLo.Text);

                        #endregion

                        #region Get PatientExam

                        objPatientExam = new TPatientExam();
                        objPatientExam.PatientCode = SoCMND;
                        objPatientExam.ObjectTypeId = 1;
                        objPatientExam.HosTrans = 0;
                        objPatientExam.InputDate = objPatientInfo.InputDate;
                        objPatientExam.UserId = objPatientInfo.UserId;
                        objPatientExam.HosStatus = 0;
                        objPatientExam.DiscountRate = 0;
                        objPatientExam.Locked = 0;
                        objPatientExam.IndentityNo = 1;
                        objPatientExam.DisplayOnReport = 0;
                        objPatientExam.NgayTao = objPatientInfo.NgayTao;
                        objPatientExam.NguoiTao = objPatientInfo.UserId;
                        objPatientExam.MaKhoaThien = "KSK";
                        objPatientExam.MaDoiTuong = "DV";
                        objPatientExam.EmergencyHos = 0;

                        #endregion

                        objAsignInfo.Barcode =
                            ChuanHoaChuoi(Utility.sDbnull(row.Cells[TAssignInfo.Columns.Barcode].Value, ""));

                        iSTT = iSTT + 1;

                        row.BeginEdit();
                        string sMaDonVi = "";
                        string errMsg = "";

                        if (
                            !_BussinessImportExcel.Save(objPatientInfo, objPatientExam, objAsignInfo, _lstAssignDetail,
                                dtNgayNhap.Value, sMaDonVi, ref errMsg))
                        {
                            row.Cells["_Error"].Value = 1;
                            _decFailed = _decFailed + 1;
                            Utility.ShowMsg(
                                "Import dữ liệu không thành công. Bạn hãy nhấn vào nút tìm kiếm theo lô và thực hiện xóa trước khi import lại.\n" +
                                errMsg);
                            return;
                        }
                        _Value = _Value + 1;
                        row.Cells["_Error"].Value = 0;
                        row.Cells["patient_code"].Value = objPatientExam.PatientCode;
                        row.Cells["patient_id"].Value = objPatientExam.PatientId;
                        row.Cells["assign_code"].Value = objAsignInfo.MaChidinh;
                        row.Cells["assign_id"].Value = objAsignInfo.AssignId;
                        row.EndEdit();
                        SetValue4Prg(progressImport, 1);
                        Application.DoEvents();
                        //if (iSTT % 10 == 0) System.Threading.Thread.Sleep(1000);
                        //Application.DoEvents();

                        #endregion
                    }
                    else
                    {
                        SetValue4Prg(progressImport, 1);
                        Application.DoEvents();
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg("Import dữ liệu không thành công" + ex.Message);
            }
        }
Exemplo n.º 11
0
        public ActionResult ThanhToanKeDonThuocTaiQuay(TPayment objPayment, TPatientExam objPatientExam, TPaymentDetail[] objArrPaymentDetail)
        {
            decimal PtramBHYT = 0;
            ///tổng tiền hiện tại truyền vào của lần payment đang thực hiện
            decimal v_TotalOrginPrice = 0;
            ///tổng tiền đã thanh toán
            decimal v_TotalPaymentDetail = 0;

            try
            {
                using (var scope = new TransactionScope())
                {
                    using (var dbscope = new SharedDbConnectionScope())
                    {
                        ///lấy tổng số Payment của mang truyền vào của pay ment hiện tại
                        //v_TotalOrginPrice = SumOfPaymentDetail_NGOAITRU(objArrPaymentDetail);


                        TPaymentCollection paymentCollection =
                            new TPaymentController().FetchByQuery(
                                TPayment.CreateQuery().AddWhere(TPayment.Columns.PatientCode, Comparison.Equals,
                                                                objPatientExam.PatientCode).AND(
                                    TPayment.Columns.PatientId, Comparison.Equals,
                                    objPatientExam.PatientId).AND(
                                    TPayment.Columns.Status, Comparison.Equals, 0).
                                AND(TPayment.Columns.KieuThanhToan, Comparison.Equals, 0).AND(
                                    TPayment.Columns.Status, Comparison.Equals, 0));


                        foreach (TPayment Payment in paymentCollection)
                        {
                            TPaymentDetailCollection paymentDetailCollection = new Select().From(TPaymentDetail.Schema)
                                                                               .Where(TPaymentDetail.Columns.IdThanhtoan).IsEqualTo(Payment.IdThanhtoan)
                                                                               .And(TPaymentDetail.Columns.IsCancel).IsEqualTo(0).ExecuteAsCollection
                                                                               <TPaymentDetailCollection>();

                            foreach (TPaymentDetail paymentDetail in paymentDetailCollection)
                            {
                                if (paymentDetail.IsPayment == 0)
                                {
                                    v_TotalPaymentDetail += Utility.Int32Dbnull(paymentDetail.Quantity) *
                                                            Utility.DecimaltoDbnull(paymentDetail.OriginPrice);
                                }
                            }
                        }
                        ///lấy thông tin chiết khấu xem đã thực hiện chưa
                        LayThongPtramBHYT(v_TotalOrginPrice + v_TotalPaymentDetail, objPatientExam, ref PtramBHYT);
                        log.Info(string.Format("Thong tin chi khau {0}, voi ma Patient_Code{1}",
                                               PtramBHYT, objPatientExam.PatientCode));

                        ///hàm thực hiện việc xử lý lại thông tin
                        // XuLyChiKhauDacBietBHYT(objPatientExam, PtramBHYT);
                        objPayment.DaIn          = 0;
                        objPayment.KieuThanhToan = 0;
                        objPayment.NguoiIn       = string.Empty;
                        objPayment.TrongGoi      = 0;
                        objPayment.IpMacTao      = BusinessHelper.GetMACAddress();
                        objPayment.IpMayTao      = BusinessHelper.GetIP4Address();
                        objPayment.PaymentCode   = BusinessHelper.GeneratePaymentCode(Convert.ToDateTime(objPayment.NgayThanhtoan), 0);
                        objPayment.IsNew         = true;
                        objPayment.Save();
                        //StoredProcedure sp = SPs.KcbThanhtoanThemmoi(objPayment.IdThanhtoan, objPayment.PatientCode, objPayment.PatientId,
                        //                  objPayment.NgayThanhtoan, objPayment.StaffId, objPayment.Status,
                        //                  objPayment.CreatedBy, objPayment.CreatedDate, objPayment.ModifyDate,
                        //                  objPayment.ModifyBy, objPayment.PaymentCode, objPayment.KieuThanhToan,
                        //                  objPayment.DaIn, objPayment.NgayIn, objPayment.NgayTHop, objPayment.NguoiIn,
                        //                  objPayment.NguoiTHop, Utility.Int32Dbnull(objPayment.TrongGoi), objPayment.IpMayTao, objPayment.IpMacTao, globalVariables.MA_KHOA_THIEN);
                        //sp.Execute();
                        //objPayment.IdThanhtoan = Utility.Int32Dbnull(sp.OutputValues[0], -1);
                        //objPayment.IdThanhtoan = Utility.Int32Dbnull(_QueryPayment.GetMax(TPayment.Columns.IdThanhtoan), -1);
                        log.Info("Lay ma thanh toan cua phan thanh toan Payment_ID={0}", objPayment.IdThanhtoan);
                        ///hàm thực hiện việc mảng thao tác mảng của chi tiết thanh toán

                        foreach (TPaymentDetail objPaymentDetail in objArrPaymentDetail)
                        {
                            log.Info("Thuc hien thanh cong cap nhap dich vu can lam sang ");
                            ///thanh toán phần thuốc);
                            if (THU_VIEN_CHUNG.LayMaDviLamViec() == "DETMAY")
                            {
                                if (objPaymentDetail.IdLoaithanhtoan == 3)
                                {
                                    new Update(TPrescription.Schema)
                                    .Set(TPrescription.Columns.TrangthaiThanhtoan).EqualTo(1)
                                    .Set(TPrescription.Columns.Status).EqualTo(2)    ///nếu =2 đối với đơn thuốc ngoại trú
                                    .Where(TPrescription.Columns.PresId).IsEqualTo(objPaymentDetail.Id).Execute();
                                }
                            }

                            log.Info("Thuc hien thanh cong cap nhap thuoc");
                            ///quần áo cho thuê);

                            log.Info("Cap nhap thong tin thanh cong cho phan giuong benh");
                            switch (BusinessHelper.GetThanhToan_TraiTuyen())
                            {
                            case "PHUTHU":
                                if (objPaymentDetail.IdLoaithanhtoan == 1)
                                {
                                    objPaymentDetail.SurchargePrice = 0;
                                }
                                break;
                            }
                            objPaymentDetail.NguoiTao    = globalVariables.UserName;
                            objPaymentDetail.NoiTru      = 0;
                            objPaymentDetail.TrongGoi    = 0;
                            objPaymentDetail.IpMacTao    = BusinessHelper.GetMACAddress();
                            objPaymentDetail.IpMayTao    = BusinessHelper.GetIP4Address();
                            objPaymentDetail.IdThanhtoan = Utility.Int32Dbnull(objPayment.IdThanhtoan, -1);
                            objPaymentDetail.MaKieuTtoan = BusinessHelper.MaKieuThanhToan(Utility.Int32Dbnull(objPaymentDetail.IdLoaithanhtoan, -1));
                            objPaymentDetail.TienBnTra   = Utility.DecimaltoDbnull(objPaymentDetail.DiscountPrice);
                            StoredProcedure spPaymentDetail = SPs.KcbThanhtoanThemchitiet(
                                objPaymentDetail.PaymentDetailId, objPaymentDetail.IdThanhtoan,
                                objPaymentDetail.Quantity, objPaymentDetail.OriginPrice,
                                objPaymentDetail.DiscountRate, Utility.DecimaltoDbnull(objPaymentDetail.DiscountPrice),
                                Utility.DecimaltoDbnull(objPaymentDetail.TienBnTra),
                                objPaymentDetail.SurchargePrice, objPaymentDetail.Id,
                                objPaymentDetail.IdDetail, objPaymentDetail.ServiceId,
                                objPaymentDetail.ServiceDetailId, objPaymentDetail.IdLoaithanhtoan,
                                objPaymentDetail.IsCancel, objPaymentDetail.IsPayment,
                                objPaymentDetail.CancelBy, objPaymentDetail.CancelDate,
                                objPaymentDetail.DepartmentId, objPaymentDetail.DoctorAssignId,
                                objPaymentDetail.ThuTuIn, objPaymentDetail.DonViTinh,
                                objPaymentDetail.MaDv, objPaymentDetail.PTramBh,
                                objPaymentDetail.ServiceDetailName, Utility.sDbnull(objPaymentDetail.ServiceDetailName),
                                objPaymentDetail.MaKieuTtoan, 0, objPaymentDetail.TrongGoi, objPaymentDetail.IdGoiDvu,
                                objPaymentDetail.NoiTru, objPaymentDetail.NguoiTao, objPaymentDetail.IpMacTao, objPaymentDetail.IpMayTao);

                            spPaymentDetail.Execute();
                            objPaymentDetail.PaymentDetailId = Utility.Int32Dbnull(spPaymentDetail.OutputValues[0], -1);
                            UpdateTrangThaiBangChucNang(objPayment, objPaymentDetail);


                            log.Info("Thuc hien dua vao chen bang ghi cua phan ky dong");
                        }

                        if (objPatientExam.MaDoiTuong == "BHYT")
                        {
                            if (globalVariables.gv_BenhVienTuyen == "TW")
                            {
                                SqlQuery sqlQuery = new Select().From(TPaymentDetail.Schema)
                                                    .Where(TPaymentDetail.Columns.IdThanhtoan).In(
                                    new Select(TPayment.Columns.IdThanhtoan).From(TPayment.Schema).Where(
                                        TPayment.Columns.PatientCode).IsEqualTo(
                                        objPatientExam.PatientCode).And(TPayment.Columns.PatientId).IsEqualTo(
                                        objPatientExam.PatientId).And(TPayment.Columns.KieuThanhToan).
                                    IsEqualTo(0).
                                    And(TPayment.Columns.Status).IsEqualTo(0))
                                                    .And(TPaymentDetail.Columns.IsCancel).IsEqualTo(0)
                                                    .And(TPaymentDetail.Columns.IsPayment).IsEqualTo(0);

                                TPaymentDetailCollection objPaymentDetailCollection =
                                    sqlQuery.ExecuteAsCollection <TPaymentDetailCollection>();
                                decimal TongTien =
                                    Utility.DecimaltoDbnull(objPaymentDetailCollection.Sum(c => c.Quantity * c.OriginPrice));
                                LayThongPtramBHYT(TongTien, objPatientExam, ref PtramBHYT);
                                foreach (TPaymentDetail objPaymentDetail in objPaymentDetailCollection)
                                {
                                    decimal BHCT = Utility.DecimaltoDbnull(objPaymentDetail.OriginPrice * PtramBHYT / 100);
                                    decimal BNCT = Utility.DecimaltoDbnull(objPaymentDetail.OriginPrice - BHCT);
                                    new Update(TPaymentDetail.Schema)
                                    .Set(TPaymentDetail.Columns.PTramBh).EqualTo(PtramBHYT)
                                    .Set(TPaymentDetail.Columns.DiscountRate).EqualTo(BHCT)
                                    .Set(TPaymentDetail.Columns.DiscountPrice).EqualTo(BNCT)
                                    .Where(TPaymentDetail.Columns.PaymentDetailId).IsEqualTo(objPaymentDetail.PaymentDetailId).Execute();
                                }
                            }
                        }
                        SPs.KydongThemthongtinThanhtoanThem(objPatientExam.PatientCode, Utility.Int32Dbnull(objPatientExam.PatientId, -1)).
                        Execute();
                    }
                    scope.Complete();
                    // Payment_Id = Utility.Int32Dbnull(objPayment.IdThanhtoan, -1);
                    log.Info("Thuc hien thanh cong viec thanh toan");
                    return(ActionResult.Success);
                }
            }
            catch (Exception ex)
            {
                log.Error("Loi thuc hien thanh toan:" + ex.ToString());
                return(ActionResult.Error);
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// hàm thục hiện tính toán thông tin
        /// </summary>
        /// <param name="v_decTotalPrice"></param>
        /// <param name="objPatientExam"></param>
        /// <param name="PtramBHYT"></param>
        /// <returns></returns>
        public decimal LayThongPtramBHYT(decimal v_decTotalPrice, TPatientExam objPatientExam, ref decimal PtramBHYT)
        {
            decimal  decDiscountTotalMoney = 0;
            SqlQuery q;

            if (!string.IsNullOrEmpty(objPatientExam.InsClinicCode) && IsBaohiem(objPatientExam))
            {
                ///thực hiện xem có đúng tuyến không

                if (objPatientExam.CorrectLine == 1)
                {
                    if (objPatientExam.InsObjectCodeNumber.ToString() == "1" || objPatientExam.InsObjectCodeNumber.ToString() == "2")
                    {
                        decDiscountTotalMoney = 0;
                        PtramBHYT             = 100;
                        log.Info("Benh nhan tuong ung voi muc =" + objPatientExam.InsObjectCodeNumber);
                    }
                    else
                    {
                        switch (globalVariables.gv_BenhVienTuyen)
                        {
                        case "TUYEN1":
                            if (v_decTotalPrice >= objPatientExam.SalaryBasic * 15 / 100)
                            {
                                log.Info(string.Format("Neu ma benh nhan lon hon muc luong co ban={0} thi bat dau tinh gia", BusinessHelper.GetLuongCoBan()));
                                q = new Select().From(LInsuranceObject.Schema)
                                    .Where(LInsuranceObject.Columns.ObjectTypeId).IsEqualTo(objPatientExam.ObjectTypeId)
                                    .And(LInsuranceObject.Columns.InsObjectCode).IsEqualTo(objPatientExam.InsObjectCode);
                                LInsuranceObject objInsuranceObject = q.ExecuteSingle <LInsuranceObject>();
                                if (objInsuranceObject != null)
                                {
                                    PtramBHYT             = Utility.DecimaltoDbnull(objInsuranceObject.Percent, 0);
                                    decDiscountTotalMoney = v_decTotalPrice * (100 - Utility.DecimaltoDbnull(objInsuranceObject.Percent, 0)) / 100;
                                    log.Info("bat dau chi khau theo doi tuong muc tien =" + decDiscountTotalMoney + " cua benh nhan co ma Patient_Code=" + objPatientExam.PatientCode);
                                }
                            }
                            else
                            {
                                PtramBHYT             = 100;
                                decDiscountTotalMoney = 0;
                                log.Info("Benh nhan dc mien phi hoan toan, voi muc chiet khau =0 tuong ung voi Patient_Code=" + objPatientExam.PatientCode);
                            }
                            break;

                        case "TW":
                            log.Info("Lấy thông tin của tuyến trung ương");
                            log.Info(string.Format("Neu ma benh nhan lon hon muc luong co ban={0} thi bat dau tinh gia", BusinessHelper.GetLuongCoBan()));
                            q = new Select().From(LInsuranceObject.Schema)
                                .Where(LInsuranceObject.Columns.ObjectTypeId).IsEqualTo(objPatientExam.ObjectTypeId)
                                .And(LInsuranceObject.Columns.InsObjectCode).IsEqualTo(objPatientExam.InsObjectCode);
                            LInsuranceObject objInsuranceObjectTW = q.ExecuteSingle <LInsuranceObject>();
                            if (objInsuranceObjectTW != null)
                            {
                                PtramBHYT             = Utility.DecimaltoDbnull(objInsuranceObjectTW.Percent, 0);
                                decDiscountTotalMoney = v_decTotalPrice * (100 - Utility.DecimaltoDbnull(objInsuranceObjectTW.Percent, 0)) / 100;
                                log.Info("bat dau chi khau theo doi tuong muc tien =" + decDiscountTotalMoney + " cua benh nhan co ma Patient_Code=" + objPatientExam.PatientCode);
                            }
                            break;

                        default:
                            if (v_decTotalPrice >= objPatientExam.SalaryBasic * 15 / 100)
                            {
                                log.Info(string.Format("Neu ma benh nhan lon hon muc luong co ban={0} thi bat dau tinh gia", BusinessHelper.GetLuongCoBan()));
                                q = new Select().From(LInsuranceObject.Schema)
                                    .Where(LInsuranceObject.Columns.ObjectTypeId).IsEqualTo(objPatientExam.ObjectTypeId)
                                    .And(LInsuranceObject.Columns.InsObjectCode).IsEqualTo(objPatientExam.InsObjectCode);
                                LInsuranceObject objInsuranceObject = q.ExecuteSingle <LInsuranceObject>();
                                if (objInsuranceObject != null)
                                {
                                    PtramBHYT             = Utility.DecimaltoDbnull(objInsuranceObject.Percent, 0);
                                    decDiscountTotalMoney = v_decTotalPrice * (100 - Utility.DecimaltoDbnull(objInsuranceObject.Percent, 0)) / 100;
                                    log.Info("bat dau chi khau theo doi tuong muc tien =" + decDiscountTotalMoney + " cua benh nhan co ma Patient_Code=" + objPatientExam.PatientCode);
                                }
                            }
                            else
                            {
                                PtramBHYT             = 100;
                                decDiscountTotalMoney = 0;
                                log.Info("Benh nhan dc mien phi hoan toan, voi muc chiet khau =0 tuong ung voi Patient_Code=" + objPatientExam.PatientCode);
                            }
                            break;
                        }
                    }
                }
                else
                {
                    ///Nếu là đối tượng trái tuyến thực hiện lấy % của trái tuyến
                    LObjectType objObjectType = LObjectType.FetchByID(objPatientExam.ObjectTypeId);
                    if (objObjectType != null)
                    {
                        decDiscountTotalMoney = v_decTotalPrice * (100 - Utility.DecimaltoDbnull(objObjectType.DiscountDiscorrectLine)) / 100;
                        PtramBHYT             = Utility.DecimaltoDbnull(objObjectType.DiscountDiscorrectLine, 0);
                    }
                }
            }
            else
            {
                LObjectType objObjectType = LObjectType.FetchByID(objPatientExam.ObjectTypeId);
                if (objObjectType != null)
                {
                    decDiscountTotalMoney = v_decTotalPrice * (100 - Utility.Int32Dbnull(objObjectType.DiscountCorrectLine, 0)) / 100;
                }
                ;
                PtramBHYT = Utility.DecimaltoDbnull(objObjectType.DiscountCorrectLine, 0);
            }
            return(decDiscountTotalMoney);
        }
Exemplo n.º 13
0
        void GetData()
        {
            try
            {
                patientExam =
                    new Select().From(TPatientExam.Schema).Where(TPatientExam.Columns.PatientCode).IsEqualTo(
                        txtPatientCode.Text).ExecuteSingle <TPatientExam>();
                if (patientExam != null)
                {
                    TPatientInfo patientInfo = TPatientInfo.FetchByID(patientExam.PatientId);

                    txtMaBenhNhan.Text     = Utility.sDbnull(patientInfo.PatientId, "");
                    txtMaLanKham.Text      = Utility.sDbnull(patientExam.PatientCode, "");
                    txtTenBenhNhan.Text    = Utility.sDbnull(patientInfo.PatientName, "");
                    txtDiaChiBenhNhan.Text = Utility.sDbnull(patientInfo.DiaChiBn, "");
                    txtTuoiBN.Text         = Utility.sDbnull(Utility.Int32Dbnull(BusinessHelper.GetSysDateTime().Year) - Utility.Int32Dbnull(patientInfo.YearOfBirth), -1);
                    txtDoiTuong.Text       = BusinessHelper.GetObjectTypeName(Utility.Int32Dbnull(patientExam.ObjectTypeId));
                    cmdMoKhoa.Enabled      = Utility.Int32Dbnull(patientExam.Locked) > 0;

                    switch (Utility.Int32Dbnull(patientExam.HosStatus, -1))
                    {
                    case 0:
                        txtTrangThaiBN.Text = "Ngoại trú";
                        break;

                    case 1:
                        txtTrangThaiBN.Text = "Nội trú";
                        break;

                    case 2:
                        txtTrangThaiBN.Text = "Đang chờ ra viện";

                        break;

                    case 3:
                        txtTrangThaiBN.Text = "Đã ra viện";
                        cmdMoKhoa.Enabled   = true;

                        break;
                    }
                    switch (Utility.Int32Dbnull(patientExam.Locked, 0))
                    {
                    case 0:
                        txtTrangthai.Text = "Chưa khóa";
                        break;

                    case 1:
                        txtTrangthai.Text = "Đã khóa";
                        break;
                    }
                    if (Utility.sDbnull(patientExam.MaDoiTuong, "") == "BHYT")
                    {
                        txtSoBHYT.Text     = Utility.sDbnull(patientExam.InsuranceNum, "");
                        txtDiaChiBHYT.Text = Utility.sDbnull(patientInfo.PatientAddr, "");
                    }
                    else
                    {
                        txtSoBHYT.Text     = "";
                        txtDiaChiBHYT.Text = "";
                    }
                    txtNgayVaoKham.Text = patientExam.InputDate.ToString("dd/MM/yyyy");
                }
                else
                {
                    CleanData();
                    Utility.SetMessageError(errorProvider1, txtPatientCode, "Không tồn tại bệnh nhân có mã lần khám đã nhập");
                }
            }
            catch (Exception)
            {
                Utility.ShowMsg("Có lỗi trong quá trình lấy thông tin bệnh nhân");
                throw;
            }
        }
Exemplo n.º 14
0
        void GetData()
        {
            try
            {
                 patientExam =
                    new Select().From(TPatientExam.Schema).Where(TPatientExam.Columns.PatientCode).IsEqualTo(
                        txtPatientCode.Text).ExecuteSingle<TPatientExam>();
                if(patientExam != null)
                {
                    TPatientInfo patientInfo = TPatientInfo.FetchByID(patientExam.PatientId);

                    txtMaBenhNhan.Text = Utility.sDbnull(patientInfo.PatientId, "");
                    txtMaLanKham.Text = Utility.sDbnull(patientExam.PatientCode, "");
                    txtTenBenhNhan.Text = Utility.sDbnull(patientInfo.PatientName, "");
                    txtDiaChiBenhNhan.Text = Utility.sDbnull(patientInfo.DiaChiBn,"");
                    txtTuoiBN.Text = Utility.sDbnull(Utility.Int32Dbnull(BusinessHelper.GetSysDateTime().Year) - Utility.Int32Dbnull(patientInfo.YearOfBirth), -1);
                    txtDoiTuong.Text = BusinessHelper.GetObjectTypeName(Utility.Int32Dbnull(patientExam.ObjectTypeId));
                    cmdMoKhoa.Enabled = Utility.Int32Dbnull(patientExam.Locked) > 0;

                    switch (Utility.Int32Dbnull(patientExam.HosStatus, -1))
                    {
                        case 0:
                            txtTrangThaiBN.Text = "Ngoại trú";
                            break;
                        case 1:
                            txtTrangThaiBN.Text = "Nội trú";
                            break;
                        case 2:
                            txtTrangThaiBN.Text = "Đang chờ ra viện";

                            break;
                        case 3:
                            txtTrangThaiBN.Text = "Đã ra viện";
                            cmdMoKhoa.Enabled = true;

                            break;
                    }
                    switch (Utility.Int32Dbnull(patientExam.Locked,0))
                    {
                        case 0:
                            txtTrangthai.Text = "Chưa khóa";
                            break;
                        case 1:
                            txtTrangthai.Text = "Đã khóa";
                            break;
                    }
                    if(Utility.sDbnull(patientExam.MaDoiTuong, "") == "BHYT")
                    {
                        txtSoBHYT.Text = Utility.sDbnull(patientExam.InsuranceNum, "");
                        txtDiaChiBHYT.Text = Utility.sDbnull(patientInfo.PatientAddr,"");
                    }
                    else
                    {
                        txtSoBHYT.Text = "";
                        txtDiaChiBHYT.Text = "";
                    }
                    txtNgayVaoKham.Text = patientExam.InputDate.ToString("dd/MM/yyyy");
                }
                else
                {
                    CleanData();
                    Utility.SetMessageError(errorProvider1, txtPatientCode,"Không tồn tại bệnh nhân có mã lần khám đã nhập");
                }
            }
            catch (Exception)
            {
                Utility.ShowMsg("Có lỗi trong quá trình lấy thông tin bệnh nhân");
                throw;
            }
        }
Exemplo n.º 15
0
        public ActionResult ThanhToanKeDonThuocTaiQuay(TPayment objPayment, TPatientExam objPatientExam, TPaymentDetail[] objArrPaymentDetail)
        {
            decimal PtramBHYT = 0;
            ///tổng tiền hiện tại truyền vào của lần payment đang thực hiện
            decimal v_TotalOrginPrice = 0;
            ///tổng tiền đã thanh toán
            decimal v_TotalPaymentDetail = 0;
            try
            {
                using (var scope = new TransactionScope())
                {
                    using (var dbscope = new SharedDbConnectionScope())
                    {
                        ///lấy tổng số Payment của mang truyền vào của pay ment hiện tại
                        //v_TotalOrginPrice = SumOfPaymentDetail_NGOAITRU(objArrPaymentDetail);

                        TPaymentCollection paymentCollection =
                            new TPaymentController().FetchByQuery(
                                TPayment.CreateQuery().AddWhere(TPayment.Columns.PatientCode, Comparison.Equals,
                                                                objPatientExam.PatientCode).AND(
                                                                    TPayment.Columns.PatientId, Comparison.Equals,
                                                                    objPatientExam.PatientId).AND(
                                                                        TPayment.Columns.Status, Comparison.Equals, 0).
                                    AND(TPayment.Columns.KieuThanhToan, Comparison.Equals, 0).AND(
                                        TPayment.Columns.Status, Comparison.Equals, 0));

                        foreach (TPayment Payment in paymentCollection)
                        {
                            TPaymentDetailCollection paymentDetailCollection = new Select().From(TPaymentDetail.Schema)
                                .Where(TPaymentDetail.Columns.IdThanhtoan).IsEqualTo(Payment.IdThanhtoan)
                                .And(TPaymentDetail.Columns.IsCancel).IsEqualTo(0).ExecuteAsCollection
                                <TPaymentDetailCollection>();

                            foreach (TPaymentDetail paymentDetail in paymentDetailCollection)
                            {
                                if (paymentDetail.IsPayment == 0)
                                    v_TotalPaymentDetail += Utility.Int32Dbnull(paymentDetail.Quantity) *
                                                            Utility.DecimaltoDbnull(paymentDetail.OriginPrice);

                            }

                        }
                        ///lấy thông tin chiết khấu xem đã thực hiện chưa
                        LayThongPtramBHYT(v_TotalOrginPrice + v_TotalPaymentDetail, objPatientExam, ref PtramBHYT);
                        log.Info(string.Format("Thong tin chi khau {0}, voi ma Patient_Code{1}",
                                               PtramBHYT, objPatientExam.PatientCode));

                        ///hàm thực hiện việc xử lý lại thông tin
                       // XuLyChiKhauDacBietBHYT(objPatientExam, PtramBHYT);
                        objPayment.DaIn = 0;
                        objPayment.KieuThanhToan = 0;
                        objPayment.NguoiIn = string.Empty;
                        objPayment.TrongGoi = 0;
                        objPayment.IpMacTao = BusinessHelper.GetMACAddress();
                        objPayment.IpMayTao = BusinessHelper.GetIP4Address();
                        objPayment.PaymentCode = BusinessHelper.GeneratePaymentCode(Convert.ToDateTime(objPayment.NgayThanhtoan), 0);
                        objPayment.IsNew = true;
                        objPayment.Save();
                        //StoredProcedure sp = SPs.KcbThanhtoanThemmoi(objPayment.IdThanhtoan, objPayment.PatientCode, objPayment.PatientId,
                        //                  objPayment.NgayThanhtoan, objPayment.StaffId, objPayment.Status,
                        //                  objPayment.CreatedBy, objPayment.CreatedDate, objPayment.ModifyDate,
                        //                  objPayment.ModifyBy, objPayment.PaymentCode, objPayment.KieuThanhToan,
                        //                  objPayment.DaIn, objPayment.NgayIn, objPayment.NgayTHop, objPayment.NguoiIn,
                        //                  objPayment.NguoiTHop, Utility.Int32Dbnull(objPayment.TrongGoi), objPayment.IpMayTao, objPayment.IpMacTao, globalVariables.MA_KHOA_THIEN);
                        //sp.Execute();
                        //objPayment.IdThanhtoan = Utility.Int32Dbnull(sp.OutputValues[0], -1);
                        //objPayment.IdThanhtoan = Utility.Int32Dbnull(_QueryPayment.GetMax(TPayment.Columns.IdThanhtoan), -1);
                        log.Info("Lay ma thanh toan cua phan thanh toan Payment_ID={0}", objPayment.IdThanhtoan);
                        ///hàm thực hiện việc mảng thao tác mảng của chi tiết thanh toán

                        foreach (TPaymentDetail objPaymentDetail in objArrPaymentDetail)
                        {

                            log.Info("Thuc hien thanh cong cap nhap dich vu can lam sang ");
                            ///thanh toán phần thuốc);
                            if (THU_VIEN_CHUNG.LayMaDviLamViec() == "DETMAY")
                            {
                                if (objPaymentDetail.IdLoaithanhtoan == 3)
                                {
                                    new Update(TPrescription.Schema)
                                        .Set(TPrescription.Columns.TrangthaiThanhtoan).EqualTo(1)
                                        .Set(TPrescription.Columns.Status).EqualTo(2)///nếu =2 đối với đơn thuốc ngoại trú
                                        .Where(TPrescription.Columns.PresId).IsEqualTo(objPaymentDetail.Id).Execute();

                                }
                            }

                            log.Info("Thuc hien thanh cong cap nhap thuoc");
                            ///quần áo cho thuê);

                            log.Info("Cap nhap thong tin thanh cong cho phan giuong benh");
                            switch (BusinessHelper.GetThanhToan_TraiTuyen())
                            {
                                case "PHUTHU":
                                    if (objPaymentDetail.IdLoaithanhtoan == 1)
                                    {
                                        objPaymentDetail.SurchargePrice = 0;
                                    }
                                    break;

                            }
                            objPaymentDetail.NguoiTao = globalVariables.UserName;
                            objPaymentDetail.NoiTru = 0;
                            objPaymentDetail.TrongGoi = 0;
                            objPaymentDetail.IpMacTao = BusinessHelper.GetMACAddress();
                            objPaymentDetail.IpMayTao = BusinessHelper.GetIP4Address();
                            objPaymentDetail.IdThanhtoan = Utility.Int32Dbnull(objPayment.IdThanhtoan, -1);
                            objPaymentDetail.MaKieuTtoan = BusinessHelper.MaKieuThanhToan(Utility.Int32Dbnull(objPaymentDetail.IdLoaithanhtoan, -1));
                            objPaymentDetail.TienBnTra = Utility.DecimaltoDbnull(objPaymentDetail.DiscountPrice);
                            StoredProcedure spPaymentDetail = SPs.KcbThanhtoanThemchitiet(
                                objPaymentDetail.PaymentDetailId, objPaymentDetail.IdThanhtoan,
                                objPaymentDetail.Quantity, objPaymentDetail.OriginPrice,
                                objPaymentDetail.DiscountRate, Utility.DecimaltoDbnull(objPaymentDetail.DiscountPrice),
                                Utility.DecimaltoDbnull(objPaymentDetail.TienBnTra),
                                objPaymentDetail.SurchargePrice, objPaymentDetail.Id,
                                objPaymentDetail.IdDetail, objPaymentDetail.ServiceId,
                                objPaymentDetail.ServiceDetailId, objPaymentDetail.IdLoaithanhtoan,
                                objPaymentDetail.IsCancel, objPaymentDetail.IsPayment,
                                objPaymentDetail.CancelBy, objPaymentDetail.CancelDate,
                                objPaymentDetail.DepartmentId, objPaymentDetail.DoctorAssignId,
                                objPaymentDetail.ThuTuIn, objPaymentDetail.DonViTinh,
                                objPaymentDetail.MaDv, objPaymentDetail.PTramBh,
                                objPaymentDetail.ServiceDetailName, Utility.sDbnull(objPaymentDetail.ServiceDetailName),
                                objPaymentDetail.MaKieuTtoan, 0, objPaymentDetail.TrongGoi, objPaymentDetail.IdGoiDvu,
                                objPaymentDetail.NoiTru, objPaymentDetail.NguoiTao, objPaymentDetail.IpMacTao, objPaymentDetail.IpMayTao);

                            spPaymentDetail.Execute();
                            objPaymentDetail.PaymentDetailId = Utility.Int32Dbnull(spPaymentDetail.OutputValues[0], -1);
                            UpdateTrangThaiBangChucNang(objPayment, objPaymentDetail);

                            log.Info("Thuc hien dua vao chen bang ghi cua phan ky dong");
                        }

                        if (objPatientExam.MaDoiTuong == "BHYT")
                        {
                            if (globalVariables.gv_BenhVienTuyen == "TW")
                            {
                                SqlQuery sqlQuery = new Select().From(TPaymentDetail.Schema)
                                    .Where(TPaymentDetail.Columns.IdThanhtoan).In(
                                        new Select(TPayment.Columns.IdThanhtoan).From(TPayment.Schema).Where(
                                            TPayment.Columns.PatientCode).IsEqualTo(
                                                objPatientExam.PatientCode).And(TPayment.Columns.PatientId).IsEqualTo(
                                                    objPatientExam.PatientId).And(TPayment.Columns.KieuThanhToan).
                                            IsEqualTo(0).
                                            And(TPayment.Columns.Status).IsEqualTo(0))
                                    .And(TPaymentDetail.Columns.IsCancel).IsEqualTo(0)
                                    .And(TPaymentDetail.Columns.IsPayment).IsEqualTo(0);

                                TPaymentDetailCollection objPaymentDetailCollection =
                                    sqlQuery.ExecuteAsCollection<TPaymentDetailCollection>();
                                decimal TongTien =
                                    Utility.DecimaltoDbnull(objPaymentDetailCollection.Sum(c => c.Quantity * c.OriginPrice));
                                LayThongPtramBHYT(TongTien, objPatientExam, ref PtramBHYT);
                                foreach (TPaymentDetail objPaymentDetail in objPaymentDetailCollection)
                                {
                                    decimal BHCT = Utility.DecimaltoDbnull(objPaymentDetail.OriginPrice * PtramBHYT / 100);
                                    decimal BNCT = Utility.DecimaltoDbnull(objPaymentDetail.OriginPrice - BHCT);
                                    new Update(TPaymentDetail.Schema)
                                        .Set(TPaymentDetail.Columns.PTramBh).EqualTo(PtramBHYT)
                                        .Set(TPaymentDetail.Columns.DiscountRate).EqualTo(BHCT)
                                        .Set(TPaymentDetail.Columns.DiscountPrice).EqualTo(BNCT)
                                        .Where(TPaymentDetail.Columns.PaymentDetailId).IsEqualTo(objPaymentDetail.PaymentDetailId).Execute();

                                }
                            }

                        }
                        SPs.KydongThemthongtinThanhtoanThem(objPatientExam.PatientCode, Utility.Int32Dbnull(objPatientExam.PatientId, -1)).
                           Execute();

                    }
                    scope.Complete();
                   // Payment_Id = Utility.Int32Dbnull(objPayment.IdThanhtoan, -1);
                    log.Info("Thuc hien thanh cong viec thanh toan");
                    return ActionResult.Success;
                }
            }
            catch (Exception ex)
            {
                log.Error("Loi thuc hien thanh toan:" + ex.ToString());
                return ActionResult.Error;
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// hàm thục hiện tính toán thông tin 
        /// </summary>
        /// <param name="v_decTotalPrice"></param>
        /// <param name="objPatientExam"></param>
        /// <param name="PtramBHYT"></param>
        /// <returns></returns>
        public decimal LayThongPtramBHYT(decimal v_decTotalPrice, TPatientExam objPatientExam, ref  decimal PtramBHYT)
        {
            decimal decDiscountTotalMoney = 0;
            SqlQuery q;
            if (!string.IsNullOrEmpty(objPatientExam.InsClinicCode) && IsBaohiem(objPatientExam))
            {
                ///thực hiện xem có đúng tuyến không

                if (objPatientExam.CorrectLine == 1)
                {
                    if (objPatientExam.InsObjectCodeNumber.ToString() == "1" || objPatientExam.InsObjectCodeNumber.ToString() == "2")
                    {
                        decDiscountTotalMoney = 0;
                        PtramBHYT = 100;
                        log.Info("Benh nhan tuong ung voi muc =" + objPatientExam.InsObjectCodeNumber);
                    }
                    else
                    {
                        switch (globalVariables.gv_BenhVienTuyen)
                        {
                            case "TUYEN1":
                                if (v_decTotalPrice >= objPatientExam.SalaryBasic * 15 / 100)
                                {
                                    log.Info(string.Format("Neu ma benh nhan lon hon muc luong co ban={0} thi bat dau tinh gia", BusinessHelper.GetLuongCoBan()));
                                    q = new Select().From(LInsuranceObject.Schema)
                                       .Where(LInsuranceObject.Columns.ObjectTypeId).IsEqualTo(objPatientExam.ObjectTypeId)
                                       .And(LInsuranceObject.Columns.InsObjectCode).IsEqualTo(objPatientExam.InsObjectCode);
                                    LInsuranceObject objInsuranceObject = q.ExecuteSingle<LInsuranceObject>();
                                    if (objInsuranceObject != null)
                                    {
                                        PtramBHYT = Utility.DecimaltoDbnull(objInsuranceObject.Percent, 0);
                                        decDiscountTotalMoney = v_decTotalPrice * (100 - Utility.DecimaltoDbnull(objInsuranceObject.Percent, 0)) / 100;
                                        log.Info("bat dau chi khau theo doi tuong muc tien =" + decDiscountTotalMoney + " cua benh nhan co ma Patient_Code=" + objPatientExam.PatientCode);
                                    }

                                }
                                else
                                {

                                    PtramBHYT = 100;
                                    decDiscountTotalMoney = 0;
                                    log.Info("Benh nhan dc mien phi hoan toan, voi muc chiet khau =0 tuong ung voi Patient_Code=" + objPatientExam.PatientCode);
                                }
                                break;
                            case "TW":
                                log.Info("Lấy thông tin của tuyến trung ương");
                                log.Info(string.Format("Neu ma benh nhan lon hon muc luong co ban={0} thi bat dau tinh gia", BusinessHelper.GetLuongCoBan()));
                                q = new Select().From(LInsuranceObject.Schema)
                                   .Where(LInsuranceObject.Columns.ObjectTypeId).IsEqualTo(objPatientExam.ObjectTypeId)
                                   .And(LInsuranceObject.Columns.InsObjectCode).IsEqualTo(objPatientExam.InsObjectCode);
                                LInsuranceObject objInsuranceObjectTW = q.ExecuteSingle<LInsuranceObject>();
                                if (objInsuranceObjectTW != null)
                                {
                                    PtramBHYT = Utility.DecimaltoDbnull(objInsuranceObjectTW.Percent, 0);
                                    decDiscountTotalMoney = v_decTotalPrice * (100 - Utility.DecimaltoDbnull(objInsuranceObjectTW.Percent, 0)) / 100;
                                    log.Info("bat dau chi khau theo doi tuong muc tien =" + decDiscountTotalMoney + " cua benh nhan co ma Patient_Code=" + objPatientExam.PatientCode);
                                }
                                break;
                            default:
                                if (v_decTotalPrice >= objPatientExam.SalaryBasic * 15 / 100)
                                {
                                    log.Info(string.Format("Neu ma benh nhan lon hon muc luong co ban={0} thi bat dau tinh gia", BusinessHelper.GetLuongCoBan()));
                                    q = new Select().From(LInsuranceObject.Schema)
                                       .Where(LInsuranceObject.Columns.ObjectTypeId).IsEqualTo(objPatientExam.ObjectTypeId)
                                       .And(LInsuranceObject.Columns.InsObjectCode).IsEqualTo(objPatientExam.InsObjectCode);
                                    LInsuranceObject objInsuranceObject = q.ExecuteSingle<LInsuranceObject>();
                                    if (objInsuranceObject != null)
                                    {
                                        PtramBHYT = Utility.DecimaltoDbnull(objInsuranceObject.Percent, 0);
                                        decDiscountTotalMoney = v_decTotalPrice * (100 - Utility.DecimaltoDbnull(objInsuranceObject.Percent, 0)) / 100;
                                        log.Info("bat dau chi khau theo doi tuong muc tien =" + decDiscountTotalMoney + " cua benh nhan co ma Patient_Code=" + objPatientExam.PatientCode);
                                    }

                                }
                                else
                                {

                                    PtramBHYT = 100;
                                    decDiscountTotalMoney = 0;
                                    log.Info("Benh nhan dc mien phi hoan toan, voi muc chiet khau =0 tuong ung voi Patient_Code=" + objPatientExam.PatientCode);
                                }
                                break;

                        }

                    }

                }
                else
                {
                    ///Nếu là đối tượng trái tuyến thực hiện lấy % của trái tuyến
                    LObjectType objObjectType = LObjectType.FetchByID(objPatientExam.ObjectTypeId);
                    if (objObjectType != null)
                    {
                        decDiscountTotalMoney = v_decTotalPrice * (100 - Utility.DecimaltoDbnull(objObjectType.DiscountDiscorrectLine)) / 100;
                        PtramBHYT = Utility.DecimaltoDbnull(objObjectType.DiscountDiscorrectLine, 0);

                    }

                }

            }
            else
            {

                LObjectType objObjectType = LObjectType.FetchByID(objPatientExam.ObjectTypeId);
                if (objObjectType != null)
                    decDiscountTotalMoney = v_decTotalPrice * (100 - Utility.Int32Dbnull(objObjectType.DiscountCorrectLine, 0)) / 100; ;
                PtramBHYT = Utility.DecimaltoDbnull(objObjectType.DiscountCorrectLine, 0);

            }
            return decDiscountTotalMoney;
        }
Exemplo n.º 17
0
        private void grdListPatientExam_SelectionChanged(object sender, EventArgs e)
        {
            try
            {
                if(grdListPatientExam.CurrentRow != null)
                {
                    string PatientCode = Utility.sDbnull(grdListPatientExam.GetValue(TPatientExam.Columns.PatientCode), "");
                    ObjPatientExam = new Select().From(TPatientExam.Schema).Where(TPatientExam.Columns.PatientCode).IsEqualTo(PatientCode)
                        .And(TPatientExam.Columns.PatientId).IsEqualTo(PatientId).ExecuteSingle<TPatientExam>();
                    if (ObjPatientExam != null)
                    {

                         txtPatient_Code.Text = Utility.sDbnull(ObjPatientExam.PatientCode, "");
                         barcode.Data = Utility.sDbnull(ObjPatientExam.PatientCode,"");

                        txtObjectType_Name.Text = BusinessHelper.GetObjectTypeName(ObjPatientExam.ObjectTypeId);
                        txtObjectType_Code.Text = Utility.sDbnull(ObjPatientExam.MaDoiTuong, "");
                        txtSoBHYT.Text = Utility.sDbnull(ObjPatientExam.InsuranceNum, "");
                        txtBHTT.Text = Utility.sDbnull(ObjPatientExam.DiscountRate, "0");
                        txtHanTheBHYT.Text = Utility.sDbnull(ObjPatientExam.InsuranceFromDate, "");
                        Load_Trieuchung_LanKham(ObjPatientExam.PatientCode, PatientId);
                        DataTable dt_TRegExam = new Select().From(TRegExam.Schema)
                            .Where(TRegExam.Columns.PatientCode).IsEqualTo(ObjPatientExam.PatientCode)
                            .And(TRegExam.Columns.PatientId).IsEqualTo(ObjPatientExam.PatientId).ExecuteDataSet().Tables[0];
                        if(dt_TRegExam.Rows.Count > 0)
                        {
                            cboRegExam.DataSource = dt_TRegExam;
                            cboRegExam.ValueMember = TRegExam.Columns.RegId;
                            cboRegExam.DisplayMember = TRegExam.Columns.KieuKhambenh;
                            cboRegExam.SelectedIndex = 0;
                            if(dt_TRegExam.Rows.Count > 1)
                            {
                                cboRegExam.Enabled = true;
                            }else
                            {
                                cboRegExam.Enabled = false;
                            }
                        }
                    }
                    else
                    {
                        ClearControl();
                    }
                }
            }
            catch (Exception)
            {
                Utility.ShowMsg("Có lỗi trong quá trình lấy thông tin lấy khám");
            }
        }
Exemplo n.º 18
0
        public bool Save(TPatientInfo objPatientInfo, TPatientExam objPatientExam, TAssignInfo objAssignInfo, List<TAssignDetail> lstAssignDetail, DateTime dtNgayNhap, string MaDonVi,ref string errMsg)
        {
            Logger log = LogManager.GetCurrentClassLogger();    
            string PatientID = "";
            string PatientCode = "";
            string _AssignCode = "";
            SqlQuery query = null;
            try
            {
                using (TransactionScope trans = new TransactionScope())
                {
                    using (SharedDbConnectionScope shs = new SubSonic.SharedDbConnectionScope())
                    {
                        TAssignInfoCollection _lstAssign=new Select().From(TAssignInfo.Schema)
                            .Where(TAssignInfo.Columns.Barcode).IsEqualTo(objAssignInfo.Barcode)
                            .And(TAssignInfo.Columns.RegDate).IsEqualTo(objAssignInfo.RegDate.Date)
                            .ExecuteAsCollection<TAssignInfoCollection>();
                        if (_lstAssign.Count > 0)
                        {
                            Utility.ShowMsg("Barcode " + objAssignInfo.Barcode + " đã được một bệnh nhân khác sử dụng trong ngày " + objAssignInfo.RegDate.Date.ToString("dd/MM/yyyy") + "\nĐề nghị bạn kiểm tra lại");
                            return false;
                        }
                        //PatientID = this.GetPatientID(dtNgayNhap.ToString("yyyyMMdd"), MaDonVi);
                        //PatientCode = this.GetPatientCode();
                        //Barcode = this.GetBarcode();
                        PatientCode = BusinessHelper.GeneratePatientCode();
                        _AssignCode = BusinessHelper.NOITIET_KetNoi_SinhMaBarCode_CD(objPatientExam.MaKhoaThien);
                        #region Save PatientInfo
                        //query = new Select().From(KskTPatientInfo.Schema).Where(KskTPatientInfo.Columns.PatientId).IsEqualTo(PatientID);
                        //if (query.GetRecordCount() > 0)
                        //{
                        //    PatientID = this.GetPatientID(dtNgayNhap.ToString("yyyyMMdd"), MaDonVi);
                        //}
                        //objPatientInfo.PatientId = PatientID;
                        if (objPatientInfo.IdentifyNum.Contains("@")) objPatientInfo.IdentifyNum = "";
                        objPatientInfo.IsNew = true;                        
                        objPatientInfo.Save();
                        #endregion

                        #region Save PatientExam
                        objPatientExam.IsNew = true;
                        objPatientExam.PatientId = objPatientInfo.PatientId;
                        objPatientExam.PatientCode = PatientCode;
                        objPatientExam.Save();
                        query = new Select().From(TPatientExam.Schema)
                                    .Where(TPatientExam.Columns.PatientCode).IsEqualTo(PatientCode)
                                    .And(TPatientExam.Columns.PatientId).IsNotEqualTo(objPatientInfo.PatientId);
                        if (query.GetRecordCount() > 0)
                        {
                            //PatientCode = this.GetPatientCode();
                            PatientCode = BusinessHelper.GeneratePatientCode();
                            new Update(TPatientExam.Schema)
                                .Set(TPatientExam.Columns.PatientCode).EqualTo(PatientCode)
                                .Where(TPatientExam.Columns.PatientId).IsEqualTo(objPatientInfo.PatientId)
                                .And(TPatientExam.Columns.PatientCode).IsEqualTo(objPatientExam.PatientCode)
                                .Execute();
                        }
                        #endregion

                        #region Save AssignInfo
                        objAssignInfo.IsNew = true;
                        objAssignInfo.PatientCode = PatientCode;
                        objAssignInfo.PatientId = objPatientInfo.PatientId;
                        objAssignInfo.AssignCode = _AssignCode;
                        objAssignInfo.MaChidinh = _AssignCode;
                        objAssignInfo.Save();
                        query = new Select().From(TAssignInfo.Schema).Where(TAssignInfo.Columns.AssignCode).IsEqualTo(_AssignCode).And(TAssignInfo.Columns.PatientId).IsNotEqualTo(objPatientInfo.PatientId).And(TAssignInfo.Columns.PatientCode).IsNotEqualTo(PatientCode);
                        if (query.GetRecordCount() > 0)
                        {
                            //Barcode = this.GetBarcode();
                            _AssignCode = BusinessHelper.NOITIET_KetNoi_SinhMaBarCode_CD(objPatientExam.MaKhoaThien);
                            new Update(TAssignInfo.Schema)
                                .Set(TAssignInfo.Columns.AssignCode).EqualTo(_AssignCode)
                                .Set(TAssignInfo.Columns.MaChidinh).EqualTo(_AssignCode)
                                .Where(TAssignInfo.Columns.PatientCode).IsEqualTo(PatientCode)
                                .And(TAssignInfo.Columns.PatientId).IsNotEqualTo(objPatientInfo.PatientId)
                                .Execute();
                        }
                        #endregion

                        #region Save AssignDetail
                        for (int i = 0; i < lstAssignDetail.Count; i++)
                        {
                           
                            lstAssignDetail[i].IsNew = true;
                            lstAssignDetail[i].DaGuiCls=1;
                            lstAssignDetail[i].ModifyDate = BusinessHelper.GetSysDateTime();
                            lstAssignDetail[i].ModifyBy = globalVariables.UserName;
                            lstAssignDetail[i].NguoiGuiCls = globalVariables.UserName;
                            lstAssignDetail[i].NgayGuiCls = BusinessHelper.GetSysDateTime();
                            lstAssignDetail[i].AssignId = objAssignInfo.AssignId;
                            lstAssignDetail[i].Save();
                        }
                        #endregion
                    }
                    trans.Complete();
                }
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
                log.Error(ex.Message);                    
                return false;
            }
            return true;
        }