Esempio n. 1
0
        /// <summary>
        /// hàm thực hiện việc tính phần trăm của bảo hiểm y tế của thuốc
        /// </summary>
        /// <param name="objPatientExam"></param>
        public static void TinhPtramBHYTForThuoc(KcbLuotkham objPatientExam)
        {
            SqlQuery sqlQuery = new Select().From(KcbDonthuocChitiet.Schema)
                                .Where(KcbDonthuocChitiet.Columns.IdDonthuoc).In(
                new Select(KcbDonthuoc.Columns.IdDonthuoc).From(KcbDonthuoc.Schema).Where(
                    KcbDonthuoc.Columns.MaLuotkham).IsEqualTo(
                    objPatientExam.MaLuotkham).And(KcbDonthuoc.Columns.IdBenhnhan).IsEqualTo(
                    objPatientExam.IdBenhnhan).And(KcbDonthuoc.Columns.Noitru).IsEqualTo(1));
            KcbDonthuocChitietCollection objPresDetailCollection = sqlQuery.ExecuteAsCollection <KcbDonthuocChitietCollection>();

            foreach (KcbDonthuocChitiet objPresDetail in objPresDetailCollection)
            {
                decimal PtramBHYT = Utility.DecimaltoDbnull(objPatientExam.PtramBhyt, 0);
                TinhGiaThuoc.GB_TinhPhtramBHYT(objPresDetail, PtramBHYT);
                //if (objPatientExam.MaDoiTuong == "BHYT")
                //{
                //    objPresDetail.PhuThu = 0;
                //}
                new Update(KcbDonthuocChitiet.Schema)

                .Set(KcbDonthuocChitiet.Columns.DonGia).EqualTo(objPresDetail.DonGia)
                .Set(KcbDonthuocChitiet.Columns.BnhanChitra).EqualTo(objPresDetail.BnhanChitra)
                .Set(KcbDonthuocChitiet.Columns.BhytChitra).EqualTo(objPresDetail.BhytChitra)
                .Set(KcbDonthuocChitiet.Columns.PhuThu).EqualTo(objPresDetail.PhuThu)
                .Where(KcbDonthuocChitiet.Columns.IdChitietdonthuoc).IsEqualTo(objPresDetail.IdChitietdonthuoc).Execute();
            }
        }
 public KcbDonthuocChitietCollection FetchAll()
 {
     KcbDonthuocChitietCollection coll = new KcbDonthuocChitietCollection();
     Query qry = new Query(KcbDonthuocChitiet.Schema);
     coll.LoadAndCloseReader(qry.ExecuteReader());
     return coll;
 }
        public KcbDonthuocChitietCollection FetchByQuery(Query qry)
        {
            KcbDonthuocChitietCollection coll = new KcbDonthuocChitietCollection();

            coll.LoadAndCloseReader(qry.ExecuteReader());
            return(coll);
        }
        public KcbDonthuocChitietCollection FetchAll()
        {
            KcbDonthuocChitietCollection coll = new KcbDonthuocChitietCollection();
            Query qry = new Query(KcbDonthuocChitiet.Schema);

            coll.LoadAndCloseReader(qry.ExecuteReader());
            return(coll);
        }
Esempio n. 5
0
        public static bool InValiKiemTraDonThuoc(KcbDonthuocChitietCollection lstChitiet,byte noitru)
        {
            try
            {
                foreach (KcbDonthuocChitiet item in lstChitiet)
                {

                    int SoLuongTon = CommonLoadDuoc.SoLuongTonTrongKho((long)item.IdDonthuoc, Utility.Int32Dbnull(item.IdKho, -1), item.IdThuoc, Utility.Int64Dbnull(item.IdThuockho, -1),0, noitru);//Ko cần kiểm tra chờ xác nhận
                    if (SoLuongTon < item.SoLuong)
                    {
                        Utility.ShowMsg(string.Format("Bạn không thể xác nhận đơn thuốc, Vì thuốc :{0} số lượng tồn hiện tại trong kho không đủ\n Mời bạn xem lại số lượng", item.IdThuoc));
                        return false;
                    }
                }

                return true;
            }
            catch
            {
                return false;
            }
        }
 public KcbDonthuocChitietCollection FetchByQuery(Query qry)
 {
     KcbDonthuocChitietCollection coll = new KcbDonthuocChitietCollection();
     coll.LoadAndCloseReader(qry.ExecuteReader());
     return coll;
 }
 public KcbDonthuocChitietCollection FetchByID(object IdChitietdonthuoc)
 {
     KcbDonthuocChitietCollection coll = new KcbDonthuocChitietCollection().Where("id_chitietdonthuoc", IdChitietdonthuoc).Load();
     return coll;
 }
        public KcbDonthuocChitietCollection FetchByID(object IdChitietdonthuoc)
        {
            KcbDonthuocChitietCollection coll = new KcbDonthuocChitietCollection().Where("id_chitietdonthuoc", IdChitietdonthuoc).Load();

            return(coll);
        }
        public static ActionResult CapnhatLichsuDoituongKCB(List<KcbLichsuDoituongKcb> lstLichsu,List<long> lstDelete)
        {
            try
            {
                ActionResult _ActionResult = ActionResult.Success;

                using (var Scope = new TransactionScope())
                {
                    using (var dbScope = new SharedDbConnectionScope())
                    {
                        KcbLichsuDoituongKcb _item=lstLichsu[0];

                        List<long> lstID = new List<long>();
                        KcbDangkyKcbCollection lstDangkyKCB = new Select().From(KcbDangkyKcb.Schema)
                            .Where(KcbDangkyKcb.Columns.IdBenhnhan).IsEqualTo(_item.IdBenhnhan)
                            .And(KcbDangkyKcb.Columns.MaLuotkham).IsEqualTo(_item.MaLuotkham)
                            .ExecuteAsCollection<KcbDangkyKcbCollection>();

                        NoitruPhanbuonggiuongCollection lstbuonggiuong=new Select().From(NoitruPhanbuonggiuong.Schema)
                            .Where(NoitruPhanbuonggiuong.Columns.IdBenhnhan).IsEqualTo(_item.IdBenhnhan)
                            .And(NoitruPhanbuonggiuong.Columns.MaLuotkham).IsEqualTo(_item.MaLuotkham)
                            .ExecuteAsCollection<NoitruPhanbuonggiuongCollection>();

                        KcbDonthuocCollection lstDonthuoc = new Select().From(KcbDonthuoc.Schema)
                            .Where(KcbDonthuoc.Columns.IdBenhnhan).IsEqualTo(_item.IdBenhnhan)
                            .And(KcbDonthuoc.Columns.MaLuotkham).IsEqualTo(_item.MaLuotkham)
                            .ExecuteAsCollection<KcbDonthuocCollection>();
                        lstID = lstDonthuoc.Select(c => c.IdDonthuoc).ToList<long>();
                        KcbDonthuocChitietCollection lstDonthuocChitiet = new KcbDonthuocChitietCollection();
                        if (lstID.Count > 0)
                            lstDonthuocChitiet = new Select().From(KcbDonthuocChitiet.Schema)
                                 .Where(KcbDonthuocChitiet.Columns.IdDonthuoc).In(lstID)
                                 .ExecuteAsCollection<KcbDonthuocChitietCollection>();

                        KcbChidinhclCollection lstChidinh = new Select().From(KcbChidinhcl.Schema)
                            .Where(KcbChidinhcl.Columns.IdBenhnhan).IsEqualTo(_item.IdBenhnhan)
                            .And(KcbChidinhcl.Columns.MaLuotkham).IsEqualTo(_item.MaLuotkham)
                            .ExecuteAsCollection<KcbChidinhclCollection>();
                        lstID = lstChidinh.Select(c => c.IdChidinh).ToList<long>();

                        KcbChidinhclsChitietCollection lstChidinhChitiet = new KcbChidinhclsChitietCollection();
                        if (lstID.Count > 0)
                            lstChidinhChitiet = new Select().From(KcbChidinhclsChitiet.Schema)
                           .Where(KcbChidinhclsChitiet.Columns.IdChidinh).In(lstID)
                           .ExecuteAsCollection<KcbChidinhclsChitietCollection>();
                        if (lstDelete.Count > 0)
                            new Delete().From(KcbLichsuDoituongKcb.Schema).Where(KcbLichsuDoituongKcb.Columns.IdLichsuDoituongKcb).In(lstDelete).Execute();
                        foreach (KcbLichsuDoituongKcb objLichsu in lstLichsu)
                        {

                            //Gán thông tin nội trú
                            if (objLichsu.TrangthaiNoitru > 0)
                            {
                                var q = from p in lstbuonggiuong
                                        where Utility.Int32Dbnull(Utility.GetYYYYMMDD(p.NgayVaokhoa), 0) >= Utility.Int32Dbnull(Utility.GetYYYYMMDD(objLichsu.NgayHieuluc), 0)
                                        select p;
                                if (q.Any())
                                {
                                    objLichsu.IdKhoanoitru = q.FirstOrDefault().IdKhoanoitru;
                                    objLichsu.IdBuong = q.FirstOrDefault().IdBuong;
                                    objLichsu.IdGiuong = q.FirstOrDefault().IdGiuong;
                                    objLichsu.IdRavien = q.FirstOrDefault().IdKhoanoitru;

                                }
                            }
                            objLichsu.Save();
                           _ActionResult= CapnhatChiphiKCB(objLichsu, lstDangkyKCB.ToList<KcbDangkyKcb>());
                            if (_ActionResult == ActionResult.Cancel)
                                return _ActionResult;
                            List<KcbChidinhcl> _chidinhCLS = (from p in lstChidinh
                                                              where Utility.Int32Dbnull(Utility.GetYYYYMMDD(p.NgayChidinh), 0) >= Utility.Int32Dbnull(Utility.GetYYYYMMDD(objLichsu.NgayHieuluc), 0)
                                                              && Utility.Int32Dbnull(Utility.GetYYYYMMDD(p.NgayChidinh), 0) <= Utility.Int32Dbnull(Utility.GetYYYYMMDD(objLichsu.NgayHethieuluc,new DateTime(2099,1,1)), 0)
                                                              select p).ToList<KcbChidinhcl>();
                            lstID = _chidinhCLS.Select(c => c.IdChidinh).ToList<long>();

                            List<KcbChidinhclsChitiet> _chidinhCLsChitiet = (from p in lstChidinhChitiet
                                                                             where lstID.Contains(p.IdChidinh)
                                                                             select p).ToList<KcbChidinhclsChitiet>();

                          _ActionResult=  CapnhatChiphiCLS(objLichsu, _chidinhCLS, _chidinhCLsChitiet);
                            if (_ActionResult == ActionResult.Cancel)
                                return _ActionResult;
                            List<KcbDonthuoc> _donthuoc = (from p in lstDonthuoc
                                                           where Utility.Int32Dbnull(Utility.GetYYYYMMDD(p.NgayKedon), 0) >= Utility.Int32Dbnull(Utility.GetYYYYMMDD(objLichsu.NgayHieuluc), 0)
                                                             && Utility.Int32Dbnull(Utility.GetYYYYMMDD(p.NgayKedon), 0) <= Utility.Int32Dbnull(Utility.GetYYYYMMDD(objLichsu.NgayHethieuluc, new DateTime(2099, 1, 1)), 0)
                                                           select p).ToList<KcbDonthuoc>();
                            lstID = _donthuoc.Select(c => c.IdDonthuoc).ToList<long>();

                            List<KcbDonthuocChitiet> _donthuocChitiet = (from p in lstDonthuocChitiet
                                                                         where lstID.Contains(p.IdDonthuoc)
                                                                         select p).ToList<KcbDonthuocChitiet>();

                           _ActionResult= CapnhatChiphiThuoc(objLichsu, _donthuoc, _donthuocChitiet);
                            if (_ActionResult == ActionResult.Cancel)
                                return _ActionResult;
                            List<NoitruPhanbuonggiuong> _Bg = (from p in lstbuonggiuong
                                                                     where p.NgayVaokhoa >= objLichsu.NgayHieuluc && p.NgayVaokhoa <= objLichsu.NgayHethieuluc
                                                                     select p).ToList<NoitruPhanbuonggiuong>();
                          _ActionResult=  CapnhatBuonggiuong(objLichsu, _Bg);
                            if (_ActionResult == ActionResult.Cancel)
                                return _ActionResult;

                        }
                        DateTime maxDate = lstLichsu.Max(c => c.NgayHieuluc);
                        KcbLichsuDoituongKcb objMax = lstLichsu.Where(c => c.NgayHieuluc == maxDate).FirstOrDefault();
                        if (objMax != null)
                        {
                            new Update(KcbLuotkham.Schema)
                                                      .Set(KcbLuotkham.Columns.MatheBhyt).EqualTo(objMax.MatheBhyt)
                                                      .Set(KcbLuotkham.Columns.MaNoicapBhyt).EqualTo(objMax.MaNoicapBhyt)
                                                      .Set(KcbLuotkham.Columns.MaQuyenloi).EqualTo(objMax.MaQuyenloi)
                                                      .Set(KcbLuotkham.Columns.NgaybatdauBhyt).EqualTo(objMax.NgaybatdauBhyt)
                                                      .Set(KcbLuotkham.Columns.NgayketthucBhyt).EqualTo(objMax.NgayketthucBhyt)
                                                      .Set(KcbLuotkham.Columns.NoicapBhyt).EqualTo(objMax.NoicapBhyt)
                                                      .Set(KcbLuotkham.Columns.IdDoituongKcb).EqualTo(objMax.IdDoituongKcb)
                                                      .Set(KcbLuotkham.Columns.MaKcbbd).EqualTo(objMax.MaKcbbd)
                                                      .Set(KcbLuotkham.Columns.NoiDongtrusoKcbbd).EqualTo(objMax.NoiDongtrusoKcbbd)
                                                      .Set(KcbLuotkham.Columns.MaDoituongBhyt).EqualTo(objMax.MaDoituongBhyt)
                                                      .Set(KcbLuotkham.Columns.DungTuyen).EqualTo(objMax.DungTuyen)
                                                      .Set(KcbLuotkham.Columns.MaDoituongKcb).EqualTo(objMax.MaDoituongKcb)
                                                      .Set(KcbLuotkham.Columns.NguoiSua).EqualTo(globalVariables.UserName)
                                                      .Set(KcbLuotkham.Columns.NgaySua).EqualTo(globalVariables.SysDate)
                                                      .Set(KcbLuotkham.Columns.MadtuongSinhsong).EqualTo(objMax.MadtuongSinhsong)
                                                      .Set(KcbLuotkham.Columns.GiayBhyt).EqualTo(objMax.GiayBhyt)
                                                      .Set(KcbLuotkham.Columns.PtramBhyt).EqualTo(objMax.PtramBhyt)
                                                      .Set(KcbLuotkham.Columns.PtramBhytGoc).EqualTo(objMax.PtramBhytGoc)
                                                      .Set(KcbLuotkham.Columns.DiachiBhyt).EqualTo(objMax.DiachiBhyt)
                                                      .Set(KcbLuotkham.Columns.IdLichsuDoituongKcb).EqualTo(objMax.IdLichsuDoituongKcb)

                                                      .Where(KcbLuotkham.Columns.MaLuotkham).IsEqualTo(objMax.MaLuotkham)
                                                      .And(KcbLuotkham.Columns.IdBenhnhan).IsEqualTo(objMax.IdBenhnhan)
                                                      .Execute();

                        }
                    }
                    Scope.Complete();
                    return ActionResult.Success;
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg("Lỗi khi chuyển đối tượng:\n" + ex.Message);
                return ActionResult.Exception;
            }
        }