Exemple #1
0
        /// <summary>
        /// 获取费用信息
        /// </summary>
        /// <param name="regid"></param>
        public void m_mthGetPatientFeeInfo(string regid)
        {
            if (Patient_VO == null)
            {
                return;
            }

            prepayidarr        = new ArrayList();
            Balanceprepaymoney = 0;
            DataTable dt;

            //获取预交金
            long          l         = 0;
            clsDcl_PrePay objPrepay = new clsDcl_PrePay();

            if (Patient_VO.FeeStatus == 4)
            {
                decimal d = 0;
                l = objPrepay.m_lngGetBadChargePrepayByRegID(regid, out d);
                if (l > 0)
                {
                    Patient_VO.PrepayMoney          = 0;
                    Patient_VO.PrepayMoneyBadCharge = d;
                }
            }
            else
            {
                l = objPrepay.m_lngGetPrepayByRegID(regid, 2, out dt);
                if (l > 0 && dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        string  id    = dt.Rows[i]["prepayid_chr"].ToString();
                        string  no    = dt.Rows[i]["prepayinv_vchr"].ToString();
                        decimal money = clsPublic.ConvertObjToDecimal(dt.Rows[i]["balancetotal"]);
                        Balanceprepaymoney += money;

                        prepayidarr.Add(id + ";" + no + ";" + money.ToString());
                    }

                    //预交金改为显示当前可用预交金
                    Patient_VO.PrepayMoney = Balanceprepaymoney;
                }
            }

            //获取总费用、待结、待清、直接收费、已清、结余、清帐日期、未结天数
            decimal TotalFee         = 0;
            decimal WaitChargeFee    = 0;
            decimal WaitClearFee     = 0;
            decimal DirectorFee      = 0;
            decimal CompleteClearFee = 0;
            string  ClearFeeDate     = "";
            int     NoChargeDays     = 0;

            //最新费用时间
            maxfeedate = DateTime.Now.ToString("yyyy-MM-dd");

            clsDcl_Charge objCharge = new clsDcl_Charge();

            int intParm = 0;

            //判断是否为出院结算出院:出院结算时要判断母婴结算功能
            if (Status == 8)
            {
                //母婴合并结算功能开关0为关、1为开
                intParm = clsPublic.m_intGetSysParm("1119");
            }

            if (intParm == 0)
            {
                l = objCharge.m_lngGetChargeInfoByID(regid, 1, out dt);
            }
            else
            {
                l = objCharge.m_lngGetChargeInfoByIDForBaby(regid, out dt);
            }
            if (l > 0 && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    //单项总费用
                    decimal d = clsPublic.Round(clsPublic.ConvertObjToDecimal(dt.Rows[i]["unitprice_dec"]) * clsPublic.ConvertObjToDecimal(dt.Rows[i]["amount_dec"]), 2);
                    //单项让利
                    decimal decDiffSum = clsPublic.Round(clsPublic.ConvertObjToDecimal(dt.Rows[i]["TOTALDIFFCOSTMONEY_DEC"]), 2);
                    //总费用
                    TotalFee += d + decDiffSum;
                    //费用状态 0 待确认 1 待结 2 待清 3 已清 4 直收
                    int pstatus = Convert.ToInt32(dt.Rows[i]["pstatus_int"].ToString());
                    if (pstatus == 1)
                    {
                        WaitChargeFee += d + decDiffSum;
                    }
                    else if (pstatus == 2)
                    {
                        WaitClearFee += d + decDiffSum;
                    }
                    else if (pstatus == 3)
                    {
                        CompleteClearFee += d + decDiffSum;
                    }
                    else if (pstatus == 4)
                    {
                        DirectorFee += d + decDiffSum;
                    }
                }

                //最新费用时间
                DataView dv = new DataView(dt);
                dv.Sort = "chargeactive_dat asc";
                if (dv.Count > 0)
                {
                    maxfeedate = Convert.ToDateTime(dv[dv.Count - 1]["chargeactive_dat"].ToString()).ToString("yyyy-MM-dd");
                }

                //最大清帐日期
                dv.RowFilter = "pstatus_int = 3";
                dv.Sort      = "chearaccount_dat asc";
                if (dv.Count > 0)
                {
                    ClearFeeDate = Convert.ToDateTime(dv[dv.Count - 1]["chearaccount_dat"].ToString()).ToString("yyyy-MM-dd HH:mm:ss");
                }

                //未结(待结、待清)日期
                dv.RowFilter = "pstatus_int = 1 or pstatus_int = 2";
                dv.Sort      = "chargeactive_dat asc";
                if (dv.Count > 0)
                {
                    Hashtable has = new Hashtable();
                    foreach (DataRowView drv in dv)
                    {
                        string s = Convert.ToDateTime(drv["chargeactive_dat"].ToString()).ToString("yyyy-MM-dd");
                        if (has.ContainsKey(s) || (s == DateTime.Now.ToString("yyyy-MM-dd")))
                        {
                            continue;
                        }
                        else
                        {
                            has.Add(s, null);
                        }
                    }

                    NoChargeDays = has.Count;
                }
            }

            //结余 = 可用预交金 - 待结 - 待清
            decimal BalanceFee = Balanceprepaymoney - WaitChargeFee - WaitClearFee;

            if (Patient_VO.FeeStatus == 4 && Patient_VO.PrepayMoneyBadCharge > 0)
            {
                if (WaitClearFee >= Patient_VO.PrepayMoneyBadCharge)
                {
                    WaitClearFee -= Patient_VO.PrepayMoneyBadCharge;
                }
                else
                {
                    WaitChargeFee = WaitChargeFee + WaitClearFee - Patient_VO.PrepayMoneyBadCharge;
                    WaitClearFee  = 0;
                }

                BalanceFee        = (WaitChargeFee + WaitClearFee) * -1;
                CompleteClearFee += Patient_VO.PrepayMoneyBadCharge;
            }

            Patient_VO.TotalFee         = TotalFee;
            Patient_VO.WaitChargeFee    = WaitChargeFee;
            Patient_VO.WaitClearFee     = WaitClearFee;
            Patient_VO.DirectorFee      = DirectorFee;
            Patient_VO.CompleteClearFee = CompleteClearFee;
            Patient_VO.BalanceMoney     = BalanceFee;
            Patient_VO.ClearFeeDate     = ClearFeeDate;
            Patient_VO.NoChargeDays     = NoChargeDays;
        }