/// <summary> /// 将列的代码和行的代码转换成中文名称 /// </summary> /// <param name="tbData"></param> /// <param name="style"></param> private static void ConvertCodeToName(BaseReport report) { for (int i = 0; i < report.BaseReportData.Rows.Count; i++) { string id = Convert.IsDBNull(report.BaseReportData.Rows[i]["ID"]) ? "0" : report.BaseReportData.Rows[i]["ID"].ToString( ).Trim( ); id = id.Trim( ) == "" ? "0" : id; string code = Convert.IsDBNull(report.BaseReportData.Rows[i]["CODE"]) ? "0" : report.BaseReportData.Rows[i]["CODE"].ToString( ).Trim( ); if (report is DoctorIncomeReport || report is TollerIncomeReport) { //id = PublicDataReader.GetEmployeeNameById( Convert.ToInt32( id ) ); id = BaseDataController.GetName(BaseDataCatalog.人员列表, Convert.ToInt32(id)); } else if (report is DepartmentIncomeReport) { //id = PublicDataReader.GetDeptNameById( Convert.ToInt32( id ) ); id = BaseDataController.GetName(BaseDataCatalog.科室列表, Convert.ToInt32(id)); } else if (report is PatientTypeIncomReport) { //id = PublicDataReader.GetPatientTypeNameByCode( id ); id = BaseDataController.GetName(BaseDataCatalog.病人类型列表, id); } id = id.Trim( ) == "" ? "<未指定>" : id; if (report.StatType != StatClassType.收费支付类型) { code = GetItemNameByCode(code, report.StatType); } report.BaseReportData.Rows[i]["ID"] = id; report.BaseReportData.Rows[i]["CODE"] = code; } }
/// <summary> /// 根据发票获取病人信息 /// </summary> /// <param name="invoiceNo"></param> /// <returns></returns> public RegPatient GetPatientInfoByInvoiceNo(string PerfChar, string invoiceNo) { RegPatient patient = new RegPatient(); DataRow dr = reg_dal.GetRegPatientByInvoiceNo(PerfChar, invoiceNo); if (dr == null) { return(null); } patient.Address = dr[BLL.Tables.patientinfo.PATADDRESS].ToString( ); if (!Convert.IsDBNull(dr[BLL.Tables.patientinfo.PATBRIDATE])) { patient.BornDate = Convert.ToDateTime(dr[BLL.Tables.patientinfo.PATBRIDATE]); } patient.Folk = dr[BLL.Tables.patientinfo.PATGROUP].ToString( ); patient.HisCardNo = dr[BLL.Tables.patientinfo.MEDICARD].ToString( ); patient.IDCard = dr[BLL.Tables.patientinfo.PATNUMBER].ToString( ); patient.Occupation = dr[BLL.Tables.patientinfo.PATJOB].ToString( ); patient.PatID = Convert.ToDecimal(dr[BLL.Tables.patientinfo.PATID]); patient.PatListID = Convert.ToInt32(dr[BLL.Tables.mz_patlist.PATLISTID]); patient.PatientName = dr[BLL.Tables.patientinfo.PATNAME].ToString( ); patient.Sex = dr[BLL.Tables.patientinfo.PATSEX].ToString( ); patient.Tel = dr[BLL.Tables.patientinfo.PATTEL].ToString( ); patient.PatType = new PatientType( ); patient.PatType.Code = dr[BLL.Tables.mz_patlist.MEDITYPE].ToString( ); //patient.PatType.Name = PublicDataReader.GetPatientTypeNameByCode( patient.PatType.Code ); patient.PatType.Name = BaseDataController.GetName(BaseDataCatalog.病人类型列表, patient.PatType.Code); return(patient); }
/// <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 }
/// <summary> /// 更新本次就诊登记信息 /// </summary> /// <returns>成功标识;true</returns> public bool UpdateRegister() { try { HIS.Model.MZ_PatList register = BindEntity <Model.MZ_PatList> .CreateInstanceDAL(oleDb).GetModel(this.PatListID); register.CureDeptCode = _cureDeptCode; //就诊科室 register.CureEmpCode = _cureEmpCode; //就诊医生 register.DiseaseCode = _diseaseCode; //疾病代码 if (register.REG_DOC_CODE.Trim( ) == "") { //如果挂号医生为空,则将挂号医生更改为当前就诊医生 register.REG_DOC_CODE = _cureEmpCode; register.REG_DOC_NAME = BaseDataController.GetName(BaseDataCatalog.人员列表, Convert.ToInt32(_cureEmpCode)); //PublicDataReader.GetEmployeeNameById( Convert.ToInt32(_cureEmpCode) ); register.REG_DEPT_CODE = _cureDeptCode; register.REG_DEPT_NAME = BaseDataController.GetName(BaseDataCatalog.科室列表, Convert.ToInt32(_cureDeptCode)); // PublicDataReader.GetDeptNameById( Convert.ToInt32( _cureDeptCode ) ); } register.DiseaseName = _diseaseName.Replace("|", "") + "|" + _diseaseMemo.Replace("|", ""); //疾病名称 register.HpCode = _hpCode; //就医机构代码(病人单位代码) register.HpGrade = _hpGrade; //就医机构级别 register.MediCard = _mediCard; //医疗证卡号 register.MediType = _mediType; //就诊类型 register.PatCode = ""; //病人代码???? register.PatID = this.PatID; //病人ID,如果是普通病人,则为0;否则参见PatientInfo.PatID; register.PatListID = this.PatListID; //本次就诊号 register.PatName = this.PatientName; //病人姓名 register.PatSex = this.Sex; //性别 register.PYM = this.PYM; //拼音码 register.WBM = this.WBM; //五笔码 register.Age = this.Age; //年龄 register.VisitNo = this.VisitNo; //就诊号(门诊号) BindEntity <Model.MZ_PatList> .CreateInstanceDAL(oleDb).Update(register); Model.PatientInfo patientinfo = BindEntity <Model.PatientInfo> .CreateInstanceDAL(oleDb).GetModel(Convert.ToInt32(this.PatID)); if (patientinfo != null) { patientinfo.PatName = register.PatName; patientinfo.PatSex = register.PatSex; patientinfo.ALLERGIC = this.Allergic; BindEntity <Model.PatientInfo> .CreateInstanceDAL(oleDb).Update(patientinfo); } //将处方表中挂号的记录改为处方医生 string strWhere = Tables.mz_presmaster.PATLISTID + oleDb.EuqalTo() + this.PatListID + oleDb.And( ) + Tables.mz_presmaster.HAND_FLAG + oleDb.EuqalTo() + "0"; Model.MZ_PresMaster mz_presmaster = BindEntity <Model.MZ_PresMaster> .CreateInstanceDAL(oleDb).GetModel(strWhere); if (mz_presmaster != null) { if (mz_presmaster.PresDocCode == null || mz_presmaster.PresDocCode.Trim( ) == "") { strWhere += oleDb.And( ) + Tables.mz_presmaster.PRESMASTERID + oleDb.EuqalTo( ) + mz_presmaster.PresMasterID; BindEntity <Model.MZ_PresMaster> .CreateInstanceDAL(oleDb).Update(strWhere, Tables.mz_presmaster.PRESDOCCODE + oleDb.EuqalTo( ) + "'" + _cureEmpCode + "'", Tables.mz_presmaster.PRESDEPTCODE + oleDb.EuqalTo( ) + "'" + _cureDeptCode + "'"); } } return(true); } catch (OperatorException operr) { throw operr; } catch (Exception err) { ErrorWriter.WriteLog(err.Message); throw new Exception("更新病人等级信息发生错误!"); } }
/// <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("读取发票信息错误!"); } }
/// <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); }
/// <summary> /// 得到票据信息 /// </summary> /// <param name="kind">票据类型</param> /// <param name="tbAllInvoiceList">所有的发票列表</param> /// <returns>根据票据类型返回的票据信息</returns> private static AccountBillInfo GetBillInfo(OPDOperationType kind, DataTable tbAllInvoiceList) { int flag = (int)kind; DataTable tbInvoice = tbAllInvoiceList.Clone( ); DataRow[] drsInvoice = tbAllInvoiceList.Select("hang_flag=" + flag, "costdate asc"); for (int i = 0; i < drsInvoice.Length; i++) { tbInvoice.Rows.Add(drsInvoice[i].ItemArray); } AccountBillInfo billInfo = new AccountBillInfo( ); if (drsInvoice.Length > 0) { DataRow[] drs = tbInvoice.Select("record_flag in (0,1)", "ticketnum asc"); billInfo.Count = drs.Length; if (drs.Length > 0) { billInfo.StartNumber = drs[0]["ticketnum"].ToString( ).Trim( ); billInfo.EndNumber = drs[drs.Length - 1]["ticketnum"].ToString( ).Trim( ); } //构造发票清单 billInfo.InvoiceList = new Invoice[drs.Length]; for (int i = 0; i < drs.Length; i++) { billInfo.InvoiceList[i] = new Invoice( ); billInfo.InvoiceList[i].InvoiceNo = drs[i]["ticketnum"].ToString( ).Trim( ); //billInfo.InvoiceList[i].PatientName = PublicDataReader.GetPatientTypeNameByCode( drs[i]["meditype"].ToString( ).Trim( ) ); billInfo.InvoiceList[i].PatientName = BaseDataController.GetName(BaseDataCatalog.病人类型列表, drs[i]["meditype"].ToString().Trim()); billInfo.InvoiceList[i].TotalPay = Convert.ToDecimal(drs[i]["total_fee"]); billInfo.InvoiceList[i].CashPay = Convert.ToDecimal(drs[i]["money_fee"]); billInfo.InvoiceList[i].PosPay = Convert.ToDecimal(drs[i]["pos_fee"]); billInfo.InvoiceList[i].VillagePay = Convert.ToDecimal(drs[i]["village_fee"]); billInfo.InvoiceList[i].SelfTally = Convert.ToDecimal(drs[i]["self_tally"]); billInfo.InvoiceList[i].FavorPay = Convert.ToDecimal(drs[i]["favor_fee"]); billInfo.InvoiceList[i].ChargeDate = Convert.ToDateTime(drs[i]["costdate"]); billInfo.InvoiceList[i].RecordFlag = Convert.ToInt32(drs[i]["record_flag"]); } //退票 DataRow[] drsRefund = tbInvoice.Select("record_flag = 2 "); billInfo.RefundCount = drsRefund.Length; billInfo.RefundInvoice = new Invoice[billInfo.RefundCount]; for (int i = 0; i < drsRefund.Length; i++) { billInfo.RefundMoney += Math.Abs(Convert.ToDecimal(drsRefund[i]["total_fee"])); billInfo.RefundInvoice[i] = new Invoice( ); billInfo.RefundInvoice[i].InvoiceNo = drsRefund[i]["ticketnum"].ToString( ).Trim( ); //billInfo.RefundInvoice[i].PatientName = PublicDataReader.GetPatientTypeNameByCode( drsRefund[i]["meditype"].ToString( ).Trim( ) ); billInfo.RefundInvoice[i].PatientName = BaseDataController.GetName(BaseDataCatalog.病人类型列表, drsRefund[i]["meditype"].ToString().Trim()); billInfo.RefundInvoice[i].TotalPay = Math.Abs(Convert.ToDecimal(drsRefund[i]["total_fee"])); billInfo.RefundInvoice[i].CashPay = Math.Abs(Convert.ToDecimal(drsRefund[i]["money_fee"])); billInfo.RefundInvoice[i].PosPay = Math.Abs(Convert.ToDecimal(drsRefund[i]["pos_fee"])); billInfo.RefundInvoice[i].VillagePay = Math.Abs(Convert.ToDecimal(drsRefund[i]["village_fee"])); billInfo.RefundInvoice[i].SelfTally = Math.Abs(Convert.ToDecimal(drsRefund[i]["self_tally"])); billInfo.RefundInvoice[i].FavorPay = Math.Abs(Convert.ToDecimal(drsRefund[i]["favor_fee"])); billInfo.RefundInvoice[i].ChargeDate = Convert.ToDateTime(drsRefund[i]["costdate"]); billInfo.RefundInvoice[i].RecordFlag = Convert.ToInt32(drsRefund[i]["record_flag"]); } billInfo.Useless = new string[] { "" }; } else { billInfo.Count = 0; billInfo.StartNumber = ""; billInfo.EndNumber = ""; billInfo.RefundMoney = 0; billInfo.RefundCount = 0; billInfo.Useless = new string[] { "" }; } return(billInfo); }
/// <summary> /// 退费 /// </summary> /// <param name="invoice">要退费的发票对象</param> /// <param name="ReblancePrescriptions">需要重新补收的处方对象,主要是部分退费时会产生需要补收的处方</param> /// <returns></returns> protected bool _refundment(Invoice invoice, Prescription[] ReblancePrescriptions) { try { List <Model.MZ_CostMaster> lstCostMaster = BindEntity <Model.MZ_CostMaster> .CreateInstanceDAL(oleDb).GetListArray(Tables.mz_costmaster.COSTMASTERID + oleDb.EuqalTo( ) + invoice.ChargeID); foreach (Model.MZ_CostMaster mz_costmaster in lstCostMaster) { int oldCostMasterId = mz_costmaster.CostMasterID; //置结算记录退费 BindEntity <Model.MZ_CostMaster> .CreateInstanceDAL(oleDb).Update(Tables.mz_costmaster.COSTMASTERID + oleDb.EuqalTo( ) + oldCostMasterId, Tables.mz_costmaster.RECORD_FLAG + oleDb.EuqalTo( ) + "1"); //冲正 mz_costmaster.ChargeCode = OperatorId.ToString( ); //mz_costmaster.ChargeName = PublicDataReader.GetEmployeeNameById( OperatorId ); mz_costmaster.ChargeName = BaseDataController.GetName(BaseDataCatalog.人员列表, OperatorId); mz_costmaster.CostDate = HIS.SYSTEM.PubicBaseClasses.XcDate.ServerDateTime; mz_costmaster.Favor_Fee = mz_costmaster.Favor_Fee * -1; mz_costmaster.Money_Fee = mz_costmaster.Money_Fee * -1; mz_costmaster.OldID = mz_costmaster.CostMasterID; mz_costmaster.PresMasterID = mz_costmaster.PresMasterID; mz_costmaster.Pos_Fee = mz_costmaster.Pos_Fee * -1; mz_costmaster.Record_Flag = 2; //红冲标识 mz_costmaster.Self_Fee = mz_costmaster.Self_Fee * -1; mz_costmaster.Total_Fee = mz_costmaster.Total_Fee * -1; mz_costmaster.Village_Fee = mz_costmaster.Village_Fee * -1; mz_costmaster.Self_Tally = mz_costmaster.Self_Tally * -1; mz_costmaster.AccountID = 0; mz_costmaster.Hang_Flag = (int)OPDOperationType.门诊收费; BindEntity <Model.MZ_CostMaster> .CreateInstanceDAL(oleDb).Add(mz_costmaster); //红冲明细 List <Model.MZ_CostOrder> lstCostOrder = BindEntity <Model.MZ_CostOrder> .CreateInstanceDAL(oleDb).GetListArray(Tables.mz_costorder.COSTID + oleDb.EuqalTo( ) + oldCostMasterId); foreach (Model.MZ_CostOrder mz_costorder in lstCostOrder) { mz_costorder.CostID = mz_costmaster.CostMasterID; mz_costorder.Total_Fee = mz_costorder.Total_Fee * -1; BindEntity <Model.MZ_CostOrder> .CreateInstanceDAL(oleDb).Add(mz_costorder); } //更新对应的处方部分 List <Model.MZ_PresMaster> lstPresMaster = BindEntity <Model.MZ_PresMaster> .CreateInstanceDAL(oleDb).GetListArray(Tables.mz_presmaster.COSTMASTERID + oleDb.EuqalTo( ) + oldCostMasterId); foreach (Model.MZ_PresMaster mz_presmaster in lstPresMaster) { int oldPresMasterId = mz_presmaster.PresMasterID; //置退费标志 BindEntity <Model.MZ_PresMaster> .CreateInstanceDAL(oleDb).Update(Tables.mz_presmaster.PRESMASTERID + oleDb.EuqalTo( ) + oldPresMasterId, Tables.mz_presmaster.RECORD_FLAG + oleDb.EuqalTo( ) + "1"); //红冲 mz_presmaster.ChargeCode = OperatorId.ToString( ); mz_presmaster.OldID = mz_presmaster.PresMasterID; mz_presmaster.Record_Flag = 2; mz_presmaster.Total_Fee = mz_presmaster.Total_Fee * -1; mz_presmaster.PresMasterID = 0; mz_presmaster.Hand_Flag = (int)OPDOperationType.门诊收费; mz_presmaster.CostMasterID = mz_costmaster.CostMasterID; //记录冲正的结算ID BindEntity <Model.MZ_PresMaster> .CreateInstanceDAL(oleDb).Add(mz_presmaster); //明细 List <Model.MZ_PresOrder> lstPresOrder = BindEntity <Model.MZ_PresOrder> .CreateInstanceDAL(oleDb).GetListArray(Tables.mz_presorder.PRESMASTERID + oleDb.EuqalTo( ) + oldPresMasterId); foreach (Model.MZ_PresOrder mz_presorder in lstPresOrder) { mz_presorder.PresMasterID = mz_presmaster.PresMasterID; mz_presorder.Amount = mz_presorder.Amount * -1; mz_presorder.Tolal_Fee = mz_presorder.Tolal_Fee * -1; BindEntity <Model.MZ_PresOrder> .CreateInstanceDAL(oleDb).Add(mz_presorder); } } } return(true); } catch (Exception err) { throw err; } }
/// <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); }