Ejemplo n.º 1
0
        public bool InPhoiBHYT(KcbLuotkham objLuotkham, DataTable m_dtPayment, DateTime ngayIn)
        {
            try
            {
                KcbPhieuDct objPhieuDct = CreatePhieuDongChiTra(objLuotkham, m_dtPayment);
                objPhieuDct.NgayTao = ngayIn;
                ActionResult actionResult = new KCB_THANHTOAN().UpdatePhieuDCT(objPhieuDct, objLuotkham);
                if (actionResult == ActionResult.Success) //Tránh trường hợp in ra phôi mà ko đẩy vào CSDL
                {
                    DataTable mDtReportPhieuThu =
                        new KCB_THANHTOAN().NoiTruLaythongtinInphoiBHYT(-1, Utility.sDbnull(objLuotkham.MaLuotkham, ""),
                                                                        Utility.Int32Dbnull(objLuotkham.IdBenhnhan, -1), 0);
                    THU_VIEN_CHUNG.CreateXML(mDtReportPhieuThu);

                    //load thông tin của việc lấy dữ liệu vào datatable trong phiếu thanh toán)
                    if (mDtReportPhieuThu.Rows.Count <= 0)
                    {
                        Utility.ShowMsg("Không tìm thấy dữ liệu để in phôi BHYT ", "Thông báo");
                        return(false);
                    }
                    string ICD_Name = "";
                    string ICD_Code = "";
                    if (mDtReportPhieuThu.Rows.Count > 0)
                    {
                        GetChanDoanPhu(Utility.sDbnull(mDtReportPhieuThu.Rows[0]["ma_benhphu"], ""), ref ICD_Name, ref ICD_Code);
                    }
                    //foreach (DataRow dr in m_dtReportPhieuThu.Rows)
                    //{
                    //    dr["chuan_doanphu"] = Utility.sDbnull(dr["chuan_doanphu"]).Trim() == ""
                    //                          ? ICD_Name
                    //                          : Utility.sDbnull(dr["chuan_doanphu"]) + ";" + ICD_Name;
                    //    //dr[DmucBenh.Columns.MaBenh] = ICD_Code;
                    //   // dr["ma_icd"] = ICD_Code;
                    //}
                    //
                    foreach (DataRow drv in mDtReportPhieuThu.Rows)
                    {
                        drv["chuan_doanphu"] = Utility.sDbnull(drv["chuan_doanphu"]).Trim() == ""
                                          ? ICD_Name
                                          : Utility.sDbnull(drv["chuan_doanphu"]) + ";" + ICD_Name;
                        if (drv[KcbThanhtoanChitiet.Columns.IdLoaithanhtoan].ToString() == "1" ||//Chi phí KCB
                            drv[KcbThanhtoanChitiet.Columns.IdLoaithanhtoan].ToString() == "0" ||//Phí KCB kèm theo
                            drv[KcbThanhtoanChitiet.Columns.IdLoaithanhtoan].ToString() == "4" ||//Buồng giường
                            drv[KcbThanhtoanChitiet.Columns.IdLoaithanhtoan].ToString() == "8"   //Gói dịch vụ
                            )
                        {
                            drv["ten_loaidichvu"] = string.Empty;
                            drv["STT"]            = 1;
                            drv["id_loaidichvu"]  = -1;
                        }
                        else if (drv[KcbThanhtoanChitiet.Columns.IdLoaithanhtoan].ToString() == "2")
                        {
                            string maLoaidichvu = Utility.sDbnull(drv["id_loaidichvu"], -1);
                            //drv["id_loaidichvu"]-->Được xác định trong câu truy vấn
                            var objService = (from p in globalVariables.gv_dtDmucChung.AsEnumerable()
                                              where
                                              p[DmucChung.Columns.Loai].Equals("LOAIDICHVUCLS") &&
                                              p[DmucChung.Columns.Ma].Equals(maLoaidichvu)
                                              select p).FirstOrDefault();
                            // DmucChung objService = THU_VIEN_CHUNG.LaydoituongDmucChung("LOAIDICHVUCLS", maLoaidichvu);
                            if (objService != null)
                            {
                                drv["ten_loaidichvu"] = Utility.sDbnull(objService["ten"].ToString());
                                drv["STT"]            = Utility.sDbnull(objService["stt_hthi"]);
                            }
                        }
                        else if (drv[KcbThanhtoanChitiet.Columns.IdLoaithanhtoan].ToString() == "3" ||
                                 drv[KcbThanhtoanChitiet.Columns.IdLoaithanhtoan].ToString() == "5")
                        {
                            int drugId  = Utility.Int32Dbnull(drv["id_dichvu"], -1);
                            var objDrug = (from p in globalVariables.gv_dtDanhMucThuoc.AsEnumerable()
                                           where p[DmucThuoc.Columns.IdThuoc].Equals(drugId)
                                           select p).FirstOrDefault();
                            var objLoaithuoc = (from p in globalVariables.gv_dtLoaiThuoc.AsEnumerable()
                                                where objDrug != null && p[DmucLoaithuoc.Columns.IdLoaithuoc].Equals(objDrug["id_loaithuoc"].ToString())
                                                select p).FirstOrDefault();
                            //DmucThuoc objDrug = DmucThuoc.FetchByID(drugId);
                            //  DmucLoaithuoc objLoaithuoc = DmucLoaithuoc.FetchByID(objDrug.IdLoaithuoc);
                            if (objLoaithuoc != null)
                            {
                                if (objDrug != null)
                                {
                                    objDrug["kieu_thuocvattu"] = objLoaithuoc["kieu_thuocvattu"];
                                }
                            }
                            //LDrugType objLDrugType = LDrugType.FetchByID(objDrug.DrugTypeId);
                            if (objDrug != null && objDrug["kieu_thuocvattu"].ToString() == "THUOC")
                            {
                                drv["id_loaidichvu"]  = "THUOC";
                                drv["STT"]            = 1;
                                drv["ten_loaidichvu"] = "3.1 Trong danh mục BHYT";
                            }
                            else
                            {
                                drv["id_loaidichvu"]  = "VTTH";
                                drv["STT"]            = 2;
                                drv["ten_loaidichvu"] = "Vật tư tiêu hao";
                            }
                        }
                        if (drv[KcbThanhtoanChitiet.Columns.IdLoaithanhtoan].ToString() == "9")
                        {
                            drv["id_loaidichvu"]  = 1;
                            drv["STT"]            = 1;
                            drv["ten_loaidichvu"] = "Chi phí thêm  ";
                        }
                    }
                    mDtReportPhieuThu.AcceptChanges();
                    new INPHIEU_THANHTOAN_NOITRU(objPhieuDct.NgayTao).INPHOI_BHYT(
                        mDtReportPhieuThu, ngayIn, objLuotkham);
                }
                return(actionResult == ActionResult.Success);
            }
            catch (Exception ex)
            {
                Utility.ShowMsg("Lỗi khi thực hiện in phôi BHYT\n" + ex.Message);
                return(false);
            }
        }