Exemple #1
0
        public static InsPlan GetPlanForPriSecMed(PriSecMed priSecMed, List <PatPlan> listPatPlans, List <InsPlan> listPlans, List <InsSub> listSubs)
        {
            long   subNum = PatPlans.GetInsSubNum(listPatPlans, PatPlans.GetOrdinal(priSecMed, listPatPlans, listPlans, listSubs));
            InsSub sub    = InsSubs.GetSub(subNum, listSubs);

            return(InsPlans.GetPlan(sub.PlanNum, listPlans));
        }
        public void ProcedureCodes_GetSubstituteCodeNum_InsPlanOverrideNever()
        {
            //First, setup the test scenario.
            string  suffix  = MethodBase.GetCurrentMethod().Name;
            Patient pat     = PatientT.CreatePatient(suffix);
            Carrier carrier = CarrierT.CreateCarrier(MethodBase.GetCurrentMethod().Name);
            InsPlan plan    = new InsPlan();

            plan.CarrierNum = carrier.CarrierNum;
            plan.PlanType   = "";
            plan.CobRule    = EnumCobRule.Basic;
            plan.PlanNum    = InsPlans.Insert(plan);
            //Add a substitution code on the procedure level that has SubstitutionCondition.Never.
            ProcedureCode originalProcCode = ProcedureCodes.GetProcCode("D2330");

            //clear out any substitution codes on this procedure
            originalProcCode.SubstitutionCode = "";
            ProcedureCodeT.Update(originalProcCode);
            //Add an override for the inplan above for the originalProcCode to never substitute
            ProcedureCode downgradeProcCodeForIns = ProcedureCodes.GetProcCode("D2150");

            SubstitutionLinkT.CreateSubstitutionLink(originalProcCode.CodeNum, downgradeProcCodeForIns.ProcCode, SubstitutionCondition.Never, plan.PlanNum);
            //Next, perform the thing you're trying to test.
            Procedure proc       = ProcedureT.CreateProcedure(pat, originalProcCode.ProcCode, ProcStat.C, "9", 100);//Tooth 9
            long      subCodeNum = ProcedureCodes.GetSubstituteCodeNum(originalProcCode.ProcCode, proc.ToothNum, plan.PlanNum);

            //The procedure level and ins override is set SubstitutionCondition.Never so it should use originalProcCode.CodeNum
            Assert.AreEqual(originalProcCode.CodeNum, subCodeNum);
        }
Exemple #3
0
        ///<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);
        }
        public void ProcedureCodes_GetSubstituteCodeNum_InsPlanOverridePosterior()
        {
            //First, setup the test scenario.
            string  suffix  = MethodBase.GetCurrentMethod().Name;
            Patient pat     = PatientT.CreatePatient(suffix);
            Carrier carrier = CarrierT.CreateCarrier(MethodBase.GetCurrentMethod().Name);
            InsPlan plan    = new InsPlan();

            plan.CarrierNum = carrier.CarrierNum;
            plan.PlanType   = "";
            plan.CobRule    = EnumCobRule.Basic;
            plan.PlanNum    = InsPlans.Insert(plan);
            //Procedure code does not have a substitution code
            ProcedureCode originalProcCode = ProcedureCodes.GetProcCode("D2740");

            //clear out any substitution codes on this procedure
            originalProcCode.SubstitutionCode = "";
            ProcedureCodeT.Update(originalProcCode);
            //Add an override for the inplan above for the originalProcCode to substitute if posterior
            ProcedureCode downgradeProcCodeForIns = ProcedureCodes.GetProcCode("D2750");

            SubstitutionLinkT.CreateSubstitutionLink(originalProcCode.CodeNum, downgradeProcCodeForIns.ProcCode, SubstitutionCondition.Posterior, plan.PlanNum);
            //Posterior procedure
            Procedure proc       = ProcedureT.CreateProcedure(pat, originalProcCode.ProcCode, ProcStat.C, "4", 100);//Tooth 4
            long      subCodeNum = ProcedureCodes.GetSubstituteCodeNum(originalProcCode.ProcCode, proc.ToothNum, plan.PlanNum);

            //The ins override is set to substitute only if posterior.
            Assert.AreEqual(downgradeProcCodeForIns.CodeNum, subCodeNum);
        }
Exemple #5
0
        ///<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());
            if (!PrefC.GetBool(PrefName.EasyHideDentalSchools))
            {
                data.ListStudents = ReqStudents.GetForAppt(AptCur.AptNum);
            }
            return(data);
        }
Exemple #6
0
        ///<summary>Removes the assigned user from the InsVerify of the InsPlan that is associated to the PatPlan passed in.
        ///Will only unassign if the user assigned to the patplan matches the user assigned to the insplan.</summary>
        private static void RemoveAssignedUser(PatPlan patPlanCur)
        {
            //No Remoting check; no call to db.
            //Get the insurance verified assigned to the PatPlan.
            InsVerify insVerifyForPatPlan = InsVerifies.GetOneByFKey(patPlanCur.PatPlanNum, VerifyTypes.PatientEnrollment);

            if (insVerifyForPatPlan != null && insVerifyForPatPlan.UserNum > 0)
            {
                //Get the insplan associated to the PatPlan.
                InsSub inssub = null;
                if (patPlanCur != null)
                {
                    inssub = InsSubs.GetOne(patPlanCur.InsSubNum);
                }
                InsPlan insPlan = null;
                if (inssub != null)
                {
                    insPlan = InsPlans.RefreshOne(inssub.PlanNum);
                }
                if (insPlan != null)
                {
                    //Get the insVerify for the insplan associated to the patplan we are about to delete.
                    InsVerify insVerifyForInsPlan = InsVerifies.GetOneByFKey(insPlan.PlanNum, VerifyTypes.InsuranceBenefit);
                    //Only unassign the user for the insplan if it matches the user for the patplan being dropped
                    if (insVerifyForInsPlan != null && insVerifyForInsPlan.UserNum == insVerifyForPatPlan.UserNum)
                    {
                        //Remove user and set DateLastVerified to MinValue.
                        insVerifyForInsPlan.UserNum          = 0;
                        insVerifyForInsPlan.DateLastVerified = DateTime.MinValue;
                        InsVerifies.Update(insVerifyForInsPlan);
                    }
                }
            }
        }
        public void ProcedureCodes_GetSubstituteCodeNum_InsPlanOverrideAlways()
        {
            //First, setup the test scenario.
            string  suffix  = MethodBase.GetCurrentMethod().Name;
            Patient pat     = PatientT.CreatePatient(suffix);
            Carrier carrier = CarrierT.CreateCarrier(MethodBase.GetCurrentMethod().Name);
            InsPlan plan    = new InsPlan();

            plan.CarrierNum = carrier.CarrierNum;
            plan.PlanType   = "";
            plan.CobRule    = EnumCobRule.Basic;
            plan.PlanNum    = InsPlans.Insert(plan);
            //Add a substitution code on the procedure level.
            ProcedureCode originalProcCode  = ProcedureCodes.GetProcCode("D2330");
            ProcedureCode downgradeProcCode = ProcedureCodes.GetProcCode("D2140");

            originalProcCode.SubstitutionCode = "D2140";
            originalProcCode.SubstOnlyIf      = SubstitutionCondition.Always;
            ProcedureCodeT.Update(originalProcCode);
            //Add an override for the inplan above for the originalProcCode
            ProcedureCode downgradeProcCodeForIns = ProcedureCodes.GetProcCode("D2150");

            SubstitutionLinkT.CreateSubstitutionLink(originalProcCode.CodeNum, downgradeProcCodeForIns.ProcCode, SubstitutionCondition.Always, plan.PlanNum);
            //Next, perform the thing you're trying to test.
            Procedure proc       = ProcedureT.CreateProcedure(pat, originalProcCode.ProcCode, ProcStat.C, "9", 100);//Tooth 9
            long      subCodeNum = ProcedureCodes.GetSubstituteCodeNum(originalProcCode.ProcCode, proc.ToothNum, plan.PlanNum);

            //Finally, use one or more asserts to verify the results.
            Assert.AreEqual(downgradeProcCodeForIns.CodeNum, subCodeNum);
        }
 ///<summary>Returns the data needed for ProcFeeHelper. Does not get ListFees.</summary>
 public static ProcFeeHelper GetData(long patNum, ProcFeeHelper procFeeHelper)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         //Not passing procFeeHelper because the null lists will get turned into empty lists which messes things up.
         return(Meth.GetObject <ProcFeeHelper>(MethodBase.GetCurrentMethod(), patNum, null));
     }
     procFeeHelper              = procFeeHelper ?? new ProcFeeHelper(patNum);
     procFeeHelper.Pat          = procFeeHelper.Pat ?? Patients.GetPat(patNum);
     procFeeHelper.ListPatPlans = procFeeHelper.ListPatPlans ?? PatPlans.GetPatPlansForPat(patNum);
     procFeeHelper.ListInsSubs  = procFeeHelper.ListInsSubs ?? InsSubs.GetMany(procFeeHelper.ListPatPlans.Select(x => x.InsSubNum).ToList());
     procFeeHelper.ListInsPlans = procFeeHelper.ListInsPlans ?? InsPlans.GetPlans(procFeeHelper.ListInsSubs.Select(x => x.PlanNum).ToList());
     if (procFeeHelper.ListPatPlans.Count > 0)
     {
         PatPlan priPatPlan = procFeeHelper.ListPatPlans[0];
         InsSub  priInsSub  = InsSubs.GetSub(priPatPlan.InsSubNum, procFeeHelper.ListInsSubs);
         InsPlan priInsPlan = InsPlans.GetPlan(priInsSub.PlanNum, procFeeHelper.ListInsPlans);
         procFeeHelper.ListBenefitsPrimary = procFeeHelper.ListBenefitsPrimary ?? Benefits.RefreshForPlan(priInsPlan.PlanNum, priPatPlan.PatPlanNum);
     }
     else
     {
         procFeeHelper.ListBenefitsPrimary = new List <Benefit>();
     }
     return(procFeeHelper);
 }
Exemple #9
0
        ///<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);
        }
Exemple #10
0
        public void InsPlans_GetAllowed_NoFeeSched()
        {
            Carrier carrier = CarrierT.CreateCarrier(MethodBase.GetCurrentMethod().Name);
            InsPlan plan    = new InsPlan();

            plan.CarrierNum = carrier.CarrierNum;
            plan.PlanType   = "";
            plan.CobRule    = EnumCobRule.Basic;
            plan.PlanNum    = InsPlans.Insert(plan);
            ProcedureCode procCode = _listProcCodes[13];

            procCode.SubstitutionCode = _listProcCodes[14].ProcCode;
            ProcedureCodes.Update(procCode);
            ProcedureCodes.RefreshCache();
            Provider prov         = Providers.GetProv(PrefC.GetLong(PrefName.PracticeDefaultProv));
            long     provFeeSched = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, MethodBase.GetCurrentMethod().Name);

            prov.FeeSched = provFeeSched;
            Providers.Update(prov);
            Providers.RefreshCache();
            Fee defaultFee = FeeT.GetNewFee(Providers.GetProv(PrefC.GetLong(PrefName.PracticeDefaultProv)).FeeSched,
                                            ProcedureCodes.GetSubstituteCodeNum(procCode.ProcCode, "", plan.PlanNum), 80);
            double amt = InsPlans.GetAllowed(procCode.ProcCode, plan.FeeSched, plan.AllowedFeeSched, plan.CodeSubstNone, plan.PlanType, "", 0, 0, plan.PlanNum);

            Assert.AreEqual(defaultFee.Amount, amt);
        }
Exemple #11
0
        public static string RunOne(bool showForms)
        {
            string  retVal  = "";
            long    provNum = ProviderC.ListShort[0].ProvNum;       //dentist #1
            Patient pat     = Patients.GetPat(PatientTC.PatNum1);   //patient#1

            if (pat.PriProv != provNum)
            {
                Patient oldPat = pat.Copy();
                pat.PriProv = provNum;              //this script uses the primary provider for the patient
                Patients.Update(pat, oldPat);
            }
            PatPlan patplan = PatPlans.GetPatPlan(pat.PatNum, 1);
            InsSub  sub     = InsSubs.GetOne(patplan.InsSubNum);
            InsPlan plan    = InsPlans.GetPlan(sub.PlanNum, new List <InsPlan>());
            //the UI would block this due to carrier not supporting this transaction type.
            Clearinghouse    clearinghouseHq   = Clearinghouses.GetDefaultDental();
            Clearinghouse    clearinghouseClin = Clearinghouses.OverrideFields(clearinghouseHq, Clinics.ClinicNum);
            long             etransNum         = CanadianOutput.SendElegibility(clearinghouseClin, pat.PatNum, plan, new DateTime(1999, 1, 1), patplan.Relationship, patplan.PatID, showForms, sub);
            Etrans           etrans            = Etranss.GetEtrans(etransNum);
            string           message           = EtransMessageTexts.GetMessageText(etrans.EtransMessageTextNum);
            CCDFieldInputter formData          = new CCDFieldInputter(message);
            string           responseStatus    = formData.GetValue("G05");

            if (responseStatus != "R")
            {
                throw new Exception("Should be R");
            }
            retVal += "Eligibility #1 successful.\r\n";
            return(retVal);
        }
Exemple #12
0
        ///<summary>Returns true if the inssub has valid fkey references and no changes were needed.
        ///Returns false if changes were needed. doFixIfInvalid dictates if changes were actually made, separate from the return value.
        ///If doFixIfInvalid is true, we attempt to delete an inssub with an invalid PlanNum.
        ///If unable to delete, we set the PlanNum to a new insplan associated to a carrier with the CarrierName of "UNKNOWN CARRIER" (this matches DBM logic)</summary>
        public static bool ValidatePlanNum(long insSubNum, bool doFixIfInvalid = true, List <InsSub> listInsSubs = null)
        {
            //No need to check RemotingRole; no call to db.
            List <InsPlan> listInsPlan   = new List <InsPlan>();
            InsSub         sub           = InsSubs.GetSub(insSubNum, listInsSubs);
            long           subscriberNum = sub.Subscriber;
            InsPlan        plan          = InsPlans.GetPlan(sub.PlanNum, listInsPlan);

            if (plan != null)           //Plan exists.  This means the reference from the inssub is intact.
            {
                return(true);
            }
            if (!doFixIfInvalid)
            {
                //There is an invalid PlanNum reference.
                //Don't automatically fix the reference if the caller doesn't want it fixed.
                return(false);
            }
            try {
                //The inssub points to an invalid plan, attempt to delete sub
                InsSubs.Delete(sub.InsSubNum);
                SecurityLogs.MakeLogEntry(Permissions.InsPlanEditSub, subscriberNum, "Deleted inssub with invalid insplan attached.");
            }
            catch (Exception ex) {
                ex.DoNothing();
                //Create blank insplan and attach to inssub
                InsSubs.AssignBlankPlanToInsSub(sub);
                SecurityLogs.MakeLogEntry(Permissions.InsPlanEditSub, subscriberNum, "Inssub with invalid insplan found, attached blank insplan.");
            }
            //Return false because the plan wasn't valid when entering the method, although it is now valid.
            return(false);
        }
Exemple #13
0
        ///<summary>Creates a procedure and returns its procedure fee.</summary>
        private double GetProcFee(string suffix, bool doUseMedicalCode)
        {
            Prefs.UpdateBool(PrefName.InsPpoAlwaysUseUcrFee, true);
            Prefs.UpdateBool(PrefName.MedicalFeeUsedForNewProcs, doUseMedicalCode);
            Patient pat            = PatientT.CreatePatient(suffix);
            long    ucrFeeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "UCR " + suffix);

            FeeSchedT.UpdateUCRFeeSched(pat, ucrFeeSchedNum);
            long ppoFeeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "PPO " + suffix);

            InsuranceT.AddInsurance(pat, suffix, "p", ppoFeeSchedNum, 1, true);
            List <InsSub>  listSubs     = InsSubT.GetInsSubs(pat);
            List <InsPlan> listPlans    = InsPlans.RefreshForSubList(listSubs);
            List <PatPlan> listPatPlans = PatPlans.Refresh(pat.PatNum);
            string         procStr      = "D0150";
            string         procStrMed   = "D0120";
            ProcedureCode  procCode     = ProcedureCodes.GetProcCode(procStr);
            ProcedureCode  procCodeMed  = ProcedureCodes.GetProcCode(procStrMed);

            procCode.MedicalCode = procCodeMed.ProcCode;
            FeeT.CreateFee(ucrFeeSchedNum, procCode.CodeNum, 300);
            FeeT.CreateFee(ppoFeeSchedNum, procCode.CodeNum, 120);
            FeeT.CreateFee(ucrFeeSchedNum, procCodeMed.CodeNum, 175);
            FeeT.CreateFee(ppoFeeSchedNum, procCodeMed.CodeNum, 85);
            Procedure proc = ProcedureT.CreateProcedure(pat, procStr, ProcStat.TP, "", 300);

            return(Procedures.GetProcFee(pat, listPatPlans, listSubs, listPlans, procCode.CodeNum, proc.ProvNum, proc.ClinicNum, procCode.MedicalCode));
        }
Exemple #14
0
        ///<summary>Looks for logs that show that the insplan or carrier changed and retrieves the previous insplan/carrier's information.
        ///Called from GetLinkedLogs and, between the two methods, recursively retrieves logs linked to the logs that are returned from this method.</summary>
        private static List <InsEditLog> GetChangedLogs(List <InsEditLog> listLogs)
        {
            //No need to check RemotingRole; no call to db.
            List <InsEditLog> listInsPlanChangedLogs = listLogs.FindAll(x =>
                                                                        ((x.LogType == InsEditLogType.InsPlan && x.FieldName == "PlanNum") ||
                                                                         (x.LogType == InsEditLogType.Carrier && x.FieldName == "CarrierNum")) &&
                                                                        x.OldValue != "NEW" && x.NewValue != "DELETED").ToList();

            foreach (InsEditLog editLogCur in listInsPlanChangedLogs)
            {
                if (editLogCur.FieldName == "PlanNum")
                {
                    InsPlan oldPlan = InsPlans.GetPlan(PIn.Long(editLogCur.OldValue), null);
                    if (oldPlan != null)
                    {
                        listLogs.AddRange(GetLinkedLogs(oldPlan.CarrierNum, InsEditLogType.Carrier, editLogCur, listLogs));
                    }
                    listLogs.AddRange(GetLinkedLogs(PIn.Long(editLogCur.OldValue), InsEditLogType.InsPlan, editLogCur, listLogs));
                }
                if (editLogCur.FieldName == "CarrierNum")
                {
                    listLogs.AddRange(GetLinkedLogs(PIn.Long(editLogCur.OldValue), InsEditLogType.Carrier, editLogCur, listLogs));
                }
            }
            return(listLogs);
        }
Exemple #15
0
        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);
        }
Exemple #16
0
        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));
        }
Exemple #17
0
        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);
        }
Exemple #18
0
        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);
        }
Exemple #19
0
        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;
            }
        }
Exemple #20
0
        public static InsuranceInfo AddInsurance(Patient pat, string carrierName, string planType = "", long feeSchedNum = 0, int ordinal = 1, bool isMedical = false,
                                                 EnumCobRule cobRule = EnumCobRule.Basic, long copayFeeSchedNum          = 0)
        {
            Carrier carrier = CarrierT.CreateCarrier(carrierName);
            InsPlan plan    = InsPlanT.CreateInsPlan(carrier.CarrierNum, cobRule);
            InsPlan planOld = plan.Copy();

            plan.PlanType      = planType;
            plan.FeeSched      = feeSchedNum;
            plan.IsMedical     = isMedical;
            plan.CopayFeeSched = copayFeeSchedNum;
            InsPlans.Update(plan, planOld);
            InsSub  sub     = InsSubT.CreateInsSub(pat.PatNum, plan.PlanNum);
            PatPlan patPlan = PatPlanT.CreatePatPlan((byte)ordinal, pat.PatNum, sub.InsSubNum);

            return(new InsuranceInfo {
                ListCarriers = new List <Carrier> {
                    carrier
                },
                ListInsPlans = new List <InsPlan> {
                    plan
                },
                ListInsSubs = new List <InsSub> {
                    sub
                },
                ListPatPlans = new List <PatPlan> {
                    patPlan
                },
            });
        }
Exemple #21
0
        ///<summary>Creates a general deductible of $50, a deductible of $50 on D0220, sets a $30 D0220 complete and creates a claim,
        ///creates a $100 D2750, that is TP'ed, and then creates a $30 D0220 that is TP'ed.</summary>
        ///<param name="actAssert">The first claimproc is for the D2750 and the second claimproc is for the second D0220.</param>
        public void GetDeductibleByCodeDeductLessThanGeneral(string suffix, Action <ClaimProc, ClaimProc> actAssert)
        {
            Patient pat = PatientT.CreatePatient(suffix);

            InsuranceT.AddInsurance(pat, suffix);
            List <InsSub>  listSubs     = InsSubT.GetInsSubs(pat);
            List <InsPlan> listPlans    = InsPlans.RefreshForSubList(listSubs);
            List <PatPlan> listPatPlans = PatPlans.Refresh(pat.PatNum);
            InsPlan        plan         = InsPlanT.GetPlanForPriSecMed(PriSecMed.Primary, listPatPlans, listPlans, listSubs);

            BenefitT.CreateDeductibleGeneral(plan.PlanNum, BenefitCoverageLevel.Individual, 50);
            BenefitT.CreateCategoryPercent(plan.PlanNum, EbenefitCategory.Diagnostic, 100);
            BenefitT.CreateCategoryPercent(plan.PlanNum, EbenefitCategory.Crowns, 50);
            BenefitT.CreateDeductible(plan.PlanNum, EbenefitCategory.Diagnostic, 0);
            BenefitT.CreateDeductible(plan.PlanNum, "D0220", 50);
            List <Benefit> listBens = Benefits.Refresh(listPatPlans, listSubs);
            Procedure      proc1    = ProcedureT.CreateProcedure(pat, "D0220", ProcStat.C, "", 30);//proc1 - Intraoral - periapical first film

            ClaimT.CreateClaim("P", listPatPlans, listPlans, new List <ClaimProc>(), new List <Procedure> {
                proc1
            }, pat, new List <Procedure> {
                proc1
            }, listBens,
                               listSubs);
            Procedure        proc2      = ProcedureT.CreateProcedure(pat, "D2750", ProcStat.TP, "", 100, priority: 0); //proc2 - Crown
            Procedure        proc3      = ProcedureT.CreateProcedure(pat, "D0220", ProcStat.TP, "", 30, priority: 1);  //proc3 - Intraoral - periapical first film
            List <ClaimProc> claimProcs = ProcedureT.ComputeEstimates(pat, listPatPlans, listPlans, listSubs, listBens);
            ClaimProc        claimProc2 = claimProcs.FirstOrDefault(x => x.ProcNum == proc2.ProcNum);
            ClaimProc        claimProc3 = claimProcs.FirstOrDefault(x => x.ProcNum == proc3.ProcNum);

            actAssert(claimProc2, claimProc3);
        }
Exemple #22
0
        public static string RunFour(bool showForms)
        {
            string  retVal  = "";
            long    provNum = ProviderC.ListShort[1].ProvNum;       //dentist #2
            Patient pat     = Patients.GetPat(PatientTC.PatNum6);   //patient#6

            if (pat.PriProv != provNum)
            {
                Patient oldPat = pat.Copy();
                pat.PriProv = provNum;              //this script uses the primary provider for the patient
                Patients.Update(pat, oldPat);
            }
            PatPlan          patplan        = PatPlans.GetPatPlan(pat.PatNum, 1);
            InsSub           sub            = InsSubs.GetOne(patplan.InsSubNum);
            InsPlan          plan           = InsPlans.GetPlan(sub.PlanNum, new List <InsPlan>());
            long             etransNum      = CanadianOutput.SendElegibility(pat.PatNum, plan, new DateTime(1999, 1, 1), patplan.Relationship, patplan.PatID, showForms, sub);
            Etrans           etrans         = Etranss.GetEtrans(etransNum);
            string           message        = EtransMessageTexts.GetMessageText(etrans.EtransMessageTextNum);
            CCDFieldInputter formData       = new CCDFieldInputter(message);
            string           responseStatus = formData.GetValue("G05");

            if (responseStatus != "M")
            {
                throw new Exception("Should be M");
            }
            retVal += "Eligibility #4 successful.\r\n";
            return(retVal);
        }
Exemple #23
0
        ///<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);
        }
Exemple #24
0
        ///<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 ProcedureCodes_GetSubstituteCodeNum_Posterior()
        {
            //First, setup the test scenario.
            string  suffix  = MethodBase.GetCurrentMethod().Name;
            Patient pat     = PatientT.CreatePatient(suffix);
            Carrier carrier = CarrierT.CreateCarrier(MethodBase.GetCurrentMethod().Name);
            InsPlan plan    = new InsPlan();

            plan.CarrierNum = carrier.CarrierNum;
            plan.PlanType   = "";
            plan.CobRule    = EnumCobRule.Basic;
            plan.PlanNum    = InsPlans.Insert(plan);
            //Add a substitution code on the procedure level.
            ProcedureCode originalProcCode  = ProcedureCodes.GetProcCode("D2740");
            ProcedureCode downgradeProcCode = ProcedureCodes.GetProcCode("D2750");

            originalProcCode.SubstitutionCode = "D2750";
            originalProcCode.SubstOnlyIf      = SubstitutionCondition.Posterior;
            ProcedureCodeT.Update(originalProcCode);
            //Posterior Procedure= ToothNum 4
            Procedure proc       = ProcedureT.CreateProcedure(pat, originalProcCode.ProcCode, ProcStat.C, "4", 100);//Tooth 4
            long      subCodeNum = ProcedureCodes.GetSubstituteCodeNum(originalProcCode.ProcCode, proc.ToothNum, plan.PlanNum);

            //Finally, use one or more asserts to verify the results.
            Assert.AreEqual(downgradeProcCode.CodeNum, subCodeNum);
        }
Exemple #26
0
        ///<summary>Returns number of subscribers affected.  Can throw an exception if user clicks cancel in a note box.</summary>
        private static int ProcessTrojanPlan(string trojanPlan, bool updateBenefits, bool updateNoteAutomatic)
        {
            TrojanObject troj    = ProcessTextToObject(trojanPlan);
            Carrier      carrier = new Carrier();

            carrier.Phone       = troj.ELIGPHONE;
            carrier.ElectID     = troj.PAYERID;
            carrier.CarrierName = troj.MAILTO;
            carrier.Address     = troj.MAILTOST;
            carrier.City        = troj.MAILCITYONLY;
            carrier.State       = troj.MAILSTATEONLY;
            carrier.Zip         = troj.MAILZIPONLY;
            carrier.NoSendElect = false;          //regardless of what Trojan says.  Nobody sends paper anymore.
            if (carrier.CarrierName == null || carrier.CarrierName == "")
            {
                //if, for some reason, carrier is absent from the file, we can't do a thing with it.
                return(0);
            }
            carrier = Carriers.GetIndentical(carrier);
            //now, save this all to the database.
            troj.CarrierNum = carrier.CarrierNum;
            InsPlan plan = TrojanQueries.GetPlanWithTrojanID(troj.TROJANID);

            if (plan == null)
            {
                return(0);
            }
            TrojanQueries.UpdatePlan(troj, plan.PlanNum, updateBenefits);
            plan = InsPlans.RefreshOne(plan.PlanNum);
            if (updateNoteAutomatic)
            {
                if (plan.PlanNote != troj.PlanNote)
                {
                    plan.PlanNote = troj.PlanNote;
                    InsPlans.Update(plan);
                }
            }
            else
            {
                //let user pick note
                if (plan.PlanNote != troj.PlanNote)
                {
                    string[] notes = new string[2];
                    notes[0] = plan.PlanNote;
                    notes[1] = troj.PlanNote;
                    FormNotePick FormN = new FormNotePick(notes);
                    FormN.ShowDialog();
                    if (FormN.DialogResult == DialogResult.OK)
                    {
                        if (plan.PlanNote != FormN.SelectedNote)
                        {
                            plan.PlanNote = FormN.SelectedNote;
                            InsPlans.Update(plan);
                        }
                    }
                }
            }
            return(1);
        }
Exemple #27
0
        public void InsPlan_GetAllowed_CapNoAllowedNoSubs()
        {
            InsPlan       plan     = GenerateCapPlan(MethodBase.GetCurrentMethod().Name, false);
            ProcedureCode procCode = _listProcCodes[12];
            double        amt      = InsPlans.GetAllowed(procCode.ProcCode, plan.FeeSched, plan.AllowedFeeSched, plan.CodeSubstNone, plan.PlanType, "", 0, 0, plan.PlanNum);

            Assert.AreEqual(-1, amt);
        }
Exemple #28
0
        public void InsPlans_GetCopay_Blank()
        {
            ProcedureCode procCode = _listProcCodes[0];
            InsPlan       plan     = GenerateMediFlatInsPlan(MethodBase.GetCurrentMethod().Name);
            double        amt      = InsPlans.GetCopay(procCode.CodeNum, plan.FeeSched, plan.CopayFeeSched, plan.CodeSubstNone, "", 0, 0, plan.PlanNum);

            Assert.AreEqual(-1, amt);
        }
Exemple #29
0
        ///<summary>Gets the fee schedule from the primary MEDICAL insurance plan,
        ///the first insurance plan, the patient, or the provider in that order.</summary>
        public static long GetMedFeeSched(Patient pat, List <InsPlan> planList, List <PatPlan> patPlans, List <InsSub> subList, long procProvNum)
        {
            //No need to check RemotingRole; no call to db.
            long retVal = 0;

            if (PatPlans.GetInsSubNum(patPlans, 1) != 0)
            {
                //Pick the medinsplan with the ordinal closest to zero
                int    planOrdinal = 10;            //This is a hack, but I doubt anyone would have more than 10 plans
                bool   hasMedIns   = false;         //Keep track of whether we found a medical insurance plan, if not use dental insurance fee schedule.
                InsSub subCur;
                foreach (PatPlan patplan in patPlans)
                {
                    subCur = InsSubs.GetSub(patplan.InsSubNum, subList);
                    if (patplan.Ordinal < planOrdinal && InsPlans.GetPlan(subCur.PlanNum, planList).IsMedical)
                    {
                        planOrdinal = patplan.Ordinal;
                        hasMedIns   = true;
                    }
                }
                if (!hasMedIns)                                                         //If this patient doesn't have medical insurance (under ordinal 10)
                {
                    return(GetFeeSched(pat, planList, patPlans, subList, procProvNum)); //Use dental insurance fee schedule
                }
                subCur = InsSubs.GetSub(PatPlans.GetInsSubNum(patPlans, planOrdinal), subList);
                InsPlan PlanCur = InsPlans.GetPlan(subCur.PlanNum, planList);
                if (PlanCur == null)
                {
                    retVal = 0;
                }
                else
                {
                    retVal = PlanCur.FeeSched;
                }
            }
            if (retVal == 0)
            {
                if (pat.FeeSched != 0)
                {
                    retVal = pat.FeeSched;
                }
                else
                {
                    if (pat.PriProv == 0)
                    {
                        retVal = Providers.GetFirst(true).FeeSched;
                    }
                    else
                    {
                        Provider providerFirst = Providers.GetFirst();                      //Used in order to preserve old behavior...  If this fails, then old code would have failed.
                        Provider provider      = Providers.GetFirstOrDefault(x => x.ProvNum == pat.PriProv) ?? providerFirst;
                        retVal = provider.FeeSched;
                    }
                }
            }
            return(retVal);
        }
Exemple #30
0
        ///<summary>This will replace the currently attached InsPlan with an "UNKNOWN CARRIER" InsPlan.</summary>
        public static void AssignBlankPlanToInsSub(InsSub subCur)
        {
            //No need to check RemotingRole; no call to db.
            //Will get the plan if it exists, or create a new one and insert if it does not.
            InsPlan plan = InsPlans.GetByCarrierName("UNKNOWN CARRIER");

            subCur.PlanNum = plan.PlanNum;
            Update(subCur);
        }