Beispiel #1
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));
        }
Beispiel #2
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <InsSub> TableToList(DataTable table)
        {
            List <InsSub> retVal = new List <InsSub>();
            InsSub        insSub;

            foreach (DataRow row in table.Rows)
            {
                insSub                 = new InsSub();
                insSub.InsSubNum       = PIn.Long(row["InsSubNum"].ToString());
                insSub.PlanNum         = PIn.Long(row["PlanNum"].ToString());
                insSub.Subscriber      = PIn.Long(row["Subscriber"].ToString());
                insSub.DateEffective   = PIn.Date(row["DateEffective"].ToString());
                insSub.DateTerm        = PIn.Date(row["DateTerm"].ToString());
                insSub.ReleaseInfo     = PIn.Bool(row["ReleaseInfo"].ToString());
                insSub.AssignBen       = PIn.Bool(row["AssignBen"].ToString());
                insSub.SubscriberID    = PIn.String(row["SubscriberID"].ToString());
                insSub.BenefitNotes    = PIn.String(row["BenefitNotes"].ToString());
                insSub.SubscNote       = PIn.String(row["SubscNote"].ToString());
                insSub.SecUserNumEntry = PIn.Long(row["SecUserNumEntry"].ToString());
                insSub.SecDateEntry    = PIn.Date(row["SecDateEntry"].ToString());
                insSub.SecDateTEdit    = PIn.DateT(row["SecDateTEdit"].ToString());
                retVal.Add(insSub);
            }
            return(retVal);
        }
Beispiel #3
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);
        }
Beispiel #4
0
 ///<summary>Inserts one InsSub into the database.  Returns the new priKey.</summary>
 public static long Insert(InsSub insSub)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         insSub.InsSubNum = DbHelper.GetNextOracleKey("inssub", "InsSubNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(insSub, true));
             }
             catch (Oracle.ManagedDataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     insSub.InsSubNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(insSub, false));
     }
 }
Beispiel #5
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;
            }
        }
Beispiel #6
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);
        }
Beispiel #7
0
 ///<summary></summary>
 public FormInsPlanSelect(long patNum)
 {
     InitializeComponent();
     PatNum = patNum;
     //usage: eg. from coverage.  Since can be totally new subscriber, get all plans for them.
     FamCur              = Patients.GetFamily(PatNum);
     PatCur              = FamCur.GetPatient(PatNum);
     SubList             = InsSubs.RefreshForFam(FamCur);
     PlanList            = InsPlans.RefreshForSubList(SubList);
     _listPatCurPatPlans = PatPlans.Refresh(PatNum);
     if (_listPatCurPatPlans.Count == 1)
     {
         try {
             PatRelat     = _listPatCurPatPlans[0].Relationship;
             SelectedSub  = SubList.FirstOrDefault(x => x.InsSubNum == _listPatCurPatPlans[0].InsSubNum);
             SelectedPlan = InsPlans.GetPlan(SelectedSub.PlanNum, PlanList);
             if (SelectedSub == null || SelectedPlan == null)
             {
                 throw new ApplicationException();
             }
         }
         catch {
             PatRelat     = 0;
             SelectedSub  = null;
             SelectedPlan = null;
         }
     }
     //tbPlans.CellDoubleClicked += new OpenDental.ContrTable.CellEventHandler(tbPlans_CellDoubleClicked);
     Lan.F(this);
 }
Beispiel #8
0
        public void X834_ImportInsurancePlans_ReplacePatPlan()
        {
            Patient pat    = Createx834Patient();
            string  suffix = MethodBase.GetCurrentMethod().Name;
            //Create old insurance plan and associate it to them.
            InsuranceInfo insuranceOld = InsuranceT.AddInsurance(pat, "Old Carrier" + suffix);
            //Create x834
            X834 x834 = new X834(new X12object(Properties.Resources.x834Test));
            int  createdPatsCount, updatedPatsCount, skippedPatsCount, createdCarrierCount, createdInsPlanCount, updatedInsPlanCount, createdInsSubCount,
                 updatedInsSubCount, createdPatPlanCount, droppedPatPlanCount, updatedPatPlanCount;
            StringBuilder sbErrorMessages;

            //Pass in true for dropExistingInsurance
            EtransL.ImportInsurancePlans(x834, new List <Patient> {
                pat
            }, true, true, out createdPatsCount,
                                         out updatedPatsCount, out skippedPatsCount, out createdCarrierCount, out createdInsPlanCount, out updatedInsPlanCount, out createdInsSubCount,
                                         out updatedInsSubCount, out createdPatPlanCount, out droppedPatPlanCount, out updatedPatPlanCount, out sbErrorMessages);
            //Get the pat plans for this patient from the database.
            List <PatPlan> listPatPlans = PatPlans.GetPatPlansForPat(pat.PatNum);

            Assert.AreEqual(1, listPatPlans.Count);
            Assert.AreEqual(1, droppedPatPlanCount);
            InsSub subForPatPlan        = InsSubs.GetOne(listPatPlans[0].InsSubNum);

            //These should be different as a new plan was created and the old plan was dropped.
            Assert.AreNotEqual(insuranceOld.PriInsPlan.PlanNum, subForPatPlan.PlanNum);
        }
Beispiel #9
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));
        }
Beispiel #10
0
        ///<summary>Updates one InsSub in the database.</summary>
        public static void Update(InsSub insSub)
        {
            string command = "UPDATE inssub SET "
                             + "PlanNum        =  " + POut.Long(insSub.PlanNum) + ", "
                             + "Subscriber     =  " + POut.Long(insSub.Subscriber) + ", "
                             + "DateEffective  =  " + POut.Date(insSub.DateEffective) + ", "
                             + "DateTerm       =  " + POut.Date(insSub.DateTerm) + ", "
                             + "ReleaseInfo    =  " + POut.Bool(insSub.ReleaseInfo) + ", "
                             + "AssignBen      =  " + POut.Bool(insSub.AssignBen) + ", "
                             + "SubscriberID   = '" + POut.String(insSub.SubscriberID) + "', "
                             + "BenefitNotes   =  " + DbHelper.ParamChar + "paramBenefitNotes, "
                             + "SubscNote      =  " + DbHelper.ParamChar + "paramSubscNote "
                             //SecUserNumEntry excluded from update
                             //SecDateEntry not allowed to change
                             //SecDateTEdit can only be set by MySQL
                             + "WHERE InsSubNum = " + POut.Long(insSub.InsSubNum);

            if (insSub.BenefitNotes == null)
            {
                insSub.BenefitNotes = "";
            }
            OdSqlParameter paramBenefitNotes = new OdSqlParameter("paramBenefitNotes", OdDbType.Text, POut.StringParam(insSub.BenefitNotes));

            if (insSub.SubscNote == null)
            {
                insSub.SubscNote = "";
            }
            OdSqlParameter paramSubscNote = new OdSqlParameter("paramSubscNote", OdDbType.Text, POut.StringParam(insSub.SubscNote));

            Db.NonQ(command, paramBenefitNotes, paramSubscNote);
        }
Beispiel #11
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);
        }
Beispiel #12
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
                },
            });
        }
Beispiel #13
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);
        }
Beispiel #14
0
 ///<summary>Inserts one InsSub into the database.  Provides option to use the existing priKey.</summary>
 internal static long Insert(InsSub insSub,bool useExistingPK)
 {
     if(!useExistingPK && PrefC.RandomKeys) {
         insSub.InsSubNum=ReplicationServers.GetKey("inssub","InsSubNum");
     }
     string command="INSERT INTO inssub (";
     if(useExistingPK || PrefC.RandomKeys) {
         command+="InsSubNum,";
     }
     command+="PlanNum,Subscriber,DateEffective,DateTerm,ReleaseInfo,AssignBen,SubscriberID,BenefitNotes,SubscNote) VALUES(";
     if(useExistingPK || PrefC.RandomKeys) {
         command+=POut.Long(insSub.InsSubNum)+",";
     }
     command+=
              POut.Long  (insSub.PlanNum)+","
         +    POut.Long  (insSub.Subscriber)+","
         +    POut.Date  (insSub.DateEffective)+","
         +    POut.Date  (insSub.DateTerm)+","
         +    POut.Bool  (insSub.ReleaseInfo)+","
         +    POut.Bool  (insSub.AssignBen)+","
         +"'"+POut.String(insSub.SubscriberID)+"',"
         +DbHelper.ParamChar+"paramBenefitNotes,"
         +"'"+POut.String(insSub.SubscNote)+"')";
     if(insSub.BenefitNotes==null) {
         insSub.BenefitNotes="";
     }
     OdSqlParameter paramBenefitNotes=new OdSqlParameter("paramBenefitNotes",OdDbType.Text,insSub.BenefitNotes);
     if(useExistingPK || PrefC.RandomKeys) {
         Db.NonQ(command,paramBenefitNotes);
     }
     else {
         insSub.InsSubNum=Db.NonQ(command,true,paramBenefitNotes);
     }
     return insSub.InsSubNum;
 }
Beispiel #15
0
        public void PaymentEdit_Init_AutoSplitWithClaimPayments()          //Legacy_TestFortyEight
        {
            string    suffix     = "48";
            Patient   pat        = PatientT.CreatePatient(suffix);
            long      patNum     = pat.PatNum;
            InsPlan   insPlan    = InsPlanT.CreateInsPlan(CarrierT.CreateCarrier(suffix).CarrierNum);
            InsSub    insSub     = InsSubT.CreateInsSub(patNum, insPlan.PlanNum);
            PatPlan   patPlan    = PatPlanT.CreatePatPlan(1, patNum, insSub.InsSubNum);
            Procedure procedure1 = ProcedureT.CreateProcedure(pat, "D1110", ProcStat.C, "", 50, DateTime.Now.AddDays(-1));
            Procedure procedure2 = ProcedureT.CreateProcedure(pat, "D0120", ProcStat.C, "", 40, DateTime.Now.AddDays(-2));
            Procedure procedure3 = ProcedureT.CreateProcedure(pat, "D0220", ProcStat.C, "", 60, DateTime.Now.AddDays(-3));

            ClaimProcT.AddInsPaid(patNum, insPlan.PlanNum, procedure1.ProcNum, 20, insSub.InsSubNum, 0, 0);
            ClaimProcT.AddInsPaid(patNum, insPlan.PlanNum, procedure2.ProcNum, 5, insSub.InsSubNum, 5, 0);
            ClaimProcT.AddInsPaid(patNum, insPlan.PlanNum, procedure3.ProcNum, 20, insSub.InsSubNum, 0, 10);
            Payment        payment       = PaymentT.MakePaymentNoSplits(patNum, 150, DateTime.Today);
            Family         famForPat     = Patients.GetFamily(patNum);
            List <Patient> listFamForPat = famForPat.ListPats.ToList();

            PaymentEdit.InitData init = PaymentEdit.Init(listFamForPat, famForPat, new Family {
            }, payment, new List <PaySplit>(), new List <Procedure>(), patNum);
            //Auto Splits will be in opposite order from least recent to most recent.
            //ListSplitsCur should contain four splits, 30, 35, and 30, then one unallocated for the remainder of the payment 55.
            Assert.AreEqual(4, init.AutoSplitData.ListSplitsCur.Count);
            Assert.IsFalse(init.AutoSplitData.ListSplitsCur[0].SplitAmt != 40 || init.AutoSplitData.ListSplitsCur[0].ProcNum != procedure3.ProcNum ||
                           init.AutoSplitData.ListSplitsCur[0].PatNum != patNum);
            Assert.IsFalse(init.AutoSplitData.ListSplitsCur[1].SplitAmt != 35 || init.AutoSplitData.ListSplitsCur[1].ProcNum != procedure2.ProcNum ||
                           init.AutoSplitData.ListSplitsCur[1].PatNum != patNum);
            Assert.IsFalse(init.AutoSplitData.ListSplitsCur[2].SplitAmt != 30 || init.AutoSplitData.ListSplitsCur[2].ProcNum != procedure1.ProcNum ||
                           init.AutoSplitData.ListSplitsCur[2].PatNum != patNum);
            Assert.IsFalse(init.AutoSplitData.ListSplitsCur[3].SplitAmt != 45 || init.AutoSplitData.ListSplitsCur[3].ProcNum != 0);
        }
Beispiel #16
0
 ///<summary>Inserts one InsSub into the database.  Returns the new priKey.</summary>
 internal static long Insert(InsSub insSub)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         insSub.InsSubNum=DbHelper.GetNextOracleKey("inssub","InsSubNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(insSub,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     insSub.InsSubNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(insSub,false);
     }
 }
Beispiel #17
0
        //1. Find claiprocs for current plan
        //2. Find EO and C procs for claimprocs on current plan
        //3. Only have procs on this insplan that are EO and C
        //4. Fill in date info based on EO or C proc list
        //5. On OK click, fetch all claimprocs for EO and C procs
        //5a. Date filled, no matching EO or C proc - User entered date themselves, make new proc with claimproc status inshist
        //5b. Date filled, matching EO or C proc and user changed the date.-
        //Modify proc and claimproc for that category ONLY if the proc has a status of EO to be the date specified
        //If the proc has a status of C and the new date is greater than the the current ProcDate, create a new EO procedure and InsHist ClaimProc with the new date entered.
        //5c. No date, no proc - Do nothing
        //5d. No date, matching EO or C proc - User erased the date, delete proc/claimproc ONLY if proc has a status of EO.


        public FormInsHistSetup(long patNum, InsSub insSub)
        {
            InitializeComponent();
            Lan.F(this);
            _patCur           = Patients.GetPat(patNum);
            _insSubCur        = insSub;
            _dictInsHistProcs = Procedures.GetDictInsHistProcs(patNum, insSub.InsSubNum, out _listClaimProcsForInsHistProcs);
        }
Beispiel #18
0
        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);
        }
Beispiel #19
0
        ///<summary></summary>
        public static InsSub CreateInsSub(long subscriberNum, long planNum, string subscriberID = "1234")
        {
            InsSub sub = new InsSub();

            sub.Subscriber   = subscriberNum;
            sub.PlanNum      = planNum;
            sub.SubscriberID = subscriberID;
            InsSubs.Insert(sub);
            return(sub);
        }
Beispiel #20
0
        public void X271_EB271_SetInsuranceHistoryDates()
        {
            Patient      pat               = PatientT.CreatePatient(lName: "Doe", fName: "John");
            Carrier      carrier           = CarrierT.CreateCarrier("X271Test");
            InsPlan      insPlan           = InsPlanT.CreateInsPlan(carrier.CarrierNum);
            InsSub       insSub            = InsSubT.CreateInsSub(pat.PatNum, insPlan.PlanNum);
            List <EB271> listEb            = _x271.GetListEB(true, carrier.IsCoinsuranceInverted);
            int          countValidInsHist = EB271.SetInsuranceHistoryDates(listEb, pat.PatNum, insSub);

            Assert.AreEqual(3, countValidInsHist);           //There are 4 valid fields but 1 has an invalid date.
        }
Beispiel #21
0
        public static void SetAssignBen(bool assignBen, long subNum)
        {
            InsSub sub = InsSubs.GetOne(subNum);

            if (sub.AssignBen == assignBen)
            {
                return;                //no change needed
            }
            sub.AssignBen = assignBen;
            InsSubs.Update(sub);
        }
Beispiel #22
0
        ///<summary>Inserts one InsSub into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(InsSub insSub, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO inssub (";

            if (!useExistingPK && isRandomKeys)
            {
                insSub.InsSubNum = ReplicationServers.GetKeyNoCache("inssub", "InsSubNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "InsSubNum,";
            }
            command += "PlanNum,Subscriber,DateEffective,DateTerm,ReleaseInfo,AssignBen,SubscriberID,BenefitNotes,SubscNote,SecUserNumEntry,SecDateEntry) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(insSub.InsSubNum) + ",";
            }
            command +=
                POut.Long(insSub.PlanNum) + ","
                + POut.Long(insSub.Subscriber) + ","
                + POut.Date(insSub.DateEffective) + ","
                + POut.Date(insSub.DateTerm) + ","
                + POut.Bool(insSub.ReleaseInfo) + ","
                + POut.Bool(insSub.AssignBen) + ","
                + "'" + POut.String(insSub.SubscriberID) + "',"
                + DbHelper.ParamChar + "paramBenefitNotes,"
                + DbHelper.ParamChar + "paramSubscNote,"
                + POut.Long(insSub.SecUserNumEntry) + ","
                + DbHelper.Now() + ")";
            //SecDateTEdit can only be set by MySQL
            if (insSub.BenefitNotes == null)
            {
                insSub.BenefitNotes = "";
            }
            OdSqlParameter paramBenefitNotes = new OdSqlParameter("paramBenefitNotes", OdDbType.Text, POut.StringParam(insSub.BenefitNotes));

            if (insSub.SubscNote == null)
            {
                insSub.SubscNote = "";
            }
            OdSqlParameter paramSubscNote = new OdSqlParameter("paramSubscNote", OdDbType.Text, POut.StringParam(insSub.SubscNote));

            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command, paramBenefitNotes, paramSubscNote);
            }
            else
            {
                insSub.InsSubNum = Db.NonQ(command, true, "InsSubNum", "insSub", paramBenefitNotes, paramSubscNote);
            }
            return(insSub.InsSubNum);
        }
Beispiel #23
0
 private void gridMain_CellDoubleClick(object sender, OpenDental.UI.ODGridClickEventArgs e)
 {
     if (listRelat.SelectedIndex == -1)
     {
         MessageBox.Show(Lan.g(this, "Please select a relationship first."));
         return;
     }
     PatRelat     = (Relat)listRelat.SelectedIndex;
     SelectedSub  = (InsSub)gridMain.ListGridRows[e.Row].Tag;
     SelectedPlan = InsPlans.GetPlan(SelectedSub.PlanNum, PlanList);
     DialogResult = DialogResult.OK;
 }
Beispiel #24
0
 ///<summary>Inserts one InsSub into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(InsSub insSub)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(insSub, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             insSub.InsSubNum = DbHelper.GetNextOracleKey("inssub", "InsSubNum");                  //Cacheless method
         }
         return(InsertNoCache(insSub, true));
     }
 }
Beispiel #25
0
        public void InsPlan_GetDedRemainDisplay_IndividualAndFamilyDeductiblesInsRemaining()
        {
            string  suffix = "20";
            Patient pat    = PatientT.CreatePatient(suffix);       //guarantor
            long    patNum = pat.PatNum;
            Patient pat2   = PatientT.CreatePatient(suffix);

            PatientT.SetGuarantor(pat2, pat.PatNum);
            Patient pat3 = PatientT.CreatePatient(suffix);

            PatientT.SetGuarantor(pat3, 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;
            PatPlan patPlan  = PatPlanT.CreatePatPlan(1, pat.PatNum, subNum);  //all three patients have the same plan
            PatPlan patPlan2 = PatPlanT.CreatePatPlan(1, pat2.PatNum, subNum); //all three patients have the same plan
            PatPlan patPlan3 = PatPlanT.CreatePatPlan(1, pat3.PatNum, subNum); //all three patients have the same plan

            BenefitT.CreateDeductibleGeneral(planNum, BenefitCoverageLevel.Individual, 75);
            BenefitT.CreateDeductibleGeneral(planNum, BenefitCoverageLevel.Family, 150);
            ClaimProcT.AddInsUsedAdjustment(pat3.PatNum, planNum, 0, subNum, 75);               //Adjustment goes on the third patient
            Procedure proc = ProcedureT.CreateProcedure(pat2, "D2750", ProcStat.C, "20", 1280); //proc for second patient with a deductible already applied.

            ClaimProcT.AddInsPaid(pat2.PatNum, planNum, proc.ProcNum, 304, subNum, 50, 597);
            proc = ProcedureT.CreateProcedure(pat, "D4355", ProcStat.TP, "", 135);      //proc is for the first patient
            long procNum = proc.ProcNum;
            //Lists
            List <ClaimProc>     claimProcs  = ClaimProcs.Refresh(patNum);
            Family               fam         = Patients.GetFamily(patNum);
            List <InsSub>        subList     = InsSubs.RefreshForFam(fam);
            List <InsPlan>       planList    = InsPlans.RefreshForSubList(subList);
            List <PatPlan>       patPlans    = PatPlans.Refresh(patNum);
            List <Benefit>       benefitList = Benefits.Refresh(patPlans, subList);
            List <ClaimProcHist> histList    = ClaimProcs.GetHistList(patNum, benefitList, patPlans, planList, DateTime.Today, subList);
            List <ClaimProcHist> loopList    = new List <ClaimProcHist>();
            //Validate
            List <ClaimProcHist> HistList = ClaimProcs.GetHistList(pat.PatNum, benefitList, patPlans, planList, DateTime.Today, subList);
            double dedFam = Benefits.GetDeductGeneralDisplay(benefitList, planNum, patPlan.PatPlanNum, BenefitCoverageLevel.Family);
            double ded    = Benefits.GetDeductGeneralDisplay(benefitList, planNum, patPlan.PatPlanNum, BenefitCoverageLevel.Individual);
            double dedRem = InsPlans.GetDedRemainDisplay(HistList, DateTime.Today, planNum, patPlan.PatPlanNum, -1, planList, pat.PatNum, ded, dedFam);  //test family and individual deductible together

            Assert.AreEqual(25, dedRem);
            dedRem = InsPlans.GetDedRemainDisplay(HistList, DateTime.Today, planNum, patPlan.PatPlanNum, -1, planList, pat.PatNum, ded, -1);  //test individual deductible by itself
            Assert.AreEqual(75, dedRem);
        }
Beispiel #26
0
        private void pd_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            Rectangle bounds = e.MarginBounds;
            //new Rectangle(50,40,800,1035);//Some printers can handle up to 1042
            Graphics g = e.Graphics;
            string   text;
            Font     headingFont    = new Font("Arial", 12, FontStyle.Bold);
            Font     subHeadingFont = new Font("Arial", 10, FontStyle.Bold);
            int      yPos           = bounds.Top;
            int      center         = bounds.X + bounds.Width / 2;

            #region printHeading
            if (!headingPrinted)
            {
                text = Lan.g(this, "Electronic Benefits Response");
                g.DrawString(text, headingFont, Brushes.Black, center - g.MeasureString(text, headingFont).Width / 2, yPos);
                yPos += (int)g.MeasureString(text, headingFont).Height;
                InsSub  sub   = InsSubs.GetSub(this.SubNum, new List <InsSub>());
                InsPlan plan  = InsPlans.GetPlan(this.PlanNum, new List <InsPlan>());
                Patient subsc = Patients.GetPat(sub.Subscriber);
                text = Lan.g(this, "Subscriber: ") + subsc.GetNameFL();
                g.DrawString(text, subHeadingFont, Brushes.Black, center - g.MeasureString(text, subHeadingFont).Width / 2, yPos);
                yPos += (int)g.MeasureString(text, subHeadingFont).Height;
                Carrier carrier = Carriers.GetCarrier(plan.CarrierNum);
                if (carrier.CarrierNum != 0)               //not corrupted
                {
                    text = carrier.CarrierName;
                    g.DrawString(text, subHeadingFont, Brushes.Black, center - g.MeasureString(text, subHeadingFont).Width / 2, yPos);
                }
                yPos          += 20;
                headingPrinted = true;
                headingPrintH  = yPos;
            }
            #endregion
            yPos = gridMain.PrintPage(g, pagesPrinted, bounds, headingPrintH);
            pagesPrinted++;
            if (yPos == -1)
            {
                e.HasMorePages = true;
            }
            else
            {
                e.HasMorePages = false;
            }
            g.Dispose();
        }
Beispiel #27
0
        public void Claims_CalculateAndUpdate_ProcedureCodeDowngradeHigherFee()
        {
            string  suffix         = "61";
            Patient pat            = PatientT.CreatePatient(suffix);
            long    ucrFeeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "UCR Fees" + suffix);
            long    ppoFeeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "PPO Downgrades" + suffix);
            Carrier carrier        = CarrierT.CreateCarrier(suffix);
            InsPlan plan           = InsPlanT.CreateInsPlan(carrier.CarrierNum);
            InsSub  sub            = InsSubT.CreateInsSub(pat.PatNum, plan.PlanNum);
            long    subNum         = sub.InsSubNum;

            BenefitT.CreateCategoryPercent(plan.PlanNum, EbenefitCategory.Restorative, 100);
            PatPlanT.CreatePatPlan(1, pat.PatNum, subNum);
            ProcedureCode originalProcCode  = ProcedureCodes.GetProcCode("D2391");
            ProcedureCode downgradeProcCode = ProcedureCodes.GetProcCode("D2140");

            originalProcCode.SubstitutionCode = "D2140";
            originalProcCode.SubstOnlyIf      = SubstitutionCondition.Always;
            ProcedureCodes.Update(originalProcCode);
            FeeT.CreateFee(ucrFeeSchedNum, originalProcCode.CodeNum, 140);
            FeeT.CreateFee(ucrFeeSchedNum, downgradeProcCode.CodeNum, 120);
            FeeT.CreateFee(ppoFeeSchedNum, originalProcCode.CodeNum, 80);
            FeeT.CreateFee(ppoFeeSchedNum, downgradeProcCode.CodeNum, 100);
            Procedure        proc             = ProcedureT.CreateProcedure(pat, "D2391", ProcStat.C, "1", 140);//Tooth 1
            List <ClaimProc> claimProcs       = ClaimProcs.Refresh(pat.PatNum);
            List <ClaimProc> claimProcListOld = new List <ClaimProc>();
            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 <Procedure> ProcList    = Procedures.Refresh(pat.PatNum);
            InsPlan          insPlan     = planList[0];//Should only be one
            InsPlan          planOld     = insPlan.Copy();

            insPlan.PlanType = "p";
            insPlan.FeeSched = ppoFeeSchedNum;
            InsPlans.Update(insPlan, planOld);
            //Creates the claim in the same manner as the account module, including estimates.
            Claim     claim  = ClaimT.CreateClaim("P", patPlans, planList, claimProcs, ProcList, pat, ProcList, benefitList, subList);
            ClaimProc clProc = ClaimProcs.Refresh(pat.PatNum)[0];          //Should only be one

            Assert.AreEqual(80, clProc.InsEstTotal);
            Assert.AreEqual(60, clProc.WriteOff);
        }
 private PatPlan InsertOrUpdatePatPlan(PatPlan patPlan, InsSub insSub, InsPlan insPlan, Hx834_Member member,
                                       Carrier carrier, List <PatPlan> listOtherPatPlans)
 {
     if (patPlan == null)
     {
         patPlan         = new PatPlan();
         patPlan.Ordinal = 0;
         for (int p = 0; p < listOtherPatPlans.Count; p++)
         {
             if (listOtherPatPlans[p].Ordinal > patPlan.Ordinal)
             {
                 patPlan.Ordinal = listOtherPatPlans[p].Ordinal;
             }
         }
         patPlan.Ordinal++;                //Greatest ordinal for patient.
         patPlan.PatNum       = member.Pat.PatNum;
         patPlan.InsSubNum    = insSub.InsSubNum;
         patPlan.Relationship = member.PlanRelat;
         if (member.PlanRelat != Relat.Self)
         {
             //This is not needed yet.  If we do this in the future, then we need to mimic the Move tool in the Family module.
             //member.Pat.Guarantor=insSubMatch.Subscriber;
             //Patient memberPatOld=member.Pat.Copy();
             //Patients.Update(member.Pat,memberPatOld);
         }
         PatPlans.Insert(patPlan);
         SecurityLogs.MakeLogEntry(Permissions.InsPlanAddPat, patPlan.PatNum,
                                   "Insurance plan added to patient for carrier '" + carrier.CarrierName + "' and groupnum "
                                   + "'" + insPlan.GroupNum + "' and subscriber ID '" + insSub.SubscriberID + "' "
                                   + "from Import Ins Plans 834.", insPlan.PlanNum, LogSources.InsPlanImport834, insPlan.SecDateTEdit);
     }
     else
     {
         PatPlan patPlanOld = patPlan.Copy();
         patPlan.Relationship = member.PlanRelat;
         if (OpenDentBusiness.Crud.PatPlanCrud.UpdateComparison(patPlan, patPlanOld))
         {
             SecurityLogs.MakeLogEntry(Permissions.InsPlanEdit, patPlan.PatNum, "Insurance plan relationship changed from "
                                       + member.PlanRelat + " to " + patPlan.Relationship + " for carrier '" + carrier.CarrierName + "' and groupnum "
                                       + "'" + insPlan.GroupNum + "' from Import Ins Plans 834.", insPlan.PlanNum, LogSources.InsPlanImport834, insPlan.SecDateTEdit);
             PatPlans.Update(patPlan);
         }
     }
     return(patPlan);
 }
Beispiel #29
0
        public static string Run(int scriptNum, string responseExpected, Claim claim)
        {
            string           retVal         = "";
            InsPlan          insPlan        = InsPlans.GetPlan(claim.PlanNum, null);
            InsSub           insSub         = InsSubs.GetOne(claim.InsSubNum);
            long             etransNum      = CanadianOutput.SendClaimReversal(claim, insPlan, insSub);
            Etrans           etrans         = Etranss.GetEtrans(etransNum);
            string           message        = EtransMessageTexts.GetMessageText(etrans.EtransMessageTextNum);
            CCDFieldInputter formData       = new CCDFieldInputter(message);
            string           responseStatus = formData.GetValue("G05");

            if (responseStatus != responseExpected)
            {
                return("G05 should be " + responseExpected + "\r\n");
            }
            retVal += "Reversal #" + scriptNum.ToString() + " successful.\r\n";
            return(retVal);
        }
Beispiel #30
0
        ///<summary>Inserts one InsSub into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(InsSub insSub, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                insSub.InsSubNum = ReplicationServers.GetKey("inssub", "InsSubNum");
            }
            string command = "INSERT INTO inssub (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "InsSubNum,";
            }
            command += "PlanNum,Subscriber,DateEffective,DateTerm,ReleaseInfo,AssignBen,SubscriberID,BenefitNotes,SubscNote) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(insSub.InsSubNum) + ",";
            }
            command +=
                POut.Long(insSub.PlanNum) + ","
                + POut.Long(insSub.Subscriber) + ","
                + POut.Date(insSub.DateEffective) + ","
                + POut.Date(insSub.DateTerm) + ","
                + POut.Bool(insSub.ReleaseInfo) + ","
                + POut.Bool(insSub.AssignBen) + ","
                + "'" + POut.String(insSub.SubscriberID) + "',"
                + DbHelper.ParamChar + "paramBenefitNotes,"
                + "'" + POut.String(insSub.SubscNote) + "')";
            if (insSub.BenefitNotes == null)
            {
                insSub.BenefitNotes = "";
            }
            OdSqlParameter paramBenefitNotes = new OdSqlParameter("paramBenefitNotes", OdDbType.Text, insSub.BenefitNotes);

            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command, paramBenefitNotes);
            }
            else
            {
                insSub.InsSubNum = Db.NonQ(command, true, paramBenefitNotes);
            }
            return(insSub.InsSubNum);
        }
Beispiel #31
0
 ///<summary>Returns true if Update(InsSub,InsSub) would make changes to the database.
 ///Does not make any changes to the database and can be called before remoting role is checked.</summary>
 public static bool UpdateComparison(InsSub insSub, InsSub oldInsSub)
 {
     if (insSub.PlanNum != oldInsSub.PlanNum)
     {
         return(true);
     }
     if (insSub.Subscriber != oldInsSub.Subscriber)
     {
         return(true);
     }
     if (insSub.DateEffective.Date != oldInsSub.DateEffective.Date)
     {
         return(true);
     }
     if (insSub.DateTerm.Date != oldInsSub.DateTerm.Date)
     {
         return(true);
     }
     if (insSub.ReleaseInfo != oldInsSub.ReleaseInfo)
     {
         return(true);
     }
     if (insSub.AssignBen != oldInsSub.AssignBen)
     {
         return(true);
     }
     if (insSub.SubscriberID != oldInsSub.SubscriberID)
     {
         return(true);
     }
     if (insSub.BenefitNotes != oldInsSub.BenefitNotes)
     {
         return(true);
     }
     if (insSub.SubscNote != oldInsSub.SubscNote)
     {
         return(true);
     }
     //SecUserNumEntry excluded from update
     //SecDateEntry not allowed to change
     //SecDateTEdit can only be set by MySQL
     return(false);
 }
Beispiel #32
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<InsSub> TableToList(DataTable table){
			List<InsSub> retVal=new List<InsSub>();
			InsSub insSub;
			for(int i=0;i<table.Rows.Count;i++) {
				insSub=new InsSub();
				insSub.InsSubNum    = PIn.Long  (table.Rows[i]["InsSubNum"].ToString());
				insSub.PlanNum      = PIn.Long  (table.Rows[i]["PlanNum"].ToString());
				insSub.Subscriber   = PIn.Long  (table.Rows[i]["Subscriber"].ToString());
				insSub.DateEffective= PIn.Date  (table.Rows[i]["DateEffective"].ToString());
				insSub.DateTerm     = PIn.Date  (table.Rows[i]["DateTerm"].ToString());
				insSub.ReleaseInfo  = PIn.Bool  (table.Rows[i]["ReleaseInfo"].ToString());
				insSub.AssignBen    = PIn.Bool  (table.Rows[i]["AssignBen"].ToString());
				insSub.SubscriberID = PIn.String(table.Rows[i]["SubscriberID"].ToString());
				insSub.BenefitNotes = PIn.String(table.Rows[i]["BenefitNotes"].ToString());
				insSub.SubscNote    = PIn.String(table.Rows[i]["SubscNote"].ToString());
				retVal.Add(insSub);
			}
			return retVal;
		}
        public void FeeSchedTools_GlobalUpdateWriteoffEstimates()
        {
            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.FixedBenefit, 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);
            //Set up insurance
            InsuranceInfo  info         = InsuranceT.AddInsurance(pat, suffix, "c", feeSchedNum);
            List <InsSub>  listSubs     = info.ListInsSubs;
            List <InsPlan> listPlans    = info.ListInsPlans;
            List <PatPlan> listPatPlans = info.ListPatPlans;
            InsPlan        priPlan      = info.PriInsPlan;
            InsSub         priSub       = info.PriInsSub;

            info.ListBenefits.Add(BenefitT.CreatePercentForProc(priPlan.PlanNum, procCode.CodeNum, 90));
            //Create the procedure and claimproc
            Procedure proc         = ProcedureT.CreateProcedure(pat, procStr, ProcStat.TP, "", procFee);
            ClaimProc priClaimProc = ClaimProcT.CreateClaimProc(pat.PatNum, proc.ProcNum, priPlan.PlanNum, priSub.InsSubNum, DateTime.Today, -1, -1, -1,
                                                                ClaimProcStatus.CapEstimate);

            Procedures.ComputeEstimates(proc, pat.PatNum, new List <ClaimProc>(), true, listPlans, listPatPlans, info.ListBenefits, pat.Age, info.ListInsSubs);
            priClaimProc = ClaimProcs.Refresh(pat.PatNum).FirstOrDefault(x => x.ProcNum == proc.ProcNum);
            Assert.AreEqual(procFee, priClaimProc.WriteOff);
            procFee = 50;
            Procedure procNew = proc.Copy();

            procNew.ProcFee = procFee;
            Procedures.Update(procNew, proc);
            //GlobalUpdate
            long updated = GlobalUpdateWriteoffs(clinic.ClinicNum);

            Assert.AreEqual(1, updated);
            ClaimProc priClaimProcDb = ClaimProcs.Refresh(pat.PatNum).FirstOrDefault(x => x.ClaimProcNum == priClaimProc.ClaimProcNum);

            Assert.AreEqual(procFee, priClaimProcDb.WriteOff);
        }
Beispiel #34
0
		///<summary>Updates one InsSub in the database.</summary>
		public static void Update(InsSub insSub){
			string command="UPDATE inssub SET "
				+"PlanNum      =  "+POut.Long  (insSub.PlanNum)+", "
				+"Subscriber   =  "+POut.Long  (insSub.Subscriber)+", "
				+"DateEffective=  "+POut.Date  (insSub.DateEffective)+", "
				+"DateTerm     =  "+POut.Date  (insSub.DateTerm)+", "
				+"ReleaseInfo  =  "+POut.Bool  (insSub.ReleaseInfo)+", "
				+"AssignBen    =  "+POut.Bool  (insSub.AssignBen)+", "
				+"SubscriberID = '"+POut.String(insSub.SubscriberID)+"', "
				+"BenefitNotes =  "+DbHelper.ParamChar+"paramBenefitNotes, "
				+"SubscNote    = '"+POut.String(insSub.SubscNote)+"' "
				+"WHERE InsSubNum = "+POut.Long(insSub.InsSubNum);
			if(insSub.BenefitNotes==null) {
				insSub.BenefitNotes="";
			}
			OdSqlParameter paramBenefitNotes=new OdSqlParameter("paramBenefitNotes",OdDbType.Text,insSub.BenefitNotes);
			Db.NonQ(command,paramBenefitNotes);
		}
Beispiel #35
0
		///<summary>Only for creating the IN1 segment(s).</summary>
		public static string GenerateFieldIN1(HL7Def def,string fieldName,int sequenceNum,PatPlan patplanCur,InsSub inssubCur,InsPlan insplanCur,Carrier carrierCur,int patplanCount,Patient patSub) {
			switch(fieldName) {
				#region Carrier
				case "carrier.addressCityStateZip":
					if(carrierCur==null) {
						return "";
					}
					return gConcat(def.ComponentSeparator,carrierCur.Address,carrierCur.Address2,carrierCur.City,carrierCur.State,carrierCur.Zip);
				case "carrier.CarrierName":
					if(carrierCur==null) {
						return "";
					}
					return carrierCur.CarrierName;
				case "carrier.ElectID":
					if(carrierCur==null) {
						return "";
					}
					return carrierCur.ElectID;
				case "carrier.Phone":
					//Example: ^WPN^PH^^^800^3635432
					if(carrierCur==null) {
						return "";
					}
					string carrierPh=gXTN(carrierCur.Phone,10);
					if(carrierPh=="") {
						return "";
					}
					return gConcat(def.ComponentSeparator,"","WPN","PH","","",carrierPh.Substring(0,3),carrierPh.Substring(3));//carrierPh guaranteed to be 10 digits or blank
				#endregion Carrier
				#region InsPlan
				case "insplan.cob":
					if(insplanCur==null) {
						return "";
					}
					if(patplanCount>1) {
						return "CO";
					}
					return "IN";
				case "insplan.coverageType":
					if(insplanCur==null) {
						return "";
					}
					if(insplanCur.IsMedical) {
						return "M";
					}
					return "D";
				case "insplan.empName":
					if(insplanCur==null) {
						return "";
					}
					return Employers.GetName(insplanCur.EmployerNum);//will return empty string if EmployerNum=0 or not found
				case "insplan.GroupName":
					if(insplanCur==null) {
						return "";
					}
					return insplanCur.GroupName;
				case "insplan.GroupNum":
					if(insplanCur==null) {
						return "";
					}
					return insplanCur.GroupNum;
				case "insplan.planNum":
					//Example: 2.16.840.1.113883.3.4337.1486.6566.7.1234
					//If OID for insplan is not set, then it will be ODInsPlan.1234 (where 1234=PlanNum)
					if(insplanCur==null) {
						return "";
					}
					OIDInternal insplanOid=OIDInternals.GetForType(IdentifierType.InsPlan);//returns root+".7" or whatever they have set in their oidinternal table for type InsPlan
					string insplanOidRoot="ODInsPlan";
					if(insplanOid!=null && insplanOid.IDRoot!="") {
						insplanOidRoot=insplanOid.IDRoot;
					}
					return insplanOidRoot+"."+insplanCur.PlanNum;//tack on "."+PlanNum for extension
				case "insplan.PlanType":
					if(insplanCur==null) {
						return "";
					}
					if(insplanCur.PlanType=="p") {
						return "PPO Percentage";
					}
					if(insplanCur.PlanType=="f") {
						return "Medicaid or Flat Copay";
					}
					if(insplanCur.PlanType=="c") {
						return "Capitation";
					}
					return "Category Percentage";
				#endregion InsPlan
				#region InsSub
				case "inssub.AssignBen":
					if(inssubCur==null) {
						return "";
					}
					if(inssubCur.AssignBen) {
						return "Y";
					}
					return "N";
				case "inssub.DateEffective":
					if(inssubCur==null || inssubCur.DateEffective==DateTime.MinValue) {
						return "";
					}
					return gDTM(inssubCur.DateEffective,8);
				case "inssub.DateTerm":
					if(inssubCur==null || inssubCur.DateTerm==DateTime.MinValue) {
						return "";
					}
					return gDTM(inssubCur.DateTerm,8);
				case "inssub.ReleaseInfo":
					if(inssubCur==null) {
						return "";
					}
					if(inssubCur.ReleaseInfo) {
						return "Y";
					}
					return "N";
				case "inssub.subAddrCityStateZip":
					if(patSub==null) {
						return "";
					}
					return gConcat(def.ComponentSeparator,patSub.Address,patSub.Address2,patSub.City,patSub.State,patSub.Zip);
				case "inssub.subBirthdate":
					if(patSub==null) {
						return "";
					}
					return gDTM(patSub.Birthdate,8);
				case "inssub.SubscriberID":
					if(inssubCur==null) {
						return "";
					}
					return inssubCur.SubscriberID;
				case "inssub.subscriberName":
					if(patSub==null) {
						return "";
					}
					return gConcat(def.ComponentSeparator,patSub.LName,patSub.FName,patSub.MiddleI);
				#endregion InsSub
				#region PatPlan
				case "patplan.Ordinal":
					if(patplanCur==null) {
						return "";
					}
					return patplanCur.Ordinal.ToString();
				case "patplan.policyNum":
					if(patplanCur==null || inssubCur==null) {
						return "";
					}
					if(patplanCur.PatID!="") {
						return patplanCur.PatID;
					}
					return inssubCur.SubscriberID;
				case "patplan.subRelationToPat":
					//SEL-Self, SPO-Spouse, DOM-LifePartner, CHD-Child (PAR-Parent), EME-Employee (EMR-Employer)
					//DEP-HandicapDep (GRD-Guardian), DEP-Dependent, OTH-SignifOther (OTH-Other), OTH-InjuredPlantiff
					//We store relationship to subscriber and they want subscriber's relationship to patient, therefore
					//Relat.Child will return "PAR" for Parent, Relat.Employee will return "EMR" for Employer, and Relat.HandicapDep and Relat.Dependent will return "GRD" for Guardian
					//Example: |PAR^Parent|
					if(patplanCur==null) {
						return "";
					}
					if(patplanCur.Relationship==Relat.Self) {
						return gConcat(def.ComponentSeparator,"SEL","Self");
					}
					if(patplanCur.Relationship==Relat.Spouse) {
						return gConcat(def.ComponentSeparator,"SPO","Spouse");
					}
					if(patplanCur.Relationship==Relat.LifePartner) {
						return gConcat(def.ComponentSeparator,"DOM","Life Partner");
					}
					if(patplanCur.Relationship==Relat.Child) {
						return gConcat(def.ComponentSeparator,"PAR","Parent");
					}
					if(patplanCur.Relationship==Relat.Employee) {
						return gConcat(def.ComponentSeparator,"EMR","Employer");
					}
					if(patplanCur.Relationship==Relat.Dependent || patplanCur.Relationship==Relat.HandicapDep) {
						return gConcat(def.ComponentSeparator,"GRD","Guardian");
					}
					//if Relat.SignifOther or Relat.InjuredPlaintiff or any others
					return gConcat(def.ComponentSeparator,"OTH","Other");
				#endregion PatPlan
				case "sequenceNum":
					return sequenceNum.ToString();
				default:
					return "";
			}
		}
Beispiel #36
0
		///<summary>Updates one InsSub in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.  Returns true if an update occurred.</summary>
		public static bool Update(InsSub insSub,InsSub oldInsSub){
			string command="";
			if(insSub.PlanNum != oldInsSub.PlanNum) {
				if(command!=""){ command+=",";}
				command+="PlanNum = "+POut.Long(insSub.PlanNum)+"";
			}
			if(insSub.Subscriber != oldInsSub.Subscriber) {
				if(command!=""){ command+=",";}
				command+="Subscriber = "+POut.Long(insSub.Subscriber)+"";
			}
			if(insSub.DateEffective != oldInsSub.DateEffective) {
				if(command!=""){ command+=",";}
				command+="DateEffective = "+POut.Date(insSub.DateEffective)+"";
			}
			if(insSub.DateTerm != oldInsSub.DateTerm) {
				if(command!=""){ command+=",";}
				command+="DateTerm = "+POut.Date(insSub.DateTerm)+"";
			}
			if(insSub.ReleaseInfo != oldInsSub.ReleaseInfo) {
				if(command!=""){ command+=",";}
				command+="ReleaseInfo = "+POut.Bool(insSub.ReleaseInfo)+"";
			}
			if(insSub.AssignBen != oldInsSub.AssignBen) {
				if(command!=""){ command+=",";}
				command+="AssignBen = "+POut.Bool(insSub.AssignBen)+"";
			}
			if(insSub.SubscriberID != oldInsSub.SubscriberID) {
				if(command!=""){ command+=",";}
				command+="SubscriberID = '"+POut.String(insSub.SubscriberID)+"'";
			}
			if(insSub.BenefitNotes != oldInsSub.BenefitNotes) {
				if(command!=""){ command+=",";}
				command+="BenefitNotes = "+DbHelper.ParamChar+"paramBenefitNotes";
			}
			if(insSub.SubscNote != oldInsSub.SubscNote) {
				if(command!=""){ command+=",";}
				command+="SubscNote = '"+POut.String(insSub.SubscNote)+"'";
			}
			if(command==""){
				return false;
			}
			if(insSub.BenefitNotes==null) {
				insSub.BenefitNotes="";
			}
			OdSqlParameter paramBenefitNotes=new OdSqlParameter("paramBenefitNotes",OdDbType.Text,insSub.BenefitNotes);
			command="UPDATE inssub SET "+command
				+" WHERE InsSubNum = "+POut.Long(insSub.InsSubNum);
			Db.NonQ(command,paramBenefitNotes);
			return true;
		}