/// <summary> /// 确费 /// </summary> /// <param name="presorders"></param> /// <param name="ConfirDoc"></param> /// <returns></returns> public override bool SaveConfir(List <int> presorders, int ConfirDoc, int ConfirDept) { try { if (presorders.Count == 0) { return(false); } object obj = GetConfig(); oleDb.BeginTransaction(); for (int i = 0; i < presorders.Count; i++) { HIS.Model.MZ_PresOrder presorder = BindEntity <HIS.Model.MZ_PresOrder> .CreateInstanceDAL(oleDb).GetModel(presorders[i]); HIS.Model.Medical_Confir Confir = new HIS.Model.Medical_Confir(); Confir.Cancel_Flag = 0; Confir.ConfirDate = XcDate.ServerDateTime; Confir.ConfirDept = ConfirDept; Confir.ConfirDoc = ConfirDoc; Confir.Mark_Flag = 0; Confir.PatListId = presorder.PatListID; Confir.PresOrderId = presorder.PresOrderID; string strWhere = Tables.medical_confir.PRESORDERID + oleDb.EuqalTo() + presorder.PresOrderID + oleDb.And() + Tables.medical_confir.CANCEL_FLAG + oleDb.EuqalTo() + 0 + oleDb.And() + Tables.medical_confir.MARK_FLAG + oleDb.EuqalTo() + 0; if (BindEntity <HIS.Model.Medical_Confir> .CreateInstanceDAL(oleDb).Exists(strWhere)) { continue; } BindEntity <HIS.Model.Medical_Confir> .CreateInstanceDAL(oleDb).Add(Confir); HIS.Model.MZ_PresMaster presmaster = BindEntity <HIS.Model.MZ_PresMaster> .CreateInstanceDAL(oleDb).GetModel(presorder.PresMasterID); if (obj == null || obj.ToString().Trim() == "1") //按医技科室确费的修改执行科室 { presmaster.ExecDeptCode = ConfirDept.ToString(); BindEntity <HIS.Model.MZ_PresMaster> .CreateInstanceDAL(oleDb).Update(presmaster); } } oleDb.CommitTransaction(); return(true); } catch (System.Exception e) { oleDb.RollbackTransaction(); throw new Exception(e.Message); } }
/// <summary> /// 保存处方 /// </summary> /// <param name="patient">处方所属病人</param> /// <param name="Prescriptions">要保存的处方</param> /// <returns></returns> public bool SavePrescription(BasePatient patient, Prescription[] Prescriptions) { oleDb.BeginTransaction( ); try { for (int i = 0; i < Prescriptions.Length; i++) { if (!Prescriptions[i].Modified && Prescriptions[i].DocPresId == 0) { continue; } if (Prescriptions[i].PresDetails == null) { continue; } if (Prescriptions[i].PresDetails.Length == 0) { continue; } HIS.Model.MZ_PresMaster t_mz_prescMaster = new HIS.Model.MZ_PresMaster( ); #region 赋值 t_mz_prescMaster.PatID = Prescriptions[i].PatientID; t_mz_prescMaster.PatListID = Prescriptions[i].RegisterID; t_mz_prescMaster.Charge_Flag = Prescriptions[i].Charge_Flag; t_mz_prescMaster.ChargeCode = Prescriptions[i].ChargeCode; t_mz_prescMaster.CostMasterID = Prescriptions[i].ChargeID; t_mz_prescMaster.Drug_Flag = Prescriptions[i].Drug_Flag; t_mz_prescMaster.ExecDeptCode = Prescriptions[i].ExecDeptCode; t_mz_prescMaster.ExecDocCode = Prescriptions[i].ExecDocCode; t_mz_prescMaster.OldID = Prescriptions[i].OldPresID; t_mz_prescMaster.PresCostCode = Prescriptions[i].PresCostCode; t_mz_prescMaster.PresMasterID = Prescriptions[i].PrescriptionID; t_mz_prescMaster.PresType = Prescriptions[i].PrescType; t_mz_prescMaster.PresDeptCode = Prescriptions[i].PresDeptCode; t_mz_prescMaster.PresDocCode = Prescriptions[i].PresDocCode; t_mz_prescMaster.Record_Flag = Prescriptions[i].Record_Flag; t_mz_prescMaster.TicketCode = Prescriptions[i].TicketCode; t_mz_prescMaster.TicketNum = Prescriptions[i].TicketNum; t_mz_prescMaster.Total_Fee = Prescriptions[i].Total_Fee; t_mz_prescMaster.PresDate = Prescriptions[i].PresDate; t_mz_prescMaster.PresAmount = Prescriptions[i].PresDetails[0].PresAmount; t_mz_prescMaster.Hand_Flag = (int)OPDOperationType.门诊收费; t_mz_prescMaster.DocPresId = Prescriptions[i].DocPresId; #endregion if (BindEntity <Model.MZ_PresMaster> .CreateInstanceDAL(oleDb).Exists(Prescriptions[i].PrescriptionID)) { Model.MZ_PresMaster mz_presmaster = BindEntity <Model.MZ_PresMaster> .CreateInstanceDAL(oleDb).GetModel(Prescriptions[i].PrescriptionID); if (mz_presmaster.Charge_Flag == 1) { throw new OperatorException("处方已收费,不能修改!"); } //更新处方头 BindEntity <Model.MZ_PresMaster> .CreateInstanceDAL(oleDb).Update(t_mz_prescMaster); } else { //插入新处方 int ret1 = BindEntity <Model.MZ_PresMaster> .CreateInstanceDAL(oleDb).Add(t_mz_prescMaster); Prescriptions[i].PrescriptionID = ret1; } //更新或增加明细 PrescriptionDetail[] details = Prescriptions[i].PresDetails; for (int j = 0; j < details.Length; j++) { if (details[j].Amount == 0) { throw new OperatorException("【" + details[j].Itemname + "】数量为零,请输入一个大于零的数"); } if (details[j].BigitemCode == "01" || details[j].BigitemCode == "02" || details[j].BigitemCode == "03") { decimal sellprice, buyprice, storevalue; decimal inputValue = details[j].Amount * details[j].PresAmount; PublicDataReader.StoreExists(details[j].ItemId, Prescriptions[i].ExecDeptCode, inputValue, out sellprice, out buyprice, out storevalue); details[j].Buy_price = buyprice; details[j].Sell_price = sellprice; } HIS.Model.MZ_PresOrder t_mz_presOrder = new HIS.Model.MZ_PresOrder( ); #region 赋值 t_mz_presOrder.Amount = details[j].Amount; t_mz_presOrder.BigItemCode = details[j].BigitemCode; t_mz_presOrder.Buy_Price = details[j].Buy_price; t_mz_presOrder.CaseID = details[j].ComplexId; t_mz_presOrder.ItemID = details[j].ItemId; t_mz_presOrder.ItemName = details[j].Itemname; t_mz_presOrder.ItemType = details[j].ItemType; t_mz_presOrder.Order_Flag = details[j].Order_Flag; t_mz_presOrder.PassID = details[j].PassId; t_mz_presOrder.PatID = patient.PatID; t_mz_presOrder.PatListID = patient.PatListID; t_mz_presOrder.PresAmount = details[j].PresAmount; t_mz_presOrder.PresMasterID = Prescriptions[i].PrescriptionID; t_mz_presOrder.PresOrderID = details[j].DetailId; t_mz_presOrder.RelationNum = details[j].RelationNum; t_mz_presOrder.Sell_Price = details[j].Sell_price; t_mz_presOrder.Standard = details[j].Standard; t_mz_presOrder.Tolal_Fee = details[j].Tolal_Fee; t_mz_presOrder.Unit = details[j].Unit; #endregion if (BindEntity <Model.MZ_PresOrder> .CreateInstanceDAL(oleDb).Exists(details[j].DetailId)) { //更新处方明细 BindEntity <Model.MZ_PresOrder> .CreateInstanceDAL(oleDb).Update(t_mz_presOrder); } else { //插入新处方明细 int ret2 = BindEntity <Model.MZ_PresOrder> .CreateInstanceDAL(oleDb).Add(t_mz_presOrder); details[j].DetailId = ret2; } } } oleDb.CommitTransaction( ); return(true); } catch (OperatorException operr) { oleDb.RollbackTransaction( ); throw operr; } catch (Exception err) { oleDb.RollbackTransaction( ); ErrorWriter.WriteLog(err.Message); throw new Exception("保存处方发生错误!"); } }
private bool _charge(ChargeInfo[] BudgetaryChargeInfos, Prescription[] prescriptions, out BaseInvoice[] ChargeInvoicies) { try { for (int chargeCount = 0; chargeCount < BudgetaryChargeInfos.Length; chargeCount++) { if (MSAccessDb.Exists("MZ_COSTMASTER", Tables.mz_costmaster.COSTMASTERID + "=" + BudgetaryChargeInfos[chargeCount].ChargeID)) { HIS.Model.MZ_CostMaster chargeBill = new HIS.Model.MZ_CostMaster( ); 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.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].InvoiceSerialNO = Convert.ToInt32(chargeBill.TicketNum); BudgetaryChargeInfos[chargeCount].ChargeDate = chargeBill.CostDate; MSAccessDb.UpdateRecord(chargeBill); //更新结算表 //更新处方表收费标识 HIS.Model.MZ_PresMaster presMaster = new HIS.Model.MZ_PresMaster( ); //presMaster = BindEntity<HIS.Model.MZ_PresMaster>.CreateInstanceDAL( oleDb ).GetModel( BudgetaryChargeInfos[chargeCount].PrescriptionID ); presMaster = (MZ_PresMaster)MSAccessDb.GetModel("MZ_PRESMASTER", Tables.mz_presmaster.PRESMASTERID + "=" + BudgetaryChargeInfos[chargeCount].PrescriptionID, typeof(MZ_PresMaster)); 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 = BudgetaryChargeInfos[chargeCount].InvoiceNO; presMaster.TicketNum = chargeBill.TicketNum; presMaster.CostMasterID = BudgetaryChargeInfos[chargeCount].ChargeID; presMaster.ChargeCode = OperatorId.ToString( ); //BindEntity<HIS.Model.MZ_PresMaster>.CreateInstanceDAL( oleDb ).Update( presMaster ); MSAccessDb.UpdateRecord(presMaster); } else { throw new Exception("该处方已被其他收费员收费!"); } } else { throw new Exception("没有找到结算号的记录!"); } } //生成发票 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 (Exception err) { throw err; } }
/// <summary> /// 保存处方 /// </summary> /// <param name="Prescriptions">要保存的处方</param> /// <returns>成功标志</returns> /// <remarks></remarks> public bool SavePrescription(Prescription[] Prescriptions) { //oleDb.BeginTransaction(); MSAccessDb.BeginTrans( ); try { for (int i = 0; i < Prescriptions.Length; i++) { if (!Prescriptions[i].Modified) { continue; } if (Prescriptions[i].PresDetails == null) { continue; } if (Prescriptions[i].PresDetails.Length == 0) { continue; } HIS.Model.MZ_PresMaster t_mz_prescMaster = new HIS.Model.MZ_PresMaster( ); #region 赋值 t_mz_prescMaster.PatID = Prescriptions[i].PatientID; t_mz_prescMaster.PatListID = Prescriptions[i].RegisterID; t_mz_prescMaster.Charge_Flag = Prescriptions[i].Charge_Flag; t_mz_prescMaster.ChargeCode = Prescriptions[i].ChargeCode; t_mz_prescMaster.CostMasterID = Prescriptions[i].ChargeID; t_mz_prescMaster.Drug_Flag = Prescriptions[i].Drug_Flag; t_mz_prescMaster.ExecDeptCode = Prescriptions[i].ExecDeptCode; t_mz_prescMaster.ExecDocCode = Prescriptions[i].ExecDocCode; t_mz_prescMaster.OldID = Prescriptions[i].OldPresID; t_mz_prescMaster.PresCostCode = Prescriptions[i].PresCostCode; t_mz_prescMaster.PresMasterID = Prescriptions[i].PrescriptionID; t_mz_prescMaster.PresType = Prescriptions[i].PrescType; t_mz_prescMaster.PresDeptCode = Prescriptions[i].PresDeptCode; t_mz_prescMaster.PresDocCode = Prescriptions[i].PresDocCode; t_mz_prescMaster.Record_Flag = Prescriptions[i].Record_Flag; t_mz_prescMaster.TicketCode = Prescriptions[i].TicketCode; t_mz_prescMaster.TicketNum = Prescriptions[i].TicketNum; t_mz_prescMaster.Total_Fee = Prescriptions[i].Total_Fee; t_mz_prescMaster.PresDate = Prescriptions[i].PresDate; t_mz_prescMaster.PresAmount = Prescriptions[i].PresDetails[0].PresAmount; t_mz_prescMaster.Hand_Flag = (int)OPDOperationType.门诊收费; #endregion if (MSAccessDb.Exists("MZ_PRESMASTER", Tables.mz_presmaster.PRESMASTERID + "=" + Prescriptions[i].PrescriptionID)) { MZ_PresMaster mz_presmaster = (MZ_PresMaster)MSAccessDb.GetModel("MZ_PRESMASTER", Tables.mz_presmaster.PRESMASTERID + "=" + Prescriptions[i].PrescriptionID, typeof(MZ_PresMaster)); if (mz_presmaster.Charge_Flag == 1) { throw new Exception("处方已收费,不能修改!"); } //更新处方头 //BindEntity<MZ_PresMaster>.CreateInstanceDAL( oleDb ).Update( t_mz_prescMaster ); MSAccessDb.UpdateRecord(t_mz_prescMaster); } else { //插入新处方 t_mz_prescMaster.PresMasterID = MSAccessDb.GetMaxID("MZ_PRESMASTER", Tables.mz_presmaster.PRESMASTERID); MSAccessDb.InsertRecord(t_mz_prescMaster, Tables.mz_presmaster.PRESMASTERID); Prescriptions[i].PrescriptionID = t_mz_prescMaster.PresMasterID; } //更新或增加明细 PrescriptionDetail[] details = Prescriptions[i].PresDetails; int temp_detail_id = MSAccessDb.GetMaxID("MZ_PRESORDER", Tables.mz_presorder.PRESORDERID); for (int j = 0; j < details.Length; j++) { HIS.Model.MZ_PresOrder t_mz_presOrder = new HIS.Model.MZ_PresOrder( ); #region 赋值 t_mz_presOrder.Amount = details[j].Amount; t_mz_presOrder.BigItemCode = details[j].BigitemCode; t_mz_presOrder.Buy_Price = details[j].Buy_price; t_mz_presOrder.CaseID = details[j].ComplexId; t_mz_presOrder.ItemID = details[j].ItemId; t_mz_presOrder.ItemName = details[j].Itemname; t_mz_presOrder.ItemType = details[j].ItemType; t_mz_presOrder.Order_Flag = details[j].Order_Flag; t_mz_presOrder.PassID = details[j].PassId; t_mz_presOrder.PatID = this.patient.PatID; t_mz_presOrder.PatListID = this.patient.PatListID; t_mz_presOrder.PresAmount = details[j].PresAmount; t_mz_presOrder.PresMasterID = Prescriptions[i].PrescriptionID; t_mz_presOrder.PresOrderID = details[j].DetailId; t_mz_presOrder.RelationNum = details[j].RelationNum; t_mz_presOrder.Sell_Price = details[j].Sell_price; t_mz_presOrder.Standard = details[j].Standard; t_mz_presOrder.Tolal_Fee = details[j].Tolal_Fee; t_mz_presOrder.Unit = details[j].Unit; #endregion if (MSAccessDb.Exists("MZ_PRESORDER", Tables.mz_presorder.PRESORDERID + "=" + details[j].DetailId)) { //更新处方明细 MSAccessDb.UpdateRecord(t_mz_presOrder); } else { //插入新处方明细 t_mz_presOrder.PresOrderID = temp_detail_id; int ret2 = MSAccessDb.InsertRecord(t_mz_presOrder, Tables.mz_presorder.PRESORDERID); details[j].DetailId = temp_detail_id; temp_detail_id++; } } } MSAccessDb.CommitTrans( ); return(true); } catch (Exception err) { MSAccessDb.RollbackTrans( ); throw new Exception("保存处方发生错误!"); } }