Пример #1
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);
            }
        }
Пример #2
0
        private void GetData()
        {
            string ReasonBy = "";

            string sAccountName = THU_VIEN_CHUNG.LayMaDviLamViec();

            LayThongTinPaymentDetail(sAccountName);
            //grdPaymentDetail.DataSource = m_dtPaymentDetail;


            SqlQuery sqlQuery = new Select().From(TPhieuthu.Schema)
                                .Where(TPhieuthu.Columns.PaymentId).IsEqualTo(Utility.Int32Dbnull(txtPayment_ID.Text)).And(
                TPhieuthu.Columns.LoaiPhieu).IsEqualTo(status);

            if (sqlQuery.GetRecordCount() <= 0)
            {
                TPayment objPayment = TPayment.FetchByID(Utility.Int32Dbnull(txtPayment_ID.Text, -1));
                if (objPayment != null)
                {
                    dtCreateDate.Value = Convert.ToDateTime(objPayment.PaymentDate);
                    txtPayment_ID.Text = Utility.sDbnull(objPayment.PaymentId, "-1");
                    txtMA_PTHU.Text    = BusinessHelper.GetMaPhieuThu(dtCreateDate.Value, 0);
                    Janus.Windows.GridEX.GridEXColumn gridExColumn = grdPaymentDetail.RootTable.Columns["TONG"];
                    txtSO_TIEN.Text        = Utility.sDbnull(grdPaymentDetail.GetTotal(gridExColumn, Janus.Windows.GridEX.AggregateFunction.Sum));
                    txtSLUONG_CTU_GOC.Text = "1";
                    TPatientInfo objPatientInfo = TPatientInfo.FetchByID(objPayment.PatientId);
                    if (objPatientInfo != null)
                    {
                        txtNGUOI_NOP.Text = objPatientInfo.PatientName;
                        label9.Text       = "Người nhận";
                    }
                    if (status == 0)
                    {
                        switch (sAccountName)
                        {
                        case "YHOCHAIQUAN":
                            ReasonBy        = BusinessHelper.GetLyDo_PhieuThu(m_dtPaymentDetail);
                            txtLDO_NOP.Text = ReasonBy;
                            break;

                        case "KYDONG":
                            ReasonBy        = BusinessHelper.GetLyDo_PhieuThu(m_dtPaymentDetail);
                            txtLDO_NOP.Text = ReasonBy;
                            break;

                        case "DETMAY":
                            LObjectType objectType = LObjectType.FetchByID(v_ObjectType_Id);
                            if (objectType.ObjectTypeType == 0)
                            {
                                txtLDO_NOP.Text = string.Format("Bệnh nhân cùng chi trả :{0} %", (100 - v_DiscountRate));
                            }
                            else
                            {
                                ReasonBy        = BusinessHelper.GetLyDo_PhieuThu(m_dtPaymentDetail);
                                txtLDO_NOP.Text = ReasonBy;
                            }

                            break;

                        default:
                            ReasonBy        = BusinessHelper.GetLyDo_PhieuThu(m_dtPaymentDetail);
                            txtLDO_NOP.Text = ReasonBy;
                            break;
                        }
                    }
                    if (status == 1)
                    {
                        ReasonBy        = "Trả lại tiền cho bệnh nhân";
                        txtLDO_NOP.Text = ReasonBy;
                    }
                }
            }
            else
            {
                var objPhieuthu = sqlQuery.ExecuteSingle <TPhieuthu>();
                if (objPhieuthu != null)
                {
                    txtSLUONG_CTU_GOC.Text = Utility.sDbnull(objPhieuthu.SluongCtuGoc, 1);
                    txtMA_PTHU.Text        = Utility.sDbnull(objPhieuthu.MaPthu, "");
                    txtNGUOI_NOP.Text      = Utility.sDbnull(objPhieuthu.NguoiNop);
                    txtSO_TIEN.Text        = Utility.sDbnull(objPhieuthu.SoTien);
                    txtTKHOAN_CO.Text      = Utility.sDbnull(objPhieuthu.TkhoanCo, "");
                    txtTKHOAN_NO.Text      = Utility.sDbnull(objPhieuthu.TkhoanNo, "");
                    txtLDO_NOP.Text        = objPhieuthu.LdoNop;
                    dtCreateDate.Value     = Convert.ToDateTime(objPhieuthu.NgayThien);
                }
            }
        }
Пример #3
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;
        }
Пример #4
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;
            }
        }