/// <summary> /// hàm thực hiện việc tính phàn trăm bảo hiểm y tế cho cận lâm sàng /// </summary> /// <param name="objPatientExam"></param> public static void TinhPtramBHYTForCLS(KcbLuotkham objPatientExam) { 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( objPatientExam.MaLuotkham).And(KcbChidinhcl.Columns.IdBenhnhan).IsEqualTo( objPatientExam.IdBenhnhan).And(KcbChidinhcl.Columns.Noitru).IsEqualTo(1)); KcbChidinhclsChitietCollection objAssignDetailCollection = sqlQuery.ExecuteAsCollection <KcbChidinhclsChitietCollection>(); decimal PtramBHYT = Utility.DecimaltoDbnull(objPatientExam.PtramBhyt); foreach (KcbChidinhclsChitiet objAssignDetail in objAssignDetailCollection) { TinhCLS.GB_TinhPhtramBHYT(objAssignDetail, objPatientExam, PtramBHYT); new Update(KcbChidinhclsChitiet.Schema) .Set(KcbChidinhclsChitiet.Columns.NgaySua).EqualTo(globalVariables.SysDate) .Set(KcbChidinhclsChitiet.Columns.NguoiSua).EqualTo(globalVariables.UserName) .Set(KcbChidinhclsChitiet.Columns.PtramBhyt).EqualTo(objAssignDetail.PtramBhyt) .Set(KcbChidinhclsChitiet.Columns.BnhanChitra).EqualTo(objAssignDetail.BnhanChitra) .Set(KcbChidinhclsChitiet.Columns.BhytChitra).EqualTo(objAssignDetail.BhytChitra) .Set(KcbChidinhclsChitiet.Columns.PhuThu).EqualTo(objAssignDetail.PhuThu) .Where(KcbChidinhclsChitiet.Columns.IdChitietchidinh).IsEqualTo(objAssignDetail.IdChitietchidinh).Execute(); } }
/// <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); } }
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); } }