Exemplo n.º 1
0
        ///<summary>Runs Procedures.ComputeEstimates for given proc and listClaimProcs.
        ///Does not update existing ClaimProcs or insert new ClaimProcs in the database.
        ///Outs new ClaimProcs added by Procedures.ComputeEstimates, listClaimProcs will contain any added claimProcs.</summary>
        private void RecomputeEstimates(Procedure proc, List <ClaimProc> listClaimProcs, out List <ClaimProc> listNewClaimProcs,
                                        OrthoProcLink orthoProcLink, OrthoCase orthoCase, OrthoSchedule orthoSchedule, List <OrthoProcLink> listOrthoProcLinksForOrthoCase)
        {
            List <ClaimProc> listOrigClaimProcs = new List <ClaimProc>(listClaimProcs);
            Patient          pat          = Patients.GetPat(proc.PatNum);
            List <PatPlan>   listPatPlans = PatPlans.GetPatPlansForPat(pat.PatNum);
            List <InsSub>    listInsSubs  = InsSubs.GetMany(listPatPlans.Select(x => x.InsSubNum).ToList());
            List <InsPlan>   listInsPlans = InsPlans.GetByInsSubs(listInsSubs.Select(x => x.InsSubNum).ToList());
            List <Benefit>   listBenefits = Benefits.Refresh(listPatPlans, listInsSubs);      //Same method used in FormProcEdit.Load()->GetLoadData()
            //FormProcEdit uses GetHistList(....,procDate:DateTimeOD.Today,...)
            List <ClaimProcHist> listHist = ClaimProcs.GetHistList(pat.PatNum, listBenefits, listPatPlans, listInsPlans, DateTimeOD.Today, listInsSubs);
            bool isSaveToDb = false;

            //When isSaveToDb is true any estimates that are missing will be inserted into DB and it refreshes listClaimProcs from the Db.
            //Refreshing the list results in losing the changes to ProvNum and ProcDate.
            Procedures.ComputeEstimates(proc, pat.PatNum, ref listClaimProcs, false, listInsPlans, listPatPlans, listBenefits, listHist,
                                        new List <ClaimProcHist> {
            }, isSaveToDb, pat.Age, listInsSubs
                                        , useProcDateOnProc: true,
                                        orthoProcLink: orthoProcLink, orthoCase: orthoCase, orthoSchedule: orthoSchedule, listOrthoProcLinksForOrthoCase: listOrthoProcLinksForOrthoCase);
            listNewClaimProcs = listClaimProcs.Except(listOrigClaimProcs).ToList();
        }
        ///<summary>Sets the foreground text to red if any row has a DOS between textDOSFrom and textDOSTo and matches textClaimFee </summary>
        private void HighlightRows()
        {
            DateTime dateFrom           = PIn.Date(textDateFrom.Text);
            DateTime dateTo             = PIn.Date(textDateTo.Text);
            double   fee                = PIn.Double(textClaimFee.Text);
            int      rowsHighlightCount = 0;
            int      lastHighlightIndex = 0;

            gridClaims.BeginUpdate();
            for (int i = 0; i < gridClaims.ListGridRows.Count; i++)
            {
                gridClaims.ListGridRows[i].ColorText = Color.Black; //reset row highlighting
                gridClaims.ListGridRows[i].Bold      = false;       //reset row highlighting
                Claim claim       = (Claim)gridClaims.ListGridRows[i].Tag;
                YN    isFeeMatch  = YN.No;                          //If fee matches then yes, if fee doesnt match then no, if no fee entered then unknown
                YN    isDateMatch = YN.No;                          //If both dates match then yes, if both dates dont match then no, if no dates entered then unknown
                //Check fee
                if (textClaimFee.Text == "")                        //No fee entered
                {
                    isFeeMatch = YN.Unknown;
                }
                else
                {
                    if (claim.ClaimFee.ToString("f").Contains(textClaimFee.Text))
                    {
                        isFeeMatch = YN.Yes;
                    }
                }
                //Check date
                if (dateFrom == DateTime.MinValue && dateTo == DateTime.MinValue)               //No dates entered
                {
                    isDateMatch = YN.Unknown;
                }
                else                    //At least one date entered
                {
                    if ((dateFrom.CompareTo(claim.DateService) <= 0 || dateFrom == DateTime.MinValue) &&
                        (dateTo.CompareTo(claim.DateService) >= 0 || dateTo == DateTime.MinValue))
                    {
                        isDateMatch = YN.Yes;
                    }
                }
                Hx835_Proc proc         = _x835Claim.ListProcs.FirstOrDefault();
                bool       isPlanMatch  = true;                                                                                             //Assume true for backwards compatiablity, because older 837s did not send out the Ordinal and PlanNum.
                bool       isBasicMatch = (isFeeMatch == YN.Yes || isDateMatch == YN.Yes) && (isFeeMatch != YN.No && isDateMatch != YN.No); //If either match and neither don't match
                if (isBasicMatch && proc != null && proc.PlanNum != 0)                                                                      //Consider new 837 REF*6R pattern for values starting with 'x'.
                {
                    if (_listPatPlans == null)
                    {
                        _listPatPlans = PatPlans.GetPatPlansForPat(_patNum);
                    }
                    //Strict PlanNum AND Ordinal match.  Users can manually change ordinals easily after sending claims.
                    //A failure to match here is OK because we will give the user the option to manually select the correct claim from the grid.
                    if (proc.PlanNum != claim.PlanNum || PatPlans.GetOrdinal(claim.InsSubNum, _listPatPlans) != proc.PlanOrdinal)
                    {
                        isPlanMatch = false;
                    }
                }
                if (isBasicMatch && isPlanMatch)
                {
                    //Highlight row
                    gridClaims.ListGridRows[i].ColorText = Color.Red;
                    gridClaims.ListGridRows[i].Bold      = true;
                    rowsHighlightCount++;
                    lastHighlightIndex = i;
                }
            }
            gridClaims.EndUpdate();
            if (rowsHighlightCount == 1)
            {
                gridClaims.SetSelected(lastHighlightIndex, true);
                FillClaimDetails(lastHighlightIndex);
            }
        }