Пример #1
0
        /// <summary>
        /// 预算
        /// </summary>
        /// <param name="prescriptions">要预算的处方</param>
        /// <returns>预算信息,供正式结算用</returns>
        public override ChargeInfo[] Budget(Prescription[] prescriptions)
        {
            //单张处方明细转化为大项目明细合并后累加在取舍。
            //保存每张处方的大项目明细
            List <List <Item> > lstStatItems = new List <List <Item> >( );
            //本次结算总金额(等于每张处方舍入后的金额的合计)
            decimal chargeTotalCost = 0;

            #region 合并大类并计算舍入金额
            try
            {
                for (int i = 0; i < prescriptions.Length; i++)
                {
                    List <Item> lstTemp = new List <Item>( );
                    lstTemp         = MergePrescriptionByStatItemCode(ref prescriptions[i]);
                    chargeTotalCost = chargeTotalCost + prescriptions[i].Total_Fee;
                    lstStatItems.Add(lstTemp);
                }
            }
            catch (Exception err)
            {
                ErrorWriter.WriteLog(err.Message + "\r\n" + err.StackTrace);
                throw new OperatorException("合并项目发生错误!");
            }
            #endregion
            //保存合并后的所有大项目明细,类型MZ_CostOrder
            Hashtable htCostOrder = new Hashtable();
            #region 合并所有结算明细(不需要再舍入)
            try
            {
                foreach (List <Item> lstTemp in lstStatItems)
                {
                    foreach (object obj in lstTemp)
                    {
                        if (htCostOrder.ContainsKey(((Item)obj).Text.Trim( )))
                        {
                            Item item = (Item)obj;
                            Model.MZ_CostOrder mz_costorder = (Model.MZ_CostOrder)htCostOrder[item.Text.Trim( )];
                            mz_costorder.Total_Fee = mz_costorder.Total_Fee + Convert.ToDecimal(item.Value);
                        }
                        else
                        {
                            Model.MZ_CostOrder mz_costorder = new HIS.Model.MZ_CostOrder( );
                            mz_costorder.ItemType  = ((Item)obj).Text.Trim( );
                            mz_costorder.Total_Fee = Convert.ToDecimal(((Item)obj).Value);
                            htCostOrder.Add(mz_costorder.ItemType, mz_costorder);
                        }
                    }
                }
            }
            catch (Exception err)
            {
                ErrorWriter.WriteLog(err.Message);
                throw new OperatorException("合并明细大类发生错误!");
            }
            #endregion
            int costmasterid = 0; //本次结算ID
            #region 数据库操作,得到结算号
            try
            {
                oleDb.BeginTransaction( );

                #region 赋值结算头表并保存
                HIS.Model.MZ_CostMaster mz_costmaster = new HIS.Model.MZ_CostMaster( );
                mz_costmaster.PatID        = Patient.PatID;
                mz_costmaster.PatListID    = Patient.PatListID;
                mz_costmaster.PresMasterID = 0;
                mz_costmaster.TicketNum    = "";
                mz_costmaster.TicketCode   = "";
                mz_costmaster.ChargeCode   = OperatorId.ToString( );
                //mz_costmaster.ChargeName = PublicDataReader.GetEmployeeNameById( OperatorId );
                mz_costmaster.ChargeName   = BaseDataController.GetName(BaseDataCatalog.人员列表, OperatorId);
                mz_costmaster.Total_Fee    = chargeTotalCost;//结算表的总金额
                mz_costmaster.Self_Fee     = 0;
                mz_costmaster.Village_Fee  = 0;
                mz_costmaster.Favor_Fee    = 0;
                mz_costmaster.Pos_Fee      = 0;
                mz_costmaster.Money_Fee    = 0;
                mz_costmaster.Ticket_Flag  = 0;
                mz_costmaster.Record_Flag  = 9;//预结算记录状态置为9
                mz_costmaster.OldID        = 0;
                mz_costmaster.AccountID    = 0;
                mz_costmaster.Hang_Flag    = (int)OPDOperationType.门诊收费;
                mz_costmaster.Hurried_Flag = Patient.IsEmergency ? 1 : 0;
                mz_costmaster.CostMasterID = BindEntity <Model.MZ_CostMaster> .CreateInstanceDAL(oleDb).Add(mz_costmaster);

                #endregion
                costmasterid = mz_costmaster.CostMasterID;
                #region 更新处方表的结算号和总金额,舍入金额
                for (int prescCount = 0; prescCount < prescriptions.Length; prescCount++)
                {
                    string strWhere = Tables.mz_presmaster.PRESMASTERID + oleDb.EuqalTo( ) + prescriptions[prescCount].PrescriptionID;
                    Model.MZ_PresMaster mz_presmaster = BindEntity <Model.MZ_PresMaster> .CreateInstanceDAL(oleDb).GetModel(strWhere);

                    if (mz_presmaster.Charge_Flag == 1)
                    {
                        throw new OperatorException("处方已被别的收费员收费,请确认!");
                    }
                    if (prescriptions[prescCount].DocPresId != 0)
                    {
                        if (HIS.Interface.InstanceFactory.CreatMZ_ClinicDataInstance().CheckPresStatus(prescriptions[prescCount].DocPresId) == false)
                        {
                            throw new OperatorException("处方已经收费,请重新刷新病人信息以获取最新未收费处方!\r\n(建议不要同时打开多个收费界面)");
                        }
                    }
                    //更新处方表的结算号和总金额,舍入金额
                    BindEntity <Model.MZ_PresMaster> .CreateInstanceDAL(oleDb).Update(strWhere,
                                                                                      Tables.mz_presmaster.COSTMASTERID + oleDb.EuqalTo( ) + mz_costmaster.CostMasterID,
                                                                                      Tables.mz_presmaster.TOTAL_FEE + oleDb.EuqalTo( ) + prescriptions[prescCount].Total_Fee,
                                                                                      Tables.mz_presmaster.ROUNGINGMONEY + oleDb.EuqalTo( ) + prescriptions[prescCount].RoundingMoney);
                }
                #endregion

                #region 保存结算明细到数据库(按大项目保存)
                foreach (object obj in htCostOrder)
                {
                    HIS.Model.MZ_CostOrder mz_costorder = (HIS.Model.MZ_CostOrder)((System.Collections.DictionaryEntry)obj).Value;
                    mz_costorder.CostID = mz_costmaster.CostMasterID;
                    //保存到数据库
                    mz_costorder.CostOrderID = BindEntity <Model.MZ_CostOrder> .CreateInstanceDAL(oleDb).Add(mz_costorder);
                }
                #endregion

                oleDb.CommitTransaction( );
            }
            catch (OperatorException oe)
            {
                oleDb.RollbackTransaction( );
                throw oe;
            }
            catch (Exception err)
            {
                oleDb.RollbackTransaction( );
                ErrorWriter.WriteLog(err.Message + "\r\n" + err.StackTrace);
                throw new OperatorException("保存预算结果到数据库发生错误!");
            }
            #endregion
            //回填处方的结算号
            for (int prescCount = 0; prescCount < prescriptions.Length; prescCount++)
            {
                prescriptions[prescCount].ChargeID = costmasterid;
            }

            #region 返回预算结果
            try
            {
                Hashtable htInvoiceItem = new Hashtable( );
                foreach (object obj in htCostOrder)
                {
                    HIS.Model.MZ_CostOrder mz_costorder = (HIS.Model.MZ_CostOrder)((System.Collections.DictionaryEntry)obj).Value;
                    InvoiceItem            invoice      = GetInvoiceByStatCode(mz_costorder.ItemType.Trim( ));
                    invoice.Cost = mz_costorder.Total_Fee;
                    if (htInvoiceItem.ContainsKey(invoice.ItemCode.Trim( )))
                    {
                        InvoiceItem _invoice = (InvoiceItem)htInvoiceItem[invoice.ItemCode];
                        _invoice.Cost = _invoice.Cost + invoice.Cost;
                        htInvoiceItem.Remove(invoice.ItemCode);
                        htInvoiceItem.Add(_invoice.ItemCode, _invoice);
                    }
                    else
                    {
                        htInvoiceItem.Add(invoice.ItemCode, invoice);
                    }
                }
                List <InvoiceItem> chargeItems = new List <InvoiceItem>( );
                foreach (object item in htInvoiceItem)
                {
                    chargeItems.Add((InvoiceItem)((DictionaryEntry)item).Value);
                }

                ChargeInfo chargeInfos = new ChargeInfo( );
                chargeInfos.Items    = chargeItems.ToArray( );
                chargeInfos.ChargeID = costmasterid;
                chargeInfos.TotalFee = chargeTotalCost;

                ChargeInfo[] chargeInfo = new ChargeInfo[1];
                chargeInfo[0].TotalFee = chargeTotalCost;
                chargeInfo[0]          = chargeInfos;
                //计算本次的优惠金额
                chargeInfo[0].FavorFee = GetFavorCost(Patient.MediType, chargeInfo[0], prescriptions);
                return(chargeInfo);
            }
            catch (Exception err)
            {
                ErrorWriter.WriteLog(err);
                throw new OperatorException("返回预算结果发生错误!");
            }
            #endregion
        }
Пример #2
0
        /// <summary>
        /// 发票号
        /// </summary>
        /// <param name="InvoiceNo">发票号</param>
        public Invoice(string PerfChar, string InvoiceNo, OPDBillKind kind)
        {
            HIS.Model.MZ_CostMaster m_mz_costmaster = new HIS.Model.MZ_CostMaster( );
            HIS.DAL.MZ_DAL          mz_dal          = new HIS.DAL.MZ_DAL( );
            mz_dal._OleDB = oleDb;
            try
            {
                string condiction = "TicketNum='" + InvoiceNo + "' and record_flag in (0,1)";
                //if ( PerfChar.Trim( ) != "" )
                condiction += " and TicketCode ='" + PerfChar + "'";

                if (kind == OPDBillKind.门诊挂号发票)
                {
                    condiction += " and hang_flag=" + (int)OPDOperationType.门诊挂号;
                }
                if (kind == OPDBillKind.门诊收费发票)
                {
                    condiction += " and hang_flag=" + (int)OPDOperationType.门诊收费;
                }

                m_mz_costmaster = BindEntity <Model.MZ_CostMaster> .CreateInstanceDAL(oleDb).GetModel(condiction);

                _perfchar  = PerfChar;
                _billKind  = kind;
                _chargeId  = m_mz_costmaster.CostMasterID;
                _invoiceNo = InvoiceNo;
                _perfChar  = m_mz_costmaster.TicketCode;
                Model.MZ_CostMaster mz_costmaster = BindEntity <Model.MZ_CostMaster> .CreateInstanceDAL(oleDb).GetModel(m_mz_costmaster.CostMasterID);

                Model.MZ_PatList mz_patlist = BindEntity <Model.MZ_PatList> .CreateInstanceDAL(oleDb).GetModel(mz_costmaster.PatListID);

                _patientName  = mz_patlist == null ? "" : mz_patlist.PatName;
                _totalPay     = m_mz_costmaster.Total_Fee;
                _posPay       = m_mz_costmaster.Pos_Fee;
                _favorPay     = m_mz_costmaster.Favor_Fee;
                _villagePay   = m_mz_costmaster.Village_Fee;
                _selfTally    = m_mz_costmaster.Self_Tally;
                _chargeUser   = m_mz_costmaster.ChargeName;
                _chargeUserId = m_mz_costmaster.ChargeCode;
                _chargeDate   = m_mz_costmaster.CostDate;
                _record_flag  = m_mz_costmaster.Record_Flag;
                _cashPay      = _totalPay - _posPay - _villagePay - _favorPay - _selfTally;//m_mz_costmaster.Money_Fee;
                //发票内容
                System.Data.DataTable tb = mz_dal.GetInvoiceDetail(mz_costmaster.CostMasterID);
                //Hashtable htInvoiceItems = new Hashtable();
                //for (int i = 0; i < tb.Rows.Count; i++)
                //{
                //    InvoiceItem item = new InvoiceItem();
                //    item.ItemName = tb.Rows[i]["Item_Name"].ToString().Trim();
                //    item.Cost = Convert.ToDecimal(tb.Rows[i]["Total_fee"]);
                //    item.Item_Name = tb.Rows[i]["ItemName"].ToString().Trim();
                //    item.Tolal_Fee = Convert.ToDecimal(tb.Rows[i]["Fee"]);

                //    if (htInvoiceItems.ContainsKey(item.ItemName))
                //    {
                //        InvoiceItem item1 = (InvoiceItem)htInvoiceItems[item.ItemName];
                //        if (tb.Rows[i]["itemtype"].ToString() == "01" || tb.Rows[i]["itemtype"].ToString() == "02" || tb.Rows[i]["itemtype"].ToString() == "03")
                //        {
                //            item1.Cost = item1.Cost + item.Cost;
                //            htInvoiceItems.Remove(item.ItemName);
                //        }
                //        htInvoiceItems.Add(item1.ItemName, item1);
                //    }
                //    else
                //    {
                //        htInvoiceItems.Add(item.ItemName, item);
                //    }
                //}

                _items = new InvoiceItem[tb.Rows.Count];
                // int invoiceCount = 0;
                for (int i = 0; i < tb.Rows.Count; i++)
                {
                    _items[i].ItemName = tb.Rows[i]["Item_Name"].ToString().Trim();
                    _items[i].Cost     = Convert.ToDecimal(tb.Rows[i]["Total_fee"]);

                    _items[i].Item_Name = tb.Rows[i]["ItemName"].ToString().Trim();
                    if (_items[i].Item_Name.Trim() == "")
                    {
                        _items[i].Tolal_Fee = "";
                    }
                    else
                    {
                        _items[i].Tolal_Fee = tb.Rows[i]["Fee"].ToString();
                    }
                }
                //foreach (object obj in htInvoiceItems)
                //{
                //    _items[invoiceCount].ItemName = ((InvoiceItem)((DictionaryEntry)obj).Value).ItemName;
                //    _items[invoiceCount].Cost = ((InvoiceItem)((DictionaryEntry)obj).Value).Cost;
                //    _items[invoiceCount].ItemName = ((InvoiceItem)((DictionaryEntry)obj).Value).Item_Name;
                //    _items[invoiceCount].Tolal_Fee = ((InvoiceItem)((DictionaryEntry)obj).Value).Tolal_Fee;

                //    invoiceCount++;
                //}
                //处方信息
                #region ...
                //定义统计大类容器
                Hashtable htStatItems = new Hashtable( );
                List <HIS.Model.MZ_PresMaster> lst_mz_presmaster = new List <HIS.Model.MZ_PresMaster>( );
                lst_mz_presmaster = BindEntity <Model.MZ_PresMaster> .CreateInstanceDAL(oleDb).GetListArray(Tables.mz_presmaster.COSTMASTERID + oleDb.EuqalTo() + _chargeId);

                _prescription = new Prescription[lst_mz_presmaster.Count];
                int index = 0;
                foreach (Model.MZ_PresMaster model_mz_presmaster in lst_mz_presmaster)
                {
                    _prescription[index]                = new Prescription( );
                    _prescription[index].Charge_Flag    = model_mz_presmaster.Charge_Flag;
                    _prescription[index].ChargeCode     = model_mz_presmaster.ChargeCode;
                    _prescription[index].ChargeID       = model_mz_presmaster.CostMasterID;
                    _prescription[index].Drug_Flag      = model_mz_presmaster.Drug_Flag;
                    _prescription[index].ExecDeptCode   = model_mz_presmaster.ExecDeptCode;
                    _prescription[index].ExecDocCode    = model_mz_presmaster.ExecDocCode;
                    _prescription[index].OldPresID      = model_mz_presmaster.OldID;
                    _prescription[index].PresCostCode   = model_mz_presmaster.PresCostCode;
                    _prescription[index].PrescriptionID = model_mz_presmaster.PresMasterID;
                    _prescription[index].PrescType      = model_mz_presmaster.PresType;
                    _prescription[index].PresDeptCode   = model_mz_presmaster.PresDocCode;
                    _prescription[index].PresDocCode    = model_mz_presmaster.PresDocCode;
                    _prescription[index].Record_Flag    = model_mz_presmaster.Record_Flag;
                    _prescription[index].TicketCode     = model_mz_presmaster.TicketCode;
                    _prescription[index].TicketNum      = model_mz_presmaster.TicketNum;
                    _prescription[index].Total_Fee      = model_mz_presmaster.Total_Fee;
                    _prescription[index].Drug_Flag      = model_mz_presmaster.Drug_Flag;
                    _prescription[index].DocPresId      = model_mz_presmaster.DocPresId;
                    List <HIS.Model.MZ_PresOrder> orders = BindEntity <Model.MZ_PresOrder> .CreateInstanceDAL(oleDb).GetListArray("PresmasterID=" + _prescription[index].PrescriptionID);

                    PrescriptionDetail[] details = new PrescriptionDetail[orders.Count];
                    for (int j = 0; j < orders.Count; j++)
                    {
                        #region 明细
                        details[j]             = new PrescriptionDetail();
                        details[j].Amount      = orders[j].Amount;
                        details[j].BigitemCode = orders[j].BigItemCode;
                        details[j].Buy_price   = orders[j].Buy_Price;
                        details[j].ComplexId   = orders[j].CaseID;
                        details[j].DetailId    = orders[j].PresOrderID;
                        details[j].ItemId      = orders[j].ItemID;
                        details[j].Itemname    = orders[j].ItemName;
                        details[j].ItemType    = orders[j].ItemType;
                        details[j].Order_Flag  = orders[j].Order_Flag;
                        details[j].PassId      = orders[j].PassID;
                        details[j].PresAmount  = orders[j].PresAmount;
                        details[j].PresctionId = orders[j].PresMasterID;
                        details[j].RelationNum = orders[j].RelationNum;
                        details[j].Sell_price  = orders[j].Sell_Price;
                        details[j].Standard    = orders[j].Standard;
                        details[j].Tolal_Fee   = orders[j].Tolal_Fee;
                        details[j].Unit        = orders[j].Unit;
                        details[j].Comp_Money  = orders[j].Comp_Money;
                        #endregion

                        #region 生成大项目列表
                        if (htStatItems.ContainsKey(orders[j].BigItemCode.Trim()))
                        {
                            InvoiceItem item = (InvoiceItem)htStatItems[orders[j].BigItemCode.Trim( )];
                            item.Cost += orders[j].Tolal_Fee;
                            htStatItems.Remove(orders[j].BigItemCode.Trim( ));
                            htStatItems.Add(item.ItemCode, item);
                        }
                        else
                        {
                            InvoiceItem item = new InvoiceItem( );
                            item.ItemCode = orders[j].BigItemCode.Trim();
                            //item.ItemName = GetStatItemNameByStatCode( item.ItemCode );
                            item.ItemName = BaseDataController.GetName(BaseDataCatalog.基本分类科目, item.ItemCode);
                            item.Cost     = orders[j].Tolal_Fee;
                            htStatItems.Add(item.ItemCode, item);
                        }
                        #endregion
                    }
                    _prescription[index].PresDetails = details;
                    index++;
                }
                #endregion
                _statitems = new InvoiceItem[htStatItems.Count];
                index      = 0;
                foreach (object obj in htStatItems.Values)
                {
                    _statitems[index] = (InvoiceItem)obj;
                    index++;
                }
                paytype = "";
                if (_cashPay > 0)
                {
                    paytype += " 现金 ";
                }
                if (_posPay > 0)
                {
                    paytype += " POS ";
                }
                if (_villagePay > 0)
                {
                    paytype += " 农合医保记账 ";
                }
                if (_selfTally > 0)
                {
                    paytype += " 单位记账 ";
                }
            }
            catch (Exception err)
            {
                ErrorWriter.WriteLog(err.Message);
                throw new Exception("读取发票信息错误!");
            }
        }
Пример #3
0
        /// <summary>
        /// 汇总所有人账单
        /// </summary>
        /// <param name="Books"></param>
        /// <returns></returns>
        public static CollectAccountBook CollectAllAccountBook(List <PrivyAccountBook> Books)
        {
            CollectAccountBook     totalBook        = new CollectAccountBook( );
            List <AccountBillInfo> chargeBillinfo   = new List <AccountBillInfo>( );
            List <AccountBillInfo> registerBillinfo = new List <AccountBillInfo>( );
            FundPart  cashPart      = new FundPart( );
            FundPart  favorPart     = new FundPart( );
            FundPart  tallyPart     = new FundPart( );
            Hashtable htInvoiceItem = new Hashtable( );

            foreach (PrivyAccountBook book in Books)
            {
                #region 合并发票科目部分
                if (book == null || book.InvoiceItem == null)
                {
                    continue;
                }
                totalBook.InvoiceItemSumTotal += book.InvoiceItemSumTotal;

                #region 合并收费票据部分
                chargeBillinfo.Add(book.ChargeInvoiceInfo);
                //chargeBillinfo.Count += book.ChargeInvoiceInfo.Count;

                //chargeBillinfo.RefundCount += book.ChargeInvoiceInfo.RefundCount;
                //chargeBillinfo.RefundMoney += book.ChargeInvoiceInfo.RefundMoney;
                //List<Invoice> lstChargeInvoice = new List<Invoice>( );
                //if ( chargeBillinfo.InvoiceList != null )
                //    lstChargeInvoice = chargeBillinfo.InvoiceList.ToList( );
                //if ( book.ChargeInvoiceInfo.InvoiceList != null )
                //{
                //    for ( int i = 0 ; i < book.ChargeInvoiceInfo.InvoiceList.Length ; i++ )
                //        lstChargeInvoice.Add( book.ChargeInvoiceInfo.InvoiceList[i] );
                //}
                //chargeBillinfo.InvoiceList = lstChargeInvoice.ToArray( );
                #endregion

                #region 合并挂号票据部分
                //registerBillinfo.Count += book.RegisterInvoiceInfo.Count;
                ////if ( ( registerBillinfo.StartNumber == "" || registerBillinfo.StartNumber == null ) && book.RegisterInvoiceInfo.StartNumber != "" )
                ////    registerBillinfo.StartNumber = book.RegisterInvoiceInfo.StartNumber;
                ////if ( book.RegisterInvoiceInfo.EndNumber != "" )
                ////    registerBillinfo.EndNumber = book.RegisterInvoiceInfo.EndNumber;

                //registerBillinfo.RefundCount += book.RegisterInvoiceInfo.RefundCount;
                //registerBillinfo.RefundMoney += book.RegisterInvoiceInfo.RefundMoney;
                //List<Invoice> lstRegInvoice = new List<Invoice>( );
                //if ( registerBillinfo.InvoiceList != null )
                //    lstRegInvoice = registerBillinfo.InvoiceList.ToList( );
                //if ( book.RegisterInvoiceInfo.InvoiceList != null )
                //{
                //    for ( int i = 0 ; i < book.RegisterInvoiceInfo.InvoiceList.Length ; i++ )
                //        lstRegInvoice.Add( book.RegisterInvoiceInfo.InvoiceList[i] );
                //}
                //registerBillinfo.InvoiceList = lstRegInvoice.ToArray( );
                registerBillinfo.Add(book.RegisterInvoiceInfo);
                #endregion


                for (int i = 0; i < book.InvoiceItem.Length; i++)
                {
                    if (htInvoiceItem.ContainsKey(book.InvoiceItem[i].ItemCode))
                    {
                        InvoiceItem invoiceItem = (InvoiceItem)htInvoiceItem[book.InvoiceItem[i].ItemCode];
                        invoiceItem.Cost += book.InvoiceItem[i].Cost;
                        htInvoiceItem.Remove(book.InvoiceItem[i].ItemCode);
                        htInvoiceItem.Add(invoiceItem.ItemCode, invoiceItem);
                    }
                    else
                    {
                        htInvoiceItem.Add(book.InvoiceItem[i].ItemCode, book.InvoiceItem[i]);
                    }
                }
                #endregion

                #region 合并现金部分
                cashPart.TotalMoney += book.CashPart.TotalMoney;
                if (cashPart.Details == null)
                {
                    cashPart.Details = new FundInfo[3];
                }
                for (int i = 0; i < book.CashPart.Details.Length; i++)
                {
                    cashPart.Details[i].BillCount += book.CashPart.Details[i].BillCount;
                    cashPart.Details[i].Money     += book.CashPart.Details[i].Money;
                    cashPart.Details[i].PayCode    = book.CashPart.Details[i].PayCode;
                    cashPart.Details[i].PayName    = book.CashPart.Details[i].PayName;
                }
                #endregion

                #region 合并记账部分
                tallyPart.TotalMoney += book.TallyPart.TotalMoney;
                if (tallyPart.Details == null)
                {
                    tallyPart.Details = new FundInfo[book.TallyPart.Details.Length];
                }

                for (int i = 0; i < book.TallyPart.Details.Length; i++)
                {
                    tallyPart.Details[i].BillCount += book.TallyPart.Details[i].BillCount;
                    tallyPart.Details[i].Money     += book.TallyPart.Details[i].Money;
                    tallyPart.Details[i].PayCode    = book.TallyPart.Details[i].PayCode;
                    tallyPart.Details[i].PayName    = book.TallyPart.Details[i].PayName;
                }
                #endregion

                //合并优惠部分
                favorPart.TotalMoney += book.FavorPart.TotalMoney;
            }

            totalBook.ChargeInvoiceInfo   = chargeBillinfo.ToArray();
            totalBook.RegisterInvoiceInfo = registerBillinfo.ToArray();
            totalBook.CashPart            = cashPart;
            totalBook.TallyPart           = tallyPart;
            totalBook.FavorPart           = favorPart;

            totalBook.InvoiceItem = new InvoiceItem[htInvoiceItem.Count];
            int count = 0;
            foreach (object obj in htInvoiceItem)
            {
                totalBook.InvoiceItem[count] = (InvoiceItem)((DictionaryEntry)obj).Value;
                count++;
            }

            return(totalBook);
        }
Пример #4
0
        /// <summary>
        /// 获取个人账单
        /// </summary>
        /// <param name="TollCollectorId">收费员ID</param>
        /// <param name="AccountBookId">账单ID</param>
        /// <param name="tbInvoiceList">发票清单</param>
        /// <param name="tbInvoiceDetailList">发票明细列表</param>
        /// <returns></returns>
        public static PrivyAccountBook GetPrivyAccountBook(int TollCollectorId, int AccountBookId,
                                                           DataTable tbAllInvoiceList, DataTable tbAllInvoiceDetailList, DataTable tbAccountList)
        {
            DataTable tbInvoiceList = tbAllInvoiceList.Clone();

            DataRow[] drsInvoiceList = tbAllInvoiceList.Select("AccountId=" + AccountBookId);
            foreach (DataRow dr in drsInvoiceList)
            {
                tbInvoiceList.Rows.Add(dr.ItemArray);
            }

            DataTable tbInvoiceDetailList = tbAllInvoiceDetailList.Clone( );

            DataRow[] drsInvoiceDetailList = tbAllInvoiceDetailList.Select("AccountId=" + AccountBookId);
            foreach (DataRow dr in drsInvoiceDetailList)
            {
                tbInvoiceDetailList.Rows.Add(dr.ItemArray);
            }

            DataRow[] drAccounts = tbAccountList.Select("ACCOUNTID=" + AccountBookId);
            DataRow   drAccount  = null;

            if (drAccounts.Length != 0)
            {
                drAccount = drAccounts[0];
            }

            PrivyAccountBook accountBook = new PrivyAccountBook( );

            if (drAccount != null)
            {
                accountBook.AccountBookDate = Convert.ToDateTime(drAccount["AccountDate"]);
                accountBook.AccountId       = Convert.ToInt32(drAccount["AccountId"]);
                //accountBook.TollCollectorName = PublicDataReader.GetEmployeeNameById( TollCollectorId );
                accountBook.TollCollectorName = BaseDataController.GetName(BaseDataCatalog.人员列表, TollCollectorId);
            }
            else
            {
                accountBook.AccountId = 0;
            }
            #region 发票科目明细列表
            Hashtable htInvoiceItems = new Hashtable( );
            for (int i = 0; i < tbInvoiceDetailList.Rows.Count; i++)
            {
                string      mzfp_code   = tbInvoiceDetailList.Rows[i]["mzfp_code"].ToString( ).Trim( );
                string      mzfp_name   = tbInvoiceDetailList.Rows[i]["item_name"].ToString( ).Trim( );
                decimal     item_fee    = Convert.ToDecimal(tbInvoiceDetailList.Rows[i]["total_fee"]);
                InvoiceItem invoiceItem = new InvoiceItem( );
                invoiceItem.ItemCode = mzfp_code;
                invoiceItem.ItemName = mzfp_name;
                invoiceItem.Cost     = item_fee;

                if (htInvoiceItems.ContainsKey(invoiceItem.ItemCode))
                {
                    InvoiceItem _invoiceItem = (InvoiceItem)htInvoiceItems[invoiceItem.ItemCode];
                    htInvoiceItems.Remove(invoiceItem.ItemCode);
                    _invoiceItem.Cost = _invoiceItem.Cost + invoiceItem.Cost;
                    htInvoiceItems.Add(_invoiceItem.ItemCode, _invoiceItem);
                }
                else
                {
                    htInvoiceItems.Add(invoiceItem.ItemCode, invoiceItem);
                }
                accountBook.InvoiceItemSumTotal += invoiceItem.Cost;
            }
            accountBook.InvoiceItem = new InvoiceItem[htInvoiceItems.Count];
            int invoiceItemIndex = 0;
            foreach (object obj in htInvoiceItems)
            {
                accountBook.InvoiceItem[invoiceItemIndex] = (InvoiceItem)((DictionaryEntry)obj).Value;
                invoiceItemIndex++;
            }
            #endregion
            //收费票据信息
            AccountBillInfo chargeBillInfo = GetBillInfo(OPDOperationType.门诊收费, tbInvoiceList);
            //chargeBillInfo.ChargeName = PublicDataReader.GetEmployeeNameById( TollCollectorId );
            chargeBillInfo.ChargeName     = BaseDataController.GetName(BaseDataCatalog.人员列表, TollCollectorId);
            accountBook.ChargeInvoiceInfo = chargeBillInfo;
            //挂号票据信息
            AccountBillInfo registerBillInfo = GetBillInfo(OPDOperationType.门诊挂号, tbInvoiceList);
            registerBillInfo.ChargeName     = chargeBillInfo.ChargeName;
            accountBook.RegisterInvoiceInfo = registerBillInfo;
            //优惠部分
            accountBook.FavorPart = GetFavorPart(tbInvoiceList);
            //现金部分
            accountBook.CashPart = GetCashPart(tbInvoiceList, tbInvoiceDetailList);
            //记账部分
            accountBook.TallyPart = GetTallyPart(tbInvoiceList);

            return(accountBook);
        }
Пример #5
0
        /// <summary>
        /// 预算
        /// </summary>
        /// <param name="prescriptions">要进行计算的处方,数组对象</param>
        /// <returns></returns>
        private ChargeInfo[] _budget(Prescription[] prescriptions)
        {
            //MZClinicInterface clinicInterface = new MZClinicInterface();

            ChargeInfo[] chargeInfos = new ChargeInfo[prescriptions.Length];
            try
            {
                for (int prescCount = 0; prescCount < prescriptions.Length; prescCount++)
                {
                    List <Item> lstStatItems = MergePrescriptionByStatItemCode(ref prescriptions[prescCount]);

                    Prescription prescription = prescriptions[prescCount];
                    chargeInfos[prescCount] = new ChargeInfo( );
                    //保存结算头
                    HIS.Model.MZ_CostMaster chargeBill = new HIS.Model.MZ_CostMaster( );
                    #region ....
                    chargeBill.PatID        = Patient.PatID;
                    chargeBill.PatListID    = Patient.PatListID;
                    chargeBill.PresMasterID = prescription.PrescriptionID;
                    chargeBill.TicketNum    = "";
                    chargeBill.TicketCode   = "";
                    chargeBill.ChargeCode   = OperatorId.ToString( );
                    //chargeBill.ChargeName = PublicDataReader.GetEmployeeNameById( OperatorId ); //BindEntity<HIS.Model.BASE_EMPLOYEE_PROPERTY>.CreateInstanceDAL(oleDb).GetModel(OperatorId).NAME ;
                    chargeBill.ChargeName  = BaseDataController.GetName(BaseDataCatalog.人员列表, OperatorId);
                    chargeBill.Total_Fee   = prescription.Total_Fee;
                    chargeBill.Self_Fee    = 0;
                    chargeBill.Village_Fee = 0;
                    chargeBill.Favor_Fee   = 0;
                    chargeBill.Pos_Fee     = 0;
                    chargeBill.Money_Fee   = 0;
                    chargeBill.Ticket_Flag = 0;
                    //chargeBill.CostDate;//预结算不写结算时间
                    chargeBill.Record_Flag  = 9;//预结算记录状态置为9
                    chargeBill.OldID        = 0;
                    chargeBill.AccountID    = 0;
                    chargeBill.Hang_Flag    = (int)OPDOperationType.门诊收费;
                    chargeBill.Hurried_Flag = Patient.IsEmergency ? 1 : 0;
                    #endregion
                    int ret1 = BindEntity <Model.MZ_CostMaster> .CreateInstanceDAL(oleDb).Add(chargeBill);

                    chargeBill.CostMasterID            = ret1;
                    prescriptions[prescCount].ChargeID = ret1;
                    //累加每张处方结算信息
                    chargeInfos[prescCount].ChargeID       = chargeBill.CostMasterID;
                    chargeInfos[prescCount].PrescriptionID = chargeBill.PresMasterID;
                    chargeInfos[prescCount].TotalFee       = chargeBill.Total_Fee;
                    chargeInfos[prescCount].SelfFee        = chargeBill.Self_Fee;
                    chargeInfos[prescCount].VillageFee     = chargeBill.Village_Fee;
                    chargeInfos[prescCount].FavorFee       = chargeBill.Favor_Fee;
                    if (ret1 > 0)
                    {
                        List <InvoiceItem> chargeItems = new List <InvoiceItem>( );
                        #region  大项目保存结算明细
                        foreach (object obj in lstStatItems)
                        {
                            Item item = (Item)obj;
                            HIS.Model.MZ_CostOrder chargeDetail = new HIS.Model.MZ_CostOrder( );
                            chargeDetail.CostID    = chargeBill.CostMasterID;
                            chargeDetail.ItemType  = item.Text;
                            chargeDetail.Total_Fee = Convert.ToDecimal(item.Value);

                            int ret2 = BindEntity <Model.MZ_CostOrder> .CreateInstanceDAL(oleDb).Add(chargeDetail);

                            if (ret2 > 0)
                            {
                                InvoiceItem invoice = GetInvoiceByStatCode(chargeDetail.ItemType);
                                invoice.Cost = chargeDetail.Total_Fee;
                                chargeItems.Add(invoice);
                            }
                        }
                        #endregion
                        chargeInfos[prescCount].Items = chargeItems.ToArray( );
                    }
                }

                //for (int i = 0; i < prescriptions.Length; i++)//预算就修改门诊处方状态
                //    clinicInterface.ChangePresStatus(prescriptions[i].DocPresId, 1);
            }
            catch (Exception err)
            {
                throw err;
            }
            //计算每张处方的打折金额
            for (int i = 0; i < chargeInfos.Length; i++)
            {
                chargeInfos[i].FavorFee = GetFavorCost(Patient.MediType, chargeInfos[i], prescriptions[i]);
            }
            return(chargeInfos);
        }