Пример #1
0
 private void FillGrid()
 {
     carrierList = Carriers.GetCarriers(CarrierNums);
     tbCarriers.ResetRows(carrierList.Count);
     tbCarriers.SetGridColor(Color.Gray);
     tbCarriers.SetBackGColor(Color.White);
     for (int i = 0; i < carrierList.Count; i++)
     {
         tbCarriers.Cell[0, i] = carrierList[i].CarrierName;
         tbCarriers.Cell[1, i] = carrierList[i].Phone;
         tbCarriers.Cell[2, i] = carrierList[i].Address;
         tbCarriers.Cell[3, i] = carrierList[i].Address2;
         tbCarriers.Cell[4, i] = carrierList[i].City;
         tbCarriers.Cell[5, i] = carrierList[i].State;
         tbCarriers.Cell[6, i] = carrierList[i].Zip;
         tbCarriers.Cell[7, i] = carrierList[i].ElectID;
     }
     tbCarriers.LayoutTables();
 }
Пример #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();
        }
Пример #3
0
        private bool VerifyCarrierCombineData(long pickedCarrierNum, List <long> pickedCarrierNums)
        {
            List <Carrier> listCarriers = Carriers.GetCarriers(pickedCarrierNums);
            List <string>  listWarnings = new List <string>();
            Carrier        carCur       = listCarriers.FirstOrDefault(x => x.CarrierNum == pickedCarrierNum);

            if (carCur == null)           //In case it wasn't included in the list of picked carrier nums.
            {
                carCur = Carriers.GetCarrier(pickedCarrierNum);
            }
            if (carCur == null)           //In case it is a completely invalid carrier
            {
                return(false);            //should never happen.
            }
            //==================== NAME ====================
            if (listCarriers.Any(x => x.CarrierName != carCur.CarrierName && !string.IsNullOrWhiteSpace(x.CarrierName)))
            {
                listWarnings.Add(Lan.g(this, "Carrier Name"));
            }
            //==================== ADDRESS INFO ====================
            if (listCarriers.Any(x => x.Address != carCur.Address && !string.IsNullOrWhiteSpace(x.Address)) ||
                listCarriers.Any(x => x.Address2 != carCur.Address2 && !string.IsNullOrWhiteSpace(x.Address2)) ||
                listCarriers.Any(x => x.City != carCur.City && !string.IsNullOrWhiteSpace(x.City)) ||
                listCarriers.Any(x => x.State != carCur.State && !string.IsNullOrWhiteSpace(x.State)) ||
                listCarriers.Any(x => x.Zip != carCur.Zip && !string.IsNullOrWhiteSpace(x.Zip)))
            {
                listWarnings.Add(Lan.g(this, "Carrier Address"));
            }
            //==================== PHONE ====================
            if (listCarriers.Any(x => x.Phone != carCur.Phone && !string.IsNullOrWhiteSpace(x.Phone)))
            {
                listWarnings.Add(Lan.g(this, "Carrier Phone"));
            }
            //==================== ElectID ====================
            if (listCarriers.Any(x => x.ElectID != carCur.ElectID && !string.IsNullOrWhiteSpace(x.ElectID)))
            {
                listWarnings.Add(Lan.g(this, "Carrier ElectID"));
            }
            //==================== TIN ====================
            if (listCarriers.Any(x => x.TIN != carCur.TIN && !string.IsNullOrWhiteSpace(x.TIN)))
            {
                listWarnings.Add(Lan.g(this, "Carrier TIN"));
            }
            //==================== CDAnetVersion ====================
            if (listCarriers.Any(x => x.CDAnetVersion != carCur.CDAnetVersion && !string.IsNullOrWhiteSpace(x.CDAnetVersion)))
            {
                listWarnings.Add(Lan.g(this, "Carrier CDAnet Version"));
            }
            //==================== IsCDA ====================
            if (listCarriers.Any(x => x.IsCDA != carCur.IsCDA))
            {
                listWarnings.Add(Lan.g(this, "Carrier Is CDA"));
            }
            //==================== CanadianNetworkNum ====================
            if (listCarriers.Any(x => x.CanadianNetworkNum != carCur.CanadianNetworkNum))
            {
                listWarnings.Add(Lan.g(this, "Canadian Network"));
            }
            //==================== NoSendElect ====================
            if (listCarriers.Any(x => x.NoSendElect != carCur.NoSendElect))
            {
                listWarnings.Add(Lan.g(this, "Send Elect"));
            }
            //==================== IsHidden ====================
            if (listCarriers.Any(x => x.IsHidden != carCur.IsHidden))
            {
                listWarnings.Add(Lan.g(this, "Is Hidden"));
            }
            //==================== CanadianEncryptionMethod ====================
            if (listCarriers.Any(x => x.CanadianEncryptionMethod != carCur.CanadianEncryptionMethod))
            {
                listWarnings.Add(Lan.g(this, "Canadian Encryption Method"));
            }
            //==================== CanadianSupportedTypes ====================
            if (listCarriers.Any(x => x.CanadianSupportedTypes != carCur.CanadianSupportedTypes))
            {
                listWarnings.Add(Lan.g(this, "Canadian Supported Types"));
            }
            //==================== Additional fields ====================
            //If anyone asks for them, these fields can also be checked.
            // public long							SecUserNumEntry;
            // public DateTime					SecDateEntry;
            // public DateTime					SecDateTEdit;
            //====================USER PROMPT====================
            if (listWarnings.Count > 0)
            {
                string warningMessage = Lan.g(this, "WARNING!") + " " + Lan.g(this, "Mismatched data has been detected between selected carriers") + ":\r\n\r\n"
                                        + string.Join("\r\n", listWarnings) + "\r\n\r\n"
                                        + Lan.g(this, "Would you like to continue combining carriers anyway?");
                if (MessageBox.Show(warningMessage, "", MessageBoxButtons.YesNo) != DialogResult.Yes)
                {
                    return(false);
                }
            }
            return(true);
        }