/// <summary> /// 根据发票号获取处方 /// </summary> /// <returns>处方信息</returns> public Prescription[] GetPrescriptionByInvoiceSerialNo(string InvoiceSerialNo) { string condiction = ""; condiction = " PatListID = " + this.PatListID + " AND Charge_Flag = 1 AND Record_Flag = 0 And TicketNum='" + InvoiceSerialNo + "' and hand_flag=" + (int)OPDOperationType.门诊收费; condiction = condiction + " order by presmasterid"; //得到实体列表 List <HIS.Model.MZ_PresMaster> presMastList = MSAccessDb.GetListArray <MZ_PresMaster>("MZ_PRESMASTER", condiction); if (presMastList.Count == 0) { throw new Exception("找不到发票信息!\r\n1、请确认发票号是否正确。\r\n2、请确认该发票是否已退费。"); } if (presMastList.Count > 1) { //判断发票里是否有药品 foreach (MZ_PresMaster mz_presmaster in presMastList) { if (mz_presmaster.Drug_Flag == 1) { throw new Exception("该发票内有药品并且还未退药,要退费请先进行退药操作!"); } } } else { if (presMastList[0].Drug_Flag == 1) { throw new Exception("该发票已经发药,要退费请先进行退药操作!"); } } //定义返回的处方 Prescription[] prescriptions = new Prescription[presMastList.Count]; for (int i = 0; i < presMastList.Count; i++) { #region 读取处方头 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].PresDocCode; 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; #endregion //HIS.DAL.MZ_PresOrder mz_presorder = new HIS.DAL.MZ_PresOrder( ); //mz_presorder._oleDB = oleDb; List <HIS.Model.MZ_PresOrder> presDetailList = MSAccessDb.GetListArray <MZ_PresOrder>("MZ_PRESORDER", " 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].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; #endregion } prescriptions[i].PresDetails = details; } return(prescriptions); }
/// <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<MZ_CostMaster>.CreateInstanceDAL(oleDb).GetModel( condiction ); m_mz_costmaster = (MZ_CostMaster)MSAccessDb.GetModel("MZ_COSTMASTER", condiction, typeof(MZ_CostMaster)); _chargeId = m_mz_costmaster.CostMasterID; _invoiceNo = InvoiceNo; MZ_CostMaster mz_costmaster = (MZ_CostMaster)MSAccessDb.GetModel("MZ_COSTMASTER", Tables.mz_costmaster.COSTMASTERID + "=" + m_mz_costmaster.CostMasterID, typeof(MZ_CostMaster)); MZ_PatList mz_patlist = (MZ_PatList)MSAccessDb.GetModel("MZ_PATLIST", Tables.mz_patlist.PATLISTID + "=" + mz_costmaster.PatListID, typeof(MZ_PatList)); _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; _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;//m_mz_costmaster.Money_Fee; //发票内容 // string sql = @"select b.ITEM_NAME,TOTAL_FEE // from mz_costorder as a,base_stat_mzfp as b,base_stat_item as c // where a.ITEMTYPE = c.CODE AND c.MZFP_CODE = b.CODE AND a.COSTID = " + mz_costmaster.CostMasterID; // System.Data.DataTable tb = mz_dal.GetInvoiceDetail( mz_costmaster.CostMasterID ); string sql = @"select c.mzfp_name as ITEM_NAME,TOTAL_FEE from mz_costorder as a,base_stat_item as c where a.ITEMTYPE = c.CODE AND a.COSTID = " + mz_costmaster.CostMasterID; DataTable tb = MSAccessDb.GetDataTable(sql); 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"]); if (htInvoiceItems.ContainsKey(item.ItemName)) { InvoiceItem item1 = (InvoiceItem)htInvoiceItems[item.ItemName]; item1.Cost = item1.Cost + item.Cost; htInvoiceItems.Remove(item.ItemName); htInvoiceItems.Add(item1.ItemName, item1); } else { htInvoiceItems.Add(item.ItemName, item); } } _items = new InvoiceItem[htInvoiceItems.Count]; int invoiceCount = 0; foreach (object obj in htInvoiceItems) { _items[invoiceCount].ItemName = ((InvoiceItem)((DictionaryEntry)obj).Value).ItemName; _items[invoiceCount].Cost = ((InvoiceItem)((DictionaryEntry)obj).Value).Cost; invoiceCount++; } //处方信息 #region ... //定义统计大类容器 Hashtable htStatItems = new Hashtable( ); List <HIS.Model.MZ_PresMaster> lst_mz_presmaster = new List <HIS.Model.MZ_PresMaster>( ); //lst_mz_presmaster = BindEntity<MZ_PresMaster>.CreateInstanceDAL( oleDb ).GetListArray( Tables.mz_presmaster.COSTMASTERID + oleDb.EuqalTo() + _chargeId ); lst_mz_presmaster = MSAccessDb.GetListArray <MZ_PresMaster>("MZ_PRESMASTER", Tables.mz_presmaster.COSTMASTERID + "=" + _chargeId); _prescription = new Prescription[lst_mz_presmaster.Count]; int index = 0; foreach (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; //List<HIS.Model.MZ_PresOrder> orders = BindEntity<MZ_PresOrder>.CreateInstanceDAL( oleDb ).GetListArray( "PresmasterID=" + _prescription[index].PrescriptionID ); List <MZ_PresOrder> orders = MSAccessDb.GetListArray <MZ_PresOrder>("MZ_PRESORDER", "PresmasterID=" + _prescription[index].PrescriptionID); PrescriptionDetail[] details = new PrescriptionDetail[orders.Count]; for (int j = 0; j < orders.Count; j++) { #region 明细 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.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 += " 记账 "; } } catch (Exception err) { throw new Exception("读取发票信息错误!"); } }
/// <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; } if (!IsCharge) { condiction = condiction + " and PRESTYPE in ('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 = MSAccessDb.GetListArray <MZ_PresMaster>("MZ_PRESMASTER", condiction); //定义返回的处方 Prescription[] prescriptions = new Prescription[presMastList.Count]; for (int i = 0; i < presMastList.Count; i++) { #region 读取处方头 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].PresDocCode; 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 //HIS.DAL.MZ_PresOrder mz_presorder = new HIS.DAL.MZ_PresOrder( ); //mz_presorder._oleDB = oleDb; List <HIS.Model.MZ_PresOrder> presDetailList = MSAccessDb.GetListArray <MZ_PresOrder>("MZ_PRESORDER", " 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].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; } return(prescriptions); }