public void Fees_GetAmount0() { double amt = _defaultFeeAmt * _rand.NextDouble(); Fee fee = CreateSingleFee(MethodBase.GetCurrentMethod().Name, amt, true, true); Assert.AreEqual(0, Fees.GetAmount0(_listProcCodes.Last().CodeNum, fee.FeeSched, fee.ClinicNum, fee.ProvNum)); Assert.AreEqual(fee.Amount, Fees.GetAmount0(fee.CodeNum, fee.FeeSched, fee.ClinicNum, fee.ProvNum), _precision); }
public void Claims_CalculateAndUpdate_Allowed1Allowed2CompletedProcedures() { string suffix = "8"; Patient pat = PatientT.CreatePatient(suffix); long patNum = pat.PatNum; long feeSchedNum1 = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, suffix); long feeSchedNum2 = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, suffix + "b"); //Standard Fee long codeNum = ProcedureCodes.GetCodeNum("D2750"); Fee fee = Fees.GetFee(codeNum, 53, 0, 0); if (fee == null) { fee = new Fee(); fee.CodeNum = codeNum; fee.FeeSched = 53; fee.Amount = 1200; Fees.Insert(fee); } else { fee.Amount = 1200; Fees.Update(fee); } //PPO fees fee = new Fee(); fee.CodeNum = codeNum; fee.FeeSched = feeSchedNum1; fee.Amount = 600; Fees.Insert(fee); fee = new Fee(); fee.CodeNum = codeNum; fee.FeeSched = feeSchedNum2; fee.Amount = 800; Fees.Insert(fee); //Carrier Carrier carrier = CarrierT.CreateCarrier(suffix); long planNum1 = InsPlanT.CreateInsPlanPPO(carrier.CarrierNum, feeSchedNum1).PlanNum; long planNum2 = InsPlanT.CreateInsPlanPPO(carrier.CarrierNum, feeSchedNum2).PlanNum; InsSub sub1 = InsSubT.CreateInsSub(pat.PatNum, planNum1); long subNum1 = sub1.InsSubNum; InsSub sub2 = InsSubT.CreateInsSub(pat.PatNum, planNum2); long subNum2 = sub2.InsSubNum; BenefitT.CreateCategoryPercent(planNum1, EbenefitCategory.Crowns, 50); BenefitT.CreateCategoryPercent(planNum2, EbenefitCategory.Crowns, 50); BenefitT.CreateAnnualMax(planNum1, 1000); BenefitT.CreateAnnualMax(planNum2, 1000); PatPlanT.CreatePatPlan(1, patNum, subNum1); PatPlanT.CreatePatPlan(2, patNum, subNum2); Procedure proc = ProcedureT.CreateProcedure(pat, "D2750", ProcStat.TP, "8", Fees.GetAmount0(codeNum, 53)); //crown on 8 long procNum = proc.ProcNum; //Lists List <ClaimProc> claimProcs = ClaimProcs.Refresh(patNum); Family fam = Patients.GetFamily(patNum); List <InsSub> subList = InsSubs.RefreshForFam(fam); List <InsPlan> planList = InsPlans.RefreshForSubList(subList); List <PatPlan> patPlans = PatPlans.Refresh(patNum); List <Benefit> benefitList = Benefits.Refresh(patPlans, subList); List <Procedure> procList = Procedures.Refresh(patNum); //Set complete and attach to claim ProcedureT.SetComplete(proc, pat, planList, patPlans, claimProcs, benefitList, subList); claimProcs = ClaimProcs.Refresh(patNum); List <Procedure> procsForClaim = new List <Procedure>(); procsForClaim.Add(proc); Claim claim = ClaimT.CreateClaim("P", patPlans, planList, claimProcs, procList, pat, procsForClaim, benefitList, subList); //Validate Assert.AreEqual(500, claim.WriteOff); }
///<summary>Most of the logic for breaking an appointment. Pass in the brokenFee (the number the user enters in the brokenAppointment window), ///Optionally pass in if the brokenappointment procedure is being deleted. Returns the broken procedure that was created.</summary> public static Procedure BreakAppointment(Appointment appt, Patient pat, ProcedureCode procCode, double feeOverride, bool isDeleteBrokenProc = false) { //suppressHistory is true due to below logic creating a log with a specific HistAppointmentAction instead of the generic changed. DateTime datePrevious = appt.DateTStamp; bool suppressHistory = false; if (procCode != null) { suppressHistory = procCode.ProcCode == "D9986" || procCode.ProcCode == "D9987"; } Appointments.SetAptStatus(appt, ApptStatus.Broken, suppressHistory); //Appointments S-Class handles Signalods if (appt.AptStatus != ApptStatus.Complete) //seperate log entry for completed appointments. { SecurityLogs.MakeLogEntry(Permissions.AppointmentEdit, pat.PatNum, appt.ProcDescript + ", " + appt.AptDateTime.ToString() + ", Broken from the Appts module.", appt.AptNum, datePrevious); } else { SecurityLogs.MakeLogEntry(Permissions.AppointmentCompleteEdit, pat.PatNum, appt.ProcDescript + ", " + appt.AptDateTime.ToString() + ", Broken from the Appts module.", appt.AptNum, datePrevious); } List <Procedure> listProcedures = Procedures.GetProcsForSingle(appt.AptNum, false); //splits should only exist on procs if they are using tp pre-payments List <PaySplit> listSplitsForApptProcs = new List <PaySplit>(); bool isNonRefundable = false; double brokenProcAmount = 0; if (listProcedures.Count > 0) { listSplitsForApptProcs = PaySplits.GetPaySplitsFromProcs(listProcedures.Select(x => x.ProcNum).ToList()); } Procedure brokenProcedure = new Procedure(); #region Charting the proc if (procCode != null) { switch (procCode.ProcCode) { case "D9986": //Missed HistAppointments.CreateHistoryEntry(appt.AptNum, HistAppointmentAction.Missed); break; case "D9987": //Cancelled HistAppointments.CreateHistoryEntry(appt.AptNum, HistAppointmentAction.Cancelled); break; } brokenProcedure.PatNum = pat.PatNum; brokenProcedure.ProvNum = (procCode.ProvNumDefault > 0 ? procCode.ProvNumDefault : appt.ProvNum); brokenProcedure.CodeNum = procCode.CodeNum; brokenProcedure.ProcDate = DateTime.Today; brokenProcedure.DateEntryC = DateTime.Now; brokenProcedure.ProcStatus = ProcStat.C; brokenProcedure.ClinicNum = appt.ClinicNum; brokenProcedure.UserNum = Security.CurUser.UserNum; brokenProcedure.Note = Lans.g("AppointmentEdit", "Appt BROKEN for") + " " + appt.ProcDescript + " " + appt.AptDateTime.ToString(); brokenProcedure.PlaceService = (PlaceOfService)PrefC.GetInt(PrefName.DefaultProcedurePlaceService); //Default proc place of service for the Practice is used. List <InsSub> listInsSubs = InsSubs.RefreshForFam(Patients.GetFamily(pat.PatNum)); List <InsPlan> listInsPlans = InsPlans.RefreshForSubList(listInsSubs); List <PatPlan> listPatPlans = PatPlans.Refresh(pat.PatNum); InsPlan insPlanPrimary = null; InsSub insSubPrimary = null; if (listPatPlans.Count > 0) { insSubPrimary = InsSubs.GetSub(listPatPlans[0].InsSubNum, listInsSubs); insPlanPrimary = InsPlans.GetPlan(insSubPrimary.PlanNum, listInsPlans); } double procFee; long feeSch; if (insPlanPrimary == null || procCode.NoBillIns) { feeSch = FeeScheds.GetFeeSched(0, pat.FeeSched, brokenProcedure.ProvNum); } else //Only take into account the patient's insurance fee schedule if the D9986 procedure is not marked as NoBillIns { feeSch = FeeScheds.GetFeeSched(insPlanPrimary.FeeSched, pat.FeeSched, brokenProcedure.ProvNum); } procFee = Fees.GetAmount0(brokenProcedure.CodeNum, feeSch, brokenProcedure.ClinicNum, brokenProcedure.ProvNum); if (insPlanPrimary != null && insPlanPrimary.PlanType == "p" && !insPlanPrimary.IsMedical) //PPO { double provFee = Fees.GetAmount0(brokenProcedure.CodeNum, Providers.GetProv(brokenProcedure.ProvNum).FeeSched, brokenProcedure.ClinicNum, brokenProcedure.ProvNum); brokenProcedure.ProcFee = Math.Max(provFee, procFee); } else { brokenProcedure.ProcFee = procFee; } if (!PrefC.GetBool(PrefName.EasyHidePublicHealth)) { brokenProcedure.SiteNum = pat.SiteNum; } Procedures.Insert(brokenProcedure); Procedure procOld = brokenProcedure.Copy(); //Now make a claimproc if the patient has insurance. We do this now for consistency because a claimproc could get created in the future. List <Benefit> listBenefits = Benefits.Refresh(listPatPlans, listInsSubs); List <ClaimProc> listClaimProcsForProc = ClaimProcs.RefreshForProc(brokenProcedure.ProcNum); Procedures.ComputeEstimates(brokenProcedure, pat.PatNum, listClaimProcsForProc, false, listInsPlans, listPatPlans, listBenefits, pat.Age, listInsSubs); if (listSplitsForApptProcs.Count > 0 && PrefC.GetBool(PrefName.TpPrePayIsNonRefundable) && procCode.ProcCode == "D9986") { //if there are pre-payments, non-refundable pre-payments is turned on, and the broken appointment is a missed code then auto-fill //the window with the sum of the procs for the appointment. Transfer money below after broken procedure is confirmed by the user. //normally goes to the form to let the user speficy, this is the auto filled amount for the form. brokenProcedure.ProcFee = feeOverride; //listSplitsForApptProcs.Sum(x => x.SplitAmt); isNonRefundable = true; } if (isDeleteBrokenProc) { brokenProcedure.ProcStatus = ProcStat.D; } brokenProcedure.ProcFee = feeOverride; brokenProcAmount = feeOverride; Procedures.Update(brokenProcedure, procOld); } #endregion //Note this MUST come after FormProcBroken since clicking cancel in that window will delete the procedure. if (isNonRefundable && !isDeleteBrokenProc && listSplitsForApptProcs.Count > 0) { //transfer what the user specified in the broken appointment window. //transfer up to the amount specified by the user foreach (Procedure proc in listProcedures) { if (brokenProcAmount == 0) { break; } List <PaySplit> listSplitsForAppointmentProcedure = listSplitsForApptProcs.FindAll(x => x.ProcNum == proc.ProcNum); foreach (PaySplit split in listSplitsForAppointmentProcedure) { if (brokenProcAmount == 0) { break; } double amt = Math.Min(brokenProcAmount, split.SplitAmt); Payments.CreateTransferForTpProcs(proc, new List <PaySplit> { split }, brokenProcedure, amt); brokenProcAmount -= amt; } } } return(brokenProcedure); }