public ActionResult ChuyenVTTHvaogoi(long IdDonthuoc, List <long> lstchitiet, int id_goi)
        {
            try
            {
                using (var scope = new TransactionScope())
                {
                    using (var sh = new SharedDbConnectionScope())
                    {
                        //Tạo phiếu mới
                        KcbDonthuoc objnew = KcbDonthuoc.FetchByID(IdDonthuoc);
                        objnew.IsNew    = true;
                        objnew.IdGoi    = id_goi;
                        objnew.Noitru   = 1;
                        objnew.TrongGoi = 1;
                        objnew.Save();
                        new Update(KcbDonthuocChitiet.Schema)
                        .Set(KcbDonthuocChitiet.Columns.IdGoi).EqualTo(id_goi)
                        .Set(KcbDonthuocChitiet.Columns.IdDonthuoc).EqualTo(objnew.IdDonthuoc)
                        .Set(KcbDonthuocChitiet.Columns.IdDonthuocChuyengoi).EqualTo(IdDonthuoc)
                        .Set(KcbDonthuocChitiet.Columns.TrongGoi).EqualTo(1)
                        .Where(KcbDonthuocChitiet.Columns.IdChitietdonthuoc).In(lstchitiet).Execute();
                    }
                    scope.Complete();
                    return(ActionResult.Success);
                }
            }

            catch (Exception exception)
            {
                log.Error("loi trong qua trinh xoa phieu dieu tri {0}", exception.ToString());
                return(ActionResult.Error);
            }
        }
示例#2
0
        public ActionResult ThemDonThuoc(KcbLuotkham objLuotkham, KcbDonthuoc objDonthuoc, KcbDonthuocChitiet[] arrDonthuocChitiet, KcbChandoanKetluan _KcbChandoanKetluan, ref int p_intIdDonthuoc, ref Dictionary <long, long> lstChitietDonthuoc)
        {
            // Query _Query = KcbDonthuoc.CreateQuery();
            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    using (SharedDbConnectionScope sh = new SharedDbConnectionScope())
                    {
                        if (objLuotkham != null)
                        {
                            if (objDonthuoc.NgayKedon <= Convert.ToDateTime("01/01/1900"))
                            {
                                objDonthuoc.NgayKedon = globalVariables.SysDate;
                            }

                            objDonthuoc.IsNew       = true;
                            objDonthuoc.TenDonthuoc = THU_VIEN_CHUNG.TaoTenDonthuoc(objLuotkham.MaLuotkham,
                                                                                    Utility.Int32Dbnull(
                                                                                        objLuotkham.IdBenhnhan,
                                                                                        -1));

                            objDonthuoc.Save();
                            if (!Utility.Byte2Bool(objDonthuoc.Noitru))
                            {
                                CapnhatChandoan(_KcbChandoanKetluan);
                            }
                            p_intIdDonthuoc = objDonthuoc.IdDonthuoc;
                            decimal PtramBH = Utility.DecimaltoDbnull(objLuotkham.PtramBhyt, 0);

                            foreach (KcbDonthuocChitiet objDonthuocChitiet in arrDonthuocChitiet)
                            {
                                objDonthuocChitiet.IdKham     = objDonthuoc.IdKham;
                                objDonthuocChitiet.MaLuotkham = objDonthuoc.MaLuotkham;
                                objDonthuocChitiet.IdBenhnhan = objDonthuoc.IdBenhnhan;
                                objDonthuocChitiet.IdDonthuoc = objDonthuoc.IdDonthuoc;
                                ThemChitiet(objDonthuoc, objDonthuocChitiet, PtramBH, objLuotkham);
                                if (!lstChitietDonthuoc.ContainsKey(objDonthuocChitiet.IdThuockho.Value))
                                {
                                    lstChitietDonthuoc.Add(objDonthuocChitiet.IdThuockho.Value, objDonthuocChitiet.IdChitietdonthuoc);
                                }
                            }
                        }
                    }
                    scope.Complete();
                    return(ActionResult.Success);
                }
            }
            catch (Exception exception)
            {
                log.Error("Loi trong qua trinh luu don thuoc {0}", exception);
                return(ActionResult.Error);
            }
        }
示例#3
0
        public ActionResult ThemDonThuoc(KcbDanhsachBenhnhan objBenhnhan, KcbDonthuoc objDonthuoc, KcbDonthuocChitiet[] arrDonthuocChitiet, ref int p_intIdDonthuoc, ref Dictionary <long, long> lstChitietDonthuoc)
        {
            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    using (SharedDbConnectionScope sh = new SharedDbConnectionScope())
                    {
                        objBenhnhan.Save();
                        if (objBenhnhan != null)
                        {
                            if (objDonthuoc.NgayKedon <= Convert.ToDateTime("01/01/1900"))
                            {
                                objDonthuoc.NgayKedon = globalVariables.SysDate;
                            }
                            objDonthuoc.IdBenhnhan  = objBenhnhan.IdBenhnhan;
                            objDonthuoc.MaLuotkham  = "";
                            objDonthuoc.IdKham      = -1;
                            objDonthuoc.IsNew       = true;
                            objDonthuoc.TenDonthuoc = "";

                            objDonthuoc.Save();
                            p_intIdDonthuoc = objDonthuoc.IdDonthuoc;
                            decimal PtramBH = 0;

                            foreach (KcbDonthuocChitiet objDonthuocChitiet in arrDonthuocChitiet)
                            {
                                objDonthuocChitiet.IdKham     = objDonthuoc.IdKham;
                                objDonthuocChitiet.MaLuotkham = objDonthuoc.MaLuotkham;
                                objDonthuocChitiet.IdBenhnhan = objDonthuoc.IdBenhnhan;
                                objDonthuocChitiet.IdDonthuoc = objDonthuoc.IdDonthuoc;
                                objDonthuocChitiet.IsNew      = true;
                                objDonthuocChitiet.Save();
                                if (!lstChitietDonthuoc.ContainsKey(objDonthuocChitiet.IdThuockho.Value))
                                {
                                    lstChitietDonthuoc.Add(objDonthuocChitiet.IdThuockho.Value, objDonthuocChitiet.IdChitietdonthuoc);
                                }
                            }
                        }
                    }
                    scope.Complete();
                    return(ActionResult.Success);
                }
            }
            catch (Exception exception)
            {
                Utility.CatchException(exception);
                log.Error("Loi trong qua trinh luu don thuoc {0}", exception);
                return(ActionResult.Error);
            }
        }
        public ActionResult ChuyenVTTHrakhoigoi(long IdDonthuoc_source, List <long> lstId)
        {
            try
            {
                using (var scope = new TransactionScope())
                {
                    using (var sh = new SharedDbConnectionScope())
                    {
                        foreach (long _id in lstId)
                        {
                            KcbDonthuoc objKcbDonthuoc = KcbDonthuoc.FetchByID(_id);
                            if (objKcbDonthuoc == null)
                            {
                                objKcbDonthuoc          = KcbDonthuoc.FetchByID(IdDonthuoc_source);
                                objKcbDonthuoc.IdGoi    = -1;
                                objKcbDonthuoc.TrongGoi = 0;
                                objKcbDonthuoc.IsNew    = true;
                                objKcbDonthuoc.Save();
                                new Update(KcbDonthuocChitiet.Schema)
                                .Set(KcbDonthuocChitiet.Columns.IdGoi).EqualTo(-1)
                                .Set(KcbDonthuocChitiet.Columns.IdDonthuoc).EqualTo(objKcbDonthuoc.IdDonthuoc)
                                .Set(KcbDonthuocChitiet.Columns.IdDonthuocChuyengoi).EqualTo(-1)
                                .Set(KcbDonthuocChitiet.Columns.TrongGoi).EqualTo(0)
                                .Where(KcbDonthuocChitiet.Columns.IdDonthuocChuyengoi).IsEqualTo(_id).Execute();
                            }
                            else
                            {
                                new Update(KcbDonthuocChitiet.Schema)
                                .Set(KcbDonthuocChitiet.Columns.IdGoi).EqualTo(-1)
                                .Set(KcbDonthuocChitiet.Columns.IdDonthuoc).EqualTo(objKcbDonthuoc.IdDonthuoc)
                                .Set(KcbDonthuocChitiet.Columns.IdDonthuocChuyengoi).EqualTo(-1)
                                .Set(KcbDonthuocChitiet.Columns.TrongGoi).EqualTo(0)
                                .Where(KcbDonthuocChitiet.Columns.IdDonthuocChuyengoi).IsEqualTo(_id).Execute();
                            }
                        }
                    }
                    scope.Complete();
                    return(ActionResult.Success);
                }
            }

            catch (Exception exception)
            {
                log.Error("loi trong qua trinh xoa phieu dieu tri {0}", exception.ToString());
                return(ActionResult.Error);
            }
        }
示例#5
0
        public ActionResult ThemDonThuoc(KcbLuotkham objLuotkham, KcbDonthuoc objDonthuoc, KcbDonthuocChitiet[] arrDonthuocChitiet,KcbChandoanKetluan _KcbChandoanKetluan, ref int p_intIdDonthuoc, ref Dictionary<long, long> lstChitietDonthuoc)
        {
            // Query _Query = KcbDonthuoc.CreateQuery();
             try
             {
                 using (TransactionScope scope = new TransactionScope())
                 {
                     using (SharedDbConnectionScope sh = new SharedDbConnectionScope())
                     {
                         if (objLuotkham != null)
                         {
                             if (objDonthuoc.NgayKedon <= Convert.ToDateTime("01/01/1900"))
                                 objDonthuoc.NgayKedon = globalVariables.SysDate;

                             objDonthuoc.IsNew = true;
                             objDonthuoc.TenDonthuoc = THU_VIEN_CHUNG.TaoTenDonthuoc(objLuotkham.MaLuotkham,
                                                                                        Utility.Int32Dbnull(
                                                                                            objLuotkham.IdBenhnhan,
                                                                                            -1));

                             objDonthuoc.Save();
                             if (!Utility.Byte2Bool(objDonthuoc.Noitru))
                                 CapnhatChandoan(_KcbChandoanKetluan);
                             p_intIdDonthuoc = objDonthuoc.IdDonthuoc;
                             decimal PtramBH = Utility.DecimaltoDbnull(objLuotkham.PtramBhyt, 0);

                             foreach (KcbDonthuocChitiet objDonthuocChitiet in arrDonthuocChitiet)
                             {
                                 objDonthuocChitiet.IdKham = objDonthuoc.IdKham;
                                 objDonthuocChitiet.MaLuotkham = objDonthuoc.MaLuotkham;
                                 objDonthuocChitiet.IdBenhnhan = objDonthuoc.IdBenhnhan;
                                 objDonthuocChitiet.IdDonthuoc = objDonthuoc.IdDonthuoc;
                                 ThemChitiet(objDonthuoc, objDonthuocChitiet, PtramBH, objLuotkham);
                                 if (!lstChitietDonthuoc.ContainsKey(objDonthuocChitiet.IdThuockho.Value))
                                     lstChitietDonthuoc.Add(objDonthuocChitiet.IdThuockho.Value, objDonthuocChitiet.IdChitietdonthuoc);
                             }

                         }

                     }
                     scope.Complete();
                     return ActionResult.Success;
                 }
             }
             catch (Exception exception)
             {

                 log.Error("Loi trong qua trinh luu don thuoc {0}", exception);
                 return ActionResult.Error;
             }
        }
示例#6
0
        public ActionResult ThemDonThuoc(KcbDanhsachBenhnhan objBenhnhan,  KcbDonthuoc objDonthuoc, KcbDonthuocChitiet[] arrDonthuocChitiet, ref int p_intIdDonthuoc, ref Dictionary<long, long> lstChitietDonthuoc)
        {
            try
             {
                 using (TransactionScope scope = new TransactionScope())
                 {
                     using (SharedDbConnectionScope sh = new SharedDbConnectionScope())
                     {
                         objBenhnhan.Save();
                         if (objBenhnhan != null)
                         {
                             if (objDonthuoc.NgayKedon <= Convert.ToDateTime("01/01/1900"))
                                 objDonthuoc.NgayKedon = globalVariables.SysDate;
                             objDonthuoc.IdBenhnhan = objBenhnhan.IdBenhnhan;
                             objDonthuoc.MaLuotkham = "";
                             objDonthuoc.IdKham = -1;
                             objDonthuoc.IsNew = true;
                             objDonthuoc.TenDonthuoc = "";

                             objDonthuoc.Save();
                             p_intIdDonthuoc = objDonthuoc.IdDonthuoc;
                             decimal PtramBH = 0;

                             foreach (KcbDonthuocChitiet objDonthuocChitiet in arrDonthuocChitiet)
                             {
                                 objDonthuocChitiet.IdKham = objDonthuoc.IdKham;
                                 objDonthuocChitiet.MaLuotkham = objDonthuoc.MaLuotkham;
                                 objDonthuocChitiet.IdBenhnhan = objDonthuoc.IdBenhnhan;
                                 objDonthuocChitiet.IdDonthuoc = objDonthuoc.IdDonthuoc;
                                 objDonthuocChitiet.IsNew = true;
                                 objDonthuocChitiet.Save();
                                 if (!lstChitietDonthuoc.ContainsKey(objDonthuocChitiet.IdThuockho.Value))
                                     lstChitietDonthuoc.Add(objDonthuocChitiet.IdThuockho.Value, objDonthuocChitiet.IdChitietdonthuoc);
                             }

                         }

                     }
                     scope.Complete();
                     return ActionResult.Success;
                 }
             }
             catch (Exception exception)
             {
                 Utility.CatchException(exception);
                 log.Error("Loi trong qua trinh luu don thuoc {0}", exception);
                 return ActionResult.Error;
             }
        }
        public void Insert(int? IdPhieudieutri,int? IdKhoadieutri,int? IdDonthuocthaythe,long? IdKham,long? IdBenhnhan,string MaLuotkham,DateTime NgayKedon,short? IdBacsiChidinh,byte TrangThai,byte? TthaiTonghop,byte TrangthaiThanhtoan,DateTime? NgayThanhtoan,int? IdGoi,byte? TrongGoi,string NguoiTao,DateTime NgayTao,string NguoiSua,DateTime? NgaySua,string MotaThem,string TenDonthuoc,string MaDoituongKcb,byte? Noitru,byte? KieuDonthuoc,short? IdPhongkham,long? IdBuongGiuong,short? IdBuongNoitru,short? IdGiuongNoitru,string TenKieudonthuoc,string LoidanBacsi,DateTime? NgayTaikham,string TaiKham,string MaKhoaThuchien,byte? DonthuocTaiquay,DateTime? NgayCapphat,string KieuThuocvattu,DateTime? NgayChot,int? IdChot,DateTime? NgayHuychot,string NguoiHuychot,string LydoHuychot,DateTime? NgayHuyxacnhan,string NguoiHuyxacnhan,string LydoHuyxacnhan,DateTime? NgayXacnhan,string NguoiXacnhan,string IpMaytao,string IpMaysua,string TenMaytao,string TenMaysua)
        {
            KcbDonthuoc item = new KcbDonthuoc();

            item.IdPhieudieutri = IdPhieudieutri;

            item.IdKhoadieutri = IdKhoadieutri;

            item.IdDonthuocthaythe = IdDonthuocthaythe;

            item.IdKham = IdKham;

            item.IdBenhnhan = IdBenhnhan;

            item.MaLuotkham = MaLuotkham;

            item.NgayKedon = NgayKedon;

            item.IdBacsiChidinh = IdBacsiChidinh;

            item.TrangThai = TrangThai;

            item.TthaiTonghop = TthaiTonghop;

            item.TrangthaiThanhtoan = TrangthaiThanhtoan;

            item.NgayThanhtoan = NgayThanhtoan;

            item.IdGoi = IdGoi;

            item.TrongGoi = TrongGoi;

            item.NguoiTao = NguoiTao;

            item.NgayTao = NgayTao;

            item.NguoiSua = NguoiSua;

            item.NgaySua = NgaySua;

            item.MotaThem = MotaThem;

            item.TenDonthuoc = TenDonthuoc;

            item.MaDoituongKcb = MaDoituongKcb;

            item.Noitru = Noitru;

            item.KieuDonthuoc = KieuDonthuoc;

            item.IdPhongkham = IdPhongkham;

            item.IdBuongGiuong = IdBuongGiuong;

            item.IdBuongNoitru = IdBuongNoitru;

            item.IdGiuongNoitru = IdGiuongNoitru;

            item.TenKieudonthuoc = TenKieudonthuoc;

            item.LoidanBacsi = LoidanBacsi;

            item.NgayTaikham = NgayTaikham;

            item.TaiKham = TaiKham;

            item.MaKhoaThuchien = MaKhoaThuchien;

            item.DonthuocTaiquay = DonthuocTaiquay;

            item.NgayCapphat = NgayCapphat;

            item.KieuThuocvattu = KieuThuocvattu;

            item.NgayChot = NgayChot;

            item.IdChot = IdChot;

            item.NgayHuychot = NgayHuychot;

            item.NguoiHuychot = NguoiHuychot;

            item.LydoHuychot = LydoHuychot;

            item.NgayHuyxacnhan = NgayHuyxacnhan;

            item.NguoiHuyxacnhan = NguoiHuyxacnhan;

            item.LydoHuyxacnhan = LydoHuyxacnhan;

            item.NgayXacnhan = NgayXacnhan;

            item.NguoiXacnhan = NguoiXacnhan;

            item.IpMaytao = IpMaytao;

            item.IpMaysua = IpMaysua;

            item.TenMaytao = TenMaytao;

            item.TenMaysua = TenMaysua;

            item.Save(UserName);
        }
        public ActionResult SaoChepDonThuocTheoPhieuDieuTriFullTransaction(KcbDonthuoc objDonthuoc, NoitruPhieudieutri objTreatment,KcbDonthuocChitiet[] arrChitietdonthuoc)
        {
            try
            {
                using (var scope = new TransactionScope())
                {
                    using (var dbscope = new SharedDbConnectionScope())
                    {

                        objDonthuoc.IdPhieudieutri = objTreatment.IdPhieudieutri;
                        objDonthuoc.IdDonthuocthaythe = -1;
                        objDonthuoc.IdKham = objTreatment.IdPhieudieutri;
                        objDonthuoc.IdBacsiChidinh = objTreatment.IdBacsi;
                        objDonthuoc.NgaySua = null;
                        objDonthuoc.NguoiSua = null;
                        objDonthuoc.NgayKedon = Convert.ToDateTime(objTreatment.NgayDieutri);
                        objDonthuoc.Noitru = 1;
                        NoitruPhanbuonggiuong objPatientDept = NoitruPhanbuonggiuong.FetchByID(objTreatment.IdBuongGiuong);
                        if (objPatientDept != null)
                        {
                            objDonthuoc.IdKhoadieutri = Utility.Int16Dbnull(objPatientDept.IdKhoanoitru);
                            objDonthuoc.IdBuongNoitru = Utility.Int16Dbnull(objPatientDept.IdBuong);
                            objDonthuoc.IdGiuongNoitru = Utility.Int16Dbnull(objPatientDept.IdGiuong);
                        }
                        objDonthuoc.NgayXacnhan = null;
                        objDonthuoc.NgayCapphat = null;
                        objDonthuoc.DonthuocTaiquay = 0;
                        objDonthuoc.TrangThai = 0;
                        objDonthuoc.TrangthaiThanhtoan = 0;
                        objDonthuoc.MaKhoaThuchien = globalVariables.MA_KHOA_THIEN;
                        //objDonthuoc.IdBacsiChidinh = globalVariables.gv_intIDNhanvien;
                        objDonthuoc.MotaThem = "Sao chép";
                        objDonthuoc.NguoiTao = globalVariables.UserName;
                        objDonthuoc.NgayTao = globalVariables.SysDate;
                        objDonthuoc.IpMaytao = globalVariables.gv_strIPAddress;
                        objDonthuoc.TenMaytao = globalVariables.gv_strComputerName;
                        objDonthuoc.IsNew = true;
                        objDonthuoc.Save();
                        foreach (var objChitietdonthuoc in arrChitietdonthuoc)
                        {
                            KcbDonthuocChitiet newItem = KcbDonthuocChitiet.FetchByID(objChitietdonthuoc.IdChitietdonthuoc);
                            newItem.IdKham = objTreatment.IdPhieudieutri;

                            newItem.SoluongHuy = 0;
                            newItem.NgayHuy = null;
                            newItem.TrangthaiHuy = 0;
                            newItem.NguoiHuy = null;
                            newItem.TrangThai = 0;
                            newItem.SluongLinh = 0;
                            newItem.SluongSua = 0;
                            newItem.NgayXacnhan = null;
                            newItem.IdThanhtoan = -1;
                            newItem.TrangthaiThanhtoan = 0;
                            newItem.TrangthaiTonghop = 0;
                            newItem.NgayThanhtoan = null;
                            newItem.TrangthaiChuyen = 0;

                            newItem.NgaySua = null;
                            newItem.NguoiSua = null;
                            newItem.TileChietkhau = 0;
                            newItem.TienChietkhau = 0;
                            newItem.IdGoi = -1;
                            newItem.TrongGoi = 0;

                            newItem.IdDonthuoc = Utility.Int32Dbnull(objDonthuoc.IdDonthuoc);

                            newItem.NguoiTao = globalVariables.UserName;
                            newItem.NgayTao = globalVariables.SysDate;
                            newItem.IpMaytao = globalVariables.gv_strIPAddress;
                            newItem.TenMaytao = globalVariables.gv_strComputerName;

                            newItem.IsNew = true;
                            newItem.Save();
                        }
                    }
                    scope.Complete();
                    return ActionResult.Success;
                }
            }
            catch (Exception exception)
            {
                return ActionResult.Error;
            }
        }
示例#9
0
        public ActionResult ThemDonThuoc(KcbLuotkham objLuotkham, KcbDonthuoc objDonthuoc, KcbDonthuocChitiet[] arrDonthuocChitiet, KcbChandoanKetluan _KcbChandoanKetluan, ref long p_intIdDonthuoc, ref Dictionary<long, long> lstChitietDonthuoc)
        {
            // Query _Query = KcbDonthuoc.CreateQuery();
             try
             {
                 using (TransactionScope scope = new TransactionScope())
                 {
                     using (SharedDbConnectionScope sh = new SharedDbConnectionScope())
                     {
                         if (objLuotkham != null)
                         {
                             if (objDonthuoc.NgayKedon <= Convert.ToDateTime("01/01/1900"))
                                 objDonthuoc.NgayKedon = globalVariables.SysDate;

                             objDonthuoc.IsNew = true;
                             objDonthuoc.TenDonthuoc = THU_VIEN_CHUNG.TaoTenDonthuoc(objLuotkham.MaLuotkham,
                                                                                        Utility.Int32Dbnull(
                                                                                            objLuotkham.IdBenhnhan,
                                                                                            -1));

                             objDonthuoc.Save();

                             KcbDangkyKcb objKCB = KcbDangkyKcb.FetchByID(objDonthuoc.IdKham);
                             if (objKCB != null)
                             {
                                 objKCB.DakeDonthuoc = 1;
                                 objKCB.IdBacsikham = objDonthuoc.IdBacsiChidinh;
                                 objKCB.IsNew = false;
                                 objKCB.Save();
                             }

                             if (!Utility.Byte2Bool(objDonthuoc.Noitru))
                                 CapnhatChandoan(_KcbChandoanKetluan);
                             p_intIdDonthuoc = objDonthuoc.IdDonthuoc;
                             decimal PtramBH = Utility.DecimaltoDbnull(objLuotkham.PtramBhyt, 0);
                             bool TUDONGDANHDAU_TRANGTHAISUDUNG = THU_VIEN_CHUNG.Laygiatrithamsohethong("KCB_TIEMCHUNG_TUDONGDANHDAU_TRANGTHAISUDUNG", "0", false) == "1";
                             foreach (KcbDonthuocChitiet objDonthuocChitiet in arrDonthuocChitiet)
                             {
                                 objDonthuocChitiet.IdKham = objDonthuoc.IdKham;
                                 objDonthuocChitiet.MaLuotkham = objDonthuoc.MaLuotkham;
                                 objDonthuocChitiet.IdBenhnhan = objDonthuoc.IdBenhnhan;
                                 objDonthuocChitiet.IdDonthuoc = objDonthuoc.IdDonthuoc;
                                 objDonthuocChitiet.NgaySudung = objDonthuoc.NgayKedon;
                                 objDonthuocChitiet.DaDung=Utility.Bool2byte(TUDONGDANHDAU_TRANGTHAISUDUNG);
                                 ThemChitiet(objDonthuoc, objDonthuocChitiet, PtramBH, objLuotkham);
                                 //Tạo mới dòng dữ liệu tempt để kiểm tra tồn kho theo ngày
                                 TblKedonthuocTempt newItem = new TblKedonthuocTempt();
                                 newItem.IdChitietdonthuoc = objDonthuocChitiet.IdChitietdonthuoc;
                                 newItem.IdDonthuoc = objDonthuocChitiet.IdDonthuoc;
                                 newItem.IdKho =Utility.Int32Dbnull( objDonthuocChitiet.IdKho,-1);
                                 newItem.IdThuoc = objDonthuocChitiet.IdThuoc;
                                 newItem.IdThuockho =Utility.Int64Dbnull( objDonthuocChitiet.IdThuockho,-1);
                                 newItem.NgayKedon = objDonthuoc.NgayKedon;
                                 newItem.SoLuong = objDonthuocChitiet.SoLuong;
                                 newItem.TrangThai = Utility.ByteDbnull(objDonthuocChitiet.TrangThai, 0);
                                 newItem.IsNew = true;
                                 newItem.Save();
                                 if (!lstChitietDonthuoc.ContainsKey(objDonthuocChitiet.IdThuockho.Value))
                                     lstChitietDonthuoc.Add(objDonthuocChitiet.IdThuockho.Value, objDonthuocChitiet.IdChitietdonthuoc);
                             }

                         }

                     }
                     scope.Complete();
                     return ActionResult.Success;
                 }
             }
             catch (Exception exception)
             {

                 log.Error("Loi trong qua trinh luu don thuoc {0}", exception);
                 return ActionResult.Error;
             }
        }
        public ActionResult SaoChepDonThuocTheoPhieuDieuTriFullTransaction(KcbDonthuoc objDonthuoc, NoitruPhieudieutri objTreatment, KcbDonthuocChitiet[] arrChitietdonthuoc)
        {
            try
            {
                using (var scope = new TransactionScope())
                {
                    using (var dbscope = new SharedDbConnectionScope())
                    {
                        objDonthuoc.IdPhieudieutri    = objTreatment.IdPhieudieutri;
                        objDonthuoc.IdDonthuocthaythe = -1;
                        objDonthuoc.IdKham            = objTreatment.IdPhieudieutri;
                        objDonthuoc.IdBacsiChidinh    = objTreatment.IdBacsi;
                        objDonthuoc.NgaySua           = null;
                        objDonthuoc.NguoiSua          = null;
                        objDonthuoc.NgayKedon         = Convert.ToDateTime(objTreatment.NgayDieutri);
                        objDonthuoc.Noitru            = 1;
                        NoitruPhanbuonggiuong objPatientDept = NoitruPhanbuonggiuong.FetchByID(objTreatment.IdBuongGiuong);
                        if (objPatientDept != null)
                        {
                            objDonthuoc.IdKhoadieutri  = Utility.Int16Dbnull(objPatientDept.IdKhoanoitru);
                            objDonthuoc.IdBuongNoitru  = Utility.Int16Dbnull(objPatientDept.IdBuong);
                            objDonthuoc.IdGiuongNoitru = Utility.Int16Dbnull(objPatientDept.IdGiuong);
                        }
                        objDonthuoc.NgayXacnhan        = null;
                        objDonthuoc.NgayCapphat        = null;
                        objDonthuoc.TrangThai          = 0;
                        objDonthuoc.TrangthaiThanhtoan = 0;
                        objDonthuoc.KieuDonthuoc       = 0;
                        objDonthuoc.MaKhoaThuchien     = globalVariables.MA_KHOA_THIEN;
                        //objDonthuoc.IdBacsiChidinh = globalVariables.gv_intIDNhanvien;
                        objDonthuoc.MotaThem  = "Sao chép";
                        objDonthuoc.NguoiTao  = globalVariables.UserName;
                        objDonthuoc.NgayTao   = globalVariables.SysDate;
                        objDonthuoc.IpMaytao  = globalVariables.gv_strIPAddress;
                        objDonthuoc.TenMaytao = globalVariables.gv_strComputerName;
                        objDonthuoc.IsNew     = true;
                        objDonthuoc.Save();
                        foreach (var objChitietdonthuoc in arrChitietdonthuoc)
                        {
                            KcbDonthuocChitiet newItem = KcbDonthuocChitiet.FetchByID(objChitietdonthuoc.IdChitietdonthuoc);
                            newItem.IdKham = objTreatment.IdPhieudieutri;

                            newItem.SoluongHuy         = 0;
                            newItem.NgayHuy            = null;
                            newItem.TrangthaiHuy       = 0;
                            newItem.NguoiHuy           = null;
                            newItem.TrangThai          = 0;
                            newItem.SluongLinh         = 0;
                            newItem.SluongSua          = 0;
                            newItem.NgayXacnhan        = null;
                            newItem.IdThanhtoan        = -1;
                            newItem.TrangthaiThanhtoan = 0;
                            newItem.TrangthaiTonghop   = 0;
                            newItem.NgayThanhtoan      = null;
                            newItem.TrangthaiChuyen    = 0;

                            newItem.NgaySua       = null;
                            newItem.NguoiSua      = null;
                            newItem.TileChietkhau = 0;
                            newItem.TienChietkhau = 0;
                            newItem.IdGoi         = -1;
                            newItem.TrongGoi      = 0;



                            newItem.IdDonthuoc = Utility.Int32Dbnull(objDonthuoc.IdDonthuoc);

                            newItem.NguoiTao  = globalVariables.UserName;
                            newItem.NgayTao   = globalVariables.SysDate;
                            newItem.IpMaytao  = globalVariables.gv_strIPAddress;
                            newItem.TenMaytao = globalVariables.gv_strComputerName;

                            newItem.IsNew = true;
                            newItem.Save();
                        }
                    }
                    scope.Complete();
                    return(ActionResult.Success);
                }
            }
            catch (Exception exception)
            {
                return(ActionResult.Error);
            }
        }
示例#11
0
        public ActionResult SaoChepPhieuDieuTri(NoitruPhieudieutri[] lstPhieudieutri, KcbLuotkham objLuotkham, KcbChidinhclsChitiet[] arrChidinhCLSChitiet, KcbDonthuocChitiet[] arrDonthuocChitiet)
        {
            try
            {
                using (var scope = new TransactionScope())
                {
                    using (var dbscope = new SharedDbConnectionScope())
                    {
                        foreach (NoitruPhieudieutri objTreatment in lstPhieudieutri)
                        {
                            objTreatment.NguoiTao      = globalVariables.UserName;
                            objTreatment.NgayTao       = DateTime.Now;
                            objTreatment.TthaiBosung   = 0;
                            objTreatment.IdBacsi       = globalVariables.gv_intIDNhanvien;
                            objTreatment.IdKhoanoitru  = objLuotkham.IdKhoanoitru;
                            objTreatment.MaLuotkham    = objLuotkham.MaLuotkham;
                            objTreatment.IdBenhnhan    = objTreatment.IdBenhnhan;
                            objTreatment.IdBuongGiuong = objLuotkham.IdRavien;
                            objTreatment.TrangThai     = 0;
                            objTreatment.TthaiIn       = 0;
                            objTreatment.IpMaytao      = globalVariables.gv_strIPAddress;
                            objTreatment.TenMaytao     = globalVariables.gv_strComputerName;
                            objTreatment.GioDieutri    = Utility.GetFormatDateTime(globalVariables.SysDate, "hh:mm:ss");
                            objTreatment.IsNew         = true;
                            objTreatment.Save();
                            if (arrChidinhCLSChitiet.Length > 0)
                            {
                                KcbChidinhcl objAssignInfo = new KcbChidinhcl();
                                objAssignInfo.IdDieutri      = objTreatment.IdPhieudieutri;
                                objAssignInfo.IdBuongGiuong  = objTreatment.IdBuongGiuong;
                                objAssignInfo.MaLuotkham     = objTreatment.MaLuotkham;
                                objAssignInfo.IdBenhnhan     = Utility.Int32Dbnull(objTreatment.IdBenhnhan);
                                objAssignInfo.IdBacsiChidinh = globalVariables.gv_intIDNhanvien;
                                objAssignInfo.Noitru         = 1;
                                objAssignInfo.IdKhoadieutri  = objTreatment.IdKhoanoitru;
                                objAssignInfo.IdKhoaChidinh  = objTreatment.IdKhoanoitru;
                                objAssignInfo.IdKham         = -1;
                                objAssignInfo.IdDoituongKcb  = objLuotkham.IdDoituongKcb;
                                objAssignInfo.IdPhongChidinh = objTreatment.IdKhoanoitru;
                                objAssignInfo.Barcode        = string.Empty;

                                objAssignInfo.NgayChidinh = objTreatment.NgayDieutri.Value;
                                objAssignInfo.NguoiTao    = globalVariables.UserName;
                                objAssignInfo.NgayTao     = globalVariables.SysDate;
                                objAssignInfo.IpMaytao    = globalVariables.gv_strIPAddress;
                                objAssignInfo.TenMaytao   = globalVariables.gv_strComputerName;

                                objAssignInfo.MaChidinh = THU_VIEN_CHUNG.SinhMaChidinhCLS();
                                objAssignInfo.IsNew     = true;
                                objAssignInfo.Save();
                                List <KcbChidinhclsChitiet> lstChidinhCLSChitiet = new List <KcbChidinhclsChitiet>();
                                foreach (KcbChidinhclsChitiet objAssignDetail in arrChidinhCLSChitiet)
                                {
                                    KcbChidinhclsChitiet objDetail = KcbChidinhclsChitiet.FetchByID(objAssignDetail.IdChitietchidinh);
                                    if (objDetail != null)
                                    {
                                        objDetail.IdChitietchidinh   = -1;
                                        objDetail.IdChidinh          = objAssignInfo.IdChidinh;
                                        objDetail.IdKham             = -1;
                                        objDetail.TrangthaiThanhtoan = 0;
                                        objDetail.NgayThanhtoan      = null;
                                        objDetail.TrangthaiHuy       = 0;
                                        objDetail.TrangthaiChuyencls = 0;
                                        objDetail.TrangthaiXacnhan   = 0;
                                        objDetail.ImgPath1           = string.Empty;
                                        objDetail.ImgPath2           = string.Empty;
                                        objDetail.ImgPath3           = string.Empty;
                                        objDetail.ImgPath4           = string.Empty;
                                        objDetail.TrangThai          = 0;
                                        objDetail.MotaThem           = null;
                                        objDetail.TrangthaiBhyt      = 0;
                                        objDetail.IdThanhtoan        = -1;
                                        objDetail.IdKhoaThuchien     = (short)objAssignInfo.IdKhoadieutri;
                                        objDetail.IdPhongThuchien    = objDetail.IdKhoaThuchien;
                                        objDetail.IdGoi           = -1;
                                        objDetail.IdBacsiThuchien = -1;
                                        objDetail.NgayThuchien    = null;
                                        objDetail.NguoiThuchien   = null;
                                        objDetail.KetLuan         = null;
                                        objDetail.KetQua          = null;
                                        objDetail.DeNghi          = null;
                                        objDetail.MaVungkhaosat   = null;
                                        objDetail.KetquaXn        = "";
                                        objDetail.NguoiTao        = globalVariables.UserName;
                                        objDetail.NgayTao         = globalVariables.SysDate;
                                        objDetail.IpMaytao        = globalVariables.gv_strIPAddress;
                                        objDetail.TenMaytao       = globalVariables.gv_strComputerName;
                                        objDetail.IsNew           = true;
                                        lstChidinhCLSChitiet.Add(objDetail);
                                    }
                                    new KCB_CHIDINH_CANLAMSANG().InsertAssignDetail(objAssignInfo, objLuotkham, lstChidinhCLSChitiet.ToArray <KcbChidinhclsChitiet>());
                                }
                            }
                            if (arrDonthuocChitiet.Length > 0)
                            {
                                var query = (from donthuoc in arrDonthuocChitiet.AsEnumerable()
                                             let y = donthuoc.IdDonthuoc
                                                     select y).Distinct();
                                foreach (var pres_id in query.ToList())
                                {
                                    KcbDonthuoc objPresInfo = KcbDonthuoc.FetchByID(Utility.Int32Dbnull(pres_id));
                                    if (objPresInfo != null)
                                    {
                                        objPresInfo.IsNew = true;
                                        objPresInfo.Save();
                                        List <KcbDonthuocChitiet> lstDonthuocchitiet = (from donthuoc in arrDonthuocChitiet.AsEnumerable()
                                                                                        where donthuoc.IdDonthuoc == pres_id
                                                                                        select donthuoc).ToList <KcbDonthuocChitiet>();
                                        SaoChepDonThuocTheoPhieuDieuTri(objPresInfo, objTreatment, lstDonthuocchitiet.ToArray <KcbDonthuocChitiet>());
                                    }
                                }
                            }
                        }
                    }
                    scope.Complete();
                    return(ActionResult.Success);
                }
            }
            catch (Exception exception)
            {
                return(ActionResult.Error);
            }
        }
        public void Insert(long?IdPhieudieutri, int?IdKhoadieutri, long?IdDonthuocthaythe, long?IdKham, long?IdBenhnhan, string MaLuotkham, DateTime NgayKedon, short?IdBacsiChidinh, byte TrangThai, byte?TthaiTonghop, byte TrangthaiThanhtoan, DateTime?NgayThanhtoan, int?IdGoi, byte?TrongGoi, string NguoiTao, DateTime NgayTao, string NguoiSua, DateTime?NgaySua, string MotaThem, string TenDonthuoc, string MaDoituongKcb, byte?Noitru, byte?KieuDonthuoc, short?IdPhongkham, long?IdBuongGiuong, short?IdBuongNoitru, short?IdGiuongNoitru, string LoidanBacsi, DateTime?NgayTaikham, string TaiKham, string MaKhoaThuchien, DateTime?NgayCapphat, string KieuThuocvattu, DateTime?NgayChot, int?IdChot, DateTime?NgayHuychot, string NguoiHuychot, string LydoHuychot, DateTime?NgayHuyxacnhan, string NguoiHuyxacnhan, string LydoHuyxacnhan, DateTime?NgayXacnhan, string NguoiXacnhan, long?IdLichsuDoituongKcb, string MatheBhyt, string IpMaytao, string IpMaysua, string TenMaytao, string TenMaysua, string LastActionName)
        {
            KcbDonthuoc item = new KcbDonthuoc();

            item.IdPhieudieutri = IdPhieudieutri;

            item.IdKhoadieutri = IdKhoadieutri;

            item.IdDonthuocthaythe = IdDonthuocthaythe;

            item.IdKham = IdKham;

            item.IdBenhnhan = IdBenhnhan;

            item.MaLuotkham = MaLuotkham;

            item.NgayKedon = NgayKedon;

            item.IdBacsiChidinh = IdBacsiChidinh;

            item.TrangThai = TrangThai;

            item.TthaiTonghop = TthaiTonghop;

            item.TrangthaiThanhtoan = TrangthaiThanhtoan;

            item.NgayThanhtoan = NgayThanhtoan;

            item.IdGoi = IdGoi;

            item.TrongGoi = TrongGoi;

            item.NguoiTao = NguoiTao;

            item.NgayTao = NgayTao;

            item.NguoiSua = NguoiSua;

            item.NgaySua = NgaySua;

            item.MotaThem = MotaThem;

            item.TenDonthuoc = TenDonthuoc;

            item.MaDoituongKcb = MaDoituongKcb;

            item.Noitru = Noitru;

            item.KieuDonthuoc = KieuDonthuoc;

            item.IdPhongkham = IdPhongkham;

            item.IdBuongGiuong = IdBuongGiuong;

            item.IdBuongNoitru = IdBuongNoitru;

            item.IdGiuongNoitru = IdGiuongNoitru;

            item.LoidanBacsi = LoidanBacsi;

            item.NgayTaikham = NgayTaikham;

            item.TaiKham = TaiKham;

            item.MaKhoaThuchien = MaKhoaThuchien;

            item.NgayCapphat = NgayCapphat;

            item.KieuThuocvattu = KieuThuocvattu;

            item.NgayChot = NgayChot;

            item.IdChot = IdChot;

            item.NgayHuychot = NgayHuychot;

            item.NguoiHuychot = NguoiHuychot;

            item.LydoHuychot = LydoHuychot;

            item.NgayHuyxacnhan = NgayHuyxacnhan;

            item.NguoiHuyxacnhan = NguoiHuyxacnhan;

            item.LydoHuyxacnhan = LydoHuyxacnhan;

            item.NgayXacnhan = NgayXacnhan;

            item.NguoiXacnhan = NguoiXacnhan;

            item.IdLichsuDoituongKcb = IdLichsuDoituongKcb;

            item.MatheBhyt = MatheBhyt;

            item.IpMaytao = IpMaytao;

            item.IpMaysua = IpMaysua;

            item.TenMaytao = TenMaytao;

            item.TenMaysua = TenMaysua;

            item.LastActionName = LastActionName;


            item.Save(UserName);
        }