예제 #1
0
        private void butRun_Click(object sender, EventArgs e)
        {
            List <ClaimPaySplit> splits = Claims.GetInsPayNotAttachedForFixTool();

            if (splits.Count == 0)
            {
                MsgBox.Show(this, "There are currently no insurance payments that are not attached to an insurance check.");
                return;
            }
            Cursor = Cursors.WaitCursor;
            for (int i = 0; i < splits.Count; i++)
            {
                Claim        claim = Claims.GetClaim(splits[i].ClaimNum);
                ClaimPayment cp    = new ClaimPayment();
                cp.CheckDate   = claim.DateService;
                cp.CheckAmt    = splits[i].InsPayAmt;
                cp.ClinicNum   = claim.ClinicNum;
                cp.CarrierName = splits[i].Carrier;
                ClaimPayments.Insert(cp);
                List <ClaimProc> claimP = ClaimProcs.RefreshForClaim(splits[i].ClaimNum);
                for (int j = 0; j < claimP.Count; j++)
                {
                    claimP[j].DateCP          = claim.DateService;
                    claimP[j].ClaimPaymentNum = cp.ClaimPaymentNum;
                    ClaimProcs.Update(claimP[j]);
                }
            }
            Cursor = Cursors.Default;
            MessageBox.Show(Lan.g(this, "Insurance checks created: ") + splits.Count);
        }
예제 #2
0
        private void butRun_Click(object sender, EventArgs e)
        {
            List <ClaimPaySplit> splits = Claims.GetInsPayNotAttachedForFixTool();

            if (splits.Count == 0)
            {
                MsgBox.Show(this, "There are currently no insurance payments that are not attached to an insurance check.");
                DialogResult = DialogResult.OK;              //Close the window because there is nothing else to do
                return;
            }
            Cursor = Cursors.WaitCursor;
            string   invalidClaimDate = "";
            DateTime curDate          = MiscData.GetNowDateTime().Date;

            for (int i = 0; i < splits.Count; i++)
            {
                Claim claim = Claims.GetClaim(splits[i].ClaimNum);
                if (claim == null)
                {
                    continue;
                }
                if (claim.DateReceived.Date > curDate && !PrefC.GetBool(PrefName.AllowFutureInsPayments) && !PrefC.GetBool(PrefName.FutureTransDatesAllowed))
                {
                    invalidClaimDate += "\r\n" + Lan.g(this, "PatNum") + " " + claim.PatNum + ", " + claim.DateService.ToShortDateString();
                    continue;
                }
                ClaimPayment cp = new ClaimPayment();
                cp.CheckDate   = claim.DateReceived;
                cp.CheckAmt    = splits[i].InsPayAmt;
                cp.ClinicNum   = claim.ClinicNum;
                cp.CarrierName = splits[i].Carrier;
                cp.PayType     = Defs.GetFirstForCategory(DefCat.InsurancePaymentType, true).DefNum;
                ClaimPayments.Insert(cp);
                List <ClaimProc> claimP = ClaimProcs.RefreshForClaim(splits[i].ClaimNum);
                for (int j = 0; j < claimP.Count; j++)
                {
                    if (claimP[j].ClaimPaymentNum != 0 || claimP[j].InsPayAmt == 0) //If claimpayment already attached to claimproc or ins didn't pay.
                    {
                        continue;                                                   //Do not change
                    }
                    claimP[j].DateCP          = claim.DateReceived;
                    claimP[j].ClaimPaymentNum = cp.ClaimPaymentNum;
                    ClaimProcs.Update(claimP[j]);
                }
            }
            Cursor = Cursors.Default;
            if (invalidClaimDate != "")
            {
                invalidClaimDate = "\r\n" + Lan.g(this, "Cannot make future-dated insurance payments for these claims:") + invalidClaimDate;
            }
            MsgBoxCopyPaste messageBox = new MsgBoxCopyPaste(Lan.g(this, "Insurance checks created:") + " " + splits.Count + invalidClaimDate);

            messageBox.Show();
            DialogResult = DialogResult.OK;          //Close the window because there is nothing else to do
        }
예제 #3
0
 private void butOK_Click(object sender, System.EventArgs e)
 {
     if (textDate.errorProvider1.GetError(textDate) != "" ||
         textInsUsed.errorProvider1.GetError(textInsUsed) != "" ||
         textDedUsed.errorProvider1.GetError(textDedUsed) != ""
         )
     {
         MessageBox.Show(Lan.g("All", "Please fix data entry errors first."));
         return;
     }
     ClaimProcCur.ProcDate   = PIn.Date(textDate.Text);
     ClaimProcCur.InsPayAmt  = PIn.Double(textInsUsed.Text);
     ClaimProcCur.DedApplied = PIn.Double(textDedUsed.Text);
     if (IsNew)
     {
         ClaimProcs.Insert(ClaimProcCur);
     }
     else
     {
         ClaimProcs.Update(ClaimProcCur);
     }
     DialogResult = DialogResult.OK;
 }
예제 #4
0
        ///<summary>Updates all claimproc estimates and also updates claim totals to db. Must supply procList which includes all procedures that this claim is linked to.  Will also need to refresh afterwards to see the results</summary>
        public static void CalculateAndUpdate(List <Procedure> procList, List <InsPlan> planList, Claim claimCur, List <PatPlan> patPlans, List <Benefit> benefitList, int patientAge, List <InsSub> subList)
        {
            //we need more than just the claimprocs for this claim.
            //in order to run Procedures.ComputeEstimates, we need all claimprocs for all procedures attached to this claim
            List <ClaimProc> ClaimProcsAll      = ClaimProcs.Refresh(claimCur.PatNum);
            List <ClaimProc> ClaimProcsForClaim = ClaimProcs.RefreshForClaim(claimCur.ClaimNum);         //will be ordered by line number.
            double           claimFee           = 0;
            double           dedApplied         = 0;
            double           insPayEst          = 0;
            double           insPayAmt          = 0;
            double           writeoff           = 0;
            InsPlan          plan = InsPlans.GetPlan(claimCur.PlanNum, planList);

            if (plan == null)
            {
                return;
            }
            long patPlanNum = PatPlans.GetPatPlanNum(claimCur.InsSubNum, patPlans);

            //first loop handles totals for received items.
            for (int i = 0; i < ClaimProcsForClaim.Count; i++)
            {
                if (ClaimProcsForClaim[i].Status != ClaimProcStatus.Received)
                {
                    continue;                    //disregard any status except Receieved.
                }
                claimFee   += ClaimProcsForClaim[i].FeeBilled;
                dedApplied += ClaimProcsForClaim[i].DedApplied;
                insPayEst  += ClaimProcsForClaim[i].InsPayEst;
                insPayAmt  += ClaimProcsForClaim[i].InsPayAmt;
                writeoff   += ClaimProcsForClaim[i].WriteOff;
            }
            //loop again only for procs not received.
            //And for preauth.
            Procedure ProcCur;
            //InsPlan plan=InsPlans.GetPlan(claimCur.PlanNum,planList);
            List <ClaimProcHist> histList         = ClaimProcs.GetHistList(claimCur.PatNum, benefitList, patPlans, planList, claimCur.ClaimNum, claimCur.DateService, subList);
            List <ClaimProc>     claimProcListOld = new List <ClaimProc>();    //make a copy

            for (int i = 0; i < ClaimProcsAll.Count; i++)
            {
                claimProcListOld.Add(ClaimProcsAll[i].Copy());
            }
            List <ClaimProcHist> loopList = new List <ClaimProcHist>();

            for (int i = 0; i < ClaimProcsForClaim.Count; i++)       //loop through each proc
            {
                ProcCur = Procedures.GetProcFromList(procList, ClaimProcsForClaim[i].ProcNum);
                //in order for ComputeEstimates to give accurate Writeoff when creating a claim, InsPayEst must be filled for the claimproc with status of NotReceived.
                //So, we must set it here.  We need to set it in the claimProcsAll list.  Find the matching one.
                for (int j = 0; j < ClaimProcsAll.Count; j++)
                {
                    if (ClaimProcsAll[j].ClaimProcNum == ClaimProcsForClaim[i].ClaimProcNum)                  //same claimproc in a different list
                    {
                        if (ClaimProcsForClaim[i].Status == ClaimProcStatus.NotReceived &&
                            ProcCur != null)                             //ignores payments, etc
                        {
                            ClaimProcsAll[j].InsPayEst = ClaimProcs.GetInsEstTotal(ClaimProcsAll[j]);
                        }
                    }
                }
                //When this is the secondary claim, HistList includes the primary estimates, which is something we don't want because the primary calculations gets confused.
                //So, we must remove those bad entries from histList.
                for (int h = histList.Count - 1; h >= 0; h--)         //loop through the histList backwards
                {
                    if (histList[h].ProcNum != ProcCur.ProcNum)
                    {
                        continue;                        //Makes sure we will only be excluding histList entries for procs on this claim.
                    }
                    //we already excluded this claimNum when getting the histList.
                    if (histList[h].Status != ClaimProcStatus.NotReceived)
                    {
                        continue;                        //The only ones that are a problem are the ones on the primary claim not received yet.
                    }
                    histList.RemoveAt(h);
                }
                Procedures.ComputeEstimates(ProcCur, claimCur.PatNum, ref ClaimProcsAll, false, planList, patPlans, benefitList, histList, loopList, false, patientAge, subList);
                //then, add this information to loopList so that the next procedure is aware of it.
                loopList.AddRange(ClaimProcs.GetHistForProc(ClaimProcsAll, ProcCur.ProcNum, ProcCur.CodeNum));
            }
            //save changes in the list to the database
            ClaimProcs.Synch(ref ClaimProcsAll, claimProcListOld);
            ClaimProcsForClaim = ClaimProcs.RefreshForClaim(claimCur.ClaimNum);
            //But ClaimProcsAll has not been refreshed.
            for (int i = 0; i < ClaimProcsForClaim.Count; i++)
            {
                if (ClaimProcsForClaim[i].Status != ClaimProcStatus.NotReceived &&
                    ClaimProcsForClaim[i].Status != ClaimProcStatus.Preauth &&
                    ClaimProcsForClaim[i].Status != ClaimProcStatus.CapClaim)
                {
                    continue;
                }
                ProcCur = Procedures.GetProcFromList(procList, ClaimProcsForClaim[i].ProcNum);
                if (ProcCur.ProcNum == 0)
                {
                    continue;                    //ignores payments, etc
                }
                //fee:
                int qty = ProcCur.UnitQty + ProcCur.BaseUnits;
                if (qty == 0)
                {
                    qty = 1;
                }
                if (plan.ClaimsUseUCR)                 //use UCR for the provider of the procedure
                {
                    long provNum = ProcCur.ProvNum;
                    if (provNum == 0)                   //if no prov set, then use practice default.
                    {
                        provNum = PrefC.GetLong(PrefName.PracticeDefaultProv);
                    }
                    //get the fee based on code and prov fee sched
                    double feebilled = Fees.GetAmount0(ProcCur.CodeNum, ProviderC.ListLong[Providers.GetIndexLong(provNum)].FeeSched);
                    if (feebilled > ProcCur.ProcFee)
                    {
                        ClaimProcsForClaim[i].FeeBilled = qty * feebilled;
                    }
                    else
                    {
                        ClaimProcsForClaim[i].FeeBilled = qty * ProcCur.ProcFee;
                    }
                }
                //else if(claimCur.ClaimType=="Cap") {//Even for capitation, use the proc fee.
                //	ClaimProcsForClaim[i].FeeBilled=0;
                //}
                else                  //don't use ucr.  Use the procedure fee instead.
                {
                    ClaimProcsForClaim[i].FeeBilled = qty * ProcCur.ProcFee;
                }
                claimFee += ClaimProcsForClaim[i].FeeBilled;
                if (claimCur.ClaimType == "PreAuth" || claimCur.ClaimType == "Other" || claimCur.ClaimType == "Cap")
                {
                    //only the fee gets calculated, the rest does not
                    ClaimProcs.Update(ClaimProcsForClaim[i]);
                    continue;
                }
                //ClaimProcs.ComputeBaseEst(ClaimProcsForClaim[i],ProcCur.ProcFee,ProcCur.ToothNum,ProcCur.CodeNum,plan,patPlanNum,benefitList,histList,loopList);
                ClaimProcsForClaim[i].InsPayEst  = ClaimProcs.GetInsEstTotal(ClaimProcsForClaim[i]); //Yes, this is duplicated from further up.
                ClaimProcsForClaim[i].DedApplied = ClaimProcs.GetDedEst(ClaimProcsForClaim[i]);
                if (ClaimProcsForClaim[i].Status == ClaimProcStatus.NotReceived)                     //(vs preauth)
                {
                    ClaimProcsForClaim[i].WriteOff = ClaimProcs.GetWriteOffEstimate(ClaimProcsForClaim[i]);
                    writeoff += ClaimProcsForClaim[i].WriteOff;

                    /*
                     * ClaimProcsForClaim[i].WriteOff=0;
                     * if(claimCur.ClaimType=="P" && plan.PlanType=="p") {//Primary && PPO
                     *      double insplanAllowed=Fees.GetAmount(ProcCur.CodeNum,plan.FeeSched);
                     *      if(insplanAllowed!=-1) {
                     *              ClaimProcsForClaim[i].WriteOff=ProcCur.ProcFee-insplanAllowed;
                     *      }
                     *      //else, if -1 fee not found, then do not show a writeoff. User can change writeoff if they disagree.
                     * }
                     * writeoff+=ClaimProcsForClaim[i].WriteOff;*/
                }
                dedApplied += ClaimProcsForClaim[i].DedApplied;
                insPayEst  += ClaimProcsForClaim[i].InsPayEst;
                ClaimProcsForClaim[i].ProcDate = ProcCur.ProcDate.Date;              //this solves a rare bug. Keeps dates synched.
                //It's rare enough that I'm not goint to add it to the db maint tool.
                ClaimProcs.Update(ClaimProcsForClaim[i]);
                //but notice that the ClaimProcs lists are not refreshed until the loop is finished.
            }            //for claimprocs.forclaim
            claimCur.ClaimFee   = claimFee;
            claimCur.DedApplied = dedApplied;
            claimCur.InsPayEst  = insPayEst;
            claimCur.InsPayAmt  = insPayAmt;
            claimCur.WriteOff   = writeoff;
            //Cur=ClaimCur;
            Claims.Update(claimCur);
        }
예제 #5
0
        ///<summary>Updates all claimproc estimates and also updates claim totals to db. Must supply all claimprocs for this patient (or for this plan if fam max or ded).  Must supply procList which includes all procedures that this claim is linked to.  Will also need to refresh afterwards to see the results</summary>
        public static void CalculateAndUpdate(ClaimProc[] ClaimProcList, Procedure[] procList, InsPlan[] PlanList, Claim ClaimCur, PatPlan[] patPlans, Benefit[] benefitList)
        {
            ClaimProc[] ClaimProcsForClaim = ClaimProcs.GetForClaim(ClaimProcList, ClaimCur.ClaimNum);
            double      claimFee           = 0;
            double      dedApplied         = 0;
            double      insPayEst          = 0;
            double      insPayAmt          = 0;
            double      writeoff           = 0;
            InsPlan     PlanCur            = InsPlans.GetPlan(ClaimCur.PlanNum, PlanList);

            if (PlanCur == null)
            {
                return;
            }
            int    provNum;
            double dedRem;
            int    patPlanNum = PatPlans.GetPatPlanNum(patPlans, ClaimCur.PlanNum);
            //this next line has to be done outside the loop.  Takes annual max into consideration
            double insRem;            //no changes get made to insRem in the loop.

            if (patPlanNum == 0)      //patient does not have current coverage
            {
                insRem = 0;
            }
            else
            {
                insRem = InsPlans.GetInsRem(ClaimProcList, ClaimProcsForClaim[0].ProcDate, ClaimCur.PlanNum,
                                            patPlanNum, ClaimCur.ClaimNum, PlanList, benefitList);
            }
            //first loop handles totals for received items.
            for (int i = 0; i < ClaimProcsForClaim.Length; i++)
            {
                if (ClaimProcsForClaim[i].Status != ClaimProcStatus.Received)
                {
                    continue;                    //disregard any status except Receieved.
                }
                claimFee   += ClaimProcsForClaim[i].FeeBilled;
                dedApplied += ClaimProcsForClaim[i].DedApplied;
                insPayEst  += ClaimProcsForClaim[i].InsPayEst;
                insPayAmt  += ClaimProcsForClaim[i].InsPayAmt;
            }
            //loop again only for procs not received.
            //And for preauth.
            Procedure ProcCur;

            for (int i = 0; i < ClaimProcsForClaim.Length; i++)
            {
                if (ClaimProcsForClaim[i].Status != ClaimProcStatus.NotReceived &&
                    ClaimProcsForClaim[i].Status != ClaimProcStatus.Preauth)
                {
                    continue;
                }
                ProcCur = Procedures.GetProc(procList, ClaimProcsForClaim[i].ProcNum);
                if (ProcCur.ProcNum == 0)
                {
                    continue;                    //ignores payments, etc
                }
                //fee:
                int qty = ProcCur.UnitQty + ProcCur.BaseUnits;
                if (qty == 0)
                {
                    qty = 1;
                }
                if (PlanCur.ClaimsUseUCR)                //use UCR for the provider of the procedure
                {
                    provNum = ProcCur.ProvNum;
                    if (provNum == 0)                  //if no prov set, then use practice default.
                    {
                        provNum = PrefB.GetInt("PracticeDefaultProv");
                    }
                    ClaimProcsForClaim[i].FeeBilled = qty * (Fees.GetAmount0(                //get the fee based on code and prov fee sched
                                                                 ProcCur.CodeNum, Providers.ListLong[Providers.GetIndexLong(provNum)].FeeSched));
                }
                else                 //don't use ucr.  Use the procedure fee instead.
                {
                    ClaimProcsForClaim[i].FeeBilled = qty * ProcCur.ProcFee;
                }
                claimFee += ClaimProcsForClaim[i].FeeBilled;
                if (ClaimCur.ClaimType == "PreAuth" || ClaimCur.ClaimType == "Other")
                {
                    //only the fee gets calculated, the rest does not
                    ClaimProcs.Update(ClaimProcsForClaim[i]);
                    continue;
                }
                //deduct:
                if (patPlanNum == 0)              //patient does not have current coverage
                {
                    dedRem = 0;
                }
                else
                {
                    dedRem = InsPlans.GetDedRem(ClaimProcList, ClaimProcsForClaim[i].ProcDate, ClaimCur.PlanNum, patPlanNum,
                                                ClaimCur.ClaimNum, PlanList, benefitList, ProcedureCodes.GetStringProcCode(ProcCur.CodeNum))
                             - dedApplied;                  //subtracts deductible amounts already applied on this claim
                    if (dedRem < 0)
                    {
                        dedRem = 0;
                    }
                }
                if (dedRem > ClaimProcsForClaim[i].FeeBilled)                //if deductible is more than cost of procedure
                {
                    ClaimProcsForClaim[i].DedApplied = ClaimProcsForClaim[i].FeeBilled;
                }
                else
                {
                    ClaimProcsForClaim[i].DedApplied = dedRem;
                }
                if (ClaimCur.ClaimType == "P")                                                                                 //primary
                {
                    ClaimProcs.ComputeBaseEst(ClaimProcsForClaim[i], ProcCur, PriSecTot.Pri, PlanList, patPlans, benefitList); //handles dedBeforePerc
                    ClaimProcsForClaim[i].InsPayEst = Procedures.GetEst(ProcCur, ClaimProcList, PriSecTot.Pri, patPlans, true);
                }
                else if (ClaimCur.ClaimType == "S")              //secondary
                {
                    ClaimProcs.ComputeBaseEst(ClaimProcsForClaim[i], ProcCur, PriSecTot.Sec, PlanList, patPlans, benefitList);
                    ClaimProcsForClaim[i].InsPayEst = Procedures.GetEst(ProcCur, ClaimProcList, PriSecTot.Sec, patPlans, true);
                }
                if (ClaimCur.ClaimType == "P" || ClaimCur.ClaimType == "S")
                {
                    if (ClaimProcsForClaim[i].DedBeforePerc)
                    {
                        int percent = 100;
                        if (ClaimProcsForClaim[i].Percentage != -1)
                        {
                            percent = ClaimProcsForClaim[i].Percentage;
                        }
                        if (ClaimProcsForClaim[i].PercentOverride != -1)
                        {
                            percent = ClaimProcsForClaim[i].PercentOverride;
                        }
                        ClaimProcsForClaim[i].InsPayEst -= ClaimProcsForClaim[i].DedApplied * (double)percent / 100d;
                    }
                    else
                    {
                        ClaimProcsForClaim[i].InsPayEst -= ClaimProcsForClaim[i].DedApplied;
                    }
                }
                //claimtypes other than P and S only changed manually
                if (ClaimProcsForClaim[i].InsPayEst < 0)
                {
                    //example: if inspayest = 19 - 50(ded) for total of -31.
                    ClaimProcsForClaim[i].DedApplied += ClaimProcsForClaim[i].InsPayEst;                  //eg. 50+(-31)=19
                    ClaimProcsForClaim[i].InsPayEst   = 0;
                    //so only 19 of deductible gets applied, and inspayest is 0
                }
                if (insRem - insPayEst < 0)             //total remaining ins-Estimated so far on this claim
                {
                    ClaimProcsForClaim[i].InsPayEst = 0;
                }
                else if (ClaimProcsForClaim[i].InsPayEst > insRem - insPayEst)
                {
                    ClaimProcsForClaim[i].InsPayEst = insRem - insPayEst;
                }
                if (ClaimProcsForClaim[i].Status == ClaimProcStatus.NotReceived)
                {
                    ClaimProcsForClaim[i].WriteOff = 0;
                    if (ClaimCur.ClaimType == "P" && PlanCur.PlanType == "p")                //Primary && PPO
                    {
                        double insplanAllowed = Fees.GetAmount(ProcCur.CodeNum, PlanCur.FeeSched);
                        if (insplanAllowed != -1)
                        {
                            ClaimProcsForClaim[i].WriteOff = ProcCur.ProcFee - insplanAllowed;
                        }
                        //else, if -1 fee not found, then do not show a writeoff. User can change writeoff if they disagree.
                    }
                    writeoff += ClaimProcsForClaim[i].WriteOff;
                }
                dedApplied += ClaimProcsForClaim[i].DedApplied;
                insPayEst  += ClaimProcsForClaim[i].InsPayEst;
                ClaimProcs.Update(ClaimProcsForClaim[i]);
                //but notice that the ClaimProcs lists are not refreshed until the loop is finished.
            }            //for claimprocs.forclaim
            ClaimCur.ClaimFee   = claimFee;
            ClaimCur.DedApplied = dedApplied;
            ClaimCur.InsPayEst  = insPayEst;
            ClaimCur.InsPayAmt  = insPayAmt;
            ClaimCur.WriteOff   = writeoff;
            //Cur=ClaimCur;
            Update(ClaimCur);
        }
예제 #6
0
        ///<summary>Updates all claimproc estimates and also updates claim totals to db. Must supply all claimprocs for this patient.  Must supply procList which includes all procedures that this claim is linked to.  Will also need to refresh afterwards to see the results</summary>
        public static void CalculateAndUpdate(ClaimProc[] ClaimProcList, Procedure[] procList, InsPlan[] PlanList, Claim ClaimCur, PatPlan[] patPlans, Benefit[] benefitList)
        {
            //Remember that this can be called externally also
            //ClaimProcList=claimProcList;
            ClaimProc[] ClaimProcsForClaim = ClaimProcs.GetForClaim(ClaimProcList, ClaimCur.ClaimNum);
            double      claimFee           = 0;
            double      dedApplied         = 0;
            double      insPayEst          = 0;
            double      insPayAmt          = 0;
            InsPlan     PlanCur            = InsPlans.GetPlan(ClaimCur.PlanNum, PlanList);

            if (PlanCur == null)
            {
                return;
            }
            //InsPlans.Cur=(InsPlan)InsPlans.HList[ClaimCur.PlanNum];
            int    provNum;
            double dedRem;
            int    patPlanNum = PatPlans.GetPatPlanNum(patPlans, ClaimCur.PlanNum);
            //this next line has to be done outside the loop.  Takes annual max into consideration
            double insRem;            //no changes get made to insRem in the loop.

            if (patPlanNum == 0)      //patient does not have current coverage
            {
                insRem = 0;
            }
            else
            {
                insRem = InsPlans.GetInsRem(ClaimProcList, ClaimProcsForClaim[0].ProcDate, ClaimCur.PlanNum,
                                            patPlanNum, ClaimCur.ClaimNum, PlanList, benefitList);
            }
            //first loop handles totals for received items.
            for (int i = 0; i < ClaimProcsForClaim.Length; i++)
            {
                if (ClaimProcsForClaim[i].Status != ClaimProcStatus.Received)
                {
                    continue;                    //disregard any status except Receieved.
                }
                claimFee   += ClaimProcsForClaim[i].FeeBilled;
                dedApplied += ClaimProcsForClaim[i].DedApplied;
                insPayEst  += ClaimProcsForClaim[i].InsPayEst;
                insPayAmt  += ClaimProcsForClaim[i].InsPayAmt;
            }
            //loop again only for procs not received.
            //And for preauth.
            Procedure ProcCur;

            for (int i = 0; i < ClaimProcsForClaim.Length; i++)
            {
                if (ClaimProcsForClaim[i].Status != ClaimProcStatus.NotReceived &&
                    ClaimProcsForClaim[i].Status != ClaimProcStatus.Preauth)
                {
                    continue;
                }
                ProcCur = Procedures.GetProc(procList, ClaimProcsForClaim[i].ProcNum);
                if (ProcCur.ProcNum == 0)
                {
                    continue;                    //ignores payments, etc
                }
                //fee:
                if (PlanCur.ClaimsUseUCR)                //use UCR for the provider of the procedure
                {
                    provNum = ProcCur.ProvNum;
                    if (provNum == 0)                  //if no prov set, then use practice default.
                    {
                        provNum = PrefB.GetInt("PracticeDefaultProv");
                    }
                    ClaimProcsForClaim[i].FeeBilled = Fees.GetAmount0(                  //get the fee based on ada and prov fee sched
                        ProcCur.ADACode
                        , Providers.ListLong[Providers.GetIndexLong(provNum)].FeeSched);
                }
                else                 //don't use ucr.  Use the procedure fee instead.
                {
                    ClaimProcsForClaim[i].FeeBilled = ProcCur.ProcFee;
                }
                claimFee += ClaimProcsForClaim[i].FeeBilled;
                if (ClaimCur.ClaimType == "PreAuth" || ClaimCur.ClaimType == "Other")
                {
                    //only the fee gets calculated, the rest does not
                    ClaimProcs.Update(ClaimProcsForClaim[i]);
                    continue;
                }
                //deduct:
                if (patPlanNum == 0)              //patient does not have current coverage
                {
                    dedRem = 0;
                }
                else
                {
                    dedRem = InsPlans.GetDedRem(ClaimProcList, ClaimProcsForClaim[i].ProcDate, ClaimCur.PlanNum, patPlanNum,
                                                ClaimCur.ClaimNum, PlanList, benefitList, ProcCur.ADACode)
                             - dedApplied;                  //subtracts deductible amounts already applied on this claim
                    if (dedRem < 0)
                    {
                        dedRem = 0;
                    }
                }
                if (dedRem > ClaimProcsForClaim[i].FeeBilled)                //if deductible is more than cost of procedure
                {
                    ClaimProcsForClaim[i].DedApplied = ClaimProcsForClaim[i].FeeBilled;
                }
                else
                {
                    ClaimProcsForClaim[i].DedApplied = dedRem;
                }
                //??obsolete: if dedApplied is too big, it might be adjusted in the next few lines.??
                //insest:
                //Unlike deductible, we do not need to take into account any of the received claimprocs when calculating insest.  So insRem takes care of annual max rather than received+est.
                //if(patPlanNum==0){//patient does not have current coverage
                //	insRem=0;
                //}
                //else{
                //insRem-=insPayEst;//subtracts insest amounts already applied on this claim
                //insRem=InsPlans.GetInsRem(ClaimProcList,ClaimProcsForClaim[i].ProcDate,ClaimCur.PlanNum,
                //	patPlanNum,ClaimCur.ClaimNum,PlanList,benefitList)
                //	-insPayEst;//subtracts insest amounts already applied on this claim
                //	if(insRem<0) {
                //		insRem=0;
                //	}
                //}
                if (ClaimCur.ClaimType == "P")                                                                                 //primary
                {
                    ClaimProcs.ComputeBaseEst(ClaimProcsForClaim[i], ProcCur, PriSecTot.Pri, PlanList, patPlans, benefitList); //handles dedBeforePerc
                    ClaimProcsForClaim[i].InsPayEst = Procedures.GetEst(ProcCur, ClaimProcList, PriSecTot.Pri, patPlans, true);
                    //ClaimProcsForClaim[i].BaseEst;
                    if (!ClaimProcsForClaim[i].DedBeforePerc)
                    {
                        ClaimProcsForClaim[i].InsPayEst -= ClaimProcsForClaim[i].DedApplied;
                    }
                }
                else if (ClaimCur.ClaimType == "S")              //secondary
                {
                    ClaimProcs.ComputeBaseEst(ClaimProcsForClaim[i], ProcCur, PriSecTot.Sec, PlanList, patPlans, benefitList);
                    ClaimProcsForClaim[i].InsPayEst = Procedures.GetEst(ProcCur, ClaimProcList, PriSecTot.Sec, patPlans, true);
                    //ClaimProcsForClaim[i].BaseEst;
                    if (!ClaimProcsForClaim[i].DedBeforePerc)
                    {
                        ClaimProcsForClaim[i].InsPayEst -= ClaimProcsForClaim[i].DedApplied;
                    }
                }
                //other claimtypes only changed manually
                if (ClaimProcsForClaim[i].InsPayEst < 0)
                {
                    //example: if inspayest = 19 - 50(ded) for total of -31.
                    ClaimProcsForClaim[i].DedApplied += ClaimProcsForClaim[i].InsPayEst;                  //eg. 50+(-31)=19
                    ClaimProcsForClaim[i].InsPayEst   = 0;
                    //so only 19 of deductible gets applied, and inspayest is 0
                }
                if (insRem - insPayEst < 0)             //total remaining ins-Estimated so far on this claim
                {
                    ClaimProcsForClaim[i].InsPayEst = 0;
                }
                else if (ClaimProcsForClaim[i].InsPayEst > insRem - insPayEst)
                {
                    ClaimProcsForClaim[i].InsPayEst = insRem - insPayEst;
                }
                dedApplied += ClaimProcsForClaim[i].DedApplied;
                insPayEst  += ClaimProcsForClaim[i].InsPayEst;
                ClaimProcs.Update(ClaimProcsForClaim[i]);
                //but notice that the ClaimProcs lists are not refreshed until the loop is finished.
            }            //for claimprocs.forclaim
            ClaimCur.ClaimFee   = claimFee;
            ClaimCur.DedApplied = dedApplied;
            ClaimCur.InsPayEst  = insPayEst;
            ClaimCur.InsPayAmt  = insPayAmt;
            //Cur=ClaimCur;
            Update(ClaimCur);
        }
예제 #7
0
        private Claim CreateClaim(string claimType, List <PatPlan> patPlanList, List <InsPlan> planList, List <ClaimProc> claimProcList, Procedure proc, List <InsSub> subList)
        {
            long           claimFormNum = 0;
            InsPlan        planCur      = new InsPlan();
            InsSub         subCur       = new InsSub();
            Relat          relatOther   = Relat.Self;
            long           clinicNum    = proc.ClinicNum;
            PlaceOfService placeService = proc.PlaceService;

            switch (claimType)
            {
            case "P":
                subCur  = InsSubs.GetSub(PatPlans.GetInsSubNum(patPlanList, PatPlans.GetOrdinal(PriSecMed.Primary, patPlanList, planList, subList)), subList);
                planCur = InsPlans.GetPlan(subCur.PlanNum, planList);
                break;

            case "S":
                subCur  = InsSubs.GetSub(PatPlans.GetInsSubNum(patPlanList, PatPlans.GetOrdinal(PriSecMed.Secondary, patPlanList, planList, subList)), subList);
                planCur = InsPlans.GetPlan(subCur.PlanNum, planList);
                break;

            case "Med":
                //It's already been verified that a med plan exists
                subCur  = InsSubs.GetSub(PatPlans.GetInsSubNum(patPlanList, PatPlans.GetOrdinal(PriSecMed.Medical, patPlanList, planList, subList)), subList);
                planCur = InsPlans.GetPlan(subCur.PlanNum, planList);
                break;
            }
            ClaimProc claimProcCur = Procedures.GetClaimProcEstimate(proc.ProcNum, claimProcList, planCur, subCur.InsSubNum);

            if (claimProcCur == null)
            {
                claimProcCur = new ClaimProc();
                ClaimProcs.CreateEst(claimProcCur, proc, planCur, subCur);
            }
            Claim claimCur = new Claim();

            claimCur.PatNum       = proc.PatNum;
            claimCur.DateService  = proc.ProcDate;
            claimCur.ClinicNum    = proc.ClinicNum;
            claimCur.PlaceService = proc.PlaceService;
            claimCur.ClaimStatus  = "W";
            claimCur.DateSent     = DateTimeOD.Today;
            claimCur.PlanNum      = planCur.PlanNum;
            claimCur.InsSubNum    = subCur.InsSubNum;
            InsSub sub;

            switch (claimType)
            {
            case "P":
                claimCur.PatRelat   = PatPlans.GetRelat(patPlanList, PatPlans.GetOrdinal(PriSecMed.Primary, patPlanList, planList, subList));
                claimCur.ClaimType  = "P";
                claimCur.InsSubNum2 = PatPlans.GetInsSubNum(patPlanList, PatPlans.GetOrdinal(PriSecMed.Secondary, patPlanList, planList, subList));
                sub = InsSubs.GetSub(claimCur.InsSubNum2, subList);
                if (sub.PlanNum > 0 && InsPlans.RefreshOne(sub.PlanNum).IsMedical)
                {
                    claimCur.PlanNum2  = 0;                         //no sec ins
                    claimCur.PatRelat2 = Relat.Self;
                }
                else
                {
                    claimCur.PlanNum2  = sub.PlanNum;                         //might be 0 if no sec ins
                    claimCur.PatRelat2 = PatPlans.GetRelat(patPlanList, PatPlans.GetOrdinal(PriSecMed.Secondary, patPlanList, planList, subList));
                }
                break;

            case "S":
                claimCur.PatRelat   = PatPlans.GetRelat(patPlanList, PatPlans.GetOrdinal(PriSecMed.Secondary, patPlanList, planList, subList));
                claimCur.ClaimType  = "S";
                claimCur.InsSubNum2 = PatPlans.GetInsSubNum(patPlanList, PatPlans.GetOrdinal(PriSecMed.Primary, patPlanList, planList, subList));
                sub = InsSubs.GetSub(claimCur.InsSubNum2, subList);
                claimCur.PlanNum2  = sub.PlanNum;
                claimCur.PatRelat2 = PatPlans.GetRelat(patPlanList, PatPlans.GetOrdinal(PriSecMed.Primary, patPlanList, planList, subList));
                break;

            case "Med":
                claimCur.PatRelat  = PatPlans.GetFromList(patPlanList, subCur.InsSubNum).Relationship;
                claimCur.ClaimType = "Other";
                if (PrefC.GetBool(PrefName.ClaimMedTypeIsInstWhenInsPlanIsMedical))
                {
                    claimCur.MedType = EnumClaimMedType.Institutional;
                }
                else
                {
                    claimCur.MedType = EnumClaimMedType.Medical;
                }
                break;

            case "Other":
                claimCur.PatRelat  = relatOther;
                claimCur.ClaimType = "Other";
                //plannum2 is not automatically filled in.
                claimCur.ClaimForm = claimFormNum;
                if (planCur.IsMedical)
                {
                    if (PrefC.GetBool(PrefName.ClaimMedTypeIsInstWhenInsPlanIsMedical))
                    {
                        claimCur.MedType = EnumClaimMedType.Institutional;
                    }
                    else
                    {
                        claimCur.MedType = EnumClaimMedType.Medical;
                    }
                }
                break;
            }
            if (planCur.PlanType == "c")          //if capitation
            {
                claimCur.ClaimType = "Cap";
            }
            claimCur.ProvTreat = proc.ProvNum;
            if (Providers.GetIsSec(proc.ProvNum))
            {
                claimCur.ProvTreat = Patients.GetPat(proc.PatNum).PriProv;
                //OK if zero, because auto select first in list when open claim
            }
            claimCur.IsProsthesis  = "N";
            claimCur.ProvBill      = Providers.GetBillingProvNum(claimCur.ProvTreat, claimCur.ClinicNum);    //OK if zero, because it will get fixed in claim
            claimCur.EmployRelated = YN.No;
            claimCur.ClaimForm     = planCur.ClaimFormNum;
            Claims.Insert(claimCur);
            //attach procedure
            claimProcCur.ClaimNum = claimCur.ClaimNum;
            if (planCur.PlanType == "c")           //if capitation
            {
                claimProcCur.Status = ClaimProcStatus.CapClaim;
            }
            else
            {
                claimProcCur.Status = ClaimProcStatus.NotReceived;
            }
            if (planCur.UseAltCode && (ProcedureCodes.GetProcCode(proc.CodeNum).AlternateCode1 != ""))
            {
                claimProcCur.CodeSent = ProcedureCodes.GetProcCode(proc.CodeNum).AlternateCode1;
            }
            else if (planCur.IsMedical && proc.MedicalCode != "")
            {
                claimProcCur.CodeSent = proc.MedicalCode;
            }
            else
            {
                claimProcCur.CodeSent = ProcedureCodes.GetProcCode(proc.CodeNum).ProcCode;
                if (claimProcCur.CodeSent.Length > 5 && claimProcCur.CodeSent.Substring(0, 1) == "D")
                {
                    claimProcCur.CodeSent = claimProcCur.CodeSent.Substring(0, 5);
                }
                if (CultureInfo.CurrentCulture.Name.EndsWith("CA"))         //Canadian. en-CA or fr-CA
                {
                    if (claimProcCur.CodeSent.Length > 5)                   //In Canadian e-claims, codes can contain letters or numbers and cannot be longer than 5 characters.
                    {
                        claimProcCur.CodeSent = claimProcCur.CodeSent.Substring(0, 5);
                    }
                }
            }
            claimProcCur.LineNumber = (byte)1;
            ClaimProcs.Update(claimProcCur);
            return(claimCur);
        }