Beispiel #1
0
        ///<summary>Pass in list of procedures and covCat, return the sum of all CanadaTimeUnits of the procedures in that covCat as a double.</summary>
        private double GetAmtUsedForCat(List <Procedure> listProcs, CovCat covCat)
        {
            List <ProcedureCode> listProcCodes = new List <ProcedureCode>();

            for (int i = 0; i < listProcs.Count; i++)
            {
                listProcCodes.Add(ProcedureCodes.GetProcCode(listProcs[i].CodeNum)); //turn list of procedures into list of procedurecodes.
            }
            double total = 0;                                                        //CanadaTimeUnits can be decimal numbers, like 0.5.

            for (int i = 0; i < listProcCodes.Count; i++)                            //for every procedurecode
            //Can be null if the procedure doesn't fall within any spans (like note proc, the code is "clinical" so doesn't fall inside any spans)
            {
                CovCat benCat = CovCats.GetCovCat(CovSpans.GetCat(listProcCodes[i].ProcCode));
                //if the covCat of that code is the same as the passed-in covCat
                if (benCat != null && benCat.EbenefitCat == covCat.EbenefitCat)
                {
                    total += listProcCodes[i].CanadaTimeUnits;                   //add the Canada time units to the total.
                }
            }
            return(total);
        }
Beispiel #2
0
        private void FillGrid()
        {
            gridRemainTimeUnits.BeginUpdate();
            gridRemainTimeUnits.ListGridRows.Clear();
            List <PatPlan> listPatPlans    = PatPlans.Refresh(_patCur.PatNum);
            List <InsSub>  listInsSubs     = InsSubs.GetMany(listPatPlans.Select(x => x.InsSubNum).ToList());
            List <Benefit> listPatBenefits = Benefits.Refresh(listPatPlans, listInsSubs);

            if (listPatBenefits.IsNullOrEmpty())
            {
                gridRemainTimeUnits.EndUpdate();
                return;
            }
            List <InsPlan> listInsPlans = InsPlans.GetByInsSubs(listInsSubs.Select(x => x.InsSubNum).ToList());
            List <Carrier> listCarriers = Carriers.GetCarriers(listInsPlans.Select(x => x.CarrierNum).ToList());
            //Get the LIM information for all potential subscribers.
            List <Patient> listSubscribers = Patients.GetLimForPats(listInsSubs.Select(x => x.Subscriber).ToList());
            GridRow        gridRow;
            //Get the last year of completed procedures because there is no current TimePeriod for benefits that will care about older procedures.
            //A subset of these procedures will be used for each specific benefit in order to correctly represent the time units remaining.
            List <Procedure> listCompletedProcs = Procedures.GetCompletedForDateRange(
                DateTime.Today.AddYears(-1),
                DateTimeOD.Today,
                listPatNums: new List <long> {
                _patCur.PatNum
            });
            //Get all of the claimprocs associated to the completed procedures in order to link procedures to insurance plans.
            List <ClaimProc> listClaimProcs = ClaimProcs.GetForProcs(listCompletedProcs.Select(x => x.ProcNum).ToList());

            foreach (Benefit benefit in listPatBenefits)
            {
                if (benefit.CovCatNum == 0 ||           //no category
                    benefit.BenefitType != InsBenefitType.Limitations ||                     //benefit type is not limitations
                    (benefit.TimePeriod != BenefitTimePeriod.CalendarYear &&                     //neither calendar year, serviceyear, or 12 months
                     benefit.TimePeriod != BenefitTimePeriod.ServiceYear &&
                     benefit.TimePeriod != BenefitTimePeriod.NumberInLast12Months) ||
                    benefit.Quantity < 0 ||                    //quantity is negative (negatives are allowed in FormBenefitEdit)
                    benefit.QuantityQualifier != BenefitQuantity.NumberOfServices ||                    //qualifier us not the number of services
                    (benefit.CoverageLevel != BenefitCoverageLevel.Family &&                     //neither individual nor family coverage level
                     benefit.CoverageLevel != BenefitCoverageLevel.Individual))
                {
                    continue;
                }
                List <Procedure> listProcs;
                //for calendar year, get completed procs from January.01.CurYear ~ Curdate
                if (benefit.TimePeriod == BenefitTimePeriod.CalendarYear)
                {
                    //01/01/CurYear. is there a better way?
                    listProcs = listCompletedProcs.FindAll(x => x.ProcDate >= new DateTime(DateTimeOD.Today.Year, 1, 1));
                }
                else if (benefit.TimePeriod == BenefitTimePeriod.NumberInLast12Months)
                {
                    //today - 12 months - 1 day. Procedures exactly 1 year ago are not counted in the range
                    listProcs = listCompletedProcs.FindAll(x => x.ProcDate >= DateTimeOD.Today.AddYears(-1).AddDays(1));
                }
                else                                                                  //if not calendar year, then it must be service year
                {
                    int monthRenew = InsPlans.RefreshOne(benefit.PlanNum).MonthRenew; //monthrenew only stores the month as an int.
                    if (DateTimeOD.Today.Month >= monthRenew)                         //if the the current date is past the renewal month, use the current year
                    {
                        listProcs = listCompletedProcs.FindAll(x => x.ProcDate >= new DateTime(DateTimeOD.Today.Year, monthRenew, 1));
                    }
                    else                       //otherwise use the previous year
                    {
                        listProcs = listCompletedProcs.FindAll(x => x.ProcDate >= new DateTime(DateTimeOD.Today.Year - 1, monthRenew, 1));
                    }
                }
                Dictionary <long, List <ClaimProc> > dictClaimProcsPerSub;
                if (benefit.PatPlanNum != 0)
                {
                    //The list of benefits that we are looping through was filled via listPatPlans so this will never fail.
                    //If this line fails then it means that there was a valid PlanNum AND a valid PatPlanNum set on the benefit which is invalid ATM.
                    dictClaimProcsPerSub = listClaimProcs.FindAll(x => x.InsSubNum == listPatPlans.First(y => y.PatPlanNum == benefit.PatPlanNum).InsSubNum)
                                           .GroupBy(x => x.InsSubNum)
                                           .ToDictionary(x => x.Key, x => x.ToList());
                }
                else                  //benefit.PatPlanNum was not set so benefit.PlanNum must be set.
                {
                    dictClaimProcsPerSub = listClaimProcs.FindAll(x => x.PlanNum == benefit.PlanNum)
                                           .GroupBy(x => x.InsSubNum)
                                           .ToDictionary(x => x.Key, x => x.ToList());
                }
                foreach (long insSubNum in dictClaimProcsPerSub.Keys)
                {
                    //The insSubNum should have a corresponding entry within listInsSubs.
                    InsSub insSub = listInsSubs.FirstOrDefault(x => x.InsSubNum == insSubNum);
                    if (insSub == null)
                    {
                        continue;                        //If not found then there are claimprocs associated to an inssub that is associated to a dropped or missing plan.
                    }
                    InsPlan insPlan    = listInsPlans.FirstOrDefault(x => x.PlanNum == insSub.PlanNum);
                    Carrier carrier    = listCarriers.FirstOrDefault(x => x.CarrierNum == insPlan.CarrierNum);
                    Patient subscriber = listSubscribers.FirstOrDefault(x => x.PatNum == insSub.Subscriber);
                    CovCat  category   = CovCats.GetCovCat(benefit.CovCatNum);
                    //Filter out any procedures that are not associated to the insurance plan of the current benefit.
                    List <Procedure> listFilterProcs = listProcs.FindAll(x => x.ProcNum.In(dictClaimProcsPerSub[insSubNum].Select(y => y.ProcNum)));
                    //Calculate the amount used for one benefit.
                    double amtUsed   = CovCats.GetAmtUsedForCat(listFilterProcs, category);
                    double amtRemain = benefit.Quantity - amtUsed;
                    gridRow = new GridRow((carrier == null) ? "Unknown" : carrier.CarrierName,
                                          (subscriber == null) ? "Unknown" : subscriber.GetNameFL(),
                                          category.Description.ToString(),
                                          benefit.Quantity.ToString(),
                                          amtUsed.ToString("F"),
                                          (amtRemain > 0) ? amtRemain.ToString("F") : "0");
                    gridRemainTimeUnits.ListGridRows.Add(gridRow);
                }
            }
            gridRemainTimeUnits.EndUpdate();
        }
Beispiel #3
0
        private void FillGrid()
        {
            gridRemainTimeUnits.BeginUpdate();
            gridRemainTimeUnits.Rows.Clear();
            List <Benefit>   listPatBenefits = Benefits.Refresh(PatPlans.Refresh(_patCur.PatNum), InsSubs.GetListForSubscriber(_patCur.PatNum));
            ODGridRow        gridRow;
            List <Procedure> listProcs;
            double           amtUsed;
            int monthRenew;

            if (listPatBenefits.Count > 0)
            {
                for (int i = 0; i < listPatBenefits.Count; i++)
                {
                    if (listPatBenefits[i].CovCatNum == 0 ||               //no category
                        listPatBenefits[i].BenefitType != InsBenefitType.Limitations ||                         //benefit type is not limitations
                        (listPatBenefits[i].TimePeriod != BenefitTimePeriod.CalendarYear &&                         //neither calendar year nor serviceyear
                         listPatBenefits[i].TimePeriod != BenefitTimePeriod.ServiceYear) ||
                        listPatBenefits[i].Quantity < 0 ||                        //quantity is negative (negatives are allowed in FormBenefitEdit)
                        listPatBenefits[i].QuantityQualifier != BenefitQuantity.NumberOfServices ||                        //qualifier us not the number of services
                        (listPatBenefits[i].CoverageLevel != BenefitCoverageLevel.Family &&                         //neither individual nor family coverage level
                         listPatBenefits[i].CoverageLevel != BenefitCoverageLevel.Individual))
                    {
                        continue;
                    }
                    //for calendar year, get completed procs from January.01.CurYear ~ Curdate
                    List <long> listPatNums = new List <long> {
                        _patCur.PatNum
                    };                                                                         //for current patient.
                    if (listPatBenefits[i].TimePeriod == BenefitTimePeriod.CalendarYear)
                    {
                        //01/01/CurYear. is there a better way?
                        listProcs = Procedures.GetCompletedForDateRange(new DateTime(DateTimeOD.Today.Year, 1, 1), DateTimeOD.Today, null, listPatNums);
                    }
                    else                                                                         //if not calendar year, then it must be service year
                    {
                        monthRenew = InsPlans.RefreshOne(listPatBenefits[i].PlanNum).MonthRenew; //monthrenew only stores the month as an int.
                        if (DateTimeOD.Today.Month >= monthRenew)                                //if the the current date is past the renewal month, use the current year
                        {
                            listProcs = Procedures.GetCompletedForDateRange(new DateTime(DateTimeOD.Today.Year, monthRenew, 1), DateTimeOD.Today, null, listPatNums);
                        }
                        else                           //otherwise use the previous year
                        {
                            listProcs = Procedures.GetCompletedForDateRange(new DateTime(DateTimeOD.Today.Year - 1, monthRenew, 1), DateTimeOD.Today, null, listPatNums);
                        }
                    }
                    //Calculate the amount used for one benefit.
                    amtUsed = GetAmtUsedForCat(listProcs, CovCats.GetCovCat(listPatBenefits[i].CovCatNum));
                    gridRow = new ODGridRow();
                    gridRow.Cells.Add(CovCats.GetCovCat(listPatBenefits[i].CovCatNum).EbenefitCat.ToString()); //Coverage Category
                    gridRow.Cells.Add(listPatBenefits[i].Quantity.ToString());                                 //Quantity
                    gridRow.Cells.Add(amtUsed.ToString("F"));                                                  //Used
                    double amtRemain = listPatBenefits[i].Quantity - amtUsed;
                    if (amtRemain > 0)
                    {
                        gridRow.Cells.Add(amtRemain.ToString("F")); //quantity-used.
                    }
                    else                                            //if less then 0, just 0.
                    {
                        gridRow.Cells.Add("0");
                    }
                    gridRemainTimeUnits.Rows.Add(gridRow);
                }
            }
            gridRemainTimeUnits.EndUpdate();
        }