///<summary>Gets the data necesary to load FormApptEdit.</summary> public static LoadData GetLoadData(Appointment AptCur, bool IsNew) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <LoadData>(MethodBase.GetCurrentMethod(), AptCur, IsNew)); } LoadData data = new LoadData(); data.ListProcsForAppt = Procedures.GetProcsForApptEdit(AptCur); data.ListAppointments = Appointments.GetAppointmentsForProcs(data.ListProcsForAppt); data.Family = Patients.GetFamily(AptCur.PatNum); data.ListPatPlans = PatPlans.Refresh(AptCur.PatNum); data.ListInsSubs = InsSubs.RefreshForFam(data.Family); data.ListBenefits = Benefits.Refresh(data.ListPatPlans, data.ListInsSubs); data.ListInsPlans = InsPlans.RefreshForSubList(data.ListInsSubs); data.TableApptFields = Appointments.GetApptFields(AptCur.AptNum); data.TableComms = Appointments.GetCommTable(AptCur.PatNum.ToString(), AptCur.AptNum); data.Lab = (IsNew ? null : LabCases.GetForApt(AptCur)); data.PatientTable = Appointments.GetPatTable(AptCur.PatNum.ToString(), AptCur); data.ListClaimProcs = ClaimProcs.RefreshForProcs(data.ListProcsForAppt.Select(x => x.ProcNum).ToList()); data.ListAdjustments = Adjustments.GetForProcs(data.ListProcsForAppt.Select(x => x.ProcNum).ToList()); if (!PrefC.GetBool(PrefName.EasyHideDentalSchools)) { data.ListStudents = ReqStudents.GetForAppt(AptCur.AptNum); } return(data); }
public void InsPlan_PpoNoSubWriteoffsNoSub() { string suffix = MethodBase.GetCurrentMethod().Name; Patient pat = PatientT.CreatePatient(suffix); long ucrFeeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "UCR Fees" + suffix); long ppoFeeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "PPO " + suffix); InsuranceInfo ins = InsuranceT.AddInsurance(pat, suffix, planType: "p", feeSchedNum: ppoFeeSchedNum); ins.PriInsPlan.HasPpoSubstWriteoffs = false; InsPlans.Update(ins.PriInsPlan); BenefitT.CreateCategoryPercent(ins.PriInsPlan.PlanNum, EbenefitCategory.Restorative, 50); ProcedureCode originalProcCode = ProcedureCodes.GetProcCode("D2330"); ProcedureCode downgradeProcCode = ProcedureCodes.GetProcCode("D2140"); originalProcCode.SubstitutionCode = ""; //NOT substituting originalProcCode.SubstOnlyIf = SubstitutionCondition.Always; ProcedureCodeT.Update(originalProcCode); FeeT.CreateFee(ucrFeeSchedNum, originalProcCode.CodeNum, 100); FeeT.CreateFee(ucrFeeSchedNum, downgradeProcCode.CodeNum, 80); FeeT.CreateFee(ppoFeeSchedNum, originalProcCode.CodeNum, 60); FeeT.CreateFee(ppoFeeSchedNum, downgradeProcCode.CodeNum, 50); Procedure proc = ProcedureT.CreateProcedure(pat, "D2330", ProcStat.C, "9", 100);//Tooth 9 List <ClaimProc> listClaimProcs = ClaimProcs.Refresh(pat.PatNum); List <Procedure> listProcs = Procedures.Refresh(pat.PatNum); ins.RefreshBenefits(); Claim claim = ClaimT.CreateClaim("P", ins.ListPatPlans, ins.ListInsPlans, listClaimProcs, listProcs, pat, listProcs, ins.ListBenefits, ins.ListInsSubs); ClaimProc clProc = ClaimProcs.Refresh(pat.PatNum)[0]; //Should only be one Assert.AreEqual(50, clProc.Percentage); Assert.AreEqual(30, clProc.BaseEst); Assert.AreEqual(30, clProc.InsPayEst); Assert.AreEqual(40, clProc.WriteOffEst); }
public void InsPlan_GetInsUsedDisplay_LimitationsOverride() { string suffix = "6"; Patient pat = PatientT.CreatePatient(suffix); long patNum = pat.PatNum; Carrier carrier = CarrierT.CreateCarrier(suffix); InsPlan plan = InsPlanT.CreateInsPlan(carrier.CarrierNum); long planNum = plan.PlanNum; InsSub sub = InsSubT.CreateInsSub(pat.PatNum, planNum); //guarantor is subscriber long subNum = sub.InsSubNum; long patPlanNum = PatPlanT.CreatePatPlan(1, pat.PatNum, subNum).PatPlanNum; BenefitT.CreateAnnualMax(planNum, 1000); BenefitT.CreateLimitation(planNum, EbenefitCategory.Diagnostic, 1000); Procedure proc = ProcedureT.CreateProcedure(pat, "D0120", ProcStat.C, "", 50); //An exam long procNum = proc.ProcNum; Procedure proc2 = ProcedureT.CreateProcedure(pat, "D2750", ProcStat.C, "8", 830); //create a crown ClaimProcT.AddInsPaid(patNum, planNum, procNum, 50, subNum, 0, 0); ClaimProcT.AddInsPaid(patNum, planNum, proc2.ProcNum, 400, subNum, 0, 0); //Lists 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 <ClaimProcHist> histList = ClaimProcs.GetHistList(patNum, benefitList, patPlans, planList, DateTime.Today, subList); //Validate double insUsed = InsPlans.GetInsUsedDisplay(histList, DateTime.Today, planNum, patPlanNum, -1, planList, benefitList, patNum, subNum); Assert.AreEqual(400, insUsed); }
///<summary>Gets most of the data necessary to fill the static text fields.</summary> public static StaticTextData GetStaticTextData(Patient pat, Family fam, List <long> listProcCodeNums) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <StaticTextData>(MethodBase.GetCurrentMethod(), pat, fam, listProcCodeNums)); } StaticTextData data = new StaticTextData(); data.PatNote = PatientNotes.Refresh(pat.PatNum, pat.Guarantor); data.ListRefAttaches = RefAttaches.Refresh(pat.PatNum); data.ListSubs = InsSubs.RefreshForFam(fam); data.ListPlans = InsPlans.RefreshForSubList(data.ListSubs); data.ListPatPlans = PatPlans.Refresh(pat.PatNum); data.ListBenefits = Benefits.Refresh(data.ListPatPlans, data.ListSubs); data.HistList = ClaimProcs.GetHistList(pat.PatNum, data.ListBenefits, data.ListPatPlans, data.ListPlans, DateTime.Today, data.ListSubs); data.ListTreatPlans = TreatPlans.Refresh(pat.PatNum); data.ListRecallsForFam = Recalls.GetList(fam.ListPats.Select(x => x.PatNum).ToList()); data.ListAppts = Appointments.GetListForPat(pat.PatNum); data.ListFutureApptsForFam = Appointments.GetFutureSchedApts(fam.ListPats.Select(x => x.PatNum).ToList()); data.ListDiseases = Diseases.Refresh(pat.PatNum, true); data.ListAllergies = Allergies.GetAll(pat.PatNum, false); data.ListMedicationPats = MedicationPats.Refresh(pat.PatNum, false); data.ListFamPopups = Popups.GetForFamily(pat); data.ListProceduresSome = Procedures.RefreshForProcCodeNums(pat.PatNum, listProcCodeNums); return(data); }
public void FeeSchedTools_GlobalUpdateWriteoffEstimates_SubscriberInDifferentFamily() { string suffix = MethodBase.GetCurrentMethod().Name; string procStr = "D0145"; double procFee = 100; ProcedureCode procCode = ProcedureCodes.GetProcCode(procStr); //Set up clinic, prov, pat Clinic clinic = ClinicT.CreateClinic(suffix); long feeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, suffix); long provNum = ProviderT.CreateProvider(suffix, feeSchedNum: feeSchedNum); Fee fee = FeeT.GetNewFee(feeSchedNum, procCode.CodeNum, procFee, clinic.ClinicNum, provNum); Patient pat = PatientT.CreatePatient(suffix, provNum, clinic.ClinicNum); Patient patSubscriber = PatientT.CreatePatient(suffix + "_Subscriber", provNum, clinic.ClinicNum); //Set up insurance InsuranceInfo info = InsuranceT.AddInsurance(pat, suffix, "p", feeSchedNum); info.PriInsSub.Subscriber = patSubscriber.PatNum; InsSubs.Update(info.PriInsSub); info.ListBenefits.Add(BenefitT.CreatePercentForProc(info.PriInsPlan.PlanNum, procCode.CodeNum, 100)); //Create the procedure and claimproc Procedure proc = ProcedureT.CreateProcedure(pat, procStr, ProcStat.TP, "", procFee); ClaimProc priClaimProc = ClaimProcT.CreateClaimProc(pat.PatNum, proc.ProcNum, info.PriInsPlan.PlanNum, info.PriInsSub.InsSubNum, DateTime.Today, -1, -1, -1, ClaimProcStatus.CapEstimate); Procedures.ComputeEstimates(proc, pat.PatNum, new List <ClaimProc>(), true, info.ListInsPlans, info.ListPatPlans, info.ListBenefits, pat.Age, info.ListInsSubs); priClaimProc = ClaimProcs.Refresh(pat.PatNum).FirstOrDefault(x => x.ProcNum == proc.ProcNum); Assert.AreEqual(procFee, priClaimProc.InsPayEst); GlobalUpdateWriteoffs(clinic.ClinicNum); priClaimProc = ClaimProcs.Refresh(pat.PatNum).FirstOrDefault(x => x.ClaimProcNum == priClaimProc.ClaimProcNum); Assert.AreEqual(procFee, priClaimProc.InsPayEst); }
///<summary>Creates a procedure and computes estimates for a patient where the secondary insurance has a COB rule of Medicaid.</summary> private void ComputeEstimatesMedicaidCOB(string suffix, double procFee, double priAllowed, double secAllowed, int priPercentCovered, int secPercentCovered, Action <ClaimProc /*Primary*/, ClaimProc /*Secondary*/, Procedure> assertAct) { Patient pat = PatientT.CreatePatient(suffix); long ppoFeeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "PPO " + suffix); InsuranceT.AddInsurance(pat, suffix, "p", ppoFeeSchedNum); long medicaidFeeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "PPO " + suffix); InsuranceT.AddInsurance(pat, suffix, "p", medicaidFeeSchedNum, 2, cobRule: EnumCobRule.SecondaryMedicaid); List <InsSub> listSubs = InsSubT.GetInsSubs(pat); List <InsPlan> listPlans = InsPlans.RefreshForSubList(listSubs); List <PatPlan> listPatPlans = PatPlans.Refresh(pat.PatNum); InsPlan priPlan = InsPlanT.GetPlanForPriSecMed(PriSecMed.Primary, listPatPlans, listPlans, listSubs); BenefitT.CreateCategoryPercent(priPlan.PlanNum, EbenefitCategory.Diagnostic, priPercentCovered); InsPlan secPlan = InsPlanT.GetPlanForPriSecMed(PriSecMed.Secondary, listPatPlans, listPlans, listSubs); BenefitT.CreateCategoryPercent(secPlan.PlanNum, EbenefitCategory.Diagnostic, secPercentCovered); List <Benefit> listBens = Benefits.Refresh(listPatPlans, listSubs); string procStr = "D0150"; Procedure proc = ProcedureT.CreateProcedure(pat, procStr, ProcStat.TP, "", procFee); ProcedureCode procCode = ProcedureCodes.GetProcCode(procStr); FeeT.CreateFee(ppoFeeSchedNum, procCode.CodeNum, priAllowed); FeeT.CreateFee(medicaidFeeSchedNum, procCode.CodeNum, secAllowed); Procedures.ComputeEstimates(proc, pat.PatNum, new List <ClaimProc>(), false, listPlans, listPatPlans, listBens, pat.Age, listSubs); List <ClaimProc> listClaimProcs = ClaimProcs.Refresh(pat.PatNum); assertAct(listClaimProcs.FirstOrDefault(x => x.PlanNum == priPlan.PlanNum), listClaimProcs.FirstOrDefault(x => x.PlanNum == secPlan.PlanNum), proc); }
///<summary>Transfers unallocated to unearned (if present) and inserts those results into the database. Then performs transfer. ///This is the best representation of what the income transfer window currently does.</summary> public static PaymentEdit.IncomeTransferData BalanceAndIncomeTransfer(long patNum, Family fam, Payment regularTransferPayment , List <PayPlanCharge> payPlanCharges = null) { //get all paysplits associated to the family passed in List <PaySplit> listSplitsForPat = PaySplits.GetForPats(fam.ListPats.Select(x => x.PatNum).ToList()); //perform unallocated transfer Payment unallocatedTransfer = MakePaymentNoSplits(patNum, 0, payDate: DateTime.Today); PaymentEdit.IncomeTransferData unallocatedResults = PaymentEdit.TransferUnallocatedSplitToUnearned(listSplitsForPat, unallocatedTransfer.PayNum); foreach (PaySplit split in unallocatedResults.ListSplitsCur) { if (split.SplitAmt.IsZero()) { continue; } PaySplits.Insert(split); } foreach (PaySplits.PaySplitAssociated splitAssociated in unallocatedResults.ListSplitsAssociated) { if (splitAssociated.PaySplitOrig != null && splitAssociated.PaySplitLinked != null) { PaySplits.UpdateFSplitNum(splitAssociated.PaySplitOrig.SplitNum, splitAssociated.PaySplitLinked.SplitNum); } } if (payPlanCharges == null) { payPlanCharges = new List <PayPlanCharge>(); } #region claim fix and transfer //both of these methods have objects that get immediately inserted into the database. While testing, a spcific call wil need to be made to delete. ClaimProcs.FixClaimsNoProcedures(fam.ListPats.Select(x => x.PatNum).ToList()); //make dummy procedures and claimprocs for claims missing procs. ClaimProcs.TransferClaimsAsTotalToProcedures(fam.ListPats.Select(x => x.PatNum).ToList()); //transfer AsTotals into claim procedures #endregion return(IncomeTransfer(patNum, fam, regularTransferPayment, payPlanCharges)); }
public void InsPlan_GetPendingDisplay_LimitationsOverrideGeneralLimitations() { string suffix = "31"; Patient pat = PatientT.CreatePatient(suffix); long patNum = pat.PatNum; Carrier carrier = CarrierT.CreateCarrier(suffix); InsPlan plan = InsPlanT.CreateInsPlan(carrier.CarrierNum); long planNum = plan.PlanNum; InsSub sub = InsSubT.CreateInsSub(pat.PatNum, planNum); //guarantor is subscriber long subNum = sub.InsSubNum; long patPlanNum = PatPlanT.CreatePatPlan(1, pat.PatNum, subNum).PatPlanNum; BenefitT.CreateAnnualMax(planNum, 1000); BenefitT.CreateCategoryPercent(planNum, EbenefitCategory.RoutinePreventive, 100); BenefitT.CreateLimitation(planNum, EbenefitCategory.RoutinePreventive, 1000); //Changing this amount would affect patient portion vs ins portion. But regardless of the amount, this should prevent any pending from showing in the box, which is for general pending only. Procedure proc = ProcedureT.CreateProcedure(pat, "D1110", ProcStat.C, "", 125); //Prophy //Lists List <ClaimProc> claimProcs = ClaimProcs.Refresh(pat.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(pat.PatNum); Claim claim = ClaimT.CreateClaim("P", patPlans, planList, claimProcs, ProcList, pat, ProcList, benefitList, subList);//Creates the claim in the same manner as the account module, including estimates and status NotReceived. List <ClaimProcHist> histList = ClaimProcs.GetHistList(patNum, benefitList, patPlans, planList, DateTime.Today, subList); //Validate Assert.AreEqual(0, InsPlans.GetPendingDisplay(histList, DateTime.Today, plan, patPlanNum, -1, patNum, subNum, benefitList)); }
public static List <PayPlanProductionEntry> GetProductionForLinks(List <PayPlanLink> listCredits) { //No remoting role check; no call to db List <long> listProcNums = listCredits.FindAll(x => x.LinkType == PayPlanLinkType.Procedure).Select(x => x.FKey).ToList(); List <long> listAdjNumsForCredits = listCredits.FindAll(x => x.LinkType == PayPlanLinkType.Adjustment).Select(x => x.FKey).ToList(); List <PayPlanProductionEntry> listPayPlanProductionEntries = new List <PayPlanProductionEntry>(); //ortho cases to be implemented later. List <Procedure> listProcedures = Procedures.GetManyProc(listProcNums, false); List <Adjustment> listCreditAdjustments = Adjustments.GetMany(listAdjNumsForCredits); List <Adjustment> listProcAdjustments = Adjustments.GetForProcs(listProcNums); List <ClaimProc> listClaimProcs = ClaimProcs.GetForProcs(listProcNums); //used for calculating patient porition foreach (PayPlanLink credit in listCredits) { if (credit.LinkType == PayPlanLinkType.Procedure) { Procedure proc = listProcedures.FirstOrDefault(x => x.ProcNum == credit.FKey); if (proc != null) { listPayPlanProductionEntries.Add(new PayPlanProductionEntry(proc, credit, listClaimProcs, listProcAdjustments)); } } else if (credit.LinkType == PayPlanLinkType.Adjustment) { Adjustment adj = listCreditAdjustments.FirstOrDefault(x => x.AdjNum == credit.FKey); if (adj != null) { listPayPlanProductionEntries.Add(new PayPlanProductionEntry(adj, credit)); } } } return(listPayPlanProductionEntries); }
public void InsPlans_ComputeEstimatesForSubscriber_CanadianLabFees() { string suffix = MethodBase.GetCurrentMethod().Name; CultureInfo curCulture = CultureInfo.CurrentCulture; Thread.CurrentThread.CurrentCulture = new CultureInfo("en-CA"); //Canada try { //Create a patient and treatment plan a procedure with a lab fee. Patient pat = PatientT.CreatePatient(); ProcedureCodeT.AddIfNotPresent("14611"); ProcedureCodeT.AddIfNotPresent("99111", isCanadianLab: true); Procedure proc = ProcedureT.CreateProcedure(pat, "14611", ProcStat.TP, "", 250); Procedure procLab = ProcedureT.CreateProcedure(pat, "99111", ProcStat.TP, "", 149, procNumLab: proc.ProcNum); //Create a new primary insurance plan for this patient. //It is important that we add the insurance plan after the procedure has already been created for this particular scenario. Carrier carrier = CarrierT.CreateCarrier(suffix); InsPlan plan = InsPlanT.CreateInsPlan(carrier.CarrierNum); InsSub sub = InsSubT.CreateInsSub(pat.PatNum, plan.PlanNum); PatPlan patPlan = PatPlanT.CreatePatPlan(1, pat.PatNum, sub.InsSubNum); //Invoking ComputeEstimatesForAll() will simulate the logic of adding a new insurance plan from the Family module. //The bug that this unit test is preventing is that a duplicate claimproc was being created for the lab fee. //This was causing a faux line to show up when a claim was created for the procedure in question. //It ironically doesn't matter if the procedures above are even covered by insurance because they'll get claimprocs created regardless. InsPlans.ComputeEstimatesForSubscriber(sub.Subscriber); //Check to see how many claimproc enteries there are for the current patient. There should only be two. List <ClaimProc> listClaimProcs = ClaimProcs.Refresh(pat.PatNum); Assert.AreEqual(2, listClaimProcs.Count); } finally { Thread.CurrentThread.CurrentCulture = curCulture; } }
public void X835_TryGetMatchedClaimProc_SpecificSupplemental() { TryEnterPayment(_x835, _eraJustinSmithClaim, _claimPrimaryJustinSmith, true); //Will return if payment already entered. List <ClaimProc> listClaimProcs = ClaimProcs.Refresh(_claimPrimaryJustinSmith.PatNum); //TODO: limit list to claimProcs for primary claim only. listClaimProcs.AddRange(ClaimProcs.CreateSuppClaimProcs(listClaimProcs)); long claimProcNumExpected = listClaimProcs.Find(x => x.ClaimNum == _claimPrimaryJustinSmith.ClaimNum && x.Status == ClaimProcStatus.Received && x.CodeSent == "D0120" ).ClaimProcNum; long claimProcNumActual = 0; bool isSupplemental = _eraJustinSmithClaim.GetIsSupplemental(_listEtrans835Attaches, listClaimProcs); List <Hx835_Proc> listProcsNotMatched = new List <Hx835_Proc>(); foreach (Hx835_Proc proc in _eraJustinSmithClaim.ListProcs) { ClaimProc matchedClaimProc = null; if (!proc.TryGetMatchedClaimProc(out matchedClaimProc, listClaimProcs, isSupplemental)) { listProcsNotMatched.Add(proc); continue; } listClaimProcs.Remove(matchedClaimProc); //So it cannot be matched twice. if (claimProcNumActual != claimProcNumExpected) { claimProcNumActual = matchedClaimProc.ClaimProcNum; } else //Found a match, thats all we care about. { break; } } Assert.AreEqual(claimProcNumExpected, claimProcNumActual); }
///<summary>Users using the OpenDentalService to create claim snapshots only get primary claim snap shots created.</summary> private static void CreateClaimSnapShotService() { //No need to check RemotingRole; no call to db. List <Procedure> listCompletedProcs = Procedures.GetCompletedByDateCompleteForDateRange(DateTime.Today, DateTime.Today); List <ClaimProc> listClaimProcs = ClaimProcs.GetForProcsWithOrdinal(listCompletedProcs.Select(x => x.ProcNum).ToList(), 1).Where(x => !x.Status.In(ClaimProcStatus.Preauth, ClaimProcStatus.Adjustment)).ToList(); List <PatPlan> listPatPlans = PatPlans.GetListByInsSubNums(listClaimProcs.Select(x => x.InsSubNum).ToList()); listClaimProcs = listClaimProcs .OrderByDescending(x => x.ClaimNum) //order by claim num .ThenByDescending(x => x.SecDateEntry) //then by creation date //group by procnum and ordinal .GroupBy(x => new { ProcNum = x.ProcNum, Ordinal = PatPlans.GetOrdinal(x.InsSubNum, listPatPlans.Where(y => y.PatNum == x.PatNum).ToList()) }) .Select(x => x.First()) //get the first for each group .ToList(); //Loop through all the claimprocs and create a claimsnapshot entry for each. for (int i = 0; i < listClaimProcs.Count; i++) { ClaimProc cpCur = listClaimProcs[i]; if (cpCur.Status == ClaimProcStatus.CapClaim || cpCur.Status == ClaimProcStatus.CapComplete || cpCur.Status == ClaimProcStatus.CapEstimate || cpCur.Status == ClaimProcStatus.Preauth || cpCur.Status == ClaimProcStatus.Supplemental || cpCur.Status == ClaimProcStatus.InsHist) { continue; } //get the procfee double procFee = 0; Procedure procCur = listCompletedProcs.Find(x => x.ProcNum == cpCur.ProcNum); if (procCur != null) { procFee = procCur.ProcFee; } //get the writeoff double writeoffAmt = cpCur.WriteOff; //For the Service, only use the WriteOff amount on the claimproc if the claimproc is associated to a claim, //as this means that value has been set. if (cpCur.Status != ClaimProcStatus.NotReceived && cpCur.Status != ClaimProcStatus.Received) { if (cpCur.WriteOffEstOverride != -1) { writeoffAmt = cpCur.WriteOffEstOverride; } else { writeoffAmt = cpCur.WriteOffEst; } } //create the snapshot ClaimSnapshot snapshot = new ClaimSnapshot(); snapshot.ProcNum = cpCur.ProcNum; snapshot.Writeoff = writeoffAmt; snapshot.InsPayEst = cpCur.InsEstTotal; snapshot.Fee = procFee; snapshot.ClaimProcNum = cpCur.ClaimProcNum; snapshot.SnapshotTrigger = ClaimSnapshotTrigger.Service; ClaimSnapshots.Insert(snapshot); } }
///<summary>Gets a good chunk of the data used in the TP Module.</summary> public static TPModuleData GetModuleData(long patNum, bool doMakeSecLog) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) //Remoting role check here to reduce round-trips to the server. { return(Meth.GetObject <TPModuleData>(MethodBase.GetCurrentMethod(), patNum, doMakeSecLog)); } TPModuleData tpData = new TPModuleData(); tpData.Fam = Patients.GetFamily(patNum); tpData.Pat = tpData.Fam.GetPatient(patNum); tpData.PatPlanList = PatPlans.Refresh(patNum); if (!PatPlans.IsPatPlanListValid(tpData.PatPlanList)) { //PatPlans had invalid references and need to be refreshed. tpData.PatPlanList = PatPlans.Refresh(patNum); } tpData.SubList = InsSubs.RefreshForFam(tpData.Fam); tpData.InsPlanList = InsPlans.RefreshForSubList(tpData.SubList); tpData.BenefitList = Benefits.Refresh(tpData.PatPlanList, tpData.SubList); tpData.ClaimList = Claims.Refresh(tpData.Pat.PatNum); tpData.HistList = ClaimProcs.GetHistList(tpData.Pat.PatNum, tpData.BenefitList, tpData.PatPlanList, tpData.InsPlanList, DateTime.Today, tpData.SubList); tpData.ListSubstLinks = SubstitutionLinks.GetAllForPlans(tpData.InsPlanList); TreatPlanType tpTypeCur = (tpData.Pat.DiscountPlanNum == 0?TreatPlanType.Insurance:TreatPlanType.Discount); TreatPlans.AuditPlans(patNum, tpTypeCur); tpData.ListProcedures = Procedures.Refresh(patNum); tpData.ListTreatPlans = TreatPlans.GetAllForPat(patNum); tpData.ArrProcTPs = ProcTPs.Refresh(patNum); if (doMakeSecLog) { SecurityLogs.MakeLogEntry(Permissions.TPModule, patNum, ""); } return(tpData); }
///<summary>Gets most of the data needed to load the active treatment plan.</summary> ///<param name="doFillHistList">If false, then LoadActiveTPData.HistList will be null.</param> public static LoadActiveTPData GetLoadActiveTpData(Patient pat, long treatPlanNum, List <Benefit> listBenefits, List <PatPlan> listPatPlans, List <InsPlan> listInsPlans, DateTime dateTimeTP, List <InsSub> listInsSubs, bool doFillHistList, bool isTreatPlanSortByTooth, List <SubstitutionLink> listSubstLinks) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) //Remoting role check here to reduce round-trips to the server. { return(Meth.GetObject <LoadActiveTPData>(MethodBase.GetCurrentMethod(), pat, treatPlanNum, listBenefits, listPatPlans, listInsPlans, dateTimeTP, listInsSubs, doFillHistList, isTreatPlanSortByTooth, listSubstLinks)); } LoadActiveTPData data = new LoadActiveTPData(); data.ListTreatPlanAttaches = TreatPlanAttaches.GetAllForTreatPlan(treatPlanNum); List <Procedure> listProcs = Procedures.GetManyProc(data.ListTreatPlanAttaches.Select(x => x.ProcNum).ToList(), false); data.listProcForTP = Procedures.SortListByTreatPlanPriority(listProcs.FindAll(x => x.ProcStatus == ProcStat.TP || x.ProcStatus == ProcStat.TPi) , isTreatPlanSortByTooth, data.ListTreatPlanAttaches).ToList(); //One thing to watch out for here is that we must be absolutely sure to include all claimprocs for the procedures listed, //regardless of status. Needed for Procedures.ComputeEstimates. This should be fine. data.ClaimProcList = ClaimProcs.RefreshForTP(pat.PatNum); if (doFillHistList) { data.HistList = ClaimProcs.GetHistList(pat.PatNum, listBenefits, listPatPlans, listInsPlans, -1, dateTimeTP, listInsSubs); } List <ProcedureCode> listProcedureCodes = new List <ProcedureCode>(); foreach (Procedure procedure in listProcs) { listProcedureCodes.Add(ProcedureCodes.GetProcCode(procedure.CodeNum)); } data.ListFees = Fees.GetListFromObjects(listProcedureCodes, listProcs.Select(x => x.MedicalCode).ToList(), listProcs.Select(x => x.ProvNum).ToList(), pat.PriProv, pat.SecProv, pat.FeeSched, listInsPlans, listProcs.Select(x => x.ClinicNum).ToList(), null,//appts can be null because provs already set listSubstLinks, pat.DiscountPlanNum); return(data); }
public void X835_GetStatus_Finalized() { //Finalized => Some or all ERA claims are attached and have financial payment entered with claim payment. //Other claims must be manually detached. _x835.ListClaimsPaid[0].IsAttachedToClaim = true; _x835.ListClaimsPaid[0].ClaimNum = _claimPrimaryJustinSmith.ClaimNum; _x835.ListClaimsPaid[1].IsAttachedToClaim = true; _x835.ListClaimsPaid[1].ClaimNum = _claimPrimaryJacobJones.ClaimNum; _x835.ListClaimsPaid[2].IsAttachedToClaim = true; _x835.ListClaimsPaid[2].ClaimNum = _claimPrimaryStephanieMayer.ClaimNum; //TryEnterPayment returns if claim is recieved or payment already entered (no supplemental). TryEnterPayment(_x835, _eraJustinSmithClaim, _claimPrimaryJustinSmith, true); TryEnterPayment(_x835, _eraJacobJonesClaim, _claimPrimaryJacobJones, true); TryEnterPayment(_x835, _eraStephanieMayerClaim, _claimPrimaryStephanieMayer, true); X835Status status; if (!EtransL.TryFinalizeBatchPayment(_x835, true, true)) { status = X835Status.None; } else { List <Claim> listClaims = new List <Claim>() { _claimPrimaryJustinSmith, _claimPrimaryJacobJones, _claimPrimaryStephanieMayer }; List <long> listPatNums = new List <long>() { _claimPrimaryJustinSmith.PatNum, _claimPrimaryJacobJones.PatNum, _claimPrimaryStephanieMayer.PatNum }; status = _x835.GetStatus(listClaims, ClaimProcs.Refresh(listPatNums), _listEtrans835Attaches); } Assert.AreEqual(X835Status.Finalized, status); }
public void X835_GetStatus_FinalizedSomeDetached() { //FinalizedSomeDetached => Some ERA claims has financial information entered and claim payment. //Others are manually detached. _x835.ListClaimsPaid[0].IsAttachedToClaim = true; _x835.ListClaimsPaid[0].ClaimNum = _eraJustinSmithClaim.ClaimNum; _x835.ListClaimsPaid[1].IsAttachedToClaim = true; _x835.ListClaimsPaid[1].ClaimNum = 0; _x835.ListClaimsPaid[2].IsAttachedToClaim = true; _x835.ListClaimsPaid[2].ClaimNum = 0; //Returns if claim is recieved or payment already entered (no supplemental). TryEnterPayment(_x835, _eraJustinSmithClaim, _claimPrimaryJustinSmith, true); EtransL.TryFinalizeBatchPayment(_x835, true, true); //jsalmon - No, you should not situationally return out of a unit test without an explanation. //if(!EtransL.TryFinalizeBatchPayment(_x835,true,true)) { // return; //} List <Claim> listClaims = new List <Claim>() { _claimPrimaryJustinSmith, new Claim(), new Claim() }; //Spoof manually detached claims. List <ClaimProc> listClaimProcs = ClaimProcs.Refresh(_claimPrimaryJustinSmith.PatNum); X835Status status = _x835.GetStatus(listClaims, listClaimProcs, _listEtrans835Attaches); Assert.AreEqual(X835Status.FinalizedSomeDetached, status); }
///<summary>Gets the data necessary to load FormProcEdit.</summary> public static LoadData GetLoadData(Procedure proc, Patient pat, Family fam) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <LoadData>(MethodBase.GetCurrentMethod(), proc, pat, fam)); } LoadData data = new LoadData(); data.ListPatPlans = PatPlans.Refresh(pat.PatNum); if (!PatPlans.IsPatPlanListValid(data.ListPatPlans)) //PatPlans had invalid references and need to be refreshed. { data.ListPatPlans = PatPlans.Refresh(pat.PatNum); } data.ListInsSubs = InsSubs.RefreshForFam(fam); data.ListInsPlans = InsPlans.RefreshForSubList(data.ListInsSubs); data.ListClaims = Claims.Refresh(pat.PatNum); data.ListClaimProcsForProc = ClaimProcs.RefreshForProc(proc.ProcNum); data.ListBenefits = Benefits.Refresh(data.ListPatPlans, data.ListInsSubs); data.ListRefAttaches = RefAttaches.RefreshFiltered(proc.PatNum, false, proc.ProcNum); data.ArrPaySplits = PaySplits.Refresh(proc.PatNum); List <long> listPayNums = data.ArrPaySplits.Where(x => x.ProcNum == proc.ProcNum).Select(x => x.PayNum).ToList(); data.ListPaymentsForProc = Payments.GetPayments(listPayNums); data.ArrAdjustments = Adjustments.Refresh(proc.PatNum); data.OrthoProcedureLink = OrthoProcLinks.GetByProcNum(proc.ProcNum); return(data); }
public void InsPlan_GetInsUsedDisplay_OrthoProcsNotAffectInsUsed() { string suffix = "13"; Patient pat = PatientT.CreatePatient(suffix); Carrier carrier = CarrierT.CreateCarrier(suffix); InsPlan plan = InsPlanT.CreateInsPlan(carrier.CarrierNum); InsSub sub = InsSubT.CreateInsSub(pat.PatNum, plan.PlanNum); long subNum = sub.InsSubNum; PatPlan patPlan = PatPlanT.CreatePatPlan(1, pat.PatNum, subNum); BenefitT.CreateAnnualMax(plan.PlanNum, 100); BenefitT.CreateOrthoMax(plan.PlanNum, 500); BenefitT.CreateCategoryPercent(plan.PlanNum, EbenefitCategory.Diagnostic, 100); BenefitT.CreateCategoryPercent(plan.PlanNum, EbenefitCategory.Orthodontics, 100); Procedure proc1 = ProcedureT.CreateProcedure(pat, "D0140", ProcStat.C, "", 59); //limEx Procedure proc2 = ProcedureT.CreateProcedure(pat, "D8090", ProcStat.C, "", 348); //Comprehensive ortho ClaimProcT.AddInsPaid(pat.PatNum, plan.PlanNum, proc1.ProcNum, 59, subNum, 0, 0); ClaimProcT.AddInsPaid(pat.PatNum, plan.PlanNum, proc2.ProcNum, 348, subNum, 0, 0); //Lists Family fam = Patients.GetFamily(pat.PatNum); List <InsSub> subList = InsSubs.RefreshForFam(fam); List <InsPlan> planList = InsPlans.RefreshForSubList(subList); List <PatPlan> patPlans = PatPlans.Refresh(pat.PatNum); List <Benefit> benefitList = Benefits.Refresh(patPlans, subList); List <ClaimProcHist> histList = ClaimProcs.GetHistList(pat.PatNum, benefitList, patPlans, planList, DateTime.Today, subList); //Validate double insUsed = InsPlans.GetInsUsedDisplay(histList, DateTime.Today, plan.PlanNum, patPlan.PatPlanNum, -1, planList, benefitList, pat.PatNum, subNum); Assert.AreEqual(59, insUsed); }
public static ClaimProc AddInsUsedAdjustment(long patNum, long planNum, double insPayAmt, long subNum, double dedApplied) { ClaimProc cp = ClaimProcs.CreateInsPlanAdjustment(patNum, planNum, subNum); cp.InsPayAmt = insPayAmt; cp.DedApplied = dedApplied; ClaimProcs.Insert(cp); return(cp); }
private static Claim CreatePredetermination(Patient pat, List <Procedure> procList, long provTreat) { Family fam = Patients.GetFamily(pat.PatNum); List <InsSub> subList = InsSubs.RefreshForFam(fam); List <InsPlan> planList = InsPlans.RefreshForSubList(subList); List <PatPlan> patPlanList = PatPlans.Refresh(pat.PatNum); List <Benefit> benefitList = Benefits.Refresh(patPlanList, subList); List <ClaimProc> claimProcList = ClaimProcs.Refresh(pat.PatNum); List <Procedure> procsForPat = Procedures.Refresh(pat.PatNum); InsSub sub = InsSubs.GetSub(PatPlans.GetInsSubNum(patPlanList, 1), subList); InsPlan insPlan = InsPlans.GetPlan(sub.PlanNum, planList); Claim claim = new Claim(); Claims.Insert(claim); //to retreive a key for new Claim.ClaimNum claim.PatNum = pat.PatNum; claim.DateService = procList[0].ProcDate; claim.DateSent = DateTime.Today; claim.ClaimStatus = "W"; claim.InsSubNum = PatPlans.GetInsSubNum(patPlanList, 1); claim.InsSubNum2 = PatPlans.GetInsSubNum(patPlanList, 2); InsSub sub1 = InsSubs.GetSub(claim.InsSubNum, subList); InsSub sub2 = InsSubs.GetSub(claim.InsSubNum, subList); claim.PlanNum = sub1.PlanNum; claim.PlanNum2 = sub2.PlanNum; claim.PatRelat = PatPlans.GetRelat(patPlanList, 1); claim.PatRelat2 = PatPlans.GetRelat(patPlanList, 2); claim.ClaimType = "PreAuth"; claim.ProvTreat = provTreat; claim.IsProsthesis = "N"; claim.ProvBill = Providers.GetBillingProvNum(claim.ProvTreat, 0); claim.EmployRelated = YN.No; ClaimProc cp; List <Procedure> procListClaim = new List <Procedure>(); //this list will exclude lab fees for (int i = 0; i < procList.Count; i++) { if (procList[i].ProcNumLab == 0) { procListClaim.Add(procList[i]); } } for (int i = 0; i < procListClaim.Count; i++) { cp = new ClaimProc(); ClaimProcs.CreateEst(cp, procListClaim[i], insPlan, sub); cp.ClaimNum = claim.ClaimNum; cp.Status = ClaimProcStatus.NotReceived; cp.CodeSent = ProcedureCodes.GetProcCode(procListClaim[i].CodeNum).ProcCode; cp.LineNumber = (byte)(i + 1); ClaimProcs.Update(cp); } claimProcList = ClaimProcs.Refresh(pat.PatNum); ClaimL.CalculateAndUpdate(procsForPat, planList, claim, patPlanList, benefitList, pat.Age, subList); return(claim); }
public void X835_IsProcessed_WithPartialSupplemental() { TryEnterPayment(_x835, _eraJustinSmithClaim, _claimPrimaryJustinSmith, true); //Will return if payment already entered. List <ClaimProc> listClaimProcs = ClaimProcs.Refresh(_claimPrimaryJustinSmith.PatNum); List <ClaimProc> listSupplementalClaimProcs = ClaimProcs.CreateSuppClaimProcs(listClaimProcs); listSupplementalClaimProcs.RemoveAt(0); //For this test, only enter supplemental payment for some of the procs. listClaimProcs.AddRange(listSupplementalClaimProcs); Assert.AreEqual(true, _eraJustinSmithClaim.IsProcessed(listClaimProcs, _listEtrans835Attaches)); }
///<summary>Deletes the patplan with the specified patPlanNum. Rearranges the other patplans for the patient to keep the ordinal sequence contiguous. Then, recomputes all estimates for this patient because their coverage is now different. Also sets patient.HasIns to the correct value.</summary> public static void Delete(long patPlanNum) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), patPlanNum); return; } string command = "SELECT PatNum FROM patplan WHERE PatPlanNum=" + POut.Long(patPlanNum); DataTable table = Db.GetTable(command); if (table.Rows.Count == 0) { return; } long patNum = PIn.Long(table.Rows[0][0].ToString()); List <PatPlan> patPlans = PatPlans.Refresh(patNum); bool doDecrement = false; for (int i = 0; i < patPlans.Count; i++) { if (doDecrement) //patPlan has already been deleted, so decrement the rest. { command = "UPDATE patplan SET Ordinal=" + POut.Long(patPlans[i].Ordinal - 1) + " WHERE PatPlanNum=" + POut.Long(patPlans[i].PatPlanNum); Db.NonQ(command); continue; } if (patPlans[i].PatPlanNum == patPlanNum) { RemoveAssignedUser(patPlans[i]); command = "DELETE FROM patplan WHERE PatPlanNum=" + POut.Long(patPlanNum); Db.NonQ(command); command = "DELETE FROM benefit WHERE PatPlanNum=" + POut.Long(patPlanNum); Db.NonQ(command); doDecrement = true; InsVerifies.DeleteByFKey(patPlanNum, VerifyTypes.PatientEnrollment); } } Family fam = Patients.GetFamily(patNum); Patient pat = fam.GetPatient(patNum); List <ClaimProc> claimProcs = ClaimProcs.Refresh(patNum); List <ClaimProc> listClaimProcsEsts = claimProcs.Where(x => x.Status.In(ClaimProcStatus.Estimate, ClaimProcStatus.CapEstimate)).ToList(); List <Procedure> procs = Procedures.Refresh(patNum); patPlans = PatPlans.Refresh(patNum); List <InsSub> subList = InsSubs.RefreshForFam(fam); List <InsPlan> planList = InsPlans.RefreshForSubList(subList); List <Benefit> benList = Benefits.Refresh(patPlans, subList); Procedures.ComputeEstimatesForAll(patNum, listClaimProcsEsts, procs, planList, patPlans, benList, pat.Age, subList, claimProcs); Patients.SetHasIns(patNum); //Cameron_ Possibly create outbound ADT message to update insurance info }
public void X835_GetIsSupplemental_FalsePossitive() { TryEnterPayment(_x835, _eraJustinSmithClaim, _claimPrimaryJustinSmith, true); //Will return if payment already entered. List <ClaimProc> listClaimProcs = ClaimProcs.Refresh(_claimPrimaryJustinSmith.PatNum); List <ClaimProc> listSupplementalClaimProcs = ClaimProcs.CreateSuppClaimProcs(listClaimProcs); listSupplementalClaimProcs.RemoveAt(0); //Only enter supplemental payment for some of the procs. listClaimProcs.AddRange(listSupplementalClaimProcs); bool isEraClaimSupplemental = _eraJustinSmithClaim.GetIsSupplemental(_listEtrans835Attaches, listClaimProcs); Assert.AreEqual(false, isEraClaimSupplemental); }
///<summary>Adds procedures to the appointment.</summary> ///<returns>First item of tuple is the newly added procedures. Second item is all procedures for the appointment.</returns> public static ODTuple <List <Procedure>, List <Procedure> > QuickAddProcs(Appointment apt, Patient pat, List <string> listCodesToAdd, long provNum, long provHyg, List <InsSub> SubList, List <InsPlan> listInsPlans, List <PatPlan> listPatPlans, List <Benefit> listBenefits) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <ODTuple <List <Procedure>, List <Procedure> > >(MethodBase.GetCurrentMethod(), apt, pat, listCodesToAdd, provNum, provHyg, SubList, listInsPlans, listPatPlans, listBenefits)); } Procedures.SetDateFirstVisit(apt.AptDateTime.Date, 1, pat); List <ClaimProc> ClaimProcList = ClaimProcs.Refresh(apt.PatNum); List <Procedure> listAddedProcs = new List <Procedure>(); foreach (string code in listCodesToAdd) { Procedure proc = new Procedure(); proc.PatNum = apt.PatNum; ProcedureCode procCodeCur = ProcedureCodes.GetProcCode(code); proc.CodeNum = procCodeCur.CodeNum; proc.ProcDate = apt.AptDateTime.Date; proc.DateTP = DateTime.Today; #region ProvNum proc.ProvNum = provNum; if (procCodeCur.ProvNumDefault != 0) //Override provider for procedures with a default provider //This provider might be restricted to a different clinic than this user. { proc.ProvNum = procCodeCur.ProvNumDefault; } else if (procCodeCur.IsHygiene && provHyg != 0) { proc.ProvNum = provHyg; } #endregion ProvNum proc.ClinicNum = apt.ClinicNum; proc.MedicalCode = procCodeCur.MedicalCode; proc.ProcFee = Procedures.GetProcFee(pat, listPatPlans, SubList, listInsPlans, proc.CodeNum, proc.ProvNum, proc.ClinicNum, proc.MedicalCode); proc.ProcStatus = ProcStat.TP; proc.SiteNum = pat.SiteNum; proc.RevCode = procCodeCur.RevenueCodeDefault; proc.BaseUnits = procCodeCur.BaseUnits; proc.DiagnosticCode = PrefC.GetString(PrefName.ICD9DefaultForNewProcs); proc.PlaceService = (PlaceOfService)PrefC.GetInt(PrefName.DefaultProcedurePlaceService); //Default Proc Place of Service for the Practice is used. if (Userods.IsUserCpoe(Security.CurUser)) { //This procedure is considered CPOE because the provider is the one that has added it. proc.IsCpoe = true; } proc.Note = ProcCodeNotes.GetNote(proc.ProvNum, proc.CodeNum, proc.ProcStatus); Procedures.Insert(proc); //recall synch not required Procedures.ComputeEstimates(proc, pat.PatNum, ClaimProcList, false, listInsPlans, listPatPlans, listBenefits, pat.Age, SubList); listAddedProcs.Add(proc); } return(new ODTuple <List <Procedure>, List <Procedure> >(listAddedProcs, Procedures.GetProcsForApptEdit(apt))); }
///<summary>Do not call this until after determining if the repeate charge might generate a claim. This function checks current insurance and ///may not add claims if no insurance is found.</summary> private static List <Claim> AddClaimsHelper(RepeatCharge repeateCharge, Procedure proc) { //No remoting role check; no call to db List <PatPlan> patPlanList = PatPlans.Refresh(repeateCharge.PatNum); List <InsSub> subList = InsSubs.RefreshForFam(Patients.GetFamily(repeateCharge.PatNum)); List <InsPlan> insPlanList = InsPlans.RefreshForSubList(subList); List <Benefit> benefitList = Benefits.Refresh(patPlanList, subList); List <Claim> retVal = new List <Claim>(); Claim claimCur; if (patPlanList.Count == 0) //no current insurance, do not create a claim { return(retVal); } //create the claimprocs Procedures.ComputeEstimates(proc, proc.PatNum, new List <ClaimProc>(), true, insPlanList, patPlanList, benefitList, Patients.GetPat(proc.PatNum).Age, subList); //get claimprocs for this proc, may be more than one List <ClaimProc> claimProcList = ClaimProcs.GetForProc(ClaimProcs.Refresh(proc.PatNum), proc.ProcNum); string claimType = "P"; if (patPlanList.Count == 1 && PatPlans.GetOrdinal(PriSecMed.Medical, patPlanList, insPlanList, subList) > 0) //if there's exactly one medical plan { claimType = "Med"; } claimCur = Claims.CreateClaimForRepeatCharge(claimType, patPlanList, insPlanList, claimProcList, proc, subList); claimProcList = ClaimProcs.Refresh(proc.PatNum); if (claimCur.ClaimNum == 0) { return(retVal); } retVal.Add(claimCur); Claims.CalculateAndUpdate(new List <Procedure> { proc }, insPlanList, claimCur, patPlanList, benefitList, Patients.GetPat(proc.PatNum).Age, subList); if (PatPlans.GetOrdinal(PriSecMed.Secondary, patPlanList, insPlanList, subList) > 0 && //if there exists a secondary plan !CultureInfo.CurrentCulture.Name.EndsWith("CA")) //and not canada (don't create secondary claim for canada) { claimCur = Claims.CreateClaimForRepeatCharge("S", patPlanList, insPlanList, claimProcList, proc, subList); if (claimCur.ClaimNum == 0) { return(retVal); } retVal.Add(claimCur); ClaimProcs.Refresh(proc.PatNum); claimCur.ClaimStatus = "H"; Claims.CalculateAndUpdate(new List <Procedure> { proc }, insPlanList, claimCur, patPlanList, benefitList, Patients.GetPat(proc.PatNum).Age, subList); } return(retVal); }
public static void AddInsUsedAdjustment(long patNum, long planNum, double amtPaid, long subNum, double dedApplied) { ClaimProc cp = new ClaimProc(); cp.PatNum = patNum; cp.PlanNum = planNum; cp.InsSubNum = subNum; cp.ProcDate = DateTime.Today; cp.Status = ClaimProcStatus.Adjustment; cp.InsPayAmt = amtPaid; cp.DedApplied = dedApplied; ClaimProcs.Insert(cp); }
///<summary>Adds procedures to the appointment.</summary> ///<returns>First item of tuple is the newly added procedures. Second item is all procedures for the appointment.</returns> public static ODTuple <List <Procedure>, List <Procedure> > QuickAddProcs(Appointment apt, Patient pat, List <string> listProcCodesToAdd, long provNum, long provHyg, List <InsSub> SubList, List <InsPlan> listInsPlans, List <PatPlan> listPatPlans, List <Benefit> listBenefits) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <ODTuple <List <Procedure>, List <Procedure> > >(MethodBase.GetCurrentMethod(), apt, pat, listProcCodesToAdd, provNum, provHyg, SubList, listInsPlans, listPatPlans, listBenefits)); } Procedures.SetDateFirstVisit(apt.AptDateTime.Date, 1, pat); List <ClaimProc> ClaimProcList = ClaimProcs.Refresh(apt.PatNum); List <ProcedureCode> listProcedureCodes = new List <ProcedureCode>(); foreach (string procCode in listProcCodesToAdd) { listProcedureCodes.Add(ProcedureCodes.GetProcCode(procCode)); } List <long> listProvNumsTreat = new List <long>(); listProvNumsTreat.Add(provNum); listProvNumsTreat.Add(provHyg); //these were both passed in List <SubstitutionLink> listSubstLinks = SubstitutionLinks.GetAllForPlans(listInsPlans); //not available in FormApptEdit List <Fee> listFees = Fees.GetListFromObjects(listProcedureCodes, null, //no procs to pull medicalCodes from listProvNumsTreat, pat.PriProv, pat.SecProv, pat.FeeSched, listInsPlans, new List <long>() { apt.ClinicNum }, null, //procNums for appt already handled above listSubstLinks, pat.DiscountPlanNum); //null,listProvNumsTreat,listProcedureCodes.Select(x=>x.ProvNumDefault).ToList(), //pat.PriProv,pat.SecProv,pat.FeeSched,listInsPlans,new List<long>(){apt.ClinicNum},listProcCodesToAdd,null);//procnums for appt already handled above List <Procedure> listAddedProcs = new List <Procedure>(); //Make a copy of apt with provNum and provHyg, in order to maintain behavior of this method prior to using Procedures.ConstructProcedureForAppt //provNum and provHyg are sent in and are the selected provs in FormApptEdit, which may be different than the current provs on apt Appointment aptCur = apt.Copy(); aptCur.ProvNum = provNum; aptCur.ProvHyg = provHyg; foreach (string procCode in listProcCodesToAdd) { ProcedureCode procCodeCur = ProcedureCodes.GetProcCode(procCode); Procedure proc = Procedures.ConstructProcedureForAppt(procCodeCur.CodeNum, aptCur, pat, listPatPlans, listInsPlans, SubList, listFees); Procedures.Insert(proc); //recall synch not required Procedures.ComputeEstimates(proc, pat.PatNum, ref ClaimProcList, true, listInsPlans, listPatPlans, listBenefits, null, null, true, pat.Age, SubList, null, false, false, listSubstLinks, false, listFees); listAddedProcs.Add(proc); } return(new ODTuple <List <Procedure>, List <Procedure> >(listAddedProcs, Procedures.GetProcsForApptEdit(apt))); }
public void LedgersTests_ComputeAging_PayPlanDynamicCreditsWithClaimProcs() { List <Procedure> listProcs = new List <Procedure>(); List <Adjustment> listAdjs = new List <Adjustment>(); long provNum = ProviderT.CreateProvider("Aging_PayPlanDynamic"); string suffix = MethodBase.GetCurrentMethod().Name; Patient pat = PatientT.CreatePatient(fName: "Aging_PayPlanDynamic", suffix: suffix); Family fam = Patients.GetFamily(pat.PatNum); Procedure proc45 = ProcedureT.CreateProcedure(pat, "D0210", ProcStat.C, "", 45, DateTime.Today.AddDays(-61), provNum: provNum); ClaimProc cp45 = new ClaimProc(); InsuranceInfo insInfo = InsuranceT.AddInsurance(pat, "DynPayPlan"); ClaimProcs.CreateEst(cp45, proc45, insInfo.PriInsPlan, insInfo.PriInsSub); cp45.Status = ClaimProcStatus.NotReceived; cp45.InsEstTotal = -1; cp45.InsPayEst = 15; cp45.WriteOffEst = 0; cp45.WriteOff = 0; ClaimProcs.Update(cp45); listProcs.AddRange(new List <Procedure> { proc45 }); PayPlan payPlan = PayPlanT.CreateDynamicPaymentPlan(pat.PatNum, pat.PatNum, DateTime.Today.AddDays(-1), 0, 0, 30, listProcs, listAdjs); //make two non payplan productions to put on the account Procedure procUnattached = ProcedureT.CreateProcedure(pat, "D0210", ProcStat.C, "", 35, DateTime.Today.AddDays(-91), provNum: provNum); //Run pay plan logic to generate first set of charges List <PayPlanCharge> listChargesDb = PayPlanCharges.GetForPayPlan(payPlan.PayPlanNum); List <PayPlanLink> listEntries = PayPlanLinks.GetForPayPlans(new List <long> { payPlan.PayPlanNum }); PayPlanTerms terms = PayPlanT.GetTerms(payPlan, listEntries); List <PayPlanCharge> listChargesThisPeriod = PayPlanEdit.GetListExpectedCharges(listChargesDb, terms, fam, listEntries, payPlan, true); Assert.AreEqual(30, listChargesThisPeriod.Sum(x => x.Principal)); foreach (PayPlanCharge charge in listChargesThisPeriod) { PayPlanCharges.Insert(charge); } int payPlansVersionPrev = PrefC.GetInt(PrefName.PayPlansVersion); try { PrefT.UpdateInt(PrefName.PayPlansVersion, (int)PayPlanVersions.AgeCreditsAndDebits); CheckAgingProcLifo(pat.PatNum, 30, 0, 15, 35, 30, YN.Yes); //new - pay plan credit of $30 gets applied to cooresponding procedure CheckAgingProcLifo(pat.PatNum, 30, 0, 45, 5, 30, YN.No); //old - pay plan credit gets applied to oldest production on the account CheckAgingProcLifo(pat.PatNum, 30, 0, 45, 5, 30, YN.Unknown); } finally { PrefT.UpdateInt(PrefName.PayPlansVersion, payPlansVersionPrev); } }
public static void ReceiveClaim(Claim claim, List <ClaimProc> listClaimProcs, bool doAddPayAmount = false) { claim.ClaimStatus = "R"; Claims.Update(claim); foreach (ClaimProc cp in listClaimProcs) { cp.Status = ClaimProcStatus.Received; if (doAddPayAmount) { cp.InsPayAmt = cp.InsPayEst; } ClaimProcs.Update(cp); } }
///<summary>Deletes the patplan with the specified patPlanNum. Rearranges the other patplans for the patient to keep the ordinal sequence contiguous. Then, recomputes all estimates for this patient because their coverage is now different. Also sets patient.HasIns to the correct value.</summary> public static void Delete(long patPlanNum) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), patPlanNum); return; } string command = "SELECT PatNum FROM patplan WHERE PatPlanNum=" + POut.Long(patPlanNum); DataTable table = Db.GetTable(command); if (table.Rows.Count == 0) { return; } long patNum = PIn.Long(table.Rows[0][0].ToString()); List <PatPlan> patPlans = PatPlans.Refresh(patNum); bool doDecrement = false; for (int i = 0; i < patPlans.Count; i++) { if (doDecrement) //patPlan has already been deleted, so decrement the rest. { command = "UPDATE patplan SET Ordinal=" + POut.Long(patPlans[i].Ordinal - 1) + " WHERE PatPlanNum=" + POut.Long(patPlans[i].PatPlanNum); Db.NonQ(command); continue; } if (patPlans[i].PatPlanNum == patPlanNum) { command = "DELETE FROM patplan WHERE PatPlanNum=" + POut.Long(patPlanNum); Db.NonQ(command); command = "DELETE FROM benefit WHERE PatPlanNum=" + POut.Long(patPlanNum); Db.NonQ(command); doDecrement = true; } } Family fam = Patients.GetFamily(patNum); Patient pat = fam.GetPatient(patNum); List <ClaimProc> claimProcs = ClaimProcs.Refresh(patNum); List <Procedure> procs = Procedures.Refresh(patNum); patPlans = PatPlans.Refresh(patNum); List <InsSub> subList = InsSubs.RefreshForFam(fam); List <InsPlan> planList = InsPlans.RefreshForSubList(subList); List <Benefit> benList = Benefits.Refresh(patPlans, subList); Procedures.ComputeEstimatesForAll(patNum, claimProcs, procs, planList, patPlans, benList, pat.Age, subList); Patients.SetHasIns(patNum); }