示例#1
0
        /// <summary>
        /// 根据发票号获取处方
        /// </summary>
        /// <param name="invoiceNo">票据号</param>
        /// <param name="patlistid">病人ID</param>
        /// <returns>处方对象</returns>
        public List <Prescription> GetPrescriptionByInvoiceNo(string invoiceNo, int patlistid)
        {
            List <Prescription> preslist  = new List <Prescription>();
            BasicDataManagement basicdata = NewObject <BasicDataManagement>();
            string condiction             = string.Empty;

            condiction = " PatListID = " + patlistid + " AND ChargeFlag = 1 AND ChargeStatus = 0 And invoiceNO='" + invoiceNo + "' and regflag=0";
            condiction = condiction + " order by feeitemheadid";

            //得到实体列表
            List <OP_FeeItemHead> presMastList = NewObject <OP_FeeItemHead>().getlist <OP_FeeItemHead>(condiction);

            if (presMastList.Count == 0)
            {
                throw new Exception("找不到发票信息!\r\n1、请确认发票号是否正确。\r\n2、请确认该发票是否已退费。");
            }

            for (int i = 0; i < presMastList.Count; i++)
            {
                decimal refundfee = 0;
                List <OP_FeeItemDetail> presDetailList = NewObject <OP_FeeItemDetail>().getlist <OP_FeeItemDetail>(" FeeItemHeadID=" + presMastList[i].FeeItemHeadID + " order by PresDetailID");
                for (int j = 0; j < presDetailList.Count; j++)
                {
                    #region 明细
                    Prescription pres = new Prescription();
                    pres.PresDetailID    = presDetailList[j].PresDetailID;
                    pres.FeeItemHeadID   = presDetailList[j].FeeItemHeadID;
                    pres.PatListID       = presDetailList[j].PatListID;
                    pres.ItemID          = presDetailList[j].ItemID;
                    pres.ItemName        = presDetailList[j].ItemName;
                    pres.Spec            = presDetailList[j].Spec;
                    pres.PackUnit        = presDetailList[j].PackUnit;
                    pres.UnitNO          = presDetailList[j].UnitNO;
                    pres.StockPrice      = presDetailList[j].StockPrice;
                    pres.Amount          = presDetailList[j].Amount;
                    pres.PresAmount      = presDetailList[j].PresAmount;
                    pres.TotalFee        = presDetailList[j].TotalFee;
                    pres.ExamItemID      = presDetailList[j].ExamItemID;
                    pres.DocPresDetailID = presDetailList[j].DocPresDetailID;
                    pres.MiniUnit        = presDetailList[j].MiniUnit;
                    pres.RetailPrice     = presDetailList[j].RetailPrice;
                    pres.StatID          = presDetailList[j].StatID;
                    pres.ItemType        = presDetailList[j].ItemType;

                    pres.PrescGroupID = i + 1;
                    pres.presNO       = j == 0 ? i + 1 : 0;
                    pres.PresDeptID   = presMastList[i].PresDeptID;
                    pres.PresEmpID    = presMastList[i].PresEmpID;
                    pres.ExecDeptID   = presMastList[i].ExecDeptID;
                    pres.PresDocName  = basicdata.GetEmpName(presMastList[i].PresEmpID);
                    pres.ExecDetpName = basicdata.GetDeptName(presMastList[i].ExecDeptID);
                    pres.PresType     = presMastList[i].PresType;
                    pres.ModifyFlag   = 0;
                    pres.Selected     = 1;
                    pres.CostHeadID   = presMastList[i].CostHeadID;

                    pres.DocPresNO       = presMastList[i].DocPresNO;
                    pres.DocPresHeadID   = presMastList[i].DocPresHeadID;
                    pres.DocPresDetailID = presDetailList[j].DocPresDetailID;
                    List <OP_FeeRefundHead>   refundHeadList   = NewObject <OP_FeeRefundHead>().getlist <OP_FeeRefundHead>(" invoiceNum='" + invoiceNo + "' and flag=0");
                    List <OP_FeeRefundDetail> refundDetailList = NewObject <OP_FeeRefundDetail>().getlist <OP_FeeRefundDetail>(" ReHeadID=" + refundHeadList[0].ReHeadID + " and FeeItemDetailID=" + presDetailList[j].PresDetailID + " ");
                    if (refundDetailList.Count == 0)
                    {
                        continue;
                    }

                    OP_FeeRefundDetail refundDetail = refundDetailList[0] as OP_FeeRefundDetail;
                    pres.Refundamount = refundDetail.RefundAmount;
                    pres.Refundfee    = refundDetail.RefundFee;
                    if (Convert.ToInt32(pres.ItemType) == (int)OP_Enum.ItemType.收费项目 || Convert.ToInt32(pres.ItemType) == (int)OP_Enum.ItemType.组合项目)
                    {
                        pres.MiniAmount = presDetailList[j].Amount;
                        pres.PackAmount = (presDetailList[j].Amount - pres.MiniAmount) / pres.UnitNO;

                        pres.RefundMiniAmount = refundDetail.RefundAmount;
                        pres.RefundPackAmount = (refundDetail.RefundAmount - pres.RefundMiniAmount) / pres.UnitNO;
                    }
                    else
                    {
                        pres.MiniAmount = presDetailList[j].Amount % presDetailList[j].UnitNO;
                        pres.PackAmount = (presDetailList[j].Amount - pres.MiniAmount) / pres.UnitNO;

                        pres.RefundMiniAmount = refundDetail.RefundAmount % pres.UnitNO;
                        pres.RefundPackAmount = (refundDetail.RefundAmount - pres.RefundMiniAmount) / pres.UnitNO;
                    }

                    pres.DocPresHeadID = presMastList[i].DocPresHeadID;
                    pres.Refundfee     = refundDetail.RefundFee;
                    refundfee         += pres.Refundfee;
                    #endregion
                    preslist.Add(pres);
                }

                Prescription presTotal = new Prescription();
                presTotal.ExecDetpName = "小 计";
                presTotal.SubTotalFlag = 1;
                presTotal.PrescGroupID = i + 1;
                presTotal.presNO       = 0;
                presTotal.TotalFee     = presMastList[i].TotalFee;
                presTotal.Refundfee    = refundfee;
                presTotal.Selected     = 1;
                preslist.Add(presTotal);
            }

            return(preslist);
        }
示例#2
0
        /// <summary>
        /// 处方退费
        /// </summary>
        /// <param name="costHeadid">结算ID</param>
        /// <param name="operatoreid">操作员ID</param>
        /// <param name="refundPrescriptions">退处方对象</param>
        /// <param name="refundInvoiceNO">退费票据号</param>
        /// <returns> 被退后的处方对象</returns>
        public override List <Prescription> RefundFee(int costHeadid, int operatoreid, List <Prescription> refundPrescriptions, string refundInvoiceNO)
        {
            //先全退,再算出需退处方再退费
            AllRefund(costHeadid, operatoreid, refundPrescriptions, refundInvoiceNO);
            List <Prescription> balancePresc = new List <Prescription>();

            //返回需要补收的处方记录
            foreach (Prescription refundPresc in refundPrescriptions)
            {
                if (refundPresc.Amount != refundPresc.Refundamount)
                {
                    refundPresc.Amount   = refundPresc.Amount - refundPresc.Refundamount;
                    refundPresc.TotalFee = refundPresc.TotalFee - refundPresc.Refundfee;
                    balancePresc.Add(refundPresc);
                }
            }

            #region 暂不用
            //OP_CostHead oldCostHead = NewObject<OP_CostHead>().getmodel(costHeadid) as OP_CostHead;
            //bool autoProcess = false;
            //if (oldCostHead.TotalFee == oldCostHead.CashFee + oldCostHead.PosFee + oldCostHead.RoundingFee)
            //{
            //    autoProcess = true;
            //}
            //if (autoProcess)//全现金处理
            //{
            //    if (_isallRefund)
            //    {
            //        List<OP_FeeItemHead> feeItemHeadList = NewObject<OP_FeeItemHead>().getlist<OP_FeeItemHead>(" costHeadId=" + costHeadid + " and invoiceNO!='" + RefundInvoiceNO + " and ChargeStatus=1");
            //        if (feeItemHeadList.Count == 0)//表示一次结算只有一张票据
            //        {
            //            return balancePresc;
            //        }
            //        decimal allTotalFee = feeItemHeadList.Sum(p => p.TotalFee);
            //        OP_CostHead costHead = new OP_CostHead();
            //        costHead.CostHeadID = 0;
            //        costHead.TotalFee = allTotalFee;
            //        costHead.CashFee = allTotalFee;
            //        costHead.PosFee = 0;
            //        costHead.PromFee = 0;
            //        costHead.ChargeEmpID = operatoreid;
            //        costHead.CostDate = DateTime.Now;
            //        foreach (OP_FeeItemHead feeitemHead in feeItemHeadList)
            //        {

            //        }
            //    }
            //}
            #endregion
            BasicDataManagement basicdata = NewObject <BasicDataManagement>();

            //补收的处方数据保存到数据库
            if (balancePresc.Count > 0)
            {
                OP_FeeItemHead oldFeeitemHead = NewObject <OP_FeeItemHead>().getmodel(balancePresc[0].FeeItemHeadID) as OP_FeeItemHead;
                OP_FeeItemHead feeitemHead    = oldFeeitemHead.Clone() as OP_FeeItemHead;
                feeitemHead.FeeItemHeadID = 0;
                feeitemHead.ChargeEmpID   = operatoreid;
                feeitemHead.ChargeDate    = DateTime.Now;
                feeitemHead.ChargeFlag    = 0;
                feeitemHead.ChargeStatus  = 0;
                decimal roundingMoney = 0;
                feeitemHead.TotalFee = NewObject <PrescMoneyCalculate>().GetPrescriptionTotalMoney(balancePresc, out roundingMoney);
                this.BindDb(feeitemHead);
                feeitemHead.save();
                for (int j = 0; j < balancePresc.Count; j++)
                {
                    OP_FeeItemDetail oldfeeDetail = NewObject <OP_FeeItemDetail>().getmodel(balancePresc[j].PresDetailID) as OP_FeeItemDetail;
                    OP_FeeItemDetail feeDetial    = oldfeeDetail.Clone() as OP_FeeItemDetail;
                    feeDetial.PresDetailID  = 0;
                    feeDetial.Amount        = balancePresc[j].Amount;
                    feeDetial.TotalFee      = balancePresc[j].TotalFee;
                    feeDetial.FeeItemHeadID = feeitemHead.FeeItemHeadID;
                    feeDetial.save();
                    balancePresc[j].FeeItemHeadID = feeitemHead.FeeItemHeadID;
                    balancePresc[j].PresDetailID  = feeDetial.PresDetailID;
                    balancePresc[j].FeeNo         = feeitemHead.FeeNo;
                    balancePresc[j].ModifyFlag    = 0;
                }
            }

            OP_CostHead           oldCostHead     = NewObject <OP_CostHead>().getmodel(costHeadid) as OP_CostHead;
            List <OP_FeeItemHead> feeItemHeadList = NewObject <OP_FeeItemHead>().getlist <OP_FeeItemHead>(" costHeadId=" + costHeadid + " and invoiceNO!='" + refundInvoiceNO + "' and ChargeStatus=1");
            int i = 1;
            foreach (OP_FeeItemHead oldfeeitemhead in feeItemHeadList)
            {
                OP_FeeItemHead newfeeitemhead = oldfeeitemhead.Clone() as OP_FeeItemHead;
                newfeeitemhead.ChargeFlag    = 0;
                newfeeitemhead.FeeItemHeadID = 0;
                newfeeitemhead.ChargeStatus  = 0;
                newfeeitemhead.ChargeEmpID   = operatoreid;
                newfeeitemhead.CostHeadID    = 0;
                newfeeitemhead.save();
                List <OP_FeeItemDetail> feeItemDetaliList = NewObject <OP_FeeItemDetail>().getlist <OP_FeeItemDetail>(" feeitemheadid=" + oldfeeitemhead.FeeItemHeadID);
                foreach (OP_FeeItemDetail oldfeeItemDetail in feeItemDetaliList)
                {
                    int j = 0;
                    OP_FeeItemDetail newFeeitemDetail = oldfeeItemDetail.Clone() as OP_FeeItemDetail;
                    newFeeitemDetail.PresDetailID  = 0;
                    newFeeitemDetail.FeeItemHeadID = newfeeitemhead.FeeItemHeadID;
                    newfeeitemhead.save();
                    #region 明细
                    Prescription pres = new Prescription();
                    pres.PresDetailID    = newFeeitemDetail.PresDetailID;
                    pres.FeeItemHeadID   = newFeeitemDetail.FeeItemHeadID;
                    pres.PatListID       = newFeeitemDetail.PatListID;
                    pres.ItemID          = newFeeitemDetail.ItemID;
                    pres.ItemName        = newFeeitemDetail.ItemName;
                    pres.Spec            = newFeeitemDetail.Spec;
                    pres.PackUnit        = newFeeitemDetail.PackUnit;
                    pres.UnitNO          = newFeeitemDetail.UnitNO;
                    pres.StockPrice      = newFeeitemDetail.StockPrice;
                    pres.Amount          = newFeeitemDetail.Amount;
                    pres.PresAmount      = newFeeitemDetail.PresAmount;
                    pres.TotalFee        = newFeeitemDetail.TotalFee;
                    pres.ExamItemID      = newFeeitemDetail.ExamItemID;
                    pres.DocPresDetailID = newFeeitemDetail.DocPresDetailID;
                    pres.MiniUnit        = newFeeitemDetail.MiniUnit;
                    pres.RetailPrice     = newFeeitemDetail.RetailPrice;
                    pres.StatID          = newFeeitemDetail.StatID;
                    pres.ItemType        = newFeeitemDetail.ItemType;

                    pres.PrescGroupID = i + 1;
                    pres.presNO       = j == 0 ? i + 1 : 0;
                    pres.PresDeptID   = newfeeitemhead.PresDeptID;
                    pres.PresEmpID    = newfeeitemhead.PresEmpID;
                    pres.ExecDeptID   = newfeeitemhead.ExecDeptID;
                    pres.PresDocName  = basicdata.GetEmpName(newfeeitemhead.PresEmpID);
                    pres.ExecDetpName = basicdata.GetDeptName(newfeeitemhead.ExecDeptID);
                    pres.PresType     = newfeeitemhead.PresType;
                    pres.ModifyFlag   = 0;
                    pres.Selected     = 1;
                    if (Convert.ToInt32(pres.ItemType) == (int)OP_Enum.ItemType.收费项目 || Convert.ToInt32(pres.ItemType) == (int)OP_Enum.ItemType.组合项目)
                    {
                        pres.MiniAmount = newFeeitemDetail.Amount;
                        pres.PackAmount = (newFeeitemDetail.Amount - pres.MiniAmount) / pres.UnitNO;
                    }
                    else
                    {
                        pres.MiniAmount = newFeeitemDetail.Amount % newFeeitemDetail.UnitNO;
                        pres.PackAmount = (newFeeitemDetail.Amount - pres.MiniAmount) / pres.UnitNO;
                    }

                    pres.DocPresHeadID = newfeeitemhead.DocPresHeadID;
                    balancePresc.Add(pres);
                    j += 1;
                    #endregion
                }

                i += 1;
            }

            return(balancePresc);
        }