void cmdConfig_Click(object sender, EventArgs e)
        {
            try
            {
                if (!Utility.isValidGrid(grdServiceDetail))
                {
                    Utility.ShowMsg("Bạn cần chọn một dịch vụ liên quan đến hình ảnh(XQuang,Siêu Âm, Nội soi...) để thực hiện cấu hình");
                    return;
                }
                int IdChitietdichvu = Utility.Int32Dbnull(Utility.GetValueFromGridColumn(grdServiceDetail, DmucDichvuclsChitiet.Columns.IdChitietdichvu), -1);

                DmucDichvuclsChitiet objDichvuchitiet = DmucDichvuclsChitiet.FetchByID(IdChitietdichvu);
                try
                {
                    if (objDichvuchitiet == null)
                    {
                        Utility.ShowMsg("Bạn cần chọn chỉ định chi tiết cần cập nhật kết quả");
                        return;
                    }
                    frm_DynamicSetup _DynamicSetup = new frm_DynamicSetup();
                    _DynamicSetup.objDichvuchitiet  = objDichvuchitiet;
                    _DynamicSetup.ImageID           = -1;
                    _DynamicSetup.Id_chidinhchitiet = -1;
                    if (_DynamicSetup.ShowDialog() == DialogResult.OK)
                    {
                    }
                }
                catch (Exception)
                {
                }
            }
            catch (Exception)
            {
            }
        }
Пример #2
0
        /// <summary>
        /// Lấy toàn bộ dữ liệu CLS giống phần chỉ định CLS sau đó tính giá dựa trên dữ liệu lấy được đó. Thay vì select lại từ các bảng quan hệ
        /// </summary>
        /// <param name="objLuotkham"></param>
        /// <returns></returns>
        private static ActionResult CapnhatChiphiCLS(KcbLuotkham objLuotkham)
        {
            using (var Scope = new TransactionScope())
            {
                DataTable m_dtServiceDetail = new KCB_CHIDINH_CANLAMSANG().LaydanhsachCLS_chidinh(objLuotkham.MaDoituongKcb, objLuotkham.TrangthaiNoitru, Utility.ByteDbnull(objLuotkham.GiayBhyt, 0), -1, Utility.Int32Dbnull(objLuotkham.DungTuyen.Value, 0), objLuotkham.MaKhoaThuchien, "-GOI,-TIEN");//Ko lấy dữ liệu liên quan đến gói dịch vụ+tiền phí phụ thêm
                SqlQuery  sqlQuery          = new Select().From(KcbChidinhclsChitiet.Schema)
                                              .Where(KcbChidinhclsChitiet.Columns.IdChidinh).In(
                    new Select(KcbChidinhcl.Columns.IdChidinh).From(KcbChidinhcl.Schema)
                    .Where(KcbChidinhcl.Columns.MaLuotkham).IsEqualTo(objLuotkham.MaLuotkham)
                    .And(KcbChidinhcl.Columns.IdBenhnhan).IsEqualTo(objLuotkham.IdBenhnhan)
                    );
                var objAssignDetailCollection =
                    sqlQuery.ExecuteAsCollection <KcbChidinhclsChitietCollection>();
                foreach (KcbChidinhclsChitiet objAssignDetail in objAssignDetailCollection)
                {
                    if (objAssignDetail.TrangthaiThanhtoan == 0)//Chưa thanh toán
                    {
                        DataRow[] arrDr = m_dtServiceDetail.Select(KcbChidinhclsChitiet.Columns.IdChitietdichvu + "=" + Utility.Int32Dbnull(objAssignDetail.IdChitietdichvu, -1));
                        if (arrDr.Length > 0)
                        {
                            objAssignDetail.IdDoituongKcb = objLuotkham.IdDoituongKcb;
                            objAssignDetail.PtramBhyt     = objLuotkham.PtramBhyt;
                            objAssignDetail.DonGia        = Utility.DecimaltoDbnull(arrDr[0][KcbChidinhclsChitiet.Columns.DonGia], 0);
                            objAssignDetail.GiaDanhmuc    = Utility.DecimaltoDbnull(arrDr[0][KcbChidinhclsChitiet.Columns.DonGia], 0);
                            objAssignDetail.TuTuc         = Utility.ByteDbnull(arrDr[0][KcbChidinhclsChitiet.Columns.TuTuc], 0);
                            objAssignDetail.PhuThu        = Utility.DecimaltoDbnull(arrDr[0][KcbChidinhclsChitiet.Columns.PhuThu], 0);
                            objAssignDetail.NguoiSua      = globalVariables.UserName;
                            objAssignDetail.NgaySua       = DateTime.Now;
                            TinhCLS.GB_TinhPhtramBHYT(objAssignDetail, objLuotkham, Utility.DecimaltoDbnull(objLuotkham.PtramBhyt));
                        }
                        else //Rất khó nhảy vào nhánh này trừ phi lỗi dữ liệu đặc biệt nào đó
                        {
                            CLS_GIATHEO_KHOAKCB = THU_VIEN_CHUNG.Laygiatrithamsohethong("CLS_GIATHEO_KHOAKCB", "0", true) == "1";
                            QheDoituongDichvucl _Items = THU_VIEN_CHUNG.LayQheDoituongCLS(objLuotkham.MaDoituongKcb, objAssignDetail.IdChitietdichvu, objLuotkham.MaKhoaThuchien, CLS_GIATHEO_KHOAKCB);
                            if (_Items != null)
                            {
                                objAssignDetail.DonGia        = Utility.DecimaltoDbnull(_Items.DonGia);
                                objAssignDetail.PhuThu        = (Utility.isTrue(objLuotkham.DungTuyen) ? Utility.DecimaltoDbnull(_Items.PhuthuDungtuyen) : Utility.DecimaltoDbnull(_Items.PhuthuTraituyen));
                                objAssignDetail.TuTuc         = 0;
                                objAssignDetail.IdDoituongKcb = objLuotkham.IdDoituongKcb;
                                objAssignDetail.PtramBhyt     = objLuotkham.PtramBhyt;
                            }
                            else
                            {
                                _Items = THU_VIEN_CHUNG.LayQheDoituongCLS("DV", objAssignDetail.IdChitietdichvu, objLuotkham.MaKhoaThuchien, CLS_GIATHEO_KHOAKCB);
                                if (_Items != null)
                                {
                                    objAssignDetail.DonGia        = Utility.DecimaltoDbnull(_Items.DonGia);
                                    objAssignDetail.PhuThu        = (Utility.isTrue(objLuotkham.DungTuyen) ? Utility.DecimaltoDbnull(_Items.PhuthuDungtuyen) : Utility.DecimaltoDbnull(_Items.PhuthuTraituyen));
                                    objAssignDetail.TuTuc         = 1;
                                    objAssignDetail.IdDoituongKcb = objLuotkham.IdDoituongKcb;
                                    objAssignDetail.PtramBhyt     = 0;
                                }
                            }
                            DmucDichvuclsChitiet _DmucDichvuclsChitiet = DmucDichvuclsChitiet.FetchByID(objAssignDetail.IdChitietdichvu);
                            if (_DmucDichvuclsChitiet != null && Utility.Int32Dbnull(_DmucDichvuclsChitiet.TuTuc, 0) == 1)
                            {
                                objAssignDetail.TuTuc = 1;          //Ke ca co trong bang quan he
                            }
                            if (objLuotkham.IdLoaidoituongKcb == 1) //Đối tượng dịch vụ-->ko cần phải đánh dấu tự túc
                            {
                                objAssignDetail.TuTuc = 0;
                            }

                            objAssignDetail.NguoiSua = globalVariables.UserName;
                            objAssignDetail.NgaySua  = DateTime.Now;
                            decimal PtramBHYT = Utility.DecimaltoDbnull(objLuotkham.PtramBhyt);
                            TinhCLS.GB_TinhPhtramBHYT(objAssignDetail, objLuotkham, PtramBHYT);
                        }
                    }
                    else//Đã thanh toán-->Ko đổi
                    {
                        return(ActionResult.Cancel);
                    }
                }
                objAssignDetailCollection.SaveAll();
                Scope.Complete();
                return(ActionResult.Success);
            }
        }
Пример #3
0
        private static ActionResult CapnhatChiphiCLS_old(KcbLuotkham objLuotkham)
        {
            using (var Scope = new TransactionScope())
            {
                CLS_GIATHEO_KHOAKCB = THU_VIEN_CHUNG.Laygiatrithamsohethong("CLS_GIATHEO_KHOAKCB", "0", true) == "1";
                SqlQuery sqlQuery = new Select().From(KcbChidinhclsChitiet.Schema)
                                    .Where(KcbChidinhclsChitiet.Columns.IdChidinh).In(
                    new Select(KcbChidinhcl.Columns.IdChidinh).From(KcbChidinhcl.Schema)
                    .Where(KcbChidinhcl.Columns.MaLuotkham).IsEqualTo(objLuotkham.MaLuotkham)
                    .And(KcbChidinhcl.Columns.IdBenhnhan).IsEqualTo(objLuotkham.IdBenhnhan)
                    );
                var objAssignDetailCollection =
                    sqlQuery.ExecuteAsCollection <KcbChidinhclsChitietCollection>();
                foreach (KcbChidinhclsChitiet objAssignDetail in objAssignDetailCollection)
                {
                    if (objAssignDetail.TrangthaiThanhtoan == 0)
                    {
                        QheDoituongDichvucl _Items = THU_VIEN_CHUNG.LayQheDoituongCLS(objLuotkham.MaDoituongKcb, objAssignDetail.IdChitietdichvu, objLuotkham.MaKhoaThuchien, CLS_GIATHEO_KHOAKCB);
                        if (_Items != null)
                        {
                            objAssignDetail.DonGia        = Utility.DecimaltoDbnull(_Items.DonGia);
                            objAssignDetail.PhuThu        = (Utility.isTrue(objLuotkham.DungTuyen) ? Utility.DecimaltoDbnull(_Items.PhuthuDungtuyen) : Utility.DecimaltoDbnull(_Items.PhuthuTraituyen));
                            objAssignDetail.TuTuc         = 0;
                            objAssignDetail.IdDoituongKcb = objLuotkham.IdDoituongKcb;
                            objAssignDetail.PtramBhyt     = objLuotkham.PtramBhyt;
                        }
                        else
                        {
                            _Items = THU_VIEN_CHUNG.LayQheDoituongCLS("DV", objAssignDetail.IdChitietdichvu, objLuotkham.MaKhoaThuchien, CLS_GIATHEO_KHOAKCB);
                            if (_Items != null)
                            {
                                objAssignDetail.DonGia        = Utility.DecimaltoDbnull(_Items.DonGia);
                                objAssignDetail.PhuThu        = (Utility.isTrue(objLuotkham.DungTuyen) ? Utility.DecimaltoDbnull(_Items.PhuthuDungtuyen) : Utility.DecimaltoDbnull(_Items.PhuthuTraituyen));
                                objAssignDetail.TuTuc         = 1;
                                objAssignDetail.IdDoituongKcb = objLuotkham.IdDoituongKcb;
                                objAssignDetail.PtramBhyt     = 0;
                            }
                        }
                        DmucDichvuclsChitiet _DmucDichvuclsChitiet = DmucDichvuclsChitiet.FetchByID(objAssignDetail.IdChitietdichvu);
                        if (_DmucDichvuclsChitiet != null && Utility.Int32Dbnull(_DmucDichvuclsChitiet.TuTuc, 0) == 1)
                        {
                            objAssignDetail.TuTuc = 1;          //Ke ca co trong bang quan he
                        }
                        if (objLuotkham.IdLoaidoituongKcb == 1) //Đối tượng dịch vụ-->ko cần phải đánh dấu tự túc
                        {
                            objAssignDetail.TuTuc = 0;
                        }

                        objAssignDetail.NguoiSua = globalVariables.UserName;
                        objAssignDetail.NgaySua  = DateTime.Now;
                        decimal PtramBHYT = Utility.DecimaltoDbnull(objLuotkham.PtramBhyt);
                        TinhCLS.GB_TinhPhtramBHYT(objAssignDetail, objLuotkham, PtramBHYT);
                    }
                    else
                    {
                        return(ActionResult.Cancel);
                    }
                }
                objAssignDetailCollection.SaveAll();
                Scope.Complete();
                return(ActionResult.Success);
            }
        }
Пример #4
0
        public static bool CapnhatTrangthaiTutuc(KcbChidinhclsChitiet objChidinhChitiet, KcbLuotkham objLuotkham, bool noitru, byte tu_tuc, decimal PTramBHYT)
        {
            try
            {
                byte    TrangthaiBhyt = 1;
                decimal BHYT_PTRAM_TRAITUYENNOITRU = Utility.DecimaltoDbnull(THU_VIEN_CHUNG.Laygiatrithamsohethong("BHYT_PTRAM_TRAITUYENNOITRU", "0", false), 0m);
                bool    b_ExistPtramBHYT           = false;
                objChidinhChitiet.TuTuc = tu_tuc;
                if (!THU_VIEN_CHUNG.IsBaoHiem(objLuotkham.IdLoaidoituongKcb.Value))//Đối tượng DV
                {
                    TrangthaiBhyt           = (byte)0;
                    objChidinhChitiet.TuTuc = 0;
                }
                else
                {
                    TrangthaiBhyt = (byte)(globalVariables.gv_blnApdungChedoDuyetBHYT ? 0 : 1);
                }

                if (Utility.Int32Dbnull(objChidinhChitiet.TrangthaiHuy, -1) == -1)
                {
                    objChidinhChitiet.TrangthaiHuy = 0;
                }

                DmucDichvuclsChitiet obServiceDetail =
                    DmucDichvuclsChitiet.FetchByID(Utility.Int32Dbnull(objChidinhChitiet.IdChitietdichvu));
                QheDoituongDichvucl objqhedoituong = new QheDoituongDichvucl();
                if (obServiceDetail != null)
                {
                    if (Utility.Int32Dbnull(objChidinhChitiet.TuTuc, 0) == 1)
                    {
                        objqhedoituong = LayGiaTheoDoiTuong("DV", objChidinhChitiet.IdChitietdichvu,
                                                            objLuotkham.MaKhoaThuchien);
                    }
                    else
                    {
                        objqhedoituong = LayGiaTheoDoiTuong(objLuotkham.MaDoituongKcb, objChidinhChitiet.IdChitietdichvu,
                                                            objLuotkham.MaKhoaThuchien);
                    }
                    // objChidinhChitiet.GiaDanhmuc = Utility.DecimaltoDbnull(obServiceDetail.DonGia);
                    if (objqhedoituong != null)
                    {
                        objChidinhChitiet.GiaDanhmuc    = Utility.DecimaltoDbnull(objqhedoituong.DonGia, 0);
                        objChidinhChitiet.DonGia        = Utility.DecimaltoDbnull(objqhedoituong.DonGia, 0);
                        objChidinhChitiet.MadoituongGia = Utility.sDbnull(objqhedoituong.MaDoituongKcb);
                    }
                }
                objChidinhChitiet.PtramBhyt    = PTramBHYT;
                objChidinhChitiet.PtramBhytGoc = objLuotkham.PtramBhytGoc;
                // objChidinhChitiet.LoaiChietkhau = 0;
                // objChidinhChitiet.TrangthaiBhyt = TrangthaiBhyt;
                //objChidinhChitiet.IdLoaichidinh = 0;//Chưa hiểu trường này-->Cần xem lại
                if (Utility.Int32Dbnull(objChidinhChitiet.TuTuc, 0) == 1)
                {
                    objChidinhChitiet.BhytChitra = 0;
                    if (objqhedoituong != null)
                    {
                        objChidinhChitiet.BnhanChitra = Utility.DecimaltoDbnull(objqhedoituong.DonGia, 0);
                    }
                    objChidinhChitiet.PtramBhyt = 0;
                }
                else
                {
                    //Mục tính BHYT đặc biệt để dành sử dụng trong tương lai
                    PtramBHYTDacBiet(objChidinhChitiet, objLuotkham, 2, ref b_ExistPtramBHYT);
                    if (b_ExistPtramBHYT)
                    {
                        objChidinhChitiet.BhytChitra = Utility.DecimaltoDbnull(objChidinhChitiet.DonGia) *
                                                       Utility.DecimaltoDbnull(objChidinhChitiet.PtramBhyt) / 100;
                        objChidinhChitiet.BnhanChitra = Utility.DecimaltoDbnull(objChidinhChitiet.DonGia, 0) -
                                                        Utility.DecimaltoDbnull(objChidinhChitiet.BhytChitra);
                    }
                    else//99% rơi vào nhánh này
                    {
                        PTramBHYT = Utility.DecimaltoDbnull(objLuotkham.PtramBhyt);
                        decimal BHCT = 0m;
                        if (objLuotkham.DungTuyen == 1)//BHYT đúng tuyến rơi vào nhánh này dù nội trú ngay ngoại trú
                        {
                            BHCT = Utility.DecimaltoDbnull(objChidinhChitiet.DonGia, 0) * (Utility.DecimaltoDbnull(objLuotkham.PtramBhyt, 0) / 100);
                        }
                        else//DV và BHYT trái tuyến
                        {
                            if (objLuotkham.TrangthaiNoitru <= 0 || !noitru)//Đối tượng ngoại trú hoặc Chỉ định ngoại trú-->Lấy phần trăm ngoại trú
                            {
                                BHCT = Utility.DecimaltoDbnull(objChidinhChitiet.DonGia, 0) * (Utility.DecimaltoDbnull(objLuotkham.PtramBhyt, 0) / 100);
                            }
                            else//Nội trú cần tính=đơn giá * % đầu thẻ * % tuyến
                            {
                                BHCT = Utility.DecimaltoDbnull(objChidinhChitiet.DonGia.Value, 0) * (Utility.DecimaltoDbnull(objLuotkham.PtramBhytGoc, 0) / 100) * (BHYT_PTRAM_TRAITUYENNOITRU / 100);
                            }
                        }
                        decimal BNCT = Utility.DecimaltoDbnull(objChidinhChitiet.DonGia, 0) - BHCT;
                        objChidinhChitiet.BhytChitra  = BHCT;
                        objChidinhChitiet.BnhanChitra = BNCT;
                    }
                }
                objChidinhChitiet.MarkOld();
                objChidinhChitiet.IsNew = false;
                objChidinhChitiet.Save();
                return(true);
            }
            catch (Exception ex)
            {
                Utility.CatchException(ex);
                return(false);
            }
        }
Пример #5
0
        public static void GB_TinhPhtramBHYT(KcbChidinhclsChitiet objChidinhChitiet, KcbLichsuDoituongKcb objLichsu, bool noitru, decimal PTramBHYT)
        {
            byte    TrangthaiBhyt = 1;
            decimal BHYT_PTRAM_TRAITUYENNOITRU = Utility.DecimaltoDbnull(THU_VIEN_CHUNG.Laygiatrithamsohethong("BHYT_PTRAM_TRAITUYENNOITRU", "0", false), 0m);
            bool    b_ExistPtramBHYT           = false;

            if (!THU_VIEN_CHUNG.IsBaoHiem(objLichsu.IdLoaidoituongKcb.Value))//Đối tượng DV
            {
                TrangthaiBhyt           = (byte)0;
                objChidinhChitiet.TuTuc = 0;
            }
            else
            {
                TrangthaiBhyt = (byte)(globalVariables.gv_blnApdungChedoDuyetBHYT ? 0 : 1);
            }
            if (Utility.Int32Dbnull(objChidinhChitiet.TrangthaiHuy, -1) == -1)
            {
                objChidinhChitiet.TrangthaiHuy = 0;
            }
            DmucDichvuclsChitiet obServiceDetail =
                DmucDichvuclsChitiet.FetchByID(Utility.Int32Dbnull(objChidinhChitiet.IdChitietdichvu));

            if (obServiceDetail != null)
            {
                objChidinhChitiet.GiaDanhmuc = Utility.DecimaltoDbnull(obServiceDetail.DonGia);
            }
            objChidinhChitiet.PtramBhyt     = PTramBHYT;
            objChidinhChitiet.PtramBhytGoc  = objLichsu.PtramBhytGoc;
            objChidinhChitiet.LoaiChietkhau = 0;
            objChidinhChitiet.TrangthaiBhyt = TrangthaiBhyt;
            objChidinhChitiet.IdLoaichidinh = 0;//Chưa hiểu trường này-->Cần xem lại
            if (Utility.Int32Dbnull(objChidinhChitiet.TuTuc, 0) == 1)
            {
                objChidinhChitiet.BhytChitra  = 0;
                objChidinhChitiet.BnhanChitra = Utility.DecimaltoDbnull(objChidinhChitiet.DonGia, 0);
                objChidinhChitiet.PtramBhyt   = 0;
            }
            else
            {
                //Mục tính BHYT đặc biệt để dành sử dụng trong tương lai
                PtramBHYTDacBiet(objChidinhChitiet, objLichsu, 2, ref b_ExistPtramBHYT);
                if (b_ExistPtramBHYT)
                {
                    objChidinhChitiet.BhytChitra = Utility.DecimaltoDbnull(objChidinhChitiet.DonGia) *
                                                   Utility.DecimaltoDbnull(objChidinhChitiet.PtramBhyt) / 100;
                    objChidinhChitiet.BnhanChitra = Utility.DecimaltoDbnull(objChidinhChitiet.DonGia, 0) -
                                                    Utility.DecimaltoDbnull(objChidinhChitiet.BhytChitra);
                }
                else//99% rơi vào nhánh này
                {
                    PTramBHYT = Utility.DecimaltoDbnull(objLichsu.PtramBhyt);
                    decimal BHCT = 0m;
                    if (objLichsu.DungTuyen == 1)//BHYT đúng tuyến rơi vào nhánh này dù nội trú ngay ngoại trú
                    {
                        BHCT = Utility.DecimaltoDbnull(objChidinhChitiet.DonGia, 0) * (Utility.DecimaltoDbnull(objLichsu.PtramBhyt, 0) / 100);
                    }
                    else//DV và BHYT trái tuyến
                    {
                        if (objLichsu.TrangthaiNoitru <= 0 || !noitru)//Đối tượng ngoại trú hoặc Chỉ định ngoại trú-->Lấy phần trăm ngoại trú
                        {
                            BHCT = Utility.DecimaltoDbnull(objChidinhChitiet.DonGia, 0) * (Utility.DecimaltoDbnull(objLichsu.PtramBhyt, 0) / 100);
                        }
                        else//Nội trú cần tính=đơn giá * % đầu thẻ * % tuyến
                        {
                            BHCT = Utility.DecimaltoDbnull(objChidinhChitiet.DonGia.Value, 0) * (Utility.DecimaltoDbnull(objLichsu.PtramBhytGoc, 0) / 100) * (BHYT_PTRAM_TRAITUYENNOITRU / 100);
                        }
                    }
                    decimal BNCT = Utility.DecimaltoDbnull(objChidinhChitiet.DonGia, 0) - BHCT;
                    objChidinhChitiet.BhytChitra  = BHCT;
                    objChidinhChitiet.BnhanChitra = BNCT;
                }
            }
        }
Пример #6
0
        void mnuCancelResult_Click(object sender, EventArgs e)
        {
            if (grdKetqua.SelectedItems.Count > 1)
            {
                if (!Utility.AcceptQuestion("Bạn có chắc chắn muốn hủy kết quả các xét nghiệm đang chọn", "Hủy kết quả", true))
                {
                    return;
                }
            }
            List <KcbKetquaCl>          lstResult  = new List <KcbKetquaCl>();
            List <KcbChidinhclsChitiet> lstDetails = new List <KcbChidinhclsChitiet>();

            foreach (GridEXRow row in grdKetqua.SelectedItems)
            {
                KcbKetquaCl          _item        = null;
                KcbChidinhclsChitiet _itemchitiet = null;
                try
                {
                    int id_kq            = Utility.Int32Dbnull(Utility.GetValueFromGridColumn(row, KcbKetquaCl.Columns.IdKq), -1);
                    int IdChitietchidinh = Utility.Int32Dbnull(Utility.GetValueFromGridColumn(row, KcbChidinhclsChitiet.Columns.IdChitietchidinh), -1);
                    int IdChitietdichvu  = Utility.Int32Dbnull(Utility.GetValueFromGridColumn(row, DmucDichvuclsChitiet.Columns.IdChitietdichvu), -1);
                    _itemchitiet       = KcbChidinhclsChitiet.FetchByID(IdChitietchidinh);
                    _itemchitiet.IsNew = false;
                    _itemchitiet.MarkOld();
                    if (id_kq > 0)
                    {
                        _item           = KcbKetquaCl.FetchByID(id_kq);
                        _item.IsNew     = false;
                        _item.NguoiSua  = globalVariables.UserName;
                        _item.NgaySua   = globalVariables.SysDate;
                        _item.IpMaysua  = globalVariables.gv_strIPAddress;
                        _item.TenMaysua = globalVariables.gv_strComputerName;
                        _item.MarkOld();
                    }
                    else
                    {
                        _item           = new KcbKetquaCl();
                        _item.IsNew     = true;
                        _item.NguoiTao  = globalVariables.UserName;
                        _item.NgayTao   = globalVariables.SysDate;
                        _item.IpMaytao  = globalVariables.gv_strIPAddress;
                        _item.TenMaytao = globalVariables.gv_strComputerName;
                    }
                    DmucDichvuclsChitiet objcls = DmucDichvuclsChitiet.FetchByID(IdChitietdichvu);
                    if (objcls != null)
                    {
                        _item.MaChidinh        = Utility.GetValueFromGridColumn(grdChidinh, KcbChidinhcl.Columns.MaChidinh);
                        _item.MaBenhpham       = Utility.GetValueFromGridColumn(grdChidinh, KcbChidinhcl.Columns.MaBenhpham);
                        _item.Barcode          = Utility.GetValueFromGridColumn(grdChidinh, KcbChidinhcl.Columns.Barcode);
                        _item.IdBenhnhan       = id_benhnhan;
                        _item.MaLuotkham       = ma_luotkham;
                        _item.IdChidinh        = Utility.Int32Dbnull(Utility.GetValueFromGridColumn(row, KcbChidinhclsChitiet.Columns.IdChidinh), -1);
                        _item.IdChitietchidinh = Utility.Int32Dbnull(Utility.GetValueFromGridColumn(row, KcbChidinhclsChitiet.Columns.IdChitietchidinh), -1);
                        _item.IdDichvu         = Utility.Int32Dbnull(Utility.GetValueFromGridColumn(row, KcbChidinhclsChitiet.Columns.IdDichvu), -1);
                        _item.IdDichvuchitiet  = Utility.Int32Dbnull(Utility.GetValueFromGridColumn(row, KcbChidinhclsChitiet.Columns.IdChitietdichvu), -1);
                        _item.Barcode          = Utility.GetValueFromGridColumn(grdChidinh, KcbChidinhcl.Columns.Barcode);
                        _item.SttIn            = objcls.SttHthi;
                        _item.BtNam            = objcls.BinhthuongNam;
                        _item.BtNu             = objcls.BinhthuongNu;
                        _item.KetQua           = Utility.sDbnull(Utility.GetValueFromGridColumn(row, KcbChidinhclsChitiet.Columns.KetQua), -1);
                        if (_item.TrangThai < 3)
                        {
                            _item.TrangThai = 3;
                        }
                        if (chkSaveAndConfirm.Checked)
                        {
                            _item.TrangThai = 4;//Duyệt luôn để hiển thị trên form thăm khám của bác sĩ
                        }
                        if (Utility.DoTrim(_item.KetQua) == "")
                        {
                            _item.TrangThai = 2;//Quay ve trang thai chuyen đang thực hiện
                        }
                        //_item.TenDonvitinh = objcls.TenDonvitinh;
                        _itemchitiet.KetQua = Utility.sDbnull(Utility.GetValueFromGridColumn(row, KcbChidinhclsChitiet.Columns.KetQua), -1);
                        if (_itemchitiet.TrangThai < 3)
                        {
                            _itemchitiet.TrangThai = 3;
                        }
                        if (chkSaveAndConfirm.Checked)
                        {
                            _itemchitiet.TrangThai = 4;//Duyệt luôn để hiển thị trên form thăm khám của bác sĩ
                        }
                        if (Utility.DoTrim(_itemchitiet.KetQua) == "")
                        {
                            _itemchitiet.TrangThai = 1;//Quay ve trang thai chuyen can
                        }
                        _item.TenThongso     = "";
                        _item.TenKq          = "";
                        _item.LoaiKq         = 0;
                        _item.ChophepHienthi = 1;
                        _item.ChophepIn      = 1;
                        _item.MotaThem       = objcls.MotaThem;
                    }
                    lstResult.Add(_item);
                    lstDetails.Add(_itemchitiet);
                }
                catch (Exception)
                {
                }
            }
            if (clsXN.UpdateResult(lstResult, lstDetails) == ActionResult.Success)
            {
                Utility.ShowMsg("Đã hủy kết quả các xét nghiệm đang chọn thành công");
            }
            else
            {
                Utility.ShowMsg("Lỗi khi thực hiện hủy kết quả xét nghiệm");
            }
        }
Пример #7
0
        //KcbChidinhclsChitiet.Trang_thai:0=Mới chỉ định;1=Đã chuyển CLS;2=Đang thực hiện;3= Đã có kết quả CLS;4=Đã xác nhận kết quả
        void grdKetqua_UpdatingCell(object sender, UpdatingCellEventArgs e)
        {
            try
            {
                List <KcbKetquaCl>          lstResult  = new List <KcbKetquaCl>();
                List <KcbChidinhclsChitiet> lstDetails = new List <KcbChidinhclsChitiet>();
                int id_kq               = Utility.Int32Dbnull(Utility.GetValueFromGridColumn(grdKetqua, KcbKetquaCl.Columns.IdKq), -1);
                int IdChitietchidinh    = Utility.Int32Dbnull(Utility.GetValueFromGridColumn(grdKetqua, KcbChidinhclsChitiet.Columns.IdChitietchidinh), -1);
                int IdChitietchidinhcha = Utility.Int32Dbnull(Utility.GetValueFromGridColumn(grdChidinh, KcbChidinhclsChitiet.Columns.IdChitietchidinh), -1);
                int CoChitiet           = Utility.Int32Dbnull(Utility.GetValueFromGridColumn(grdChidinh, DmucDichvuclsChitiet.Columns.CoChitiet), -1);

                int                  IdChitietdichvu = Utility.Int32Dbnull(Utility.GetValueFromGridColumn(grdKetqua, DmucDichvuclsChitiet.Columns.IdChitietdichvu), -1);
                KcbKetquaCl          _item           = null;
                KcbChidinhclsChitiet _itemchitiet    = KcbChidinhclsChitiet.FetchByID(IdChitietchidinh);
                KcbChidinhclsChitiet _itemchitietcha = null;
                if (CoChitiet == 1)
                {
                    _itemchitietcha = KcbChidinhclsChitiet.FetchByID(IdChitietchidinhcha);
                    if (_itemchitietcha != null)
                    {
                        _itemchitietcha.IsNew = false;
                        _itemchitietcha.MarkOld();
                    }
                }
                _itemchitiet.IsNew = false;
                _itemchitiet.MarkOld();
                if (id_kq > 0)
                {
                    _item           = KcbKetquaCl.FetchByID(id_kq);
                    _item.IsNew     = false;
                    _item.NguoiSua  = globalVariables.UserName;
                    _item.NgaySua   = globalVariables.SysDate;
                    _item.IpMaysua  = globalVariables.gv_strIPAddress;
                    _item.TenMaysua = globalVariables.gv_strComputerName;
                    _item.MarkOld();
                }
                else
                {
                    _item           = new KcbKetquaCl();
                    _item.IsNew     = true;
                    _item.NguoiTao  = globalVariables.UserName;
                    _item.NgayTao   = globalVariables.SysDate;
                    _item.IpMaytao  = globalVariables.gv_strIPAddress;
                    _item.TenMaytao = globalVariables.gv_strComputerName;
                }
                DmucDichvuclsChitiet objcls = DmucDichvuclsChitiet.FetchByID(IdChitietdichvu);
                if (objcls != null)
                {
                    _item.MaChidinh        = Utility.GetValueFromGridColumn(grdChidinh, KcbChidinhcl.Columns.MaChidinh);
                    _item.MaBenhpham       = Utility.GetValueFromGridColumn(grdChidinh, KcbChidinhcl.Columns.MaBenhpham);
                    _item.Barcode          = Utility.GetValueFromGridColumn(grdChidinh, KcbChidinhcl.Columns.Barcode);
                    _item.IdBenhnhan       = id_benhnhan;
                    _item.MaLuotkham       = ma_luotkham;
                    _item.IdChidinh        = Utility.Int32Dbnull(Utility.GetValueFromGridColumn(grdKetqua, KcbChidinhclsChitiet.Columns.IdChidinh), -1);
                    _item.IdChitietchidinh = Utility.Int32Dbnull(Utility.GetValueFromGridColumn(grdKetqua, KcbChidinhclsChitiet.Columns.IdChitietchidinh), -1);
                    _item.IdDichvu         = Utility.Int32Dbnull(Utility.GetValueFromGridColumn(grdKetqua, KcbChidinhclsChitiet.Columns.IdDichvu), -1);
                    _item.IdDichvuchitiet  = Utility.Int32Dbnull(Utility.GetValueFromGridColumn(grdKetqua, KcbChidinhclsChitiet.Columns.IdChitietdichvu), -1);
                    _item.Barcode          = Utility.GetValueFromGridColumn(grdChidinh, KcbChidinhcl.Columns.Barcode);
                    _item.SttIn            = objcls.SttHthi;
                    _item.BtNam            = objcls.BinhthuongNam;
                    _item.BtNu             = objcls.BinhthuongNu;
                    _item.KetQua           = Utility.sDbnull(e.Value, "");
                    if (_item.TrangThai < 3)
                    {
                        _item.TrangThai = 3;
                    }
                    if (chkSaveAndConfirm.Checked)
                    {
                        _item.TrangThai = 4;//Duyệt luôn để hiển thị trên form thăm khám của bác sĩ
                    }
                    if (Utility.DoTrim(_item.KetQua) == "")
                    {
                        _item.TrangThai = 2;//Quay ve trang thai chuyen đang thực hiện
                    }
                    //_item.TenDonvitinh = objcls.TenDonvitinh;
                    _itemchitiet.KetQua = Utility.sDbnull(e.Value, "");
                    if (_itemchitiet.TrangThai < 3)
                    {
                        _itemchitiet.TrangThai = 3;
                    }
                    if (chkSaveAndConfirm.Checked)
                    {
                        _itemchitiet.TrangThai = 4;//Duyệt luôn để hiển thị trên form thăm khám của bác sĩ
                    }
                    if (Utility.DoTrim(_itemchitiet.KetQua) == "")
                    {
                        _itemchitiet.TrangThai = 1;//Quay ve trang thai chuyen can
                    }
                    if (_itemchitietcha != null && _itemchitietcha.TrangThai < 3)
                    {
                        _itemchitietcha.TrangThai = 3;
                    }
                    if (_itemchitietcha != null && chkSaveAndConfirm.Checked)
                    {
                        _itemchitietcha.TrangThai = 4;//Duyệt luôn để hiển thị trên form thăm khám của bác sĩ
                    }
                    if (_itemchitietcha != null && Utility.DoTrim(Utility.sDbnull(e.Value, "")) == "")
                    {
                        _itemchitietcha.TrangThai = 1;//Quay ve trang thai chuyen can
                    }
                    _item.TenThongso     = "";
                    _item.TenKq          = "";
                    _item.LoaiKq         = 0;
                    _item.ChophepHienthi = 1;
                    _item.ChophepIn      = 1;
                    _item.MotaThem       = objcls.MotaThem;
                    lstResult.Add(_item);
                    lstDetails.Add(_itemchitiet);
                    if (_itemchitietcha != null)
                    {
                        lstDetails.Add(_itemchitietcha);
                    }
                    if (clsXN.UpdateResult(lstResult, lstDetails) != ActionResult.Success)
                    {
                        e.Cancel = true;
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Пример #8
0
        void Confirm()
        {
            byte _result = 3;

            try
            {
                foreach (GridEXRow row in grdKetqua.GetDataRows())
                {
                    List <KcbKetquaCl>          lstResult  = new List <KcbKetquaCl>();
                    List <KcbChidinhclsChitiet> lstDetails = new List <KcbChidinhclsChitiet>();
                    int id_kq               = Utility.Int32Dbnull(Utility.GetValueFromGridColumn(row, KcbKetquaCl.Columns.IdKq), -1);
                    int IdChitietchidinh    = Utility.Int32Dbnull(Utility.GetValueFromGridColumn(row, KcbChidinhclsChitiet.Columns.IdChitietchidinh), -1);
                    int IdChitietchidinhcha = Utility.Int32Dbnull(dtChidinh.Rows[0][KcbChidinhclsChitiet.Columns.IdChitietchidinh], -1);


                    int IdChitietdichvu                  = Utility.Int32Dbnull(Utility.GetValueFromGridColumn(row, DmucDichvuclsChitiet.Columns.IdChitietdichvu), -1);
                    DmucDichvuclsChitiet objcls          = DmucDichvuclsChitiet.FetchByID(IdChitietdichvu);
                    int                  CoChitiet       = Utility.Int32Dbnull(objcls.CoChitiet, 0);
                    KcbKetquaCl          _item           = null;
                    KcbChidinhclsChitiet _itemchitiet    = KcbChidinhclsChitiet.FetchByID(IdChitietchidinh);
                    KcbChidinhclsChitiet _itemchitietcha = null;
                    if (CoChitiet == 1)
                    {
                        _itemchitietcha = KcbChidinhclsChitiet.FetchByID(IdChitietchidinhcha);
                        if (_itemchitietcha != null)
                        {
                            _itemchitietcha.IsNew = false;
                            _itemchitietcha.MarkOld();
                        }
                    }
                    _itemchitiet.IsNew = false;
                    _itemchitiet.MarkOld();
                    if (id_kq > 0)
                    {
                        _item           = KcbKetquaCl.FetchByID(id_kq);
                        _item.IsNew     = false;
                        _item.NguoiSua  = globalVariables.UserName;
                        _item.NgaySua   = globalVariables.SysDate;
                        _item.IpMaysua  = globalVariables.gv_strIPAddress;
                        _item.TenMaysua = globalVariables.gv_strComputerName;
                        _item.MarkOld();
                    }
                    else
                    {
                        _item           = new KcbKetquaCl();
                        _item.IsNew     = true;
                        _item.NguoiTao  = globalVariables.UserName;
                        _item.NgayTao   = globalVariables.SysDate;
                        _item.IpMaytao  = globalVariables.gv_strIPAddress;
                        _item.TenMaytao = globalVariables.gv_strComputerName;
                    }

                    if (objcls != null)
                    {
                        _item.MaChidinh        = objChidinh.MaChidinh;
                        _item.MaBenhpham       = objChidinh.MaChidinh;
                        _item.Barcode          = objChidinh.Barcode;
                        _item.IdBenhnhan       = id_benhnhan;
                        _item.MaLuotkham       = ma_luotkham;
                        _item.IdChidinh        = Utility.Int32Dbnull(Utility.GetValueFromGridColumn(grdKetqua, KcbChidinhclsChitiet.Columns.IdChidinh), -1);
                        _item.IdChitietchidinh = Utility.Int32Dbnull(Utility.GetValueFromGridColumn(grdKetqua, KcbChidinhclsChitiet.Columns.IdChitietchidinh), -1);
                        _item.IdDichvu         = Utility.Int32Dbnull(Utility.GetValueFromGridColumn(grdKetqua, KcbChidinhclsChitiet.Columns.IdDichvu), -1);
                        _item.IdDichvuchitiet  = Utility.Int32Dbnull(Utility.GetValueFromGridColumn(grdKetqua, KcbChidinhclsChitiet.Columns.IdChitietdichvu), -1);
                        _item.SttIn            = objcls.SttHthi;
                        _item.BtNam            = objcls.BinhthuongNam;
                        _item.BtNu             = objcls.BinhthuongNu;
                        _item.KetQua           = Utility.DoTrim(Utility.GetValueFromGridColumn(row, "Ket_qua"));
                        if (_item.TrangThai < 3)
                        {
                            _item.TrangThai = 3;
                        }
                        if (chkSaveAndConfirm.Checked)
                        {
                            _item.TrangThai = 4;//Duyệt luôn để hiển thị trên form thăm khám của bác sĩ
                        }
                        if (Utility.DoTrim(_item.KetQua) == "")
                        {
                            _item.TrangThai = 2;//Quay ve trang thai chuyen đang thực hiện
                        }
                        //_item.TenDonvitinh = objcls.TenDonvitinh;
                        _itemchitiet.KetQua = _item.KetQua;
                        if (_itemchitiet.TrangThai < 3)
                        {
                            _itemchitiet.TrangThai = 3;
                        }
                        if (chkSaveAndConfirm.Checked)
                        {
                            _itemchitiet.TrangThai = 4;//Duyệt luôn để hiển thị trên form thăm khám của bác sĩ
                        }
                        if (Utility.DoTrim(_itemchitiet.KetQua) == "")
                        {
                            _itemchitiet.TrangThai = 2;//Quay ve trang thai chuyen can
                        }
                        if (_itemchitietcha != null && _itemchitietcha.TrangThai < 3)
                        {
                            _itemchitietcha.TrangThai = 3;
                        }
                        if (_itemchitietcha != null && chkSaveAndConfirm.Checked)
                        {
                            _itemchitietcha.TrangThai = 4;//Duyệt luôn để hiển thị trên form thăm khám của bác sĩ
                        }
                        if (_itemchitietcha != null && _itemchitiet.KetQua == "")
                        {
                            _itemchitietcha.TrangThai = 2;//Quay ve trang thai chuyen can
                        }
                        _item.TenThongso     = "";
                        _item.TenKq          = "";
                        _item.LoaiKq         = 0;
                        _item.ChophepHienthi = 1;
                        _item.ChophepIn      = 1;

                        _item.MotaThem = objcls.MotaThem;
                        lstResult.Add(_item);
                        lstDetails.Add(_itemchitiet);
                        if (_itemchitietcha != null)
                        {
                            lstDetails.Add(_itemchitietcha);
                        }
                        if (clsXN.UpdateResult(lstResult, lstDetails) != ActionResult.Success)
                        {
                        }
                        else
                        {
                            if (_OnResult != null)
                            {
                                _OnResult(_itemchitiet.IdChitietchidinh, Utility.ByteDbnull(_itemchitiet.TrangThai, 2));
                            }
                            this.Close();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.CatchException(ex);
            }
        }
Пример #9
0
        private void StartAnalysisFile(string fullpath)
        {
            MyLog.Trace(string.Format("------------------Begin Analysing file {0}------------------", fullpath));
            var lstLines = new List <string>();

            try
            {
                if (Utility.Laygiatrithamsohethong("ASTM_SECURITY", "0", false) == "1")
                {
                    //using (new NetworkConnection(_watcherPathInfo, Utility.CreateCredentials(Utility.Laygiatrithamsohethong("ASTM_UID", "UserName", false), Utility.Laygiatrithamsohethong("ASTM_PWD", "PassWord", false))))
                    var theNetworkCredential =
                        new NetworkCredential(Utility.Laygiatrithamsohethong("ASTM_UID", "UserName", false),
                                              Utility.Laygiatrithamsohethong("ASTM_PWD", "PassWord", false));
                    var theNetcache = new CredentialCache();
                    theNetcache.Add(new Uri(Path.GetDirectoryName(fullpath)), "Basic", theNetworkCredential);
                }
                using (
                    new NetworkConnection(Path.GetDirectoryName(fullpath),
                                          Utility.CreateCredentials(Utility.Laygiatrithamsohethong("ASTM_UID", "UserName", false),
                                                                    Utility.Laygiatrithamsohethong("ASTM_PWD", "PassWord", false))))
                {
                    using (var _reader = new StreamReader(fullpath))
                    {
                        while (_reader.Peek() > -1)
                        {
                            lstLines.Add(_reader.ReadLine());
                        }
                        _reader.BaseStream.Flush();
                        _reader.Close();
                    }

                    MyLog.Trace(string.Format("Read All lines"));
                    IEnumerable <string> patientinfor = from p in lstLines.AsEnumerable()
                                                        where p.StartsWith("P")
                                                        select p;
                    IEnumerable <string> Orderinfor = from p in lstLines.AsEnumerable()
                                                      where p.StartsWith("O")
                                                      select p;
                    var lstmachidinh = new List <string>();
                    foreach (string line in lstLines)
                    {
                        if (line.StartsWith("O")) //Chỉ định
                        {
                            if (!lstmachidinh.Contains(line.Split('|')[2]))
                            {
                                lstmachidinh.Add(line.Split('|')[2]);
                            }
                        }
                    }
                    bool isOK = false;
                    if (patientinfor.Any() && Orderinfor.Any())
                    {
                        MyLog.Trace(string.Format("File format is valid"));
                        MyLog.Trace(string.Format("Number of AssignCode {0}", lstmachidinh.Count));
                        var lstKq = new KcbKetquaClCollection();
                        MyLog.Trace(string.Format("GetData base on PID {0} and AssignCode List {1} ",
                                                  patientinfor.FirstOrDefault().Split('|')[2], string.Join(",", lstmachidinh.ToArray())));
                        DataTable dtData =
                            SPs.HisLisLaydulieuCapnhatketquatuLis(patientinfor.FirstOrDefault().Split('|')[2],
                                                                  string.Join(",", lstmachidinh.ToArray())).GetDataSet().Tables[0];

                        if (dtData != null && dtData.Rows.Count > 0)
                        {
                            using (var scope = new TransactionScope())
                            {
                                using (var dbscope = new SharedDbConnectionScope())
                                {
                                    MyLog.Trace(string.Format("Number of DataRow:={0}", dtData.Rows.Count));
                                    string ma_chidinh = "";
                                    int    idx        = 0;
                                    foreach (string line in lstLines)
                                    {
                                        if (line.StartsWith("O")) //Order
                                        {
                                            ma_chidinh = line.Split('|')[2];
                                        }
                                        if (line.StartsWith("R")) //Result
                                        {
                                            idx++;
                                            MyLog.Trace(string.Format("Begin Analysing Line {0}...", idx));
                                            string[] arrValues     = line.Split('|');
                                            string   ma_xetnghiem  = arrValues[2].Replace("^", "");
                                            string   ketqua        = arrValues[3];
                                            string   dvt           = arrValues[4];
                                            string   ngaytraketqua = arrValues[12];
                                            MyLog.Trace(
                                                string.Format(
                                                    "Line Data-->ma_chidinh={0} ma_xetnghiem={1}, ketqua={2}, DVT={3},ngaytraketqua={4} ",
                                                    ma_chidinh, ma_xetnghiem, ketqua, dvt, ngaytraketqua));
                                            DataRow[] arrCt =
                                                dtData.Select("ma_xetnghiem='" + ma_xetnghiem + "' AND ma_chidinh='" +
                                                              ma_chidinh + "'");

                                            if (arrCt.Length > 0)
                                            {
                                                MyLog.Trace(
                                                    string.Format(
                                                        "Row Data-->ma_chidinh={0} ma_xetnghiem={1}, id_chidinh={2}, id_chitietchidinh={3},id_chitietdichvu={4} ",
                                                        arrCt[0]["ma_chidinh"],
                                                        arrCt[0]["ma_xetnghiem"], arrCt[0]["id_chidinh"],
                                                        arrCt[0]["id_chitietchidinh"], arrCt[0]["id_chitietdichvu"]));
                                                //Nếu không có chi tiết thì update vào cả bảng chỉ định cận lâm sàng chi tiết

                                                KcbChidinhclsChitiet objChitiet =
                                                    KcbChidinhclsChitiet.FetchByID(
                                                        Utility.Int64Dbnull(arrCt[0]["id_chitietchidinh"]));
                                                if (objChitiet != null)
                                                {
                                                    if (
                                                        !Utility.Byte2Bool(Utility.ByteDbnull(arrCt[0]["co_chitiet"], 0)))
                                                    {
                                                        objChitiet.KetQua = ketqua;
                                                    }
                                                    objChitiet.IsNew     = false;
                                                    objChitiet.TrangThai = 4;
                                                    objChitiet.MarkOld();
                                                    objChitiet.Save();
                                                }
                                                var kq = new KcbKetquaCl();
                                                kq = new Select().From(KcbKetquaCl.Schema)
                                                     .Where(KcbKetquaCl.Columns.IdChidinh)
                                                     .IsEqualTo(Utility.Int64Dbnull(arrCt[0]["id_chidinh"]))
                                                     .And(KcbKetquaCl.Columns.IdChitietchidinh)
                                                     .IsEqualTo(Utility.Int64Dbnull(arrCt[0]["id_chitietchidinh"]))
                                                     .And(KcbKetquaCl.Columns.IdDichvuchitiet)
                                                     .IsEqualTo(Utility.Int64Dbnull(arrCt[0]["id_chitietdichvu"]))
                                                     .ExecuteSingle <KcbKetquaCl>();
                                                if (kq == null)
                                                {
                                                    MyLog.Trace(
                                                        string.Format("ma_xetnghiem={0}-->insert into KcbKetquaCl",
                                                                      ma_xetnghiem));
                                                    kq       = new KcbKetquaCl();
                                                    kq.IsNew = true;
                                                }
                                                else
                                                {
                                                    MyLog.Trace(
                                                        string.Format("ma_xetnghiem={0}-->updated from KcbKetquaCl",
                                                                      ma_xetnghiem));
                                                    kq.IsNew = false;
                                                    kq.MarkOld();
                                                }
                                                DmucDichvuclsChitiet objDvuchitiet =
                                                    DmucDichvuclsChitiet.FetchByID(
                                                        Utility.Int64Dbnull(arrCt[0]["id_chitietdichvu"]));
                                                if (objDvuchitiet != null)
                                                {
                                                    kq.TenThongso = objDvuchitiet.TenChitietdichvu;
                                                }
                                                kq.IdChidinh        = Utility.Int64Dbnull(arrCt[0]["id_chidinh"]);
                                                kq.IdChitietchidinh = Utility.Int64Dbnull(arrCt[0]["id_chitietchidinh"]);
                                                kq.IdDichvu         = Utility.Int32Dbnull(arrCt[0]["id_dichvu"]);
                                                kq.IdDichvuchitiet  = Utility.Int32Dbnull(arrCt[0]["id_chitietdichvu"]);
                                                kq.IdBenhnhan       = Utility.Int64Dbnull(arrCt[0]["id_benhnhan"]);
                                                kq.MaLuotkham       = Utility.sDbnull(arrCt[0]["ma_luotkham"]);
                                                kq.MaChidinh        = Utility.sDbnull(arrCt[0]["ma_chidinh"]);
                                                kq.MaBenhpham       = Utility.sDbnull(arrCt[0]["ma_chidinh"]);
                                                kq.IdLab            = -1;
                                                kq.IdChitietLab     = -1;
                                                kq.Barcode          = "";
                                                kq.SttIn            = 0;
                                                kq.KetQua           = ketqua;
                                                kq.BtNam            = "";
                                                kq.BtNu             = "";
                                                kq.TenDonvitinh     = "";
                                                kq.TenThongso       = "";
                                                kq.TenKq            = "";
                                                kq.LoaiKq           = 0;
                                                kq.ChophepHienthi   = 1;
                                                kq.ChophepIn        = 1;
                                                kq.MotaThem         = "";
                                                kq.NguoiTao         = "WIN_SERVICE";
                                                kq.NgayTao          = DateTime.Now;
                                                kq.NguoiSua         = "WIN_SERVICE";
                                                kq.NgaySua          = DateTime.Now;
                                                kq.TrangThai        = 4;
                                                kq.NgayXacnhan      = DateTime.Now;
                                                kq.NguoiXacnhan     = "WIN_SERVICE";
                                                kq.NguoiXacnhan     = "WIN_SERVICE";
                                                kq.Save();
                                                //lstKq.Add(kq);
                                            }
                                            else
                                            {
                                                isOK = false;
                                                MyLog.Error(
                                                    string.Format(
                                                        "No data found with ma_xetnghiem={0}.Please check again",
                                                        ma_xetnghiem));
                                            }
                                        }
                                    }
                                    //lstKq.SaveAll();
                                    isOK = true;
                                }
                                scope.Complete();
                            }
                        }
                        else
                        {
                            isOK = false;
                            MyLog.Error(string.Format("Could not get Data from HIS with PID {0} and AssignCode {1}",
                                                      patientinfor.FirstOrDefault().Split('|')[3], string.Join(",", lstmachidinh.ToArray())));
                        }
                    }
                    else //Invalid file structure
                    {
                        isOK = false;
                        MyLog.Error(
                            string.Format(
                                "FileFormat is not valid(No Patient or Order tags found in this file). Pls check result file again!"));
                    }
                    if (isOK)
                    {
                        string newDestinationFolder =
                            Utility.FixedFolder(Utility.Laygiatrithamsohethong("ASTM_BACKUP_FOLDER",
                                                                               @"\\192.168.1.254\Backup", false));
                        newDestinationFolder += Path.GetFileName(fullpath);
                        string errMsg = Utility.MoveFile(fullpath, newDestinationFolder);
                        if (Utility.DoTrim(errMsg) == "")
                        {
                            MyLog.Trace(string.Format("Move file from {0} to {1} succedded", fullpath,
                                                      newDestinationFolder));
                        }
                        else
                        {
                            MyLog.Error(string.Format("Move file from {0} to {1} error-->{2}", fullpath,
                                                      newDestinationFolder, errMsg));
                        }
                    }
                    MyLog.Trace(string.Format("------------------Finish Analysing file {0}------------------", fullpath));
                }
            }
            catch (Exception ex)
            {
                MyLog.Error(string.Format("StartAnalysisFile.Exception-->{0}", ex.Message));
            }
        }
Пример #10
0
        /// <summary>
        /// hàm thực hienj việc tính phâm trăm bảo hiểm
        /// </summary>
        /// <param name="objAssignDetail"></param>
        /// <param name="PTramBHYT"></param>
        public static void GB_TinhPhtramBHYT(KcbChidinhclsChitiet objAssignDetail, KcbLuotkham objLuotkham, decimal PTramBHYT)
        {
            byte    TrangthaiBhyt = 1;
            decimal BHYT_PTRAM_TRAITUYENNOITRU = Utility.DecimaltoDbnull(THU_VIEN_CHUNG.Laygiatrithamsohethong("BHYT_PTRAM_TRAITUYENNOITRU", "0", false), 0m);
            bool    b_ExistPtramBHYT           = false;

            if (!THU_VIEN_CHUNG.IsBaoHiem(objLuotkham.IdLoaidoituongKcb.Value))//(objLuotkham.MaDoituongKcb == "DV")//Tự túc
            {
                TrangthaiBhyt         = (byte)0;
                objAssignDetail.TuTuc = 0;
            }
            else
            {
                TrangthaiBhyt = (byte)(globalVariables.gv_blnApdungChedoDuyetBHYT ? 0 : 1);
            }
            if (Utility.Int32Dbnull(objAssignDetail.TrangthaiHuy, -1) == -1)
            {
                objAssignDetail.TrangthaiHuy = 0;
            }
            DmucDichvuclsChitiet obServiceDetail =
                DmucDichvuclsChitiet.FetchByID(Utility.Int32Dbnull(objAssignDetail.IdChitietchidinh));

            if (obServiceDetail != null)
            {
                objAssignDetail.GiaDanhmuc = Utility.DecimaltoDbnull(obServiceDetail.DonGia);
            }
            objAssignDetail.PtramBhyt     = PTramBHYT;
            objAssignDetail.PtramBhytGoc  = objLuotkham.PtramBhytGoc;
            objAssignDetail.LoaiChietkhau = 0;
            objAssignDetail.TrangthaiBhyt = TrangthaiBhyt;
            objAssignDetail.IdLoaichidinh = 0;

            if (Utility.Int32Dbnull(objAssignDetail.TuTuc, 0) == 1)
            {
                objAssignDetail.BhytChitra  = 0;
                objAssignDetail.BnhanChitra = Utility.DecimaltoDbnull(objAssignDetail.DonGia, 0);
                objAssignDetail.PtramBhyt   = 0;
            }
            else
            {
                PtramBHYTDacBiet(objAssignDetail, objLuotkham, 2, ref b_ExistPtramBHYT);
                if (b_ExistPtramBHYT)
                {
                    objAssignDetail.BhytChitra = Utility.DecimaltoDbnull(objAssignDetail.DonGia) *
                                                 Utility.DecimaltoDbnull(objAssignDetail.PtramBhyt) / 100;
                    objAssignDetail.BnhanChitra = Utility.DecimaltoDbnull(objAssignDetail.DonGia, 0) -
                                                  Utility.DecimaltoDbnull(objAssignDetail.BhytChitra);
                }
                else
                {
                    PTramBHYT = Utility.DecimaltoDbnull(objLuotkham.PtramBhyt);
                    decimal BHCT = 0m;
                    if (objLuotkham.DungTuyen == 1)
                    {
                        BHCT = Utility.DecimaltoDbnull(objAssignDetail.DonGia, 0) * (Utility.DecimaltoDbnull(objLuotkham.PtramBhyt, 0) / 100);
                    }
                    else
                    {
                        if (objLuotkham.TrangthaiNoitru <= 0)
                        {
                            BHCT = Utility.DecimaltoDbnull(objAssignDetail.DonGia, 0) * (Utility.DecimaltoDbnull(objLuotkham.PtramBhyt, 0) / 100);
                        }
                        else//Nội trú cần tính=đơn giá * % đầu thẻ * % tuyến
                        {
                            BHCT = Utility.DecimaltoDbnull(objAssignDetail.DonGia.Value, 0) * (Utility.DecimaltoDbnull(objLuotkham.PtramBhytGoc, 0) / 100) * (BHYT_PTRAM_TRAITUYENNOITRU / 100);
                        }
                    }
                    decimal BNCT =
                        Utility.DecimaltoDbnull(objAssignDetail.DonGia, 0) -
                        BHCT;
                    objAssignDetail.BhytChitra  = BHCT;
                    objAssignDetail.BnhanChitra = BNCT;
                    //objAssignDetail.BhytChitra = Utility.DecimaltoDbnull(objAssignDetail.DonGia) *
                    //                     Utility.DecimaltoDbnull(PTramBHYT) / 100;
                }
            }
        }