예제 #1
0
        private static ActionResult CapnhatChiphiKCB(KcbLuotkham objLuotkham)
        {
            using (var Scope = new TransactionScope())
            {
                KcbDangkyKcbCollection objRegExamCollection =
                    new Select().From(KcbDangkyKcb.Schema).Where(KcbDangkyKcb.Columns.MaLuotkham).IsEqualTo(
                        objLuotkham.MaLuotkham).And(KcbDangkyKcb.Columns.IdBenhnhan).IsEqualTo(objLuotkham.IdBenhnhan)
                        .And(KcbDangkyKcb.Columns.LaPhidichvukemtheo).IsEqualTo(0)
                        .ExecuteAsCollection<KcbDangkyKcbCollection>();
                if (objRegExamCollection.Count > 0)
                {
                    //CHUYỂN GIÁ KHÁM BỆNH VÀO PHÒNG
                    foreach (KcbDangkyKcb objRegExam in objRegExamCollection)
                    {
                        if (objRegExam.TrangthaiThanhtoan == 0)
                        {

                            DmucDichvukcb _DichvukcbCu =
                                DmucDichvukcb.FetchByID(objRegExam.IdDichvuKcb);
                            var _DichvukcbMoi =
                                new Select().From(DmucDichvukcb.Schema)
                                    .Where(DmucDichvukcb.Columns.IdKhoaphong).IsEqualTo(_DichvukcbCu.IdKhoaphong)
                                    .And(DmucDichvukcb.Columns.IdPhongkham).IsEqualTo(_DichvukcbCu.IdPhongkham)
                                         .And(DmucDichvukcb.Columns.IdKieukham).IsEqualTo(_DichvukcbCu.IdKieukham)
                                    .AndExpression(DmucDichvukcb.Columns.MaDoituongKcb).IsEqualTo(objLuotkham.MaDoituongKcb)
                                    .Or(DmucDichvukcb.Columns.MaDoituongKcb).IsEqualTo("ALL").CloseExpression()
                                    .ExecuteSingle<DmucDichvukcb>();
                            if (_DichvukcbMoi != null)
                            {
                                objRegExam.IdDichvuKcb = Utility.Int16Dbnull(_DichvukcbMoi.IdDichvukcb, -1);
                                if (Utility.Int32Dbnull(_DichvukcbMoi.TuTuc, 0) == 1)
                                    objRegExam.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
                                    objRegExam.TuTuc = 0;
                                objRegExam.TenDichvuKcb = _DichvukcbMoi.TenDichvukcb;
                                objRegExam.DonGia = Utility.DecimaltoDbnull(_DichvukcbMoi.DonGia);
                                objRegExam.PhuThu = !Utility.Byte2Bool(objLuotkham.DungTuyen)
                                                   ? Utility.DecimaltoDbnull(_DichvukcbMoi.PhuthuDungtuyen)
                                                   : Utility.DecimaltoDbnull(_DichvukcbMoi.PhuthuTraituyen);
                                objRegExam.PtramBhyt = objLuotkham.PtramBhyt;//% BHYT ngoại trú
                                if (Utility.Byte2Bool( objRegExam.KhamNgoaigio))
                                {
                                    objRegExam.KhamNgoaigio = 1;
                                    objRegExam.DonGia = Utility.DecimaltoDbnull(_DichvukcbMoi.DongiaNgoaigio, 0);
                                    objRegExam.PhuThu = !Utility.Byte2Bool(objLuotkham.DungTuyen) ? Utility.DecimaltoDbnull(_DichvukcbMoi.PhuthuNgoaigio, 0) : Utility.DecimaltoDbnull(_DichvukcbMoi.PhuthuDungtuyen);
                                }

                                if (Utility.Int32Dbnull(objRegExam.TuTuc, 0) == 0)
                                {
                                    objRegExam.BhytChitra = Utility.DecimaltoDbnull(objRegExam.DonGia) *
                                                           Utility.DecimaltoDbnull(objLuotkham.PtramBhyt) / 100;
                                    objRegExam.BnhanChitra = Utility.DecimaltoDbnull(objRegExam.DonGia, 0) -
                                                              Utility.DecimaltoDbnull(objRegExam.BhytChitra, 0);
                                }
                                else
                                {
                                    objRegExam.BhytChitra = 0;
                                    objRegExam.BnhanChitra = Utility.DecimaltoDbnull(objRegExam.DonGia, 0);
                                }
                            }
                        }
                        else
                        {
                            return ActionResult.Cancel;
                        }
                    }
                    objRegExamCollection.SaveAll();
                }
                Scope.Complete();
                return ActionResult.Success;
            }
        }