/// <summary> /// 费用明细表赋值 /// </summary> /// <param name="feeItemheadid">费用头表ID</param> /// <param name="curPatlist">病人对象</param> /// <returns>返回费用明细</returns> private List <OP_FeeItemDetail> SetRegFeeDetailValue(int feeItemheadid, OP_PatList curPatlist) { DataTable dtRegFeeDetails = NewDao <IOPManageDao>().GetRegItemFees(curPatlist.RegTypeID); List <OP_FeeItemDetail> listFeeItemDetail = new List <OP_FeeItemDetail>(); for (int i = 0; i < dtRegFeeDetails.Rows.Count; i++) { OP_FeeItemDetail feeItemDetail = new OP_FeeItemDetail(); feeItemDetail.FeeItemHeadID = feeItemheadid; feeItemDetail.MemberID = curPatlist.MemberID; feeItemDetail.PatListID = curPatlist.PatListID; feeItemDetail.ItemID = Convert.ToInt32(dtRegFeeDetails.Rows[i]["itemid"]); feeItemDetail.ItemName = dtRegFeeDetails.Rows[i]["itemname"].ToString(); feeItemDetail.StatID = Convert.ToInt32(dtRegFeeDetails.Rows[i]["StatID"]); feeItemDetail.ItemType = dtRegFeeDetails.Rows[i]["ItemClass"].ToString(); feeItemDetail.Spec = dtRegFeeDetails.Rows[i]["Standard"].ToString(); feeItemDetail.PackUnit = dtRegFeeDetails.Rows[i]["UnPickUnit"].ToString(); feeItemDetail.UnitNO = Convert.ToDecimal(dtRegFeeDetails.Rows[i]["MiniConvertNum"]); feeItemDetail.StockPrice = Convert.ToDecimal(dtRegFeeDetails.Rows[i]["InPrice"]); feeItemDetail.RetailPrice = Convert.ToDecimal(dtRegFeeDetails.Rows[i]["SellPrice"]); feeItemDetail.Amount = 1; feeItemDetail.PresAmount = 1; feeItemDetail.TotalFee = feeItemDetail.RetailPrice; feeItemDetail.ExamItemID = 0; feeItemDetail.DocPresDetailID = 0; feeItemDetail.MiniUnit = dtRegFeeDetails.Rows[i]["MiniUnitName"].ToString(); listFeeItemDetail.Add(feeItemDetail); } return(listFeeItemDetail); }
/// <summary> /// 删除处方明细 /// </summary> /// <param name="prescriptionDetailId">要删除的明细ID</param> public void DeletePrescriptionDetail(int prescriptionDetailId) { OP_FeeItemDetail feeitemdetail = NewObject <OP_FeeItemDetail>().getmodel(prescriptionDetailId) as OP_FeeItemDetail; OP_FeeItemHead feeitemhead = NewObject <OP_FeeItemHead>().getmodel(feeitemdetail.FeeItemHeadID) as OP_FeeItemHead; if (feeitemhead.ChargeFlag == 1) { throw new Exception("该处方已经收费,不能删除!"); } try { feeitemdetail.delete(); } catch (Exception err) { throw new Exception(err.Message); } }
/// <summary> /// 费用明细表赋值 /// </summary> /// <param name="feeitemDetail">费用明细对象</param> /// <param name="presc">处方对象</param> /// <param name="curPatlist">病人对象</param> private void SetFeeDetailValue(OP_FeeItemDetail feeitemDetail, Prescription presc, OP_PatList curPatlist) { feeitemDetail.PresDetailID = presc.PresDetailID; feeitemDetail.DocPresDetailID = presc.DocPresDetailID; feeitemDetail.MemberID = curPatlist.MemberID; feeitemDetail.PatListID = curPatlist.PatListID; feeitemDetail.ItemID = presc.ItemID; feeitemDetail.ItemType = presc.ItemType; feeitemDetail.StatID = presc.StatID; feeitemDetail.ItemName = presc.ItemName; feeitemDetail.Spec = presc.Spec; feeitemDetail.PackUnit = presc.PackUnit; feeitemDetail.UnitNO = presc.UnitNO; feeitemDetail.StockPrice = presc.StockPrice; feeitemDetail.RetailPrice = presc.RetailPrice; feeitemDetail.Amount = (presc.PackAmount * presc.UnitNO) + presc.MiniAmount; feeitemDetail.PresAmount = presc.PresAmount; feeitemDetail.TotalFee = presc.TotalFee; feeitemDetail.ExamItemID = presc.ExamItemID; feeitemDetail.DocPresDetailID = presc.DocPresDetailID; feeitemDetail.MiniUnit = presc.MiniUnit; feeitemDetail.Memo = presc.Memo; feeitemDetail.DocPresDate = presc.DocPresDate; }
/// <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); }
/// <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>(); // 医生站的处方退后重新生成的处方 List <int> updateDocPres = new List <int>(); //返回需要补收的处方记录 foreach (Prescription refundPresc in refundPrescriptions) { if (refundPresc.PresAmount == 0) { refundPresc.PresAmount = 1; } if (refundPresc.Amount * refundPresc.PresAmount != refundPresc.Refundamount) { refundPresc.Amount = refundPresc.Amount * refundPresc.PresAmount - refundPresc.Refundamount; refundPresc.TotalFee = refundPresc.TotalFee - refundPresc.Refundfee; //部分退费重新生成的新处方 if (refundPresc.Refundamount > 0 && refundPresc.DocPresHeadID > 0) { updateDocPres.Add(refundPresc.FeeItemHeadID); } balancePresc.Add(refundPresc); } } if (balancePresc.Count > 0) { //补收的处方数据保存到数据库 List <int> presNum = GetPrescNum(balancePresc); for (int i = 0; i < presNum.Count; i++) { int groupid = presNum[i]; List <Prescription> presDetails = balancePresc.Where(p => p.PrescGroupID == groupid && p.SubTotalFlag == 0).ToList(); if (presDetails.Count > 0) { OP_FeeItemHead oldFeeitemHead = NewObject <OP_FeeItemHead>().getmodel(presDetails[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; if (updateDocPres.Contains(presDetails[0].FeeItemHeadID)) { feeitemHead.DocPresHeadID = 0; feeitemHead.DocPresNO = 0; } decimal roundingMoney = 0; feeitemHead.TotalFee = NewObject <PrescMoneyCalculate>().GetPrescriptionTotalMoney(presDetails, out roundingMoney); this.BindDb(feeitemHead); feeitemHead.save(); for (int j = 0; j < balancePresc.Count; j++) { if (balancePresc[j].PrescGroupID == groupid && balancePresc[j].SubTotalFlag == 0) { 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; if (updateDocPres.Contains(presDetails[0].FeeItemHeadID)) { feeDetial.DocPresDetailID = 0; balancePresc[j].DocPresDetailID = 0; balancePresc[j].DocPresHeadID = 0; balancePresc[j].DocPresNO = 0; } feeDetial.save(); balancePresc[j].FeeItemHeadID = feeitemHead.FeeItemHeadID; balancePresc[j].PresDetailID = feeDetial.PresDetailID; balancePresc[j].FeeNo = feeitemHead.FeeNo; balancePresc[j].DocPresDate = feeDetial.DocPresDate; balancePresc[j].ModifyFlag = 0; } } } } } return(balancePresc); }
/// <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); }
/// <summary> /// 处方保存 /// </summary> /// <param name="curPalist">病人对象</param> /// <param name="prescriptions">处方对象</param> /// <param name="feeHeadCount">费用头ID</param> /// <param name="operatorid">操作员ID</param> public void SavePrescription(OP_PatList curPalist, List <Prescription> prescriptions, List <int> feeHeadCount, int operatorid) { try { DrugStoreManagement drugManager = NewObject <DrugStoreManagement>(); DateTime presdate = DateTime.Now; for (int i = 0; i < feeHeadCount.Count; i++) { int groupid = feeHeadCount[i]; List <Prescription> presModifyDetails = prescriptions.Where(p => p.PrescGroupID == groupid && p.SubTotalFlag == 0 && p.ModifyFlag == 1).ToList(); if (presModifyDetails.Count == 0) { continue; } List <Prescription> presDetails = prescriptions.Where(p => p.PrescGroupID == groupid && p.SubTotalFlag == 0).ToList(); if (presDetails.Count > 0) { OP_FeeItemHead feeitemHead = new OP_FeeItemHead(); //OP_FeeItemHead赋值 SetFeeHeadValue(feeitemHead, presDetails[0], curPalist); feeitemHead.ChargeEmpID = operatorid; decimal roundingMoney = 0; feeitemHead.TotalFee = NewObject <PrescMoneyCalculate>().GetPrescriptionTotalMoney(presDetails, out roundingMoney); feeitemHead.RoungingFee = roundingMoney; if (feeitemHead.DocPresHeadID > 0) { feeitemHead.PresDate = presDetails[0].DocPresDate; } else { feeitemHead.PresDate = presdate; } feeitemHead.RegFlag = 0; if (feeitemHead.FeeItemHeadID == 0) { feeitemHead.FeeNo = DateTime.Now.Ticks;// Convert.ToDecimal( DateTime.Now.ToString("yyyyMMddHHmmssffff"));// GetTimeStamp();//生成费用流水号 } if (Convert.ToInt32(presDetails[0].ItemType) == (int)OP_Enum.ItemType.药品) { if (presDetails[0].StatID == 100) { feeitemHead.PresType = "1";//西药处方 } else if (presDetails[0].StatID == 101) { feeitemHead.PresType = "2";//中成药处方 } else if (presDetails[0].StatID == 102) { feeitemHead.PresType = "3";//中草药处方 } } else { feeitemHead.PresType = "0";//非药品处方 } this.BindDb(feeitemHead); feeitemHead.save(); for (int j = 0; j < prescriptions.Count; j++) { if (prescriptions[j].PrescGroupID == groupid && prescriptions[j].SubTotalFlag == 0) { OP_FeeItemDetail feeDetail = new OP_FeeItemDetail(); //OP_FeeItemDetail赋值 SetFeeDetailValue(feeDetail, prescriptions[j], curPalist); if (feeDetail.Amount == 0) { throw new Exception("【" + feeDetail.ItemName + "】数量为零,请输入一个大于零的数"); } if (Convert.ToInt32(feeDetail.ItemType) == (int)ItemType.药品 && prescriptions[j].Selected == 1) { //判断实时库存 decimal storAmount = drugManager.GetStorage(feeDetail.ItemID, feeitemHead.ExecDeptID); if (storAmount < feeDetail.Amount) { throw new Exception("【" + feeDetail.ItemName + "】库存不足,请重新输入"); } } feeDetail.FeeItemHeadID = feeitemHead.FeeItemHeadID; this.BindDb(feeDetail); feeDetail.save(); prescriptions[j].FeeItemHeadID = feeitemHead.FeeItemHeadID; prescriptions[j].PresDetailID = feeDetail.PresDetailID; prescriptions[j].FeeNo = feeitemHead.FeeNo; prescriptions[j].ModifyFlag = 0; } } this.BindDb(curPalist); curPalist.save(); } } } catch (Exception err) { throw new Exception(err.Message); } }
/// <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); }