コード例 #1
0
        /// <summary>
        /// 退费
        /// </summary>
        /// <param name="invoice">要退费的发票对象</param>
        /// <returns></returns>
        public override bool Refundment(Invoice invoice, Prescription[] ReblancePrescriptions, List <int> ReturnedDocPresIdList)
        {
            try
            {
                oleDb.BeginTransaction( );

                _refundment(invoice, ReblancePrescriptions);
                MZClinicInterface clinicInterface = new MZClinicInterface();
                for (int i = 0; i < ReturnedDocPresIdList.Count; i++)
                {
                    clinicInterface.ChangePresStatus(ReturnedDocPresIdList[i], 2);
                    //HIS.MZDoc_BLL.OP_Prescription.ChangePresStatus( ReturnedDocPresIdList[i], 2 );
                }

                oleDb.CommitTransaction( );
                return(true);
            }
            catch (Exception err)
            {
                oleDb.RollbackTransaction( );
                ErrorWriter.WriteLog(err.Message);
                throw err;
            }
        }
コード例 #2
0
        /// <summary>
        /// 正式结算
        /// </summary>
        /// <param name="BudgetaryChargeInfos">预算信息</param>
        /// <param name="prescriptions">要结算的处方,该处方对象经过预算方法处理</param>
        /// <returns>true:结算成功,false:结算失败</returns>
        public override bool Charge(ChargeInfo[] BudgetaryChargeInfos, Prescription[] prescriptions, out BaseInvoice[] ChargeInvoicies)
        {
            MZClinicInterface clinicInterface = new MZClinicInterface();

            oleDb.BeginTransaction();

            try
            {
                for (int presindex = 0; presindex < prescriptions.Length; presindex++)
                {
                    if (prescriptions[presindex].DocPresId > 0)
                    {
                        decimal mzdocfee = clinicInterface.GetDocPresMoney(prescriptions[presindex].DocPresId);
                        if (mzdocfee != prescriptions[presindex].Total_Fee)
                        {
                            throw new Exception("门诊医生站已对该收费处方进行修改,请重新刷新处方再点收银!");
                        }
                    }
                }
                for (int chargeCount = 0; chargeCount < BudgetaryChargeInfos.Length; chargeCount++)
                {
                    if (BindEntity <Model.MZ_CostMaster> .CreateInstanceDAL(oleDb).Exists(BudgetaryChargeInfos[chargeCount].ChargeID))
                    {
                        HIS.Model.MZ_CostMaster chargeBill = new HIS.Model.MZ_CostMaster();
                        chargeBill = BindEntity <Model.MZ_CostMaster> .CreateInstanceDAL(oleDb).GetModel(BudgetaryChargeInfos[chargeCount].ChargeID);

                        chargeBill.Self_Fee    = BudgetaryChargeInfos[chargeCount].SelfFee;
                        chargeBill.Village_Fee = BudgetaryChargeInfos[chargeCount].VillageFee;
                        chargeBill.Favor_Fee   = BudgetaryChargeInfos[chargeCount].FavorFee;
                        chargeBill.Pos_Fee     = BudgetaryChargeInfos[chargeCount].PosFee;
                        chargeBill.Money_Fee   = BudgetaryChargeInfos[chargeCount].CashFee;
                        chargeBill.Self_Tally  = BudgetaryChargeInfos[chargeCount].SelfTally;
                        chargeBill.Ticket_Flag = 0;
                        chargeBill.CostDate    = HIS.SYSTEM.PubicBaseClasses.XcDate.ServerDateTime;
                        chargeBill.Record_Flag = 0;
                        string perfCode = "";
                        chargeBill.TicketNum  = InvoiceManager.GetBillNumber(OPDBillKind.门诊收费发票, OperatorId, false, out perfCode);
                        chargeBill.TicketCode = perfCode;    //前缀 BudgetaryChargeInfos[chargeCount].InvoiceNO;

                        BudgetaryChargeInfos[chargeCount].InvoiceSerialNO = Convert.ToInt32(chargeBill.TicketNum);
                        BudgetaryChargeInfos[chargeCount].InvoiceNO       = chargeBill.TicketNum;
                        BudgetaryChargeInfos[chargeCount].PerfChar        = perfCode;
                        BudgetaryChargeInfos[chargeCount].ChargeDate      = chargeBill.CostDate;

                        BindEntity <Model.MZ_CostMaster> .CreateInstanceDAL(oleDb).Update(chargeBill);  //更新结算表


                        //更新处方表收费标识
                        List <Model.MZ_PresMaster> lstPresMaster = BindEntity <Model.MZ_PresMaster> .CreateInstanceDAL(oleDb).GetListArray(HIS.BLL.Tables.mz_presmaster.COSTMASTERID + oleDb.EuqalTo() + BudgetaryChargeInfos[chargeCount].ChargeID);

                        if (lstPresMaster.Count == 0)
                        {
                            throw new OperatorException("没有找到要结算的处方,请确认是否已被人收费");
                        }
                        foreach (Model.MZ_PresMaster mz_presmaster in lstPresMaster)
                        {
                            if (mz_presmaster.Charge_Flag == 0)
                            {
                                mz_presmaster.Charge_Flag = 1;
                                mz_presmaster.TicketCode  = perfCode;   //前缀     BudgetaryChargeInfos[chargeCount].InvoiceNO;
                                mz_presmaster.TicketNum   = chargeBill.TicketNum;
                                mz_presmaster.ChargeCode  = OperatorId.ToString();
                                BindEntity <Model.MZ_PresMaster> .CreateInstanceDAL(oleDb).Update(mz_presmaster);
                            }
                            else
                            {
                                throw new OperatorException("该处方已被其他收费员收费!");
                            }
                        }
                    }
                    else
                    {
                        throw new OperatorException("没有找到结算号的记录!");
                    }
                }

                for (int i = 0; i < prescriptions.Length; i++)
                {
                    clinicInterface.ChangePresStatus(prescriptions[i].DocPresId, 1);
                }

                oleDb.CommitTransaction( );
            }
            catch (OperatorException operr)
            {
                oleDb.RollbackTransaction( );
                throw operr;
            }
            catch (Exception err)
            {
                oleDb.RollbackTransaction( );
                ErrorWriter.WriteLog(err.Message);
                throw new Exception("正式结算发生错误!");
            }
            //发票对象
            try
            {
                ChargeInvoicies = new Invoice[BudgetaryChargeInfos.Length];
                for (int i = 0; i < BudgetaryChargeInfos.Length; i++)
                {
                    ChargeInvoicies[i] = new Invoice(BudgetaryChargeInfos[i].PerfChar, BudgetaryChargeInfos[i].InvoiceNO, OPDBillKind.门诊收费发票);
                }
            }
            catch (Exception err)
            {
                ErrorWriter.WriteLog(err.Message);
                throw new OperatorException("收费成功,但生成发票对象失败!");
            }
            return(true);
        }
コード例 #3
0
        /// <summary>
        /// 获取病人处方
        /// </summary>
        /// <param name="status"></param>
        /// <param name="IsCharge">是否收费处检索</param>
        /// <param name="beginDate">开始时间</param>
        /// <param name="endDate">结束时间</param>
        /// <param name="InvoiceNo">发票号</param>
        /// <param name="ExecDeptCode">执行科室ID</param>
        /// <returns>处方信息</returns>
        public Prescription[] GetPrescriptions(PresStatus status, bool IsCharge, string beginDate, string endDate, string InvoiceNo, int ExecDeptCode)
        {
            string condiction = "";

            switch (status)
            {
            case PresStatus.全部:
                condiction = " PatListID = " + this.PatListID + " AND Record_Flag in (0,1)";
                break;

            case PresStatus.未收费:
                condiction = " PatListID = " + this.PatListID + " AND Charge_Flag = 0 AND Record_Flag = 0 AND Drug_Flag = 0";
                break;

            case PresStatus.已收费未发药:
            case PresStatus.已收费已退药:
                condiction = " PatListID = " + this.PatListID + " AND Charge_Flag = 1 AND Record_Flag = 0 And Drug_Flag = 0";
                break;

            case PresStatus.已收费已发药:
                condiction = " PatListID = " + this.PatListID + " AND Charge_Flag = 1 AND Record_Flag = 0 And Drug_Flag = 1";
                break;
            }
            condiction += " and docpresid=0 ";
            if (!IsCharge)
            {
                condiction = condiction + " and PRESTYPE in ('0','1','2','3') ";
            }

            if (ExecDeptCode != 0)
            {
                condiction = condiction + " and ExecDeptCode = '" + ExecDeptCode.ToString() + "'";
            }

            if (InvoiceNo.Trim( ) == "")
            {
                if (beginDate.Trim( ) != "")
                {
                    condiction = condiction + " and PresDate>='" + beginDate + "'";
                }
                if (endDate.Trim( ) != "")
                {
                    condiction = condiction + " and PresDate<='" + endDate + "'";
                }
            }

            if (InvoiceNo.Trim( ) != "")
            {
                condiction = condiction + " and COSTMASTERID in (select COSTMASTERID from MZ_COSTMASTER where TICKETNUM='" + InvoiceNo + "' and RECORD_FLAG IN (0,1))";
            }

            condiction = condiction + " and hand_flag = " + (int)OPDOperationType.门诊收费 + " order by presmasterid";

            //得到实体列表
            List <HIS.Model.MZ_PresMaster> presMastList = BindEntity <Model.MZ_PresMaster> .CreateInstanceDAL(oleDb).GetListArray(condiction);

            //定义返回的处方
            Prescription[] prescriptions = new Prescription[presMastList.Count];
            for (int i = 0; i < presMastList.Count; i++)
            {
                #region 读取处方头
                prescriptions[i]                = new Prescription();
                prescriptions[i].Charge_Flag    = presMastList[i].Charge_Flag;
                prescriptions[i].ChargeCode     = presMastList[i].ChargeCode;
                prescriptions[i].ChargeID       = presMastList[i].CostMasterID;
                prescriptions[i].Drug_Flag      = presMastList[i].Drug_Flag;
                prescriptions[i].ExecDeptCode   = presMastList[i].ExecDeptCode;
                prescriptions[i].ExecDocCode    = presMastList[i].ExecDocCode;
                prescriptions[i].OldPresID      = presMastList[i].OldID;
                prescriptions[i].PresCostCode   = presMastList[i].PresCostCode;
                prescriptions[i].PrescriptionID = presMastList[i].PresMasterID;
                prescriptions[i].PrescType      = presMastList[i].PresType;
                prescriptions[i].PresDeptCode   = presMastList[i].PresDeptCode;
                prescriptions[i].PresDocCode    = presMastList[i].PresDocCode;
                prescriptions[i].Record_Flag    = presMastList[i].Record_Flag;
                prescriptions[i].TicketCode     = presMastList[i].TicketCode;
                prescriptions[i].TicketNum      = presMastList[i].TicketNum;
                prescriptions[i].Total_Fee      = presMastList[i].Total_Fee;
                prescriptions[i].VisitNo        = this.VisitNo;
                #endregion

                List <HIS.Model.MZ_PresOrder> presDetailList = BindEntity <Model.MZ_PresOrder> .CreateInstanceDAL(oleDb).GetListArray(" PresMasterID = " + presMastList[i].PresMasterID + " order by order_flag");

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

            bool readDocPres = false;
            if (Convert.ToInt32(HIS.MZ_BLL.OPDParamter.Parameters["017"]) == 1)
            {
                readDocPres = true;
            }

            if (readDocPres)
            {
                MZClinicInterface clinicInterface = new MZClinicInterface();
                if (status == PresStatus.未收费)
                {
                    List <Prescription> lstPrescription = new List <Prescription>();
                    for (int i = 0; i < prescriptions.Length; i++)
                    {
                        lstPrescription.Add(prescriptions[i]);
                    }
                    try
                    {
                        //Prescription[] docPrescs = HIS.MZDoc_BLL.OP_Prescription.GetPrescriptions(base.PatListID);
                        HIS.Interface.Structs.Prescription[] docPrescs = clinicInterface.GetPrescriptions(base.PatListID);
                        for (int i = 0; i < docPrescs.Length; i++)
                        {
                            docPrescs[i].Modified       = true;
                            docPrescs[i].DocPresId      = docPrescs[i].PrescriptionID;
                            docPrescs[i].PrescriptionID = 0;
                            for (int j = 0; j < docPrescs[i].PresDetails.Length; j++)
                            {
                                docPrescs[i].PresDetails[j].DocPrescDetailId = docPrescs[i].PresDetails[j].DetailId;
                                docPrescs[i].PresDetails[j].DetailId         = 0;
                            }
                            lstPrescription.Add(docPrescs[i]);
                        }
                    }
                    catch (Exception err)
                    {
                        ErrorWriter.WriteLog(err.Message);
                        throw new Exception("读取医生未收费处方发生错误!");
                    }

                    prescriptions = lstPrescription.ToArray();
                }
            }
            return(prescriptions);
        }
コード例 #4
0
        /// <summary>
        /// 结算
        /// </summary>
        /// <param name="BudgetaryChargeInfos">预算后产生的计算信息</param>
        /// <param name="prescriptions">要收费的处方</param>
        /// <param name="ChargeInvoicies">结算成功后返回的发票结果,数组对象</param>
        /// <returns></returns>
        private bool _charge(ChargeInfo[] BudgetaryChargeInfos, Prescription[] prescriptions, out BaseInvoice[] ChargeInvoicies)
        {
            try
            {
                MZClinicInterface clinicInterface = new MZClinicInterface();
                for (int presindex = 0; presindex < prescriptions.Length; presindex++)
                {
                    if (prescriptions[presindex].DocPresId > 0)
                    {
                        decimal mzdocfee = clinicInterface.GetDocPresMoney(prescriptions[presindex].DocPresId);
                        if (mzdocfee != prescriptions[presindex].Total_Fee)
                        {
                            throw new Exception("门诊医生站已对该收费处方进行修改,请重新刷新处方再点收银!");
                        }
                    }
                }
                for (int chargeCount = 0; chargeCount < BudgetaryChargeInfos.Length; chargeCount++)
                {
                    if (BindEntity <Model.MZ_CostMaster> .CreateInstanceDAL(oleDb).Exists(BudgetaryChargeInfos[chargeCount].ChargeID))
                    {
                        HIS.Model.MZ_CostMaster chargeBill = new HIS.Model.MZ_CostMaster( );
                        chargeBill = BindEntity <Model.MZ_CostMaster> .CreateInstanceDAL(oleDb).GetModel(BudgetaryChargeInfos[chargeCount].ChargeID);

                        chargeBill.Self_Fee    = BudgetaryChargeInfos[chargeCount].SelfFee;
                        chargeBill.Village_Fee = BudgetaryChargeInfos[chargeCount].VillageFee;
                        chargeBill.Favor_Fee   = BudgetaryChargeInfos[chargeCount].FavorFee;
                        chargeBill.Pos_Fee     = BudgetaryChargeInfos[chargeCount].PosFee;
                        chargeBill.Money_Fee   = BudgetaryChargeInfos[chargeCount].CashFee;
                        chargeBill.Self_Tally  = BudgetaryChargeInfos[chargeCount].SelfTally;
                        chargeBill.Ticket_Flag = 0;
                        chargeBill.CostDate    = HIS.SYSTEM.PubicBaseClasses.XcDate.ServerDateTime;
                        chargeBill.Record_Flag = 0;
                        string perfCode = "";
                        chargeBill.TicketNum  = InvoiceManager.GetBillNumber(OPDBillKind.门诊收费发票, OperatorId, false, out perfCode);
                        chargeBill.TicketCode = perfCode; //前缀

                        //BudgetaryChargeInfos[chargeCount].InvoiceSerialNO = Convert.ToInt32( chargeBill.TicketNum );
                        //BudgetaryChargeInfos[chargeCount].PerfChar = perfCode;
                        //BudgetaryChargeInfos[chargeCount].ChargeDate = chargeBill.CostDate;

                        BudgetaryChargeInfos[chargeCount].InvoiceSerialNO = Convert.ToInt32(chargeBill.TicketNum);
                        BudgetaryChargeInfos[chargeCount].InvoiceNO       = chargeBill.TicketNum;
                        BudgetaryChargeInfos[chargeCount].PerfChar        = perfCode;
                        BudgetaryChargeInfos[chargeCount].ChargeDate      = chargeBill.CostDate;

                        BindEntity <Model.MZ_CostMaster> .CreateInstanceDAL(oleDb).Update(chargeBill);  //更新结算表

                        //更新处方表收费标识
                        HIS.Model.MZ_PresMaster presMaster = new HIS.Model.MZ_PresMaster( );

                        presMaster = BindEntity <Model.MZ_PresMaster> .CreateInstanceDAL(oleDb).GetModel(BudgetaryChargeInfos[chargeCount].PrescriptionID);

                        if (presMaster.Charge_Flag == 0)
                        {
                            presMaster.Charge_Flag   = 1;
                            presMaster.RoungingMoney = presMaster.Total_Fee - BudgetaryChargeInfos[chargeCount].TotalFee;
                            presMaster.Total_Fee     = BudgetaryChargeInfos[chargeCount].TotalFee;
                            presMaster.TicketCode    = perfCode;//前缀//BudgetaryChargeInfos[chargeCount].InvoiceNO;
                            presMaster.TicketNum     = chargeBill.TicketNum;
                            presMaster.CostMasterID  = BudgetaryChargeInfos[chargeCount].ChargeID;
                            presMaster.ChargeCode    = OperatorId.ToString( );
                            BindEntity <Model.MZ_PresMaster> .CreateInstanceDAL(oleDb).Update(presMaster);
                        }
                        else
                        {
                            throw new OperatorException("该处方已被其他收费员收费!");
                        }
                    }
                    else
                    {
                        throw new OperatorException("没有找到结算号的记录!");
                    }
                }
                for (int i = 0; i < prescriptions.Length; i++)
                {
                    clinicInterface.ChangePresStatus(prescriptions[i].DocPresId, 1);
                }
                //生成发票
                ChargeInvoicies = new BaseInvoice[BudgetaryChargeInfos.Length];
                for (int i = 0; i < BudgetaryChargeInfos.Length; i++)
                {
                    ChargeInvoicies[i] = new Invoice(BudgetaryChargeInfos[i].PerfChar, BudgetaryChargeInfos[i].InvoiceNO, OPDBillKind.门诊收费发票);
                }
                return(true);
            }
            catch (OperatorException operr)
            {
                throw operr;
            }
            catch (Exception err)
            {
                throw err;
            }
        }