/// <summary> /// 发票流水号获得病人 /// </summary> /// <param name="InvoiceSerialNo">发票号</param> public OutPatient(string VisitNo) { List <HIS.Model.MZ_CostMaster> models = null; HIS.Model.MZ_PatList model = null; model = (MZ_PatList)MSAccessDb.GetModel("MZ_PATLIST", Tables.mz_patlist.VISITNO + "='" + VisitNo + "'", typeof(MZ_PatList)); if (model == null) { throw new Exception("输入的门诊就诊号找不到病人登记信息"); } this.PatListID = model.PatListID; this.PatID = model.PatID; this.PatientName = model.PatName; this.VisitNo = model.VisitNo; this.Sex = model.PatSex; this.Age = model.Age; this.PYM = model.PYM; this.WBM = model.WBM; _mediCard = model.MediCard; _mediType = model.MediType; _hpCode = model.HpCode; _hpGrade = model.HpGrade; _cureDeptCode = model.CureDeptCode; _cureEmpCode = model.CureEmpCode; _diseaseCode = model.DiseaseCode; string[] disease = model.DiseaseName.Split("|".ToCharArray()); _diseaseName = disease[0]; if (disease.Length > 1) { _diseaseMemo = disease[1]; } _cureDate = model.CureDate; }
/// <summary> /// 就诊号 /// </summary> /// <param name="RegisterID"></param> public OutPatient(int RegisterID) { //HIS.DAL.MZ_PatList mz_patList = new HIS.DAL.MZ_PatList( ); //mz_patList._OleDB = new HIS.SYSTEM.DatabaseAccessLayer.OleDB( ); //mz_patList._OleDB.Initialize( ); MZ_PatList model = (MZ_PatList)MSAccessDb.GetModel("MZ_PATLIST", Tables.mz_patlist.PATLISTID + "=" + RegisterID, typeof(MZ_PatList)); if (model == null) { throw new Exception("无效的就诊号!"); } this.PatListID = model.PatListID; this.PatID = model.PatID; this.VisitNo = model.VisitNo; this.PatientName = model.PatName; this.Sex = model.PatSex; this.Age = model.Age; this.PYM = model.PYM; this.WBM = model.WBM; _mediCard = model.MediCard; _mediType = model.MediType; _hpCode = model.HpCode; _hpGrade = model.HpGrade; _cureDeptCode = model.CureDeptCode; _cureEmpCode = model.CureEmpCode; _diseaseCode = model.DiseaseCode; string[] disease = model.DiseaseName.Split("|".ToCharArray()); _diseaseName = disease[0]; if (disease.Length > 1) { _diseaseMemo = disease[1]; } _cureDate = model.CureDate; }
/// <summary> /// 获取可用发票张数 /// </summary> /// <param name="billKind">发票类型</param> /// <param name="OperatorId">操作员ID(即EMPLOYEEID)</param> /// <returns></returns> public static int GetInvoiceNumberOfCanUse(OPDBillKind billKind, int OperatorId) { int count = 0; List <HIS.Model.MZ_INVOICE> invoices = null; //第一步:查找个人当前可用票据 invoices = MSAccessDb.GetListArray <MZ_INVOICE>("MZ_INVOICE", "invoice_type=" + (int)billKind + " and status=0 and employee_id =" + OperatorId); foreach (MZ_INVOICE invoice in invoices) { count = count + (invoice.END_NO - invoice.CURRENT_NO + 1); } //第二步:查找个人备用票据 invoices = MSAccessDb.GetListArray <MZ_INVOICE>("MZ_INVOICE", "invoice_type=" + (int)billKind + " and status=2 and employee_id =" + OperatorId); foreach (MZ_INVOICE invoice in invoices) { count = count + (invoice.END_NO - invoice.CURRENT_NO + 1); } //第三步:查找公共当前在用票据 invoices = MSAccessDb.GetListArray <MZ_INVOICE>("MZ_INVOICE", "invoice_type=" + (int)billKind + " and status=0 and employee_id =0"); foreach (MZ_INVOICE invoice in invoices) { count = count + (invoice.END_NO - invoice.CURRENT_NO + 1); } //第四步:查找公共备用票据 invoices = MSAccessDb.GetListArray <MZ_INVOICE>("MZ_INVOICE", "invoice_type=" + (int)billKind + " and status=2 and employee_id =0"); foreach (MZ_INVOICE invoice in invoices) { count = count + (invoice.END_NO - invoice.CURRENT_NO + 1); } return(count); }
/// <summary> /// 删除处方 /// </summary> /// <param name="PrescriptionId">要删除的处方ID</param> /// <returns>被删除的处方数</returns> public int DeletePrescription(int PrescriptionId) { //MZ_PresMaster mz_presmaster = BindEntity<MZ_PresMaster>.CreateInstanceDAL( oleDb ).GetModel( PrescriptionId ); MZ_PresMaster mz_presmaster = (MZ_PresMaster)MSAccessDb.GetModel("MZ_PRESMASTER", Tables.mz_presmaster.PRESMASTERID + "=" + PrescriptionId, typeof(MZ_PresMaster)); if (mz_presmaster.Charge_Flag == 1) { throw new Exception("该处方已经收费,不能删除!"); } MSAccessDb.BeginTrans( ); try { int effectRow = 0; List <HIS.Model.MZ_PresOrder> detail = MSAccessDb.GetListArray <MZ_PresOrder>("MZ_PRESORDER", "PRESMASTERID=" + PrescriptionId); for (int i = 0; i < detail.Count; i++) { MSAccessDb.Execute("delete * from mz_presorder where presorderid=" + ((HIS.Model.MZ_PresOrder)detail[i]).PresOrderID); effectRow++; } MSAccessDb.Execute("delete * from mz_presmaster where presmasterid = " + PrescriptionId); effectRow++; MSAccessDb.CommitTrans( ); return(effectRow); } catch { MSAccessDb.RollbackTrans( ); return(0); } }
/// <summary> /// 删除处方明细 /// </summary> /// <param name="PrescriptionDetailId">要删除的明细ID</param> /// <returns>被删除的处方明细数</returns> public int DeletePrescriptionDetail(int PrescriptionDetailId) { MZ_PresOrder mz_presorder = (MZ_PresOrder)MSAccessDb.GetModel("MZ_PRESORDER", Tables.mz_presorder.PRESORDERID + "=" + PrescriptionDetailId, typeof(MZ_PresOrder)); MZ_PresMaster mz_presmaster = (MZ_PresMaster)MSAccessDb.GetModel("MZ_PRESMASTER", Tables.mz_presmaster.PRESMASTERID + "=" + mz_presorder.PresMasterID, typeof(MZ_PresMaster)); if (mz_presmaster.Charge_Flag == 1) { throw new Exception("该处方已经收费,不能删除!"); } MSAccessDb.BeginTrans( ); try { int effectRow = 0; MZ_PresOrder detail = (MZ_PresOrder)MSAccessDb.GetModel("MZ_PRESORDER", Tables.mz_presorder.PRESORDERID + "=" + PrescriptionDetailId, typeof(MZ_PresOrder)); MSAccessDb.Execute("delete * from mz_presorder where presorderid=" + detail.PresOrderID); effectRow++; MSAccessDb.CommitTrans( ); return(effectRow); } catch (Exception err) { MSAccessDb.RollbackTrans( ); return(0); } }
/// <summary> /// /// </summary> /// <param name="billKind"></param> /// <param name="OperatorId"></param> /// <param name="NewInvoiceNo"></param> /// <returns></returns> public static bool AdjustInvoiceNo(OPDBillKind billKind, int OperatorId, string NewInvoiceNo) { string strWhere = Tables.mz_invoice.STATUS + " = 0"; strWhere += " and " + Tables.mz_invoice.EMPLOYEE_ID + " = " + OperatorId; strWhere += " and " + Tables.mz_invoice.INVOICE_TYPE + " = " + (int)billKind; MZ_INVOICE mz_invoice = (MZ_INVOICE)MSAccessDb.GetModel("MZ_INVOICE", strWhere, typeof(MZ_INVOICE)); long newInvoiceNo = Convert.ToInt64(NewInvoiceNo); if (mz_invoice != null) { if (newInvoiceNo > Convert.ToInt64(mz_invoice.END_NO)) { throw new Exception("要调整的发票号不能超出本卷票的结束号!"); } if (newInvoiceNo <= Convert.ToInt64(mz_invoice.CURRENT_NO)) { throw new Exception("要调整的发票号不能小于当前票号!"); } //BindEntity<MZ_INVOICE>.CreateInstanceDAL( oleDb ).Update( strWhere , Tables.mz_invoice.CURRENT_NO + oleDb.EuqalTo( ) + newInvoiceNo ); MSAccessDb.UpdateRecord(new string[] { Tables.mz_invoice.CURRENT_NO + " = " + newInvoiceNo }, strWhere, typeof(MZ_INVOICE)); return(true); } else { throw new Exception("没有找到当前在用发票记录!"); } }
/// <summary> /// 删除发票卷 /// </summary> /// <param name="VolumnID">发票卷号</param> /// <remarks> /// 对于在用的,已用的,停用的但之前有使用过的不能删除 /// 备用的,停用的但还未使用的可以删除 /// </remarks> /// <returns></returns> public static bool DeleteInvoiceVolumn(int VolumnID) { MZ_INVOICE invoice = (MZ_INVOICE)MSAccessDb.GetModel("MZ_INVOICE", Tables.mz_invoice.ID + "=" + VolumnID, typeof(MZ_INVOICE)); if (invoice != null) { if (invoice.STATUS == 0) { throw new Exception("该卷发票正在使用中,不能删除"); } if (invoice.STATUS == 1) { throw new Exception("该卷发票已经有使用记录,不能删除"); } if (invoice.STATUS == 3 && invoice.START_NO != invoice.CURRENT_NO) { throw new Exception("该卷发票已停用,但有部分票据已经使用过,不能删除!\r\n如果要使用未用的票据号,请将这段票据号重新分配"); } } try { string sql = "delete * from mz_invoice where id=" + VolumnID; MSAccessDb.Execute(sql); return(true); } catch (Exception err) { throw new Exception("删除票卷发生错误!"); } }
///// <summary> ///// 获取门诊票据领用记录 ///// </summary> ///// <returns>返回DataTable</returns> public static System.Data.DataTable GetInvoiceRecord() { string sql = @"select ID,iif(INVOICE_TYPE=0,'收费','挂号') as INVOICE_TYPE, B.NAME as USERNAME,PERFCHAR,START_NO,END_NO,CURRENT_NO, '' as STATUS, A.STATUS as STATUS_FLAG from mz_invoice as A Left Join base_employee_property as B on A.EMPLOYEE_ID = B.EMPLOYEE_ID "; DataTable tb = MSAccessDb.GetDataTable(sql); for (int i = 0; i < tb.Rows.Count; i++) { int status_flag = Convert.ToInt32(tb.Rows[i]["STATUS_FLAG"]); switch (status_flag) { case 0: tb.Rows[i]["STATUS"] = "正常"; break; case 1: tb.Rows[i]["STATUS"] = "用完"; break; case 2: tb.Rows[i]["STATUS"] = "待用"; break; case 3: tb.Rows[i]["STATUS"] = "停用"; break; } } return(tb); }
/// <summary> /// 获取没有交账的人员列表 /// </summary> /// <returns></returns> public static DataTable GetNotHandInAccountUser() { string strSql = ""; strSql = "select distinct CHARGECODE,CHARGENAME from mz_costmaster where accountid=0 and record_flag in (0,1,2)"; return(MSAccessDb.GetDataTable(strSql)); }
public static DataTable GetPatientList() { string date = DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd HH:mm:ss"); string sql = "select patlistid,patname,patsex,curedate from mz_patlist where curedate>#" + date + "# and upload_flag=0 order by curedate desc"; return(MSAccessDb.GetDataTable(sql)); }
/// <summary> /// 更新本次就诊登记信息 /// </summary> /// <returns>成功标识;true</returns> public bool UpdateRegister() { //HIS.SYSTEM.DatabaseAccessLayer.OleDB oleDB = new HIS.SYSTEM.DatabaseAccessLayer.OleDB( ); //oleDB.Initialize( ); try { //HIS.DAL.MZ_PatList mz_patList = new HIS.DAL.MZ_PatList( ); //mz_patList._OleDB = oleDB; HIS.Model.MZ_PatList register = (MZ_PatList)MSAccessDb.GetModel("MZ_PATLIST", Tables.mz_patlist.PATLISTID + "=" + this.PatListID, typeof(MZ_PatList)); register.CureDeptCode = _cureDeptCode; //就诊科室 register.CureEmpCode = _cureEmpCode; //就诊医生 register.DiseaseCode = _diseaseCode; //疾病代码 if (register.REG_DOC_CODE.Trim( ) == "") { //如果挂号医生为空,则将挂号医生更改为当前就诊医生 register.REG_DOC_CODE = _cureEmpCode; register.REG_DOC_NAME = DataReader.GetEmployeeNameById(Convert.ToInt32(_cureEmpCode)); register.REG_DEPT_CODE = _cureDeptCode; register.REG_DEPT_NAME = DataReader.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; //就诊号(门诊号) MSAccessDb.UpdateRecord(register); //将处方表中挂号的记录改为处方医生 string strWhere = Tables.mz_presmaster.PATLISTID + "=" + this.PatListID + " and " + Tables.mz_presmaster.HAND_FLAG + "= 0"; MZ_PresMaster mz_presmaster = (MZ_PresMaster)MSAccessDb.GetModel("MZ_PRESMASTER", strWhere, typeof(MZ_PresMaster)); if (mz_presmaster != null) { if (mz_presmaster.PresDocCode == null || mz_presmaster.PresDocCode.Trim( ) == "") { strWhere += " and " + Tables.mz_presmaster.PRESMASTERID + "=" + mz_presmaster.PresMasterID; MSAccessDb.UpdateRecord(new string[] { Tables.mz_presmaster.PRESDOCCODE + "=" + "'" + _cureEmpCode + "'", Tables.mz_presmaster.PRESDEPTCODE + "=" + "'" + _cureDeptCode + "'" }, strWhere, typeof(MZ_PresMaster)); } } return(true); } catch (Exception err) { throw new Exception("更新病人等级信息发生错误!"); } }
/// <summary> /// 上传发票信息 /// </summary> public void UploadDataWithInvoiceInfo() { if (_oleDb == null) { ConnectToRemoteDB( ); } DataTable tbInvoice = MSAccessDb.GetDataTable("select * from mz_invoice where upload_flag=0 and employee_id=" + _employeeId); int invoiceCount = tbInvoice.Rows.Count; if (invoiceCount == 0) { if (UpLoadingEvent != null) { UpLoadingEvent("没有需要上传的发票使用信息!\r\n"); } return; } if (UpLoadingEvent != null) { UpLoadingEvent(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "开始上传个人发票使用记录!\r\n"); } try { BeginTrans( ); for (int invoiceIndex = 0; invoiceIndex < tbInvoice.Rows.Count; invoiceIndex++) { int localInvoiceId = Convert.ToInt32(tbInvoice.Rows[invoiceIndex][Tables.mz_invoice.ID]); MZ_INVOICE mz_invoice = new MZ_INVOICE( ); DataBind <MZ_INVOICE>(tbInvoice.Rows[invoiceIndex], mz_invoice); string strWhere = Tables.mz_invoice.ID + _oleDb.EuqalTo( ) + localInvoiceId; if (BindEntity <MZ_INVOICE> .CreateInstanceDAL(_oleDb).Exists(strWhere)) { BindEntity <MZ_INVOICE> .CreateInstanceDAL(_oleDb).Update(mz_invoice); MSAccessDb.Execute("update mz_invoice set upload_flag = 1 where id = " + localInvoiceId); } else { BindEntity <MZ_INVOICE> .CreateInstanceDAL(_oleDb).Add(mz_invoice); int serverInvoiceId = mz_invoice.ID; MSAccessDb.Execute("update mz_invoice set upload_flag = 1,id = " + serverInvoiceId + " where id = " + localInvoiceId); } } CommitTrans( ); if (UpLoadingEvent != null) { UpLoadingEvent(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "上传个人发票使用记录成功!\r\n发票使用记录" + invoiceCount + "条\r\n\r\n"); } } catch (Exception err) { RollbackTrans( ); throw err; } }
/// <summary> /// 获取病人信息 /// </summary> /// <param name="Condiction">检索条件</param> /// <returns></returns> public static System.Data.DataTable GetPatientList(string Condiction) { //return BindEntity<MZ_PatList>.CreateInstanceDAL( oleDb ).GetList( Condiction ); if (Condiction.Trim() == "") { return(MSAccessDb.GetDataTable("select * from mz_patlist")); } else { return(MSAccessDb.GetDataTable("select * from mz_patlist where " + Condiction)); } }
/// <summary> /// 查找病人信息 /// </summary> /// <param name="strWhere">查询条件</param> /// <returns></returns> public static OutPatient[] GetPatient(string strWhere) { List <HIS.Model.MZ_PatList> patList = MSAccessDb.GetListArray <MZ_PatList>("MZ_PATLIST", strWhere); OutPatient[] patients = new OutPatient[patList.Count]; for (int i = 0; i < patList.Count; i++) { patients[i] = new OutPatient(patList[i].PatListID); } return(patients); }
/// <summary> /// 交款 /// </summary> /// <param name="userId">操作员ID(EmployeeId)</param> public static bool HandInAccount(int userId, PrivyAccountBook accountBook) { string strblankoutInvoices = ""; foreach (string invoiceNum in accountBook.ChargeInvoiceInfo.Useless) { strblankoutInvoices = strblankoutInvoices + invoiceNum + "|"; } if (strblankoutInvoices.Trim( ) != "") { strblankoutInvoices = strblankoutInvoices.Remove(strblankoutInvoices.Length - 1, 1); } MSAccessDb.BeginTrans( ); try { HIS.Model.MZ_Account new_mz_account = new HIS.Model.MZ_Account( ); new_mz_account.AccountCode = userId.ToString( ); new_mz_account.AccountDate = DateTime.Now; new_mz_account.Total_Fee = accountBook.InvoiceItemSumTotal; new_mz_account.Cash_Fee = 0; new_mz_account.POS_Fee = 0; new_mz_account.BlankOut = strblankoutInvoices; new_mz_account.AccountID = MSAccessDb.GetMaxID("MZ_ACCOUNT", Tables.mz_account.ACCOUNTID); //新增账单 MSAccessDb.InsertRecord(new_mz_account, Tables.mz_account.ACCOUNTID); //当前对象ID赋值 int accountBookId = new_mz_account.AccountID; //更新结算表,置账单号 List <MZ_CostMaster> list_costmaster = MSAccessDb.GetListArray <MZ_CostMaster>("MZ_COSTMASTER", " RECORD_FLAG<>9 and ACCOUNTID=0 and CHARGECODE='" + userId + "'"); if (list_costmaster.Count == 0) { throw new Exception("没有科目可以交账!"); } for (int i = 0; i < list_costmaster.Count; i++) { list_costmaster[i].AccountID = accountBookId; MSAccessDb.UpdateRecord(list_costmaster[i]); } MSAccessDb.CommitTrans( ); return(true); } catch (Exception err) { MSAccessDb.RollbackTrans( ); throw new Exception("交款处理发生错误!"); } }
/// <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) { MSAccessDb.BeginTrans( ); try { _charge(BudgetaryChargeInfos, prescriptions, out ChargeInvoicies); MSAccessDb.CommitTrans( ); return(true); } catch (Exception err) { MSAccessDb.RollbackTrans( ); throw new Exception("正式结算发生错误!"); } }
/// <summary> /// 发票号 /// </summary> /// <param name="InviceNo"></param> /// <param name="InvoiceType"></param> public OutPatient(string InviceNo, OPDBillKind InvoiceType) { List <HIS.Model.MZ_CostMaster> models = null; HIS.Model.MZ_PatList model = null; string strWhere = ""; if (InvoiceType == OPDBillKind.门诊收费发票) { strWhere = "TICKETNUM='" + InviceNo + "'" + " and " + Tables.mz_costmaster.HANG_FLAG + " = 1"; } else { strWhere = "TICKETNUM='" + InviceNo + "'" + " and " + Tables.mz_costmaster.HANG_FLAG + " = 0"; } models = MSAccessDb.GetListArray <MZ_CostMaster>("MZ_COSTMASTER", strWhere); if (models.Count == 0) { throw new Exception("输入的发票流水号找不到病人登记信息"); } else { model = (MZ_PatList)MSAccessDb.GetModel("MZ_PATLIST", Tables.mz_patlist.PATLISTID + "=" + models[0].PatListID, typeof(MZ_PatList)); } this.PatListID = model.PatListID; this.PatID = model.PatID; this.PatientName = model.PatName; this.VisitNo = model.VisitNo; this.Sex = model.PatSex; this.Age = model.Age; this.PYM = model.PYM; this.WBM = model.WBM; _mediCard = model.MediCard; _mediType = model.MediType; _hpCode = model.HpCode; _hpGrade = model.HpGrade; _cureDeptCode = model.CureDeptCode; _cureEmpCode = model.CureEmpCode; _diseaseCode = model.DiseaseCode; string[] disease = model.DiseaseName.Split("|".ToCharArray( )); _diseaseName = disease[0]; if (disease.Length > 1) { _diseaseMemo = disease[1]; } _cureDate = model.CureDate; }
/// <summary> /// 设置发票停用 /// </summary> /// <param name="ID">发票卷ID</param> public static void SetInvoiceNoUsed(int ID) { HIS.Model.MZ_INVOICE model_mz_invoice = null; model_mz_invoice = (MZ_INVOICE)MSAccessDb.GetModel("MZ_INVOICE", "ID=" + ID, typeof(MZ_INVOICE)); if (model_mz_invoice != null) { if (model_mz_invoice.END_NO == model_mz_invoice.CURRENT_NO && model_mz_invoice.STATUS == 1) { throw new Exception("本卷发票已经使用完,不能再停用!"); } model_mz_invoice.STATUS = 3; //BindEntity<MZ_INVOICE>.CreateInstanceDAL( oleDb ).Update( model_mz_invoice ); MSAccessDb.UpdateRecord(model_mz_invoice); } }
/// <summary> /// 预算 /// </summary> /// <param name="prescriptions">要预算的处方</param> /// <returns>预算信息,供正式结算用</returns> public override ChargeInfo[] Budget(Prescription[] prescriptions) { ChargeInfo[] chargeInfos = new ChargeInfo[prescriptions.Length]; try { MSAccessDb.BeginTrans( ); chargeInfos = _budget(prescriptions); MSAccessDb.CommitTrans( ); } catch (Exception err) { MSAccessDb.RollbackTrans( ); throw new Exception("预结算发生错误!"); } return(chargeInfos); }
/// <summary> /// 得到未上传的病人列表 /// </summary> /// <returns></returns> public List <int> GetUnUploadPatientList() { string sql = @"select distinct a.patlistid from mz_patlist a ,mz_costmaster b where a.patlistid=b.patlistid and (b.upload_flag=0 or b.upload_flag is null ) and b.record_flag in (0,1,2)"; DataTable tb = MSAccessDb.GetDataTable(sql); List <int> patList = new List <int>( ); for (int i = 0; i < tb.Rows.Count; i++) { patList.Add(Convert.ToInt32(tb.Rows[i]["patlistid"])); } return(patList); }
/// <summary> /// 设置发票记录 /// </summary> /// <param name="invoiceType">发票类型</param> /// <param name="ChargetorId">领用人ID(EmployeeId)</param> /// <param name="StartNo">开始号</param> /// <param name="EndNo">结束号</param> /// <param name="Operator">操作员(EmployeeId)</param> public static void SetInvoiceRecord(OPDBillKind invoiceType, int ChargetorId, string PerfChar, int StartNo, int EndNo, int Operator) { HIS.Model.MZ_INVOICE model_mz_invoice = new HIS.Model.MZ_INVOICE(); model_mz_invoice.ALLOT_DATE = DateTime.Now; model_mz_invoice.ALLOT_USER = Operator; model_mz_invoice.CURRENT_NO = StartNo; model_mz_invoice.EMPLOYEE_ID = ChargetorId; model_mz_invoice.END_NO = EndNo; model_mz_invoice.INVOICE_TYPE = (int)invoiceType; model_mz_invoice.START_NO = StartNo; model_mz_invoice.STATUS = 2; model_mz_invoice.PerfChar = PerfChar; model_mz_invoice.ID = MSAccessDb.GetMaxID("MZ_INVOICE", Tables.mz_invoice.ID); MSAccessDb.InsertRecord(model_mz_invoice, Tables.mz_invoice.ID); }
/// <summary> /// 登记本次就诊 /// </summary> /// <returns>本次就诊号</returns> public int NewRegister() { MSAccessDb.BeginTrans(); try { HIS.Model.MZ_PatList register = new HIS.Model.MZ_PatList( ); register.CureDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")); //就诊日期 register.CureDeptCode = _cureDeptCode; //就诊科室 register.CureEmpCode = _cureEmpCode; //就诊医生 register.DiseaseCode = _diseaseCode; //疾病代码 register.DiseaseName = _diseaseName; //疾病名称 register.HpCode = _hpCode; //就医机构代码 register.HpGrade = _hpGrade; //就医机构级别 register.MediCard = _mediCard; //医疗证卡号 register.MediType = _mediType; //就诊类型 register.PatCode = " "; //病人代码 register.PatID = 0; //病人ID,如果是普通病人,则为0;否则参见PatientInfo.PatID; register.PatName = PatientName; //病人姓名 register.PatSex = Sex; //性别 register.PYM = " "; //拼音码 register.WBM = " "; //五笔码 register.Age = Age; register.VisitNo = " "; //( new RegController( ) ).CreateVisitNo( ); register.PatListID = MSAccessDb.GetMaxID("MZ_PATLIST", Tables.mz_patlist.PATLISTID); int newRegisterno = 0; MSAccessDb.InsertRecord(register, Tables.mz_patlist.PATLISTID); newRegisterno = register.PatListID; if (newRegisterno > 0) { this.PatListID = newRegisterno; this.VisitNo = register.VisitNo; MSAccessDb.CommitTrans( ); return(this.PatListID); //返回就诊ID } else { throw new Exception("创建病人登记信息失败!"); } } catch (Exception err) { MSAccessDb.RollbackTrans( ); throw new Exception("新登记病人信息发生错误!"); } }
/// <summary> /// 读取具有有效处方的病人列表 /// </summary> /// <param name="ExistsVisitDay">有效就诊期</param> /// <param name="ExistsPresDays">处方有效期</param> /// <returns></returns> public static System.Data.DataTable GetPatientListByExistsPrescrition(int ExistsVisitDay, int ExistsPresDays) { DateTime serverDate = DateTime.Now; string pres_endDate = serverDate.ToString("yyyy-MM-dd") + " 23:59:59.999999"; string pres_beginDate = serverDate.AddDays(ExistsPresDays * -1).ToString("yyyy-MM-dd") + " 00:00:00.000000"; string visit_endDate = serverDate.ToString("yyyy-MM-dd") + " 23:59:59.999999"; string visit_beginDate = serverDate.AddDays(ExistsVisitDay * -1).ToString("yyyy-MM-dd") + " 00:00:00.000000"; //return dal.GetPatientListByExistsPrescrition( visit_beginDate, visit_endDate, pres_beginDate, pres_endDate ); string sql = @"select distinct a.patlistid,a.patid,patname,patsex,curedate,pym,wbm,visitno from mz_patlist a,mz_presmaster b where a.patlistid = b.patlistid and visitno <>'' and b.presdate between #" + visit_beginDate + "# and #" + visit_endDate + @"# and b.record_flag = 0 order by curedate desc"; return(MSAccessDb.GetDataTable(sql)); }
/// <summary> /// 退费 /// </summary> /// <param name="invoice">要退费的发票对象</param> /// <returns></returns> public override bool Refundment(Invoice invoice, Prescription[] ReblancePrescriptions) { try { MSAccessDb.BeginTrans(); _refundment(invoice, ReblancePrescriptions); MSAccessDb.CommitTrans( ); return(true); } catch (Exception err) { MSAccessDb.RollbackTrans( ); //ErrorWriter.WriteLog( err.Message ); throw err; } }
/// <summary> /// 发票查询 /// </summary> /// <param name="dateTimeFrom">开始时间</param> /// <param name="dateTimeTo">结束时间</param> /// <param name="OperatorId">操作员(EmployeeId)</param> /// <returns></returns> public static DataTable GetChargeInvoiceList(DateTime dateTimeFrom, DateTime dateTimeTo, int OperatorId) { string userWhere = ""; if (OperatorId != 0) { userWhere = " and chargecode='" + OperatorId.ToString( ) + "'"; } string sql = @"select a.TICKETNUM as invoiceno,b.PATNAME as patientname,b.VISITNO as VISITNO,b.MEDITYPE as MEDITYPE,a.TOTAL_FEE as cost,a.TOTAL_FEE-a.POS_FEE-a.VILLAGE_FEE-a.FAVOR_FEE-a.SELF_TALLY as cash,a.POS_FEE as pos,a.VILLAGE_FEE as tally,a.FAVOR_FEE as favor,a.SELF_TALLY as self_tally,a.COSTDATE as chargedate,a.CHARGENAME as chargeuser,a.unchargedate,a.unchargecost,a.unchargeuser,a.hang_flag from (select aa.*,b.COSTDATE as unchargedate, ABS(b.TOTAL_FEE) as unchargecost,b.chargename as unchargeuser from ( select TICKETNUM,PATLISTID,TOTAL_FEE,COSTDATE,MONEY_FEE,POS_FEE,VILLAGE_FEE,FAVOR_FEE,SELF_TALLY,CHARGENAME,HANG_FLAG from MZ_COSTMASTER where RECORD_FLAG IN(0,1) " + userWhere + @" AND COSTDATE BETWEEN #" + dateTimeFrom.ToString("yyyy-MM-dd") + " 00:00:00# AND #" + dateTimeTo.ToString("yyyy-MM-dd") + " 23:59:59# " + @" ) aa Left Join (select TICKETNUM,TOTAL_FEE,COSTDATE,CHARGENAME,HANG_FLAG from MZ_COSTMASTER where RECORD_FLAG = 2 ) b on aa.TICKETNUM = b.TICKETNUM AND aa.HANG_FLAG = b.HANG_FLAG ) a Left Join (select PATLISTID,PATNAME,VISITNO,MEDITYPE from MZ_PATLIST ) b on a.PATLISTID = b.PATLISTID "; return(MSAccessDb.GetDataTable(sql)); }
/// <summary> /// 获取个人账单 /// </summary> /// <param name="TollCollectorId">收费员ID</param> /// <param name="AccountBookId">账单ID</param> /// <returns></returns> public static PrivyAccountBook GetPrivyAccountBook(int TollCollectorId, int AccountBookId) { DataTable tbInvoiceList = null; DataTable tbInvoiceDetailList = null; #region 获取本次收费发票列表 // //发票列表(所有的发票,包含挂号和收费) // string sql = @"select a.patlistid,b.meditype,a.record_flag, ticketnum,total_fee,village_fee,favor_fee,pos_fee,self_tally, // (total_fee-village_fee-favor_fee-pos_fee-self_tally) as money_fee ,a.hang_flag,a.costdate // from mz_costmaster a,mz_patlist b // where a.patlistid=b.patlistid // and a.record_flag in (0,1,2) // and a.chargecode='" + TollCollectorId.ToString( ) + @"' // and a.accountid = " + AccountBookId + @" // and a.workid=" + WORK_ID + @" // and b.workid= "+ WORK_ID+ @" // order by costdate"; // tbInvoiceList = oleDb.GetDataTable( sql ); // //发票明细列表(所有的,包含挂号和收费) // sql = @"select a.ticketnum,c.code as stat_item_code,c.mzfp_code,d.item_name, b.total_fee ,a.record_flag,a.hang_flag, // a.village_fee,a.favor_fee,a.pos_fee,a.self_tally, // (a.total_fee-a.village_fee-a.favor_fee-a.pos_fee-a.self_tally) as money_fee // from mz_costmaster a,mz_costorder b ,base_stat_item c,base_stat_mzfp d // where a.costmasterid = b.costid // and b.itemtype=c.code // and c.mzfp_code = d.code // and a.record_flag in (0,1,2) // and a.chargecode='" + TollCollectorId.ToString( ) + @"' // and a.accountid = " + AccountBookId + @" // and a.workid=" + WORK_ID + @" // and b.workid= "+ WORK_ID; // tbInvoiceDetailList = oleDb.GetDataTable( sql ); #endregion GetAccountData(TollCollectorId, new int[] { AccountBookId }, out tbInvoiceList, out tbInvoiceDetailList); DataTable tbAccount = MSAccessDb.GetDataTable("select * from mz_account where accountid=" + AccountBookId); return(GetPrivyAccountBook(TollCollectorId, AccountBookId, tbInvoiceList, tbInvoiceDetailList, tbAccount)); }
/// <summary> /// 获取缴款单数据 /// </summary> /// <param name="TollCollectorId"></param> /// <param name="AccountBookId"></param> public static void GetAccountData(int TollCollectorId, int[] AccountBookIds, out DataTable tbInvoiceList, out DataTable tbInvoiceDetailList) { tbInvoiceList = null; tbInvoiceDetailList = null; string accountList = ""; for (int i = 0; i < AccountBookIds.Length - 1; i++) { accountList += AccountBookIds[i].ToString( ) + ","; } accountList += AccountBookIds[AccountBookIds.Length - 1].ToString( ); //发票列表(所有的发票,包含挂号和收费) string sql = @"select a.patlistid,b.meditype,a.record_flag, ticketnum,total_fee,village_fee,favor_fee,pos_fee,self_tally, (total_fee-village_fee-favor_fee-pos_fee-self_tally) as money_fee ,a.hang_flag,a.costdate,a.accountid from mz_costmaster a,mz_patlist b where a.patlistid=b.patlistid and a.record_flag in (0,1,2) and a.chargecode='" + TollCollectorId.ToString( ) + @"' and a.accountid in ( " + accountList + @") order by costdate"; tbInvoiceList = MSAccessDb.GetDataTable(sql); //发票明细列表(所有的,包含挂号和收费) sql = @"select a.ticketnum,c.code as stat_item_code,c.mzfp_code,d.name as item_name, b.total_fee ,a.record_flag,a.hang_flag, a.village_fee,a.favor_fee,a.pos_fee,a.self_tally, (a.total_fee-a.village_fee-a.favor_fee-a.pos_fee-a.self_tally) as money_fee,a.accountid from mz_costmaster a,mz_costorder b ,base_stat_item c,base_mzfp_item d where a.costmasterid = b.costid and b.itemtype=c.code and c.mzfp_code = d.code and a.record_flag in (0,1,2) and a.chargecode='" + TollCollectorId.ToString( ) + @"' and a.accountid in (" + accountList + ") "; tbInvoiceDetailList = MSAccessDb.GetDataTable(sql); }
/// <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) { throw new Exception("合并项目发生错误!"); } #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; MZ_CostOrder mz_costorder = (MZ_CostOrder)htCostOrder[item.Text.Trim( )]; mz_costorder.Total_Fee = mz_costorder.Total_Fee + Convert.ToDecimal(item.Value); } else { 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) { throw new Exception("合并明细大类发生错误!"); } #endregion int costmasterid = MSAccessDb.GetMaxID("MZ_COSTMASTER", Tables.mz_costmaster.COSTMASTERID); #region 数据库操作,得到结算号 try { MSAccessDb.BeginTrans(); #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 = DataReader.GetEmployeeNameById(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 = costmasterid; MSAccessDb.InsertRecord(mz_costmaster, Tables.mz_costorder.COSTORDERID); #endregion #region 更新处方表的结算号和总金额,舍入金额 for (int prescCount = 0; prescCount < prescriptions.Length; prescCount++) { string strWhere = Tables.mz_presmaster.PRESMASTERID + " = " + prescriptions[prescCount].PrescriptionID; MZ_PresMaster mz_presmaster = (MZ_PresMaster)MSAccessDb.GetModel("MZ_PRESMASTER", strWhere, typeof(MZ_PresMaster)); if (mz_presmaster.Charge_Flag == 1) { throw new Exception("处方已被别的收费员收费,请确认!"); } //更新处方表的结算号和总金额,舍入金额 //BindEntity<MZ_PresMaster>.CreateInstanceDAL( oleDb ).Update( strWhere , // Tables.mz_presmaster.COSTMASTERID + " = " + mz_costmaster.CostMasterID , // Tables.mz_presmaster.TOTAL_FEE + " = " + prescriptions[prescCount].Total_Fee , // Tables.mz_presmaster.ROUNGINGMONEY + " = " + prescriptions[prescCount].RoundingMoney ); MSAccessDb.UpdateRecord(new string[] { Tables.mz_presmaster.COSTMASTERID + " = " + mz_costmaster.CostMasterID, Tables.mz_presmaster.TOTAL_FEE + " = " + prescriptions[prescCount].Total_Fee, Tables.mz_presmaster.ROUNGINGMONEY + " = " + prescriptions[prescCount].RoundingMoney }, strWhere, typeof(MZ_PresMaster)); } #endregion #region 保存结算明细到数据库(按大项目保存) int costorderid = MSAccessDb.GetMaxID("MZ_COSTORDER", Tables.mz_costorder.COSTORDERID); 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 = costorderid; //保存到数据库 //mz_costorder.CostOrderID = BindEntity<MZ_CostOrder>.CreateInstanceDAL( oleDb ).Add( mz_costorder ); MSAccessDb.InsertRecord(mz_costorder, Tables.mz_costorder.COSTORDERID); costorderid++; } #endregion MSAccessDb.CommitTrans( ); } catch (Exception err) { MSAccessDb.RollbackTrans( ); throw new Exception("保存预算结果到数据库发生错误!"); } #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) { throw new Exception("返回预算结果发生错误!"); } #endregion }
/// <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) { MSAccessDb.BeginTrans( ); try { for (int chargeCount = 0; chargeCount < BudgetaryChargeInfos.Length; chargeCount++) { //if ( BindEntity<MZ_CostMaster>.CreateInstanceDAL( oleDb ).Exists( BudgetaryChargeInfos[chargeCount].ChargeID ) ) if (MSAccessDb.Exists("MZ_COSTMASTER", Tables.mz_costmaster.COSTMASTERID + "=" + BudgetaryChargeInfos[chargeCount].ChargeID)) { HIS.Model.MZ_CostMaster chargeBill = new HIS.Model.MZ_CostMaster( ); //chargeBill = BindEntity<MZ_CostMaster>.CreateInstanceDAL( oleDb ).GetModel( BudgetaryChargeInfos[chargeCount].ChargeID ); chargeBill = (MZ_CostMaster)MSAccessDb.GetModel("MZ_COSTMASTER", Tables.mz_costmaster.COSTMASTERID + "=" + BudgetaryChargeInfos[chargeCount].ChargeID, typeof(MZ_CostMaster)); 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 = DateTime.Now; 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; MSAccessDb.UpdateRecord(chargeBill); //更新处方表收费标识 //List<MZ_PresMaster> lstPresMaster = BindEntity<MZ_PresMaster>.CreateInstanceDAL( oleDb ).GetListArray( HIS.BLL.Tables.mz_presmaster.COSTMASTERID + " = " + BudgetaryChargeInfos[chargeCount].ChargeID ); List <MZ_PresMaster> lstPresMaster = MSAccessDb.GetListArray <MZ_PresMaster>("MZ_PRESMASTER", Tables.mz_presmaster.COSTMASTERID + " = " + BudgetaryChargeInfos[chargeCount].ChargeID); if (lstPresMaster.Count == 0) { throw new Exception("没有找到要结算的处方,请确认是否已被人收费"); } foreach (MZ_PresMaster mz_presmaster in lstPresMaster) { if (mz_presmaster.Charge_Flag == 0) { mz_presmaster.Charge_Flag = 1; mz_presmaster.TicketCode = perfCode; mz_presmaster.TicketNum = chargeBill.TicketNum; mz_presmaster.ChargeCode = OperatorId.ToString( ); //BindEntity<MZ_PresMaster>.CreateInstanceDAL( oleDb ).Update( mz_presmaster ); MSAccessDb.UpdateRecord(mz_presmaster); } else { throw new Exception("该处方已被其他收费员收费!"); } } } else { throw new Exception("没有找到结算号的记录!"); } } MSAccessDb.CommitTrans( ); } catch (Exception err) { MSAccessDb.RollbackTrans( ); 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) { throw new Exception("收费成功,但生成发票对象失败!"); } return(true); }
/// <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("读取发票信息错误!"); } }