Пример #1
0
        public ServiceResponseData PrintInvoiceAgain()
        {
            int    costHeadID = requestData.GetData <int>(0);
            string perfChar   = requestData.GetData <string>(1);
            string invoice    = requestData.GetData <string>(2);
            string invoiceNO  = perfChar + invoice;
            List <OP_FeeItemHead> feeItems = NewObject <OP_FeeItemHead>().getlist <OP_FeeItemHead>(" invoiceNO='" + invoiceNO + "'");

            if (feeItems != null && feeItems.Count > 0)
            {
                throw new Exception("您输入的票据号已经被使用过,请重新输入");
            }

            OP_CostHead costHead = NewObject <OP_CostHead>().getmodel(costHeadID) as OP_CostHead;

            if (costHead.RecipeFlag == 1)
            {
                throw new Exception("此结算记录票据已经补打过,不能再次补打");
            }

            //获取发票打印信息
            DataTable  dtInvoice                  = NewDao <IOPManageDao>().GetBalancePrintInvoiceDt(costHeadID);
            DataTable  dtInvoiceDetail            = NewDao <IOPManageDao>().GetBalancePrintDetailDt(costHeadID);
            DataTable  dtInvoiceStatDetail        = NewDao <IOPManageDao>().GetBalancePrintStatDt(costHeadID);
            ChargeInfo chargeInfo                 = new ChargeInfo();
            List <OP_CostPayMentInfo> payInfoList = NewObject <OP_CostPayMentInfo>().getlist <OP_CostPayMentInfo>("costHeadId=" + costHeadID + string.Empty);

            chargeInfo.PayInfoList = payInfoList;
            responseData.AddData(dtInvoice);
            responseData.AddData(dtInvoiceDetail);
            responseData.AddData(dtInvoiceStatDetail);
            responseData.AddData(chargeInfo);
            return(responseData);
        }
Пример #2
0
        /// <summary>
        /// 每笔记录汇总插入结账表
        /// </summary>
        /// <param name="costHead">结算对象</param>
        /// <param name="curAccountId">当前缴款ID</param>
        /// <param name="invoiceCount">收费票据张数</param>
        /// <param name="refundInvoiceCount">退费票据张数</param>
        public void AddAccoutFee(OP_CostHead costHead, int curAccountId, int invoiceCount, int refundInvoiceCount)
        {
            OP_Account opaccount = NewObject <OP_Account>().getmodel(curAccountId) as OP_Account;

            opaccount.TotalFee           += costHead.TotalFee;
            opaccount.CashFee            += costHead.CashFee;
            opaccount.PosFee             += costHead.PosFee;
            opaccount.PromFee            += costHead.PromFee;
            opaccount.RoundingFee        += costHead.RoundingFee;
            opaccount.InvoiceCount       += invoiceCount;
            opaccount.RefundInvoiceCount += refundInvoiceCount;
            this.BindDb(opaccount);
            opaccount.save();
        }
Пример #3
0
        public ServiceResponseData PrintInvoiceAgainSave()
        {
            try
            {
                int    costHeadID              = requestData.GetData <int>(0);
                string newInvoiceNO            = requestData.GetData <string>(1);
                int    operatoreid             = requestData.GetData <int>(2);
                List <OP_FeeItemHead> feeItems = NewObject <OP_FeeItemHead>().getlist <OP_FeeItemHead>(" costHeadID=" + costHeadID + string.Empty);
                DateTime printData             = DateTime.Now;
                foreach (OP_FeeItemHead feeItemHead in feeItems)
                {
                    OP_PrintInvoiceInfo printInvoice = new OP_PrintInvoiceInfo();
                    printInvoice.FeeItemHeadID    = feeItemHead.FeeItemHeadID;
                    printInvoice.OldInvoiceNumber = feeItemHead.InvoiceNO;
                    printInvoice.NewInvoiceNumber = newInvoiceNO;
                    printInvoice.PrintDate        = printData;
                    printInvoice.PrintEmpID       = operatoreid;
                    printInvoice.PrintType        = 0;
                    printInvoice.InvoiceFee       = feeItemHead.TotalFee;
                    printInvoice.PatListID        = feeItemHead.PatListID;
                    printInvoice.PatName          = feeItemHead.PatName;
                    printInvoice.CostHeadID       = feeItemHead.CostHeadID;
                    this.BindDb(printInvoice);
                    printInvoice.save();

                    feeItemHead.InvoiceNO = newInvoiceNO;
                    feeItemHead.ReciptNO  = newInvoiceNO;
                    this.BindDb(feeItemHead);
                    feeItemHead.save();
                }

                OP_CostHead costHead = NewObject <OP_CostHead>().getmodel(costHeadID) as OP_CostHead;
                costHead.RecipeFlag = 1;
                this.BindDb(costHead);
                costHead.save();
                responseData.AddData(true);
                return(responseData);
            }
            catch (Exception err)
            {
                throw new Exception(err.Message);
            }
        }
Пример #4
0
 public ServiceResponseData RefundInit()
 {
     try
     {
         int         costHeadid    = requestData.GetData <int>(0);
         OP_CostHead costHead      = NewObject <OP_CostHead>().getmodel(costHeadid) as OP_CostHead;
         bool        isMedicarePat = NewObject <CommonMethod>().IsMedicarePat(costHead.PatTypeID);
         responseData.AddData(isMedicarePat);
         List <OP_CostPayMentInfo> listPayInfo = NewObject <OP_CostPayMentInfo>().getlist <OP_CostPayMentInfo>(" costheadid=" + costHeadid);
         responseData.AddData(listPayInfo);
         responseData.AddData(costHead);
         int refundPosType = Convert.ToInt32(NewObject <CommonMethod>().GetOpConfig(OpConfigConstant.RefundPosType));
         responseData.AddData(refundPosType);
         return(responseData);
     }
     catch (Exception err)
     {
         throw new Exception(err.Message);
     }
 }
Пример #5
0
 /// <summary>
 /// 费用主表赋值
 /// </summary>
 /// <param name="feeItemHead">费用主表对象</param>
 /// <param name="costHead">结算对象</param>
 /// <param name="curPatlist">病人对象</param>
 private void SetRegFeeHeadValue(OP_FeeItemHead feeItemHead, OP_CostHead costHead, OP_PatList curPatlist)
 {
     feeItemHead.CostHeadID    = costHead.CostHeadID;
     feeItemHead.MemberID      = curPatlist.MemberID;
     feeItemHead.PatListID     = curPatlist.PatListID;
     feeItemHead.PatName       = curPatlist.PatName;
     feeItemHead.PresType      = "0";
     feeItemHead.PresEmpID     = curPatlist.RegEmpID;
     feeItemHead.PresDeptID    = curPatlist.RegDeptID;
     feeItemHead.ExecDeptID    = curPatlist.RegDeptID;
     feeItemHead.ExecEmpID     = curPatlist.RegEmpID;
     feeItemHead.ChargeEmpID   = curPatlist.OperatorID;
     feeItemHead.PresAmount    = 1;
     feeItemHead.TotalFee      = costHead.TotalFee;
     feeItemHead.InvoiceNO     = costHead.EndInvoiceNO;
     feeItemHead.ChargeStatus  = 0;
     feeItemHead.ChargeFlag    = 1;
     feeItemHead.PresDate      = curPatlist.RegDate;
     feeItemHead.DocPresHeadID = 0;
     feeItemHead.ChargeDate    = curPatlist.RegDate;
     feeItemHead.FeeNo         = 0;
     feeItemHead.RegFlag       = 1;
 }
Пример #6
0
        /// <summary>
        /// 结算主表赋值
        /// </summary>
        /// <param name="costHead">结算对象</param>
        /// <param name="curPatlist">病人对象</param>
        private void SetRegCostHead(OP_CostHead costHead, OP_PatList curPatlist)
        {
            costHead.MemberID        = curPatlist.MemberID;
            costHead.MemberAccountID = curPatlist.MemberAccountID;
            costHead.CardNO          = curPatlist.CardNO;
            costHead.PatListID       = curPatlist.PatListID;
            costHead.PatName         = curPatlist.PatName;
            costHead.PatTypeID       = curPatlist.PatTypeID;
            costHead.CostDate        = curPatlist.RegDate;
            Basic_Invoice basicInvoice = NewObject <CommonMethod>().GetCurInvoice(InvoiceType.门诊挂号, curPatlist.OperatorID);
            string        invoiceNo    = string.Empty;
            string        perfChar     = string.Empty;

            invoiceNo             = NewObject <InvoiceManagement>().GetInvoiceCurNOAndUse(InvoiceType.门诊挂号, curPatlist.OperatorID, out perfChar);
            invoiceNo             = perfChar + invoiceNo;
            costHead.BeInvoiceNO  = invoiceNo;
            costHead.EndInvoiceNO = invoiceNo;
            costHead.RecipeFlag   = 0;
            costHead.RegCategory  = curPatlist.RegCategory;
            costHead.RegFlag      = 1;
            costHead.ChargeEmpID  = curPatlist.OperatorID;
            costHead.InvoiceID    = basicInvoice.ID;
        }
Пример #7
0
        public ServiceResponseData GetBackFeeByInvoiceNO()
        {
            try
            {
                OP_Enum.MemberQueryType queryType = requestData.GetData <OP_Enum.MemberQueryType>(0); //查找类型
                string content = requestData.GetData <string>(1);                                     //退费发票号
                List <OP_FeeRefundHead> listRefundHead = NewObject <OP_FeeRefundHead>().getlist <OP_FeeRefundHead>(" invoicenum='" + content + "' and flag=0 and RefundPayFlag=0");
                if (listRefundHead == null || listRefundHead.Count == 0)
                {
                    throw new Exception("查不到该票号对应的退费消息");
                }

                List <OP_FeeRefundDetail> refundDetailList = NewObject <OP_FeeRefundDetail>().getlist <OP_FeeRefundDetail>(" ReHeadID=" + listRefundHead[0].ReHeadID);
                foreach (OP_FeeRefundDetail feerefundDetail in refundDetailList)
                {
                    if (feerefundDetail.RefundAmount > 0 && feerefundDetail.DistributeFlag == 1 && feerefundDetail.RefundFlag == 0)
                    {
                        throw new Exception("已经发药处方要先退药才能退费");
                    }
                }

                OP_PatList patlist = NewObject <OP_PatList>().getmodel(listRefundHead[0].PatListID) as OP_PatList;
                responseData.AddData(patlist);
                List <Prescription> preslist = NewObject <PrescriptionProcess>().GetPrescriptionByInvoiceNo(content, patlist.PatListID);
                DataTable           dtRefund = EFWCoreLib.CoreFrame.Common.ConvertExtend.ToDataTable <Prescription>(preslist);// EFWCoreLib.CoreFrame.Common.ConvertExtend.ToDataTable(preslist);
                responseData.AddData(dtRefund);

                int         costheadid = preslist[0].CostHeadID;
                OP_CostHead costHead   = NewObject <OP_CostHead>().getmodel(costheadid) as OP_CostHead;
                responseData.AddData(costHead.PatTypeID);
                return(responseData);
            }
            catch (Exception err)
            {
                throw new Exception(err.Message);
            }
        }
Пример #8
0
        /// <summary>
        /// 挂号提交
        /// </summary>
        /// <param name="curPatlist">病人对象</param>
        /// <param name="paymentInfoList">支付对象</param>
        /// <param name="totalFee">总金额</param>
        /// <param name="cashFee">现金金额</param>
        /// <param name="posFee">POS金额</param>
        /// <param name="dtPrint">返回的打印数据</param>
        /// <param name="promFee">优惠金额</param>
        /// <returns>true成功false失败</returns>
        public bool SaveRegInfo(OP_PatList curPatlist, PayMentInfoList paymentInfoList, decimal totalFee, decimal cashFee, decimal posFee, out DataTable dtPrint, decimal promFee)
        {
            try
            {
                dtPrint = new DataTable();
                bool result = false;

                //插入挂号就诊表记录
                #region 插入挂号就诊表记录
                SerialNumberSource serialNumberSource = NewObject <SerialNumberSource>();
                curPatlist.VisitNO     = serialNumberSource.GetSerialNumber(SnType.门诊流水号);
                curPatlist.CureDeptID  = curPatlist.RegDeptID;
                curPatlist.CureEmpID   = curPatlist.RegEmpID;
                curPatlist.RegDate     = DateTime.Now;
                curPatlist.VisitStatus = 0;
                curPatlist.RegStatus   = 0;
                curPatlist.RegCategory = 0;
                DataTable dtOld = NewObject <OP_PatList>().gettable(" MemberID=" + curPatlist.MemberID);
                if (dtOld != null && dtOld.Rows.Count > 0)
                {
                    curPatlist.IsNew = 0;
                }
                else
                {
                    curPatlist.IsNew = 1;
                }

                this.BindDb(curPatlist);
                curPatlist.save();
                #endregion
                int iAccountType = 0;

                //得到当前结账ID
                int curAccountId = NewObject <CommonMethod>().GetAccountId(curPatlist.OperatorID, iAccountType);

                //插入结算主表对象
                #region 插入结算主表对象
                OP_CostHead costHead = new OP_CostHead();
                SetRegCostHead(costHead, curPatlist);
                costHead.CashFee   = cashFee;
                costHead.PosFee    = posFee;
                costHead.TotalFee  = totalFee;
                costHead.PromFee   = promFee;
                costHead.AccountID = curAccountId;
                this.BindDb(costHead);
                costHead.save();
                #endregion

                #region 插入费用表

                //插入费用主表 OP_FeeItemHead
                OP_FeeItemHead feeItemHead = new OP_FeeItemHead();
                SetRegFeeHeadValue(feeItemHead, costHead, curPatlist);
                this.BindDb(feeItemHead);
                feeItemHead.save();

                //插入费用明细表 OP_FeeItemDetail
                List <OP_FeeItemDetail> feeDetials = SetRegFeeDetailValue(feeItemHead.FeeItemHeadID, curPatlist);
                foreach (OP_FeeItemDetail feeDetial in feeDetials)
                {
                    this.BindDb(feeDetial);
                    feeDetial.save();
                }
                #endregion

                //插入结算明细表
                #region 插入结算明细表
                DataTable dtRegFeeDetail = NewDao <IOPManageDao>().GetRegItemFeeByStat(curPatlist.RegTypeID);
                for (int rowindex = 0; rowindex < dtRegFeeDetail.Rows.Count; rowindex++)
                {
                    OP_CostDetail costDetail = new OP_CostDetail();
                    costDetail.CostHeadID    = costHead.CostHeadID;
                    costDetail.FeeItemHeadID = feeItemHead.FeeItemHeadID;
                    costDetail.ExeDeptID     = curPatlist.RegDeptID;
                    costDetail.PresEmpID     = curPatlist.RegEmpID;
                    costDetail.PresDeptID    = curPatlist.RegDeptID;
                    costDetail.TotalFee      = Convert.ToDecimal(dtRegFeeDetail.Rows[rowindex]["statFee"]);
                    costDetail.StatID        = Convert.ToInt32(dtRegFeeDetail.Rows[rowindex]["statId"]);
                    this.BindDb(costDetail);
                    costDetail.save();
                }
                #endregion

                //插入结算支付方式明细表
                #region 插入结算支付方式明细表
                foreach (OP_CostPayMentInfo costpaymentinfo in paymentInfoList.paymentInfolist)
                {
                    if (costpaymentinfo.PayMentMoney > 0)
                    {
                        costpaymentinfo.AccountID  = curAccountId;
                        costpaymentinfo.CostHeadID = costHead.CostHeadID;
                        costpaymentinfo.PatListID  = curPatlist.PatListID;
                        costpaymentinfo.PatName    = curPatlist.PatName;
                        costpaymentinfo.PatType    = costHead.PatTypeID.ToString();
                        this.BindDb(costpaymentinfo);
                        costpaymentinfo.save();
                    }
                }
                #endregion

                //挂号记录表回写costheadid
                curPatlist.CostHeadID = costHead.CostHeadID;
                curPatlist.ChargeFlag = 1;
                this.BindDb(curPatlist);
                curPatlist.save();

                //结账表插入汇总金额
                NewObject <CommonMethod>().AddAccoutFee(costHead, curAccountId, 1, 0);

                //查数据库得到打印dtPrint
                dtPrint = NewObject <IOPManageDao>().GetRegPrint(curPatlist.PatListID);
                result  = true;
                return(result);
            }
            catch (Exception err)
            {
                throw new Exception(err.Message);
            }
        }
Пример #9
0
        /// <summary>
        /// 退号提交
        /// </summary>
        /// <param name="invoiceNO">票据号</param>
        /// <param name="operatorID">操作员ID</param>
        public void BackReg(string invoiceNO, int operatorID)
        {
            int iAccountType            = 0;
            List <OP_CostHead> costList = NewObject <OP_CostHead>().getlist <OP_CostHead>(" endInvoiceNO='" + invoiceNO + "' and regFlag=1");

            if (costList == null || costList.Count == 0)
            {
                throw new Exception("找不到该票据号信息");
            }
            else if (costList[0].CostStatus != 0)
            {
                throw new Exception("该票据号已经退费,不能再退");
            }
            else if (costList[0].CostStatus == 0 && costList[0].CostDate.ToString("yyyy-MM-dd") != DateTime.Now.ToString("yyyy-MM-dd"))
            {
                throw new Exception("已超过退号日期,只能退当天挂的号");
            }

            //原op_patlist变化
            OP_PatList patlist = NewObject <OP_PatList>().getmodel(costList[0].PatListID) as OP_PatList;

            if (patlist.VisitStatus != 0)
            {
                throw new Exception("您已就诊,不能再退号");
            }

            patlist.RegStatus = 1;//原挂号记录状态置1
            this.BindDb(patlist);
            patlist.save();

            //得到当前结账ID
            int curAccountId = NewObject <CommonMethod>().GetAccountId(operatorID, iAccountType);

            //原op_costHead变化
            OP_CostHead oldCostHead = costList[0].Clone() as OP_CostHead;

            oldCostHead.CostStatus = 1;//原有记录状态改为1
            this.BindDb(oldCostHead);
            oldCostHead.save();

            //生成新op_costHead变化
            OP_CostHead newCostHead = costList[0].Clone() as OP_CostHead;

            newCostHead.CostHeadID  = 0;
            newCostHead.CostDate    = DateTime.Now;
            newCostHead.CostStatus  = 2;//新增记录状态为2
            newCostHead.ChargeEmpID = operatorID;
            newCostHead.AccountID   = curAccountId;
            newCostHead.CashFee     = (oldCostHead.CashFee + oldCostHead.PosFee) * (-1);//退金额,POS金额退现金
            newCostHead.PosFee      = 0;
            newCostHead.PromFee     = oldCostHead.PromFee * (-1);
            newCostHead.OldID       = oldCostHead.CostHeadID;//写入原退记录ID
            newCostHead.TotalFee    = newCostHead.TotalFee * (-1);
            this.BindDb(newCostHead);
            newCostHead.save();

            //得到原来OP_FeeItemHead
            List <OP_FeeItemHead> listFeeitemHead = NewObject <OP_FeeItemHead>().getlist <OP_FeeItemHead>(" costheadid=" + oldCostHead.CostHeadID);
            OP_FeeItemHead        newFeeItemHead  = new OP_FeeItemHead();

            if (listFeeitemHead != null && listFeeitemHead.Count > 0)
            {
                OP_FeeItemHead oldFeeItemHead = listFeeitemHead[0].Clone() as OP_FeeItemHead;
                oldFeeItemHead.ChargeStatus = 1;//原有记录状态改为1
                this.BindDb(oldFeeItemHead);
                oldFeeItemHead.save();

                //生成新OP_FeeItemHead变化
                newFeeItemHead = listFeeitemHead[0].Clone() as OP_FeeItemHead;
                newFeeItemHead.FeeItemHeadID = 0;
                newFeeItemHead.ChargeStatus  = 2;
                newFeeItemHead.CostHeadID    = newCostHead.CostHeadID;
                newFeeItemHead.TotalFee      = newFeeItemHead.TotalFee * (-1);
                newFeeItemHead.OldID         = oldFeeItemHead.FeeItemHeadID;//写入原退记录ID
                this.BindDb(newFeeItemHead);
                newFeeItemHead.save();

                List <OP_FeeItemDetail> listFeeItemDetail = NewObject <OP_FeeItemDetail>().getlist <OP_FeeItemDetail>(" FeeItemHeadID=" + oldFeeItemHead.FeeItemHeadID);
                foreach (OP_FeeItemDetail oldfeeitemDetail in listFeeItemDetail)
                {
                    OP_FeeItemDetail newfeeitemDetail = oldfeeitemDetail.Clone() as OP_FeeItemDetail;
                    newfeeitemDetail.PresDetailID  = 0;
                    newfeeitemDetail.FeeItemHeadID = newFeeItemHead.FeeItemHeadID;
                    newfeeitemDetail.TotalFee      = newfeeitemDetail.TotalFee * (-1);
                    newfeeitemDetail.Amount        = oldfeeitemDetail.Amount * (-1);
                    this.BindDb(newfeeitemDetail);
                    newfeeitemDetail.save();
                }
            }

            //生成新op_costDetail
            List <OP_CostDetail> costDetailList = NewObject <OP_CostDetail>().getlist <OP_CostDetail>(" costheadid=" + oldCostHead.CostHeadID);

            foreach (OP_CostDetail oldcostDetail in costDetailList)
            {
                OP_CostDetail newCostDetail = oldcostDetail.Clone() as OP_CostDetail;
                newCostDetail.CostHeadID    = newCostHead.CostHeadID;
                newCostDetail.FeeItemHeadID = newFeeItemHead.FeeItemHeadID;
                newCostDetail.TotalFee      = oldcostDetail.TotalFee * (-1);
                newCostDetail.CostDetailID  = 0;
                this.BindDb(newCostDetail);
                newCostDetail.save();
            }

            //生成新OP_CostPayMentInfo
            List <OP_CostPayMentInfo> costPayMentInfoList = NewObject <OP_CostPayMentInfo>().getlist <OP_CostPayMentInfo>(" costheadid=" + oldCostHead.CostHeadID);
            decimal oldposfee = 0;

            foreach (OP_CostPayMentInfo oldCostpayInfo in costPayMentInfoList)
            {
                if (oldCostpayInfo.PayMentCode == "02")
                {
                    oldposfee = oldCostpayInfo.PayMentMoney;
                }
            }

            foreach (OP_CostPayMentInfo oldCostpayInfo in costPayMentInfoList)
            {
                OP_CostPayMentInfo newCostPayInfo = oldCostpayInfo.Clone() as OP_CostPayMentInfo;
                newCostPayInfo.AccountID  = curAccountId;
                newCostPayInfo.ID         = 0;
                newCostPayInfo.CostHeadID = newCostHead.CostHeadID;

                //POS
                if (oldCostpayInfo.PayMentCode == "02")
                {
                    newCostPayInfo.PayMentMoney = 0;
                }

                //现金
                if (oldCostpayInfo.PayMentCode == "01")
                {
                    newCostPayInfo.PayMentMoney = (oldCostpayInfo.PayMentMoney + oldposfee) * (-1);
                }
                else
                {
                    newCostPayInfo.PayMentMoney = oldCostpayInfo.PayMentMoney * (-1);
                }

                this.BindDb(newCostPayInfo);
                newCostPayInfo.save();
            }

            //结账表插入汇总金额
            NewObject <CommonMethod>().AddAccoutFee(newCostHead, curAccountId, 0, 1);
        }
Пример #10
0
        /// <summary>
        /// 收费预算
        /// </summary>
        /// <param name="prescriptions">处方对象</param>
        /// <returns>返回预算对象</returns>
        public override List <ChargeInfo> Budget(List <Prescription> prescriptions)
        {
            List <ChargeInfo> listChargeInfos = new List <ChargeInfo>();
            decimal           toTalFee        = prescriptions.Sum(p => p.TotalFee);
            OP_CostHead       costHead        = new OP_CostHead(); //插入结算头表

            costHead.MemberID        = GetPatient.MemberID;
            costHead.CardNO          = GetPatient.CardNO;
            costHead.PatListID       = GetPatient.PatListID;
            costHead.MemberAccountID = GetPatient.MemberAccountID;
            costHead.PatName         = GetPatient.PatName;
            costHead.PatTypeID       = CostTypeid;//结算时选择的病人类型ID
            costHead.BeInvoiceNO     = string.Empty;
            costHead.EndInvoiceNO    = string.Empty;
            costHead.ChargeEmpID     = GetOperatorId;
            costHead.TotalFee        = toTalFee;
            costHead.CashFee         = 0;
            costHead.PosFee          = 0;
            costHead.PromFee         = 0;
            costHead.RecipeFlag      = 0;
            costHead.CostStatus      = 9;//修改预算状态为9
            costHead.OldID           = 0;
            costHead.AccountID       = 0;
            costHead.RegFlag         = 0;
            this.BindDb(costHead);
            costHead.save();
            List <int> feeHeadIDs = new List <int>();

            for (int groupIndex = 0; groupIndex < BudgeGroupID.Count; groupIndex++)
            {
                int groupid = BudgeGroupID[groupIndex];
                List <Prescription> presDetails = prescriptions.Where(p => p.PrescGroupID == groupid).ToList();
                var result = from p in presDetails.AsEnumerable()
                             group p by p.StatID into g
                             select new
                {
                    g.Key,
                    SumValue = g.Sum(p => p.TotalFee)
                };
                foreach (var stat in result)
                {
                    OP_CostDetail costDetail = new OP_CostDetail();
                    costDetail.StatID        = stat.Key;
                    costDetail.TotalFee      = Convert.ToDecimal(stat.SumValue);
                    costDetail.CostHeadID    = costHead.CostHeadID;
                    costDetail.FeeItemHeadID = presDetails[0].FeeItemHeadID;
                    costDetail.PresEmpID     = presDetails[0].PresEmpID;
                    costDetail.PresDeptID    = presDetails[0].PresDeptID;
                    costDetail.ExeDeptID     = presDetails[0].ExecDeptID;
                    this.BindDb(costDetail);
                    costDetail.save();
                }

                feeHeadIDs.Add(presDetails[0].FeeItemHeadID);//记录费用头ID
                OP_FeeItemHead feeItemHead = NewObject <OP_FeeItemHead>().getmodel(presDetails[0].FeeItemHeadID) as OP_FeeItemHead;
                if (feeItemHead.ChargeFlag == 1)
                {
                    throw new Exception("处方已被别的收费员收费,请确认!");
                }

                //如果是医生站处方,要判断医生站处方状态,防止医生站已经修改
                feeItemHead.CostHeadID   = costHead.CostHeadID;
                feeItemHead.ChargeStatus = 0;//处方状态不修改
                this.BindDb(feeItemHead);
                feeItemHead.save();
            }

            ChargeInfo chargeInfo = new ChargeInfo();

            chargeInfo.TotalFee       = toTalFee;             //结算总金额
            chargeInfo.CostHeadID     = costHead.CostHeadID;  //结算ID
            chargeInfo.FeeItemHeadIDs = feeHeadIDs.ToArray(); //一次结算对应的费用头表ID
            listChargeInfos.Add(chargeInfo);
            return(listChargeInfos);
        }
Пример #11
0
        /// <summary>
        /// 处方正式结算
        /// </summary>
        /// <param name="curPatlist">当前病人对象</param>
        /// <param name="operatoreid">操作员ID</param>
        /// <param name="budgeInfo">预算对象</param>
        /// <param name="prescriptions">处方对象</param>
        public override void Balance(OP_PatList curPatlist, int operatoreid, List <ChargeInfo> budgeInfo, List <Prescription> prescriptions)
        {
            #region 医生站处方判断和状态修改,医技确费状态修改
            CheckDocPrsc(prescriptions);
            #endregion

            DateTime chargedate   = DateTime.Now;
            int      iAccountType = 0;

            //得到当前结账ID
            int curAccountId = NewObject <CommonMethod>().GetAccountId(operatoreid, iAccountType);

            //实际上多张处方一次结算只有一条记录
            foreach (ChargeInfo chargeInfo in budgeInfo)
            {
                string        invoiceNo    = string.Empty;
                Basic_Invoice basicInvoice = NewObject <CommonMethod>().GetCurInvoice(InvoiceType.门诊收费, operatoreid);
                string        perfChar     = string.Empty;
                invoiceNo = NewObject <InvoiceManagement>().GetInvoiceCurNOAndUse(InvoiceType.门诊收费, operatoreid, out perfChar);
                invoiceNo = perfChar + invoiceNo; //多张处方一张票号
                int   costheadid = chargeInfo.CostHeadID;
                int[] feeHeadids = chargeInfo.FeeItemHeadIDs;
                chargeInfo.InvoiceCount = 1;
                chargeInfo.ChargeDate   = chargedate;
                OP_CostHead costHead = NewObject <OP_CostHead>().getmodel(costheadid) as OP_CostHead;
                if (costHead != null && costHead.CostHeadID > 0)
                {
                    //结算主表状态和金额写入
                    costHead.ChargeEmpID  = operatoreid;
                    costHead.CostStatus   = 0;//正常收费标志改为0
                    costHead.CostDate     = chargedate;
                    costHead.CashFee      = chargeInfo.CashFee;
                    costHead.PosFee       = chargeInfo.PosFee;
                    costHead.PromFee      = chargeInfo.FavorableTotalFee;
                    costHead.RoundingFee  = chargeInfo.RoundFee;
                    costHead.EndInvoiceNO = invoiceNo;
                    costHead.BeInvoiceNO  = invoiceNo;
                    costHead.AccountID    = curAccountId;
                    costHead.InvoiceID    = basicInvoice.ID;//保存使用票据的发票卷序号
                    this.BindDb(costHead);
                    costHead.save();

                    //费用主表状态修改
                    NewDao <IOPManageDao>().UpdateFeeItemHeadStatus(costHead.CostHeadID, invoiceNo, chargedate, operatoreid);

                    //插入结算支付方式表
                    foreach (OP_CostPayMentInfo payment in chargeInfo.PayInfoList)
                    {
                        payment.PatListID  = curPatlist.PatListID;
                        payment.PatName    = curPatlist.PatName;
                        payment.PatType    = costHead.PatTypeID.ToString();
                        payment.AccountID  = curAccountId;
                        payment.CostHeadID = costHead.CostHeadID;
                        Basic_Payment basePayment = NewObject <Basic_Payment>().getmodel(payment.PayMentID) as Basic_Payment;
                        payment.PayMentCode = basePayment.PayCode;
                        payment.PayMentName = basePayment.PayName;
                        this.BindDb(payment);
                        payment.save();
                    }

                    //减虚拟库存
                    MinisStorage(prescriptions, false);

                    //会员积分
                    AddScore(curPatlist.MemberAccountID, costHead.TotalFee, costHead.CostHeadID.ToString(), operatoreid);
                    if (chargeInfo.FavorableTotalFee > 0)
                    {
                        SavePromData(costHead.PatTypeID, costHead.MemberAccountID, costHead.TotalFee, prescriptions, operatoreid, costHead.CostHeadID);
                    }

                    AddAccoutFee(costHead, curAccountId, 1, 0);
                }
                else
                {
                    throw new Exception("没有找到结算号的记录!");
                }
            }
        }
Пример #12
0
        /// <summary>
        /// 全退处方
        /// </summary>
        /// <param name="costHeadid">结算ID</param>
        /// <param name="operatoreid">操作员ID</param>
        /// <param name="refundPrescriptions">退费处方</param>
        /// <param name="refundInvoiceNO">退费票据号</param>
        public void AllRefund(int costHeadid, int operatoreid, List <Prescription> refundPrescriptions, string refundInvoiceNO)
        {
            /*
             * 1:获取当前退费操作员结账ID
             * 2:修改原结算记录OP_CostHead CostStatus=1
             * 3:新增红冲结算记录 CostStatus = 2,写入对冲OldID,金额为负
             * 4:新增红冲结算明细记录 OP_CostDetail
             * 5:新增红冲结算支付方式记录 OP_CostPayMentInfo
             * 6:修改原费用主表 OP_FeeItemHead ChargeStatus=1
             * 7:新增红冲费用主表记录ChargeStatus=2,写入对冲OldID,金额为负
             * 8:新增红冲费用明细表记录 OP_FeeItemDetail
             * 9:修改退费消息表OP_FeeRefundHead RefundPayFlag = 1
             * 10:减会员积分
             * 11:加虚拟库存
             * 12:修改op_account汇总金额
             */
            int      iAccountType = 0;
            DateTime chargedate   = DateTime.Now;

            //获取当前操作员得到当前结账ID
            int         curAccountId = NewObject <CommonMethod>().GetAccountId(operatoreid, iAccountType);
            OP_CostHead oldCostHead  = NewObject <OP_CostHead>().getmodel(costHeadid) as OP_CostHead;

            if (oldCostHead.CostStatus != 0)
            {
                throw new Exception("该处方已经被退费");
            }

            List <OP_FeeRefundHead> feerefundheadlist = NewObject <OP_FeeRefundHead>().getlist <OP_FeeRefundHead>("invoicenum='" + refundInvoiceNO + "' and flag=0");

            if (feerefundheadlist == null || feerefundheadlist.Count == 0)
            {
                throw new Exception("退费消息已经删除");
            }

            //再次判断退费消息,是不是存在已经删除又修改状态
            List <OP_FeeRefundDetail> feerefundDetailList = NewObject <OP_FeeRefundDetail>().getlist <OP_FeeRefundDetail>(" reheadid=" + feerefundheadlist[0].ReHeadID);

            //返回需要补收的处方记录
            foreach (Prescription refundPresc in refundPrescriptions)
            {
                foreach (OP_FeeRefundDetail refundDetail in feerefundDetailList)
                {
                    if (refundPresc.FeeItemHeadID == refundDetail.FeeItemHeadID && refundPresc.PresDetailID == refundDetail.FeeItemDetailID)
                    {
                        if (refundPresc.Refundamount != refundDetail.RefundAmount)
                        {
                            throw new Exception("退费消息已经修改,请重新获取退费消息");
                        }
                    }
                }
            }

            int refundPosType = Convert.ToInt32(NewObject <CommonMethod>().GetOpConfig(OpConfigConstant.RefundPosType));

            //原结算记录状态修改
            oldCostHead.CostStatus = 1; //状态变为退费状态
            this.BindDb(oldCostHead);
            oldCostHead.save();

            //新结算主表
            OP_CostHead newCostHead = oldCostHead.Clone() as OP_CostHead;

            newCostHead.CostHeadID = 0;
            newCostHead.CostStatus = 2;            //状态为空冲
            newCostHead.AccountID  = curAccountId; //定入新的结算ID
            if (refundPosType == 0)                //pos退现金
            {
                newCostHead.CashFee = (oldCostHead.CashFee + oldCostHead.PosFee) * -1;
                newCostHead.PosFee  = 0;
            }
            else
            {
                newCostHead.CashFee = oldCostHead.CashFee * -1;
                newCostHead.PosFee  = oldCostHead.PosFee * -1;
            }

            newCostHead.TotalFee    = newCostHead.TotalFee * -1;
            newCostHead.PromFee     = newCostHead.PromFee * -1;
            newCostHead.OldID       = oldCostHead.CostHeadID;//写入原costHeadID
            newCostHead.ChargeEmpID = operatoreid;
            newCostHead.CostDate    = chargedate;
            newCostHead.RoundingFee = oldCostHead.RoundingFee * -1;
            this.BindDb(newCostHead);
            newCostHead.save();

            //新结算支付方式表
            List <OP_CostPayMentInfo> oldCostPayList = NewObject <OP_CostPayMentInfo>().getlist <OP_CostPayMentInfo>(" costheadid=" + oldCostHead.CostHeadID);

            if (refundPosType == 0)
            {
                oldCostPayList = oldCostPayList.Where(p => p.PayMentCode != "02").ToList();
                foreach (OP_CostPayMentInfo oldCostPay in oldCostPayList)
                {
                    OP_CostPayMentInfo newCostPay = oldCostPay.Clone() as OP_CostPayMentInfo;
                    newCostPay.ID         = 0;
                    newCostPay.CostHeadID = newCostHead.CostHeadID;
                    newCostPay.AccountID  = curAccountId;

                    //现金
                    if (oldCostPay.PayMentCode != "01")
                    {
                        //退现金另外处理
                        newCostPay.PayMentMoney = oldCostPay.PayMentMoney * -1;
                        this.BindDb(newCostPay);
                        newCostPay.save();
                    }
                }

                if (newCostHead.CashFee != 0)
                {
                    OP_CostPayMentInfo cashCostPay = new OP_CostPayMentInfo();
                    cashCostPay.CostHeadID   = newCostHead.CostHeadID;
                    cashCostPay.AccountID    = curAccountId;
                    cashCostPay.PatListID    = newCostHead.PatListID;
                    cashCostPay.PatName      = newCostHead.PatName;
                    cashCostPay.PatType      = newCostHead.PatTypeID.ToString();
                    cashCostPay.PayMentCode  = "01";
                    cashCostPay.PayMentID    = 1002;
                    cashCostPay.PayMentMoney = newCostHead.CashFee;
                    cashCostPay.PayMentName  = "现金支付";
                    this.BindDb(cashCostPay);
                    cashCostPay.save();
                }
            }
            else if (refundPosType == 1)
            {
                foreach (OP_CostPayMentInfo oldCostPay in oldCostPayList)
                {
                    OP_CostPayMentInfo newCostPay = oldCostPay.Clone() as OP_CostPayMentInfo;
                    newCostPay.ID           = 0;
                    newCostPay.CostHeadID   = newCostHead.CostHeadID;
                    newCostPay.AccountID    = curAccountId;
                    newCostPay.PayMentMoney = oldCostPay.PayMentMoney * -1;
                    this.BindDb(newCostPay);
                    newCostPay.save();
                }
            }

            //费用表插入红冲记录
            List <OP_FeeItemHead> oldFeeItemHeadList = NewObject <OP_FeeItemHead>().getlist <OP_FeeItemHead>(" costheadid=" + oldCostHead.CostHeadID);

            foreach (OP_FeeItemHead oldFeeHead in oldFeeItemHeadList)
            {
                oldFeeHead.ChargeStatus = 1;//退费状态
                this.BindDb(oldFeeHead);
                oldFeeHead.save();

                OP_FeeItemHead newFeeHead = oldFeeHead.Clone() as OP_FeeItemHead;
                newFeeHead.FeeItemHeadID = 0;
                newFeeHead.CostHeadID    = newCostHead.CostHeadID;
                newFeeHead.OldID         = oldFeeHead.FeeItemHeadID; //红冲退记录ID
                newFeeHead.ChargeStatus  = 2;                        //新插入记录为红冲记录
                newFeeHead.ChargeEmpID   = operatoreid;
                newFeeHead.ChargeDate    = chargedate;
                newFeeHead.TotalFee      = oldFeeHead.TotalFee * -1;
                this.BindDb(newFeeHead);
                newFeeHead.save();

                List <OP_FeeItemDetail> oldFeeItemDetailList = NewObject <OP_FeeItemDetail>().getlist <OP_FeeItemDetail>(" feeitemheadid=" + oldFeeHead.FeeItemHeadID);
                foreach (OP_FeeItemDetail oldFeeItemDetail in oldFeeItemDetailList)
                {
                    OP_FeeItemDetail newFeeItemDetail = oldFeeItemDetail.Clone() as OP_FeeItemDetail;
                    newFeeItemDetail.PresDetailID  = 0;
                    newFeeItemDetail.TotalFee      = oldFeeItemDetail.TotalFee * -1;
                    newFeeItemDetail.Amount        = oldFeeItemDetail.Amount * -1;
                    newFeeItemDetail.FeeItemHeadID = newFeeHead.FeeItemHeadID;
                    this.BindDb(newFeeItemDetail);
                    newFeeItemDetail.save();
                }
            }

            //新结算明细表
            List <OP_CostDetail> oldCostDetailList = NewObject <OP_CostDetail>().getlist <OP_CostDetail>("costheadid=" + oldCostHead.CostHeadID);

            foreach (OP_CostDetail oldCostDetail in oldCostDetailList)
            {
                OP_CostDetail newCostDetail = oldCostDetail.Clone() as OP_CostDetail;
                newCostDetail.CostDetailID  = 0;
                newCostDetail.CostHeadID    = newCostHead.CostHeadID;//写入新CostHeadID
                newCostDetail.TotalFee      = oldCostDetail.TotalFee * -1;
                newCostDetail.FeeItemHeadID = NewDao <IOPManageDao>().GetNewFeeItemHeadId(oldCostDetail.FeeItemHeadID);
                this.BindDb(newCostDetail);
                newCostDetail.save();
            }

            //退费消息表置退费状态
            List <OP_FeeRefundHead> refundHeadList = NewObject <OP_FeeRefundHead>().getlist <OP_FeeRefundHead>(" invoiceNum='" + refundInvoiceNO + "' and flag=0");

            if (refundHeadList.Count == 0)
            {
                throw new Exception("找不到退费消息");
            }

            OP_FeeRefundHead refundHead = refundHeadList[0] as OP_FeeRefundHead;

            refundHead.RefundPayFlag = 1;//退费完成状态
            this.BindDb(refundHead);
            refundHead.save();

            //减会员积分
            AddScore(newCostHead.MemberAccountID, newCostHead.TotalFee, newCostHead.CostHeadID.ToString(), operatoreid);

            //药品加虚拟库存
            MinisStorage(refundPrescriptions, true);
            AddAccoutFee(newCostHead, curAccountId, 0, 1);

            //修改医生站处方状态
            RefundDocPrsc(refundPrescriptions);
        }
Пример #13
0
 /// <summary>
 /// 每笔记录汇总插入结账表
 /// </summary>
 /// <param name="costHead">结算对象</param>
 /// <param name="curAccountId">缴款ID</param>
 /// <param name="invoiceCount">收费票据张数</param>
 /// <param name="refundInvoiceCount">退票张数</param>
 public void AddAccoutFee(OP_CostHead costHead, int curAccountId, int invoiceCount, int refundInvoiceCount)
 {
     NewObject <CommonMethod>().AddAccoutFee(costHead, curAccountId, invoiceCount, refundInvoiceCount);
 }
Пример #14
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);
        }
Пример #15
0
        /// <summary>
        /// 收费正式结算
        /// </summary>
        /// <param name="curPatlist">病人对象</param>
        /// <param name="operatoreid">操作员ID</param>
        /// <param name="budgeInfo">预算对象</param>
        /// <param name="prescriptions">处方对象</param>
        public override void Balance(OP_PatList curPatlist, int operatoreid, List <ChargeInfo> budgeInfo, List <Prescription> prescriptions)
        {
            #region 医生站处方判断和状态修改,医技确费状态修改
            CheckDocPrsc(prescriptions);
            #endregion
            DateTime chargedate   = DateTime.Now;
            int      iAccountType = 0;

            //得到当前结账ID
            int curAccountId = NewObject <CommonMethod>().GetAccountId(operatoreid, iAccountType);

            //实际上一次结算只有一条记录结算表只一条记录
            foreach (ChargeInfo chargeInfo in budgeInfo)
            {
                int   costheadid = chargeInfo.CostHeadID;
                int[] feeHeadids = chargeInfo.FeeItemHeadIDs;

                //int invoiceNum= NewObject<CommonMethod>().GetInvoiceInfo(InvoiceType.门诊收费, operatoreid, out curInvoiceNO);
                //if (invoiceNum < feeHeadids.Length)
                //{
                //    throw new Exception("本次收费需要"+feeHeadids.Length+"张票,您的可用票据张数不足");
                //}
                chargeInfo.InvoiceCount = feeHeadids.Length;
                chargeInfo.ChargeDate   = chargedate;
                OP_CostHead costHead = NewObject <OP_CostHead>().getmodel(costheadid) as OP_CostHead;
                if (costHead != null && costHead.CostHeadID > 0)
                {
                    string        bInvoiceNo   = string.Empty;
                    string        eInvoiceNo   = string.Empty;
                    Basic_Invoice basicInvoice = NewObject <CommonMethod>().GetCurInvoice(InvoiceType.门诊收费, operatoreid);
                    if (basicInvoice.EndNO - basicInvoice.CurrentNO + 1 < feeHeadids.Length)
                    {
                        throw new Exception("本次收费需要" + feeHeadids.Length + "张票,您当前使用发票卷的可用票据张数不足");
                    }

                    for (int feeIndex = 0; feeIndex < feeHeadids.Length; feeIndex++)
                    {
                        //费用主表状态修改
                        OP_FeeItemHead feeItemHead = NewObject <OP_FeeItemHead>().getmodel(feeHeadids[feeIndex]) as OP_FeeItemHead;
                        string         invoiceNo   = string.Empty;
                        string         perfChar    = string.Empty;
                        invoiceNo = NewObject <InvoiceManagement>().GetInvoiceCurNOAndUse(InvoiceType.门诊收费, operatoreid, out perfChar);
                        invoiceNo = perfChar + invoiceNo;

                        //一张处方一张票号
                        feeItemHead.InvoiceNO    = invoiceNo;
                        feeItemHead.ChargeDate   = chargedate;
                        feeItemHead.ChargeFlag   = 1;
                        feeItemHead.ChargeStatus = 0;
                        feeItemHead.ChargeEmpID  = operatoreid;
                        feeItemHead.save();
                        if (feeIndex == 0)
                        {
                            bInvoiceNo = invoiceNo;
                        }
                        else if (feeIndex == feeHeadids.Length - 1)
                        {
                            eInvoiceNo = invoiceNo;
                        }
                    }

                    //结算主表状态和金额写入
                    costHead.ChargeEmpID  = operatoreid;
                    costHead.CostStatus   = 0;//正常收费标志改为0
                    costHead.CostDate     = chargedate;
                    costHead.CashFee      = chargeInfo.CashFee;
                    costHead.PosFee       = chargeInfo.PosFee;
                    costHead.PromFee      = chargeInfo.FavorableTotalFee;
                    costHead.RoundingFee  = chargeInfo.RoundFee;
                    costHead.EndInvoiceNO = bInvoiceNo;
                    costHead.BeInvoiceNO  = eInvoiceNo;
                    costHead.AccountID    = curAccountId;
                    costHead.InvoiceID    = basicInvoice.ID;//写入发票卷序号
                    this.BindDb(costHead);
                    costHead.save();

                    //插入结算支付方式表
                    foreach (OP_CostPayMentInfo payment in chargeInfo.PayInfoList)
                    {
                        payment.PatListID  = curPatlist.PatListID;
                        payment.PatName    = curPatlist.PatName;
                        payment.PatType    = costHead.PatTypeID.ToString();
                        payment.AccountID  = curAccountId;
                        payment.CostHeadID = costHead.CostHeadID;
                        Basic_Payment basePayment = NewObject <Basic_Payment>().getmodel(payment.PayMentID) as Basic_Payment;
                        payment.PayMentCode = basePayment.PayCode;
                        payment.PayMentName = basePayment.PayName;
                        this.BindDb(payment);
                        payment.save();
                    }

                    //减虚拟库存
                    MinisStorage(prescriptions, false);
                    AddScore(curPatlist.MemberAccountID, costHead.TotalFee, costHead.CostHeadID.ToString(), operatoreid);
                    AddAccoutFee(costHead, curAccountId, feeHeadids.Length, 0);
                }
                else
                {
                    throw new Exception("没有找到结算号的记录!");
                }
            }
        }