///<summary>Gets all claims for the patient selected.  Fills gridClaims and tags each row with its corrisponding claim object.</summary>
        private void FillGridClaims()
        {
            int  sortByColIdx = gridClaims.SortedByColumnIdx;           //Keep previous sorting
            bool isSortAsc    = gridClaims.SortedIsAscending;

            if (sortByColIdx == -1)
            {
                sortByColIdx = 0;
                isSortAsc    = false;
            }
            gridClaims.BeginUpdate();
            gridClaims.ListGridRows.Clear();
            gridClaims.ListGridColumns.Clear();
            gridClaims.ListGridColumns.Add(new UI.GridColumn("Date Service", 100, HorizontalAlignment.Center)
            {
                SortingStrategy = UI.GridSortingStrategy.DateParse
            });
            gridClaims.ListGridColumns.Add(new UI.GridColumn("Carrier", 240, HorizontalAlignment.Center)
            {
                SortingStrategy = UI.GridSortingStrategy.StringCompare
            });
            gridClaims.ListGridColumns.Add(new UI.GridColumn("Status", 120, HorizontalAlignment.Center)
            {
                SortingStrategy = UI.GridSortingStrategy.StringCompare
            });
            if (PrefC.HasClinicsEnabled)             //Using clinics
            {
                gridClaims.ListGridColumns.Add(new UI.GridColumn("Clinic", 190, HorizontalAlignment.Left)
                {
                    SortingStrategy = UI.GridSortingStrategy.StringCompare
                });
            }
            gridClaims.ListGridColumns.Add(new UI.GridColumn("ClaimFee", 70, HorizontalAlignment.Right)
            {
                SortingStrategy = UI.GridSortingStrategy.AmountParse
            });
            List <Claim> listClaims = Claims.Refresh(_patNum);

            for (int i = 0; i < listClaims.Count; i++)
            {
                UI.GridRow row = new UI.GridRow();
                row.Tag = listClaims[i];
                row.Cells.Add(listClaims[i].DateService.ToShortDateString());                           //DOS
                row.Cells.Add(Carriers.GetName(InsPlans.RefreshOne(listClaims[i].PlanNum).CarrierNum)); //Carrier
                row.Cells.Add(Claims.GetClaimStatusString(listClaims[i].ClaimStatus));                  //Status
                if (PrefC.HasClinicsEnabled)                                                            //Using clinics
                {
                    Clinic clinic = Clinics.GetClinic(listClaims[i].ClinicNum);
                    if (clinic == null)
                    {
                        row.Cells.Add("");                        //Clinic
                    }
                    else
                    {
                        row.Cells.Add(clinic.Description);                        //Clinic
                    }
                }
                row.Cells.Add(listClaims[i].ClaimFee.ToString("f"));                //Claimfee
                gridClaims.ListGridRows.Add(row);
            }
            gridClaims.EndUpdate();
            gridClaims.SortForced(sortByColIdx, isSortAsc);
        }
Esempio n. 2
0
        ///<summary>Fills grid based on values in _listEtrans.
        ///Set isRefreshNeeded to true when we need to reinitialize local dictionarys after in memory list is also updated. Required true for first time running.
        ///Also allows you to passed in predetermined filter options.</summary>
        private void FillGrid(bool isRefreshNeeded, List <string> listSelectedStatuses, List <long> listSelectedClinicNums,
                              string carrierName, string checkTraceNum, string amountMin, string amountMax)
        {
            Cursor = Cursors.WaitCursor;
            Action actionCloseProgress = null;

            if (isRefreshNeeded)
            {
                actionCloseProgress = ODProgressOld.ShowProgressStatus("Etrans835", this, Lan.g(this, "Gathering data") + "...", false);
                _dictEtrans835s.Clear();
                _dictEtransClaims.Clear();
                _dictClaimPayExists.Clear();
                List <Etrans835Attach>    listAttached        = Etrans835Attaches.GetForEtrans(_listEtranss.Select(x => x.EtransNum).ToArray());
                Dictionary <long, string> dictEtransMessages  = new Dictionary <long, string>();
                List <X12ClaimMatch>      list835ClaimMatches = new List <X12ClaimMatch>();
                Dictionary <long, int>    dictClaimMatchCount = new Dictionary <long, int>(); //1:1 with _listEtranss. Stores how many claim matches each 835 has.
                int batchQueryInterval = 500;                                                 //Every 500 rows we get the next 500 message texts to save memory.
                int rowCur             = 0;
                foreach (Etrans etrans in _listEtranss)
                {
                    if (rowCur % batchQueryInterval == 0)
                    {
                        int range = Math.Min(batchQueryInterval, _listEtranss.Count - rowCur);                   //Either the full batchQueryInterval amount or the remaining amount of etrans.
                        dictEtransMessages = EtransMessageTexts.GetMessageTexts(_listEtranss.GetRange(rowCur, range).Select(x => x.EtransMessageTextNum).ToList(), false);
                    }
                    rowCur++;
                    ODEvent.Fire(new ODEventArgs("Etrans835", Lan.g(this, "Processing 835: ") + ": " + rowCur + " out of " + _listEtranss.Count));
                    List <Etrans835Attach> listAttachedTo835 = listAttached.FindAll(x => x.EtransNum == etrans.EtransNum);
                    X835 x835 = new X835(etrans, dictEtransMessages[etrans.EtransMessageTextNum], etrans.TranSetId835, listAttachedTo835, true);
                    _dictEtrans835s.Add(etrans.EtransNum, x835);
                    List <X12ClaimMatch> listClaimMatches = x835.GetClaimMatches();
                    dictClaimMatchCount.Add(etrans.EtransNum, listClaimMatches.Count);
                    list835ClaimMatches.AddRange(listClaimMatches);
                }
                #region Set 835 unattached in batch and build _dictEtransClaims and _dictClaimPayCheckNums.
                ODEvent.Fire(new ODEventArgs("Etrans835", Lan.g(this, "Gathering internal claim matches.")));
                List <long> listClaimNums = Claims.GetClaimFromX12(list835ClaimMatches);             //Can return null.
                ODEvent.Fire(new ODEventArgs("Etrans835", Lan.g(this, "Building data sets.")));
                int         claimIndexCur        = 0;
                List <long> listMatchedClaimNums = new List <long>();
                foreach (Etrans etrans in _listEtranss)
                {
                    X835 x835 = _dictEtrans835s[etrans.EtransNum];
                    if (listClaimNums != null)
                    {
                        x835.SetClaimNumsForUnattached(listClaimNums.GetRange(claimIndexCur, dictClaimMatchCount[etrans.EtransNum]));
                    }
                    claimIndexCur += dictClaimMatchCount[etrans.EtransNum];
                    listMatchedClaimNums.AddRange(x835.ListClaimsPaid.FindAll(x => x.ClaimNum != 0).Select(x => x.ClaimNum).ToList());
                }
                List <Claim> listClaims = Claims.GetClaimsFromClaimNums(listMatchedClaimNums.Distinct().ToList());
                _dictClaimPayExists = ClaimPayments.HasClaimPayment(listMatchedClaimNums);              //Every claim num is associated to a bool. True when there is an existing claimPayment.
                foreach (Etrans etrans in _listEtranss)
                {
                    X835 x835 = _dictEtrans835s[etrans.EtransNum];
                    #region _dictEtransClaims, _dictClaimPayCheckNums
                    _dictEtransClaims.Add(etrans.EtransNum, new List <Claim>());
                    List <long>  listSubClaimNums = x835.ListClaimsPaid.FindAll(x => x.ClaimNum != 0).Select(y => y.ClaimNum).ToList();
                    List <Claim> listClaimsFor835 = listClaims.FindAll(x => listSubClaimNums.Contains(x.ClaimNum));
                    foreach (Hx835_Claim claim in x835.ListClaimsPaid)
                    {
                        Claim claimCur = listClaimsFor835.FirstOrDefault(x => x.ClaimNum == claim.ClaimNum);                    //Can be null.
                        if (claimCur == null && claim.IsAttachedToClaim && claim.ClaimNum == 0)
                        {
                            claimCur = new Claim();                          //Create empty claim since user detached claim manually, will not be considered in GetStringStatus(...).
                        }
                        if (claimCur != null && claim.IsPreauth)             //User attached preauth to internal claim, no payment needed to be considered 'Finalized' in GetStringStatus(...).
                        {
                            _dictClaimPayExists[claim.ClaimNum] = true;
                        }
                        _dictEtransClaims[etrans.EtransNum].Add(claimCur);
                    }
                    #endregion
                }
                ODEvent.Fire(new ODEventArgs("Etrans835", Lan.g(this, "Filling Grid.")));
                #endregion
            }
            gridMain.BeginUpdate();
            #region Initilize columns only once
            if (gridMain.Columns.Count == 0)
            {
                ODGridColumn col;
                col = new ODGridColumn(Lan.g("TableEtrans835s", "Patient Name"), 250);
                gridMain.Columns.Add(col);
                col = new ODGridColumn(Lan.g("TableEtrans835s", "Carrier Name"), 190);
                gridMain.Columns.Add(col);
                col = new ODGridColumn(Lan.g("TableEtrans835s", "Status"), 80);
                gridMain.Columns.Add(col);
                col = new ODGridColumn(Lan.g("TableEtrans835s", "Date"), 80);
                gridMain.Columns.Add(col);
                col = new ODGridColumn(Lan.g("TableEtrans835s", "Amount"), 80);
                gridMain.Columns.Add(col);
                if (PrefC.HasClinicsEnabled)
                {
                    col = new ODGridColumn(Lan.g("TableEtrans835s", "Clinic"), 70);
                    gridMain.Columns.Add(col);
                }
                col = new ODGridColumn(Lan.g("TableEtrans835s", "Code"), 37, HorizontalAlignment.Center);
                gridMain.Columns.Add(col);
                col = new ODGridColumn(Lan.g("TableEtrans835s", "Note"), 0);
                gridMain.Columns.Add(col);
            }
            #endregion
            gridMain.Rows.Clear();
            foreach (Etrans etrans in _listEtranss)
            {
                X835 x835 = _dictEtrans835s[etrans.EtransNum];
                #region Filter: Carrier Name
                if (carrierName != "" && !x835.PayerName.ToLower().Contains(carrierName.ToLower()))
                {
                    continue;
                }
                #endregion
                string status = GetStringStatus(etrans.EtransNum);
                #region Filter: Status
                if (!listSelectedStatuses.Contains(status.Replace("*", "")))                //The filter will ignore finalized with detached claims.
                {
                    continue;
                }
                #endregion
                //List of ClinicNums for the current etrans.ListClaimsPaid from the DB.
                List <long> listClinicNums = _dictEtransClaims[etrans.EtransNum].Select(x => x == null? 0 :x.ClinicNum).Distinct().ToList();
                #region Filter: Clinics
                if (PrefC.HasClinicsEnabled && !listClinicNums.Exists(x => listSelectedClinicNums.Contains(x)))
                {
                    continue;                    //The ClinicNums associated to the 835 do not match any of the selected ClinicNums, so nothing to show in this 835.
                }
                #endregion
                #region Filter: Check and Trace Value
                if (checkTraceNum != "" && !x835.TransRefNum.Contains(checkTraceNum))               //Trace Number does not match
                {
                    continue;
                }
                #endregion
                #region Filter: Insurance Check Range Min and Max
                if (amountMin != "" && x835.InsPaid < PIn.Decimal(amountMin) || amountMax != "" && x835.InsPaid > PIn.Decimal(amountMax))
                {
                    continue;                    //Either the InsPaid is below or above our range.
                }
                #endregion
                ODGridRow row = new ODGridRow();
                #region Column: Patient Name
                List <string> listPatNames = x835.ListClaimsPaid.Select(x => x.PatientName.ToString()).Distinct().ToList();
                string        patName      = (listPatNames.Count > 0 ? listPatNames[0] : "");
                if (listPatNames.Count > 1)
                {
                    patName = "(" + POut.Long(listPatNames.Count) + ")";
                }
                row.Cells.Add(patName);
                #endregion
                row.Cells.Add(x835.PayerName);
                row.Cells.Add(status);                //See GetStringStatus(...) for possible values.
                row.Cells.Add(POut.Date(etrans.DateTimeTrans));
                row.Cells.Add(POut.Decimal(x835.InsPaid));
                #region Column: Clinic
                if (PrefC.HasClinicsEnabled)
                {
                    string clinicAbbr = "";
                    if (listClinicNums.Count == 1)
                    {
                        if (listClinicNums[0] == 0)
                        {
                            clinicAbbr = Lan.g(this, "Unassigned");
                        }
                        else
                        {
                            clinicAbbr = Clinics.GetAbbr(listClinicNums[0]);
                        }
                    }
                    else if (listClinicNums.Count > 1)
                    {
                        clinicAbbr = "(" + Lan.g(this, "Multiple") + ")";
                    }
                    row.Cells.Add(clinicAbbr);
                }
                #endregion
                row.Cells.Add(x835._paymentMethodCode);
                row.Cells.Add(etrans.Note);
                row.Tag = etrans;
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
            try {
                actionCloseProgress?.Invoke();                //When this function executes quickly this can fail rarely, fail silently because of WaitCursor.
            }
            catch (Exception ex) {
                ex.DoNothing();
            }
            Cursor = Cursors.Default;
        }
        private void butNewClaims_Click(object sender, EventArgs e)
        {
            if (gridMain.SelectedIndices.Length == 0)           //No selections made.
            {
                MsgBox.Show(this, "Please select at least one procedure.");
                return;
            }
            if (!ClaimL.CheckClearinghouseDefaults())
            {
                return;
            }
            //Ignore date lock for now, we just want to check the general permission for the button.
            if (!Security.IsAuthorized(Permissions.NewClaimsProcNotBilled, DateTime.Today))
            {
                return;
            }
            //Generate List and Table----------------------------------------------------------------------------------------------------------------------
            //List of all procedures being shown.
            //Pulls procedures based off of the PatNum, if the row was selected in gridMain and if it has been attached to a claim.
            List <ProcNotBilled> listNotBilledProcs = new List <ProcNotBilled>();
            List <long>          listPatNums        = new List <long>();
            Patient          patOld            = new Patient();
            List <Claim>     listPatClaims     = new List <Claim>();
            List <ClaimProc> listPatClaimProcs = new List <ClaimProc>();
            List <ClaimProc> listCurClaimProcs = new List <ClaimProc>();
            //find the date user is restricted by for this permission so it doesn't get called in a loop. General permission was already checked.
            DateTime dateRestricted = GroupPermissions.GetDateRestrictedForPermission(Permissions.NewClaimsProcNotBilled,
                                                                                      Security.CurUser.GetGroups(true).Select(x => x.UserGroupNum).ToList());
            //Table rows need to be 1:1 with gridMain rows due to logic in ContrAccount.toolBarButIns_Click(...).
            DataTable table = new DataTable();

            //Required columns as mentioned by ContrAccount.toolBarButIns_Click().
            table.Columns.Add("ProcNum");
            table.Columns.Add("chargesDouble");
            table.Columns.Add("ProcNumLab");
            List <long> listProcNumsPastLockDate = new List <long>();

            for (int i = 0; i < gridMain.ListGridRows.Count; i++)       //Loop through every row in gridMain to construct datatable and listNotBilledProcs.
            //Table is passed to toolBarButIns_Click(...) and must contain data for every row in the grid.
            {
                DataRow   rowCur     = (DataRow)gridMain.ListGridRows[i].Tag;
                long      procNumCur = PIn.Long(rowCur["ProcNum"].ToString());
                Procedure procCur    = Procedures.GetOneProc(procNumCur, false);
                if (procCur.ProcDate <= dateRestricted)                 //current procedure is past or on the lock date.
                {
                    listProcNumsPastLockDate.Add(procNumCur);
                }
                long patNumCur = procCur.PatNum;
                if (patOld.PatNum != patNumCur)               //Procedures in gridMain are ordered by patient, so when the patient changes, we know previous patient is complete.
                {
                    listPatClaims     = Claims.Refresh(patNumCur);
                    listPatClaimProcs = ClaimProcs.Refresh(patNumCur);
                    patOld            = Patients.GetPat(procCur.PatNum);
                }
                listCurClaimProcs = ClaimProcs.GetForProc(listPatClaimProcs, procNumCur);
                bool hasPriClaim = false;
                bool hasSecClaim = false;
                for (int j = 0; j < listCurClaimProcs.Count; j++)
                {
                    ClaimProc claimProcCur = listCurClaimProcs[j];
                    if (claimProcCur.ClaimNum > 0 && claimProcCur.Status != ClaimProcStatus.Preauth && claimProcCur.Status != ClaimProcStatus.Estimate)
                    {
                        Claim claimCur = Claims.GetFromList(listPatClaims, claimProcCur.ClaimNum);
                        switch (claimCur.ClaimType)
                        {
                        case "P":
                            hasPriClaim = true;
                            break;

                        case "S":
                            hasSecClaim = true;
                            break;
                        }
                    }
                }
                bool isSelected = gridMain.SelectedIndices.Contains(i);
                listNotBilledProcs.Add(new ProcNotBilled(patOld, procNumCur, i, isSelected, hasPriClaim, hasSecClaim, procCur.ClinicNum, procCur.PlaceService));
                DataRow row = table.NewRow();
                row["ProcNum"] = procNumCur;
                #region Calculate chargesDouble
                double writeOffCapSum = listPatClaimProcs.Where(x => x.Status == ClaimProcStatus.CapComplete).Sum(y => y.WriteOff);
                row["chargesDouble"] = procCur.ProcFeeTotal - writeOffCapSum;
                row["ProcNumLab"]    = procCur.ProcNumLab;
                #endregion Calculate chargesDouble
                table.Rows.Add(row);
                if (listPatNums.Contains(patNumCur))
                {
                    continue;
                }
                listPatNums.Add(patNumCur);
            }
            List <List <ProcNotBilled> > listGroupedProcs = new List <List <ProcNotBilled> >();
            Patient          patCur           = null;
            List <PatPlan>   listPatPlans     = null;
            List <InsSub>    listInsSubs      = null;
            List <InsPlan>   listInsPlans     = null;
            List <Procedure> listPatientProcs = null;
            ProcNotBilled    procNotBilled    = new ProcNotBilled();    //When automatically grouping,  this is used as the procedure to group by.
            long             patNumOld        = 0;
            int claimCreatedCount             = 0;
            int patIndex = 0;
            //The procedures show in the grid ordered by patient.  Also listPatNums contains unique patnums which are in the same order as the grid.
            while (patIndex < listPatNums.Count)
            {
                List <ProcNotBilled> listProcs = listNotBilledProcs.Where(x => x.Patient.PatNum == listPatNums[patIndex] && x.IsRowSelected && !x.IsAttached &&
                                                                          !x.ProcNum.In(listProcNumsPastLockDate)).ToList();
                if (listProcs.Count == 0)
                {
                    patNumOld = listPatNums[patIndex];
                    patIndex++;                    //No procedures were selected for this patient.
                    continue;
                }
                else
                {
                    //Maintain the same patient, in order to create one or more additional claims for the remaining procedures.
                    //Currently will only happen for specific instances;
                    //--Canadian customers who are attempting to create a claim with over 7 procedures.
                    //--When checkAutoGroupProcs is checked and when there are multiple procedure groupings by GroupKey status, ClinicNum, and placeService.
                }
                if (patNumOld != listPatNums[patIndex])               //The patient could repeat if we had to group the procedures for the patinet into multiple claims.
                {
                    patCur           = Patients.GetPat(listPatNums[patIndex]);
                    listPatPlans     = PatPlans.Refresh(patCur.PatNum);
                    listInsSubs      = InsSubs.RefreshForFam(Patients.GetFamily(patCur.PatNum));
                    listInsPlans     = InsPlans.RefreshForSubList(listInsSubs);
                    listPatientProcs = Procedures.Refresh(patCur.PatNum);
                }
                if (checkAutoGroupProcs.Checked)                 //Automatically Group Procedures.
                {
                    procNotBilled = listProcs[0];
                    //Update listProcs to reflect those that match the procNotBilled values.
                    listProcs = listProcs.FindAll(x => x.HasPriClaim == procNotBilled.HasPriClaim && x.HasSecClaim == procNotBilled.HasSecClaim);
                    if (PrefC.HasClinicsEnabled)                     //Group by clinic only if clinics enabled.
                    {
                        listProcs = listProcs.FindAll(x => x.ClinicNum == procNotBilled.ClinicNum);
                    }
                    else if (!PrefC.GetBool(PrefName.EasyHidePublicHealth))                     //Group by Place of Service only if Public Health feature is enabled.
                    {
                        listProcs = listProcs.FindAll(x => x.PlaceService == procNotBilled.PlaceService);
                    }
                }
                GetUniqueDiagnosticCodes(listProcs, listPatientProcs, listPatPlans, listInsSubs, listInsPlans);
                if (listProcs.Count > 7 && CultureInfo.CurrentCulture.Name.EndsWith("CA")) //Canadian. en-CA or fr-CA
                {
                    listProcs = listProcs.Take(7).ToList();                                //Returns first 7 items of the list.
                }
                listProcs.ForEach(x => x.IsAttached = true);                               //This way we can not attach procedures to multiple claims thanks to the logic above.
                if (listProcs.Any(x => listProcs[0].PlaceService != x.PlaceService) || listProcs.Any(x => listProcs[0].ClinicNum != x.ClinicNum))
                {
                    //Regardless if we are automatically grouping or not,
                    //if all procs in our list at this point do not share the same PlaceService or ClinicNum then claims will not be made.
                }
                else                  //Basic validation passed.
                {
                    if (!listProcs[0].HasPriClaim &&                 //Medical claim.
                        PatPlans.GetOrdinal(PriSecMed.Medical, listPatPlans, listInsPlans, listInsSubs) > 0 &&                    //Has medical ins.
                        PatPlans.GetOrdinal(PriSecMed.Primary, listPatPlans, listInsPlans, listInsSubs) == 0 &&                    //Does not have primary dental ins.
                        PatPlans.GetOrdinal(PriSecMed.Secondary, listPatPlans, listInsPlans, listInsSubs) == 0)                       //Does not have secondary dental ins.
                    {
                        claimCreatedCount++;
                    }
                    else                                                                                                                      //Not a medical claim.
                    {
                        if (!listProcs[0].HasPriClaim && PatPlans.GetOrdinal(PriSecMed.Primary, listPatPlans, listInsPlans, listInsSubs) > 0) //Primary claim.
                        {
                            claimCreatedCount++;
                        }
                        if (!listProcs[0].HasSecClaim && PatPlans.GetOrdinal(PriSecMed.Secondary, listPatPlans, listInsPlans, listInsSubs) > 0)                  //Secondary claim.
                        {
                            claimCreatedCount++;
                        }
                    }
                }
                listGroupedProcs.Add(listProcs);
            }
            if (claimCreatedCount <= 0 && listProcNumsPastLockDate.Count > 0)         //No claims can be created because of the lock date.
            {
                MsgBox.Show(this, "No claims can be created because all procedure dates extend past the lock date for this report.");
                return;
            }
            if (!MsgBox.Show(this, true, "Clicking OK will create up to " + POut.Int(claimCreatedCount)
                             + " claims and cannot be undone, except by manually going to each account.  "
                             + "Some claims may not be created if there are validation issues.\r\n"
                             + "Click OK to continue, otherwise click Cancel."))
            {
                return;
            }
            //Create Claims--------------------------------------------------------------------------------------------------------------------------------
            claimCreatedCount = 0;
            string claimErrors = "";
            foreach (List <ProcNotBilled> listProcs in listGroupedProcs)
            {
                patCur = listProcs[0].Patient;
                gridMain.SetSelected(false);                //Need to deslect all rows each time so that ContrAccount.toolBarButIns_Click(...) only uses pertinent rows.
                for (int j = 0; j < listProcs.Count; j++)
                {
                    gridMain.SetSelected(listProcs[j].RowIndex, true);                   //Select the pertinent rows so that they will be attached to the claim below.
                }
                int[] arraySelectedIndices = (int[])gridMain.SelectedIndices.Clone();
                CreateClaimDataWrapper createClaimDataWrapper = ClaimL.GetCreateClaimDataWrapper(patCur, Patients.GetFamily(patCur.PatNum)
                                                                                                 , ClaimL.GetCreateClaimItems(table, arraySelectedIndices), false);
                createClaimDataWrapper = ClaimL.CreateClaimFromWrapper(false, createClaimDataWrapper, procNotBilled.HasPriClaim, procNotBilled.HasSecClaim);
                string errorTitle = patCur.PatNum + " " + patCur.GetNameLFnoPref() + " - ";
                if (patNumOld == patCur.PatNum && !string.IsNullOrEmpty(createClaimDataWrapper.ErrorMessage))
                {
                    claimErrors += "\t\t" + createClaimDataWrapper.ErrorMessage + "\r\n";
                }
                else if (!string.IsNullOrEmpty(createClaimDataWrapper.ErrorMessage))
                {
                    claimErrors += errorTitle + createClaimDataWrapper.ErrorMessage + "\r\n";
                }
                claimCreatedCount += createClaimDataWrapper.ClaimCreatedCount;
                SecurityLogs.MakeLogEntry(Permissions.ClaimEdit, patCur.PatNum, "New claim created for " + patCur.LName + "," + patCur.FName);
                patNumOld = patCur.PatNum;
            }
            FillGrid();
            if (claimCreatedCount > 0)
            {
                OnPostClaimCreation?.Invoke();
            }
            if (!string.IsNullOrEmpty(claimErrors))
            {
                MsgBoxCopyPaste form = new MsgBoxCopyPaste(claimErrors);
                form.ShowDialog();
            }
            MessageBox.Show(Lan.g(this, "Number of claims created") + ": " + claimCreatedCount);
        }
Esempio n. 4
0
        private void FillGrid()
        {
            if (textDaysOldMin.Text.Trim() == "" || PIn.Double(textDaysOldMin.Text) == 0)
            {
                dateMin = DateTime.MinValue;
            }
            else
            {
                dateMin = DateTime.Today.AddDays(-1 * PIn.Int(textDaysOldMin.Text));
            }
            if (textDaysOldMax.Text.Trim() == "" || PIn.Double(textDaysOldMax.Text) == 0)
            {
                dateMax = DateTime.MinValue;
            }
            else
            {
                dateMax = DateTime.Today.AddDays(-1 * PIn.Int(textDaysOldMax.Text));
            }
            if (comboBoxMultiProv.SelectedIndices[0].ToString() == "0")
            {
                isAllProv = true;
            }
            else
            {
                isAllProv   = false;
                provNumList = new List <long>();
                for (int i = 0; i < comboBoxMultiProv.SelectedIndices.Count; i++)
                {
                    provNumList.Add((long)ProviderC.ListShort[(int)comboBoxMultiProv.SelectedIndices[i] - 1].ProvNum);
                }
            }
            isPreauth = checkPreauth.Checked;
            Table     = Claims.GetOutInsClaims(isAllProv, provNumList, dateMin, dateMax, isPreauth);
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col;

            col = new ODGridColumn(Lan.g(this, "Carrier"), 180);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Phone"), 103);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Type"), 60);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Patient Name"), 140);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Date of Service"), 93);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Date Sent"), 70);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Amount"), 85, HorizontalAlignment.Right);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow row;
            string    type;

            total = 0;
            for (int i = 0; i < Table.Rows.Count; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(Table.Rows[i]["CarrierName"].ToString());
                row.Cells.Add(Table.Rows[i]["Phone"].ToString());
                type = Table.Rows[i]["ClaimType"].ToString();
                switch (type)
                {
                case "P":
                    type = "Primary";
                    break;

                case "S":
                    type = "Secondary";
                    break;

                case "PreAuth":
                    type = "Preauth";
                    break;

                case "Other":
                    type = "Other";
                    break;

                case "Cap":
                    type = "Capitation";
                    break;

                case "Med":
                    type = "Medical";                          //For possible future use.
                    break;

                default:
                    type = "Error";                          //Not allowed to be blank.
                    break;
                }
                row.Cells.Add(type);
                if (PrefC.GetBool(PrefName.ReportsShowPatNum))
                {
                    row.Cells.Add(Table.Rows[i]["PatNum"].ToString() + "-" + Table.Rows[i]["LName"].ToString() + ", " + Table.Rows[i]["FName"].ToString() + " " + Table.Rows[i]["MiddleI"].ToString());
                }
                else
                {
                    row.Cells.Add(Table.Rows[i]["LName"].ToString() + ", " + Table.Rows[i]["FName"].ToString() + " " + Table.Rows[i]["MiddleI"].ToString());
                }
                DateTime dateService = PIn.Date(Table.Rows[i]["DateService"].ToString());
                if (dateService.Year < 1880)
                {
                    row.Cells.Add("");
                }
                else
                {
                    row.Cells.Add(dateService.ToShortDateString());
                }
                row.Cells.Add(PIn.Date(Table.Rows[i]["DateSent"].ToString()).ToShortDateString());
                row.Cells.Add(PIn.Double(Table.Rows[i]["ClaimFee"].ToString()).ToString("c"));
                gridMain.Rows.Add(row);
                total += PIn.Decimal(Table.Rows[i]["ClaimFee"].ToString());
            }
            textBox1.Text = total.ToString("c");
            gridMain.EndUpdate();
        }
Esempio n. 5
0
        ///<summary>All of the code from this method is copied directly from the account module, ContrAccount.FillSummary().</summary>
        private void FillSummary()
        {
            textFamPriMax.Text = "";
            textFamPriDed.Text = "";
            textFamSecMax.Text = "";
            textFamSecDed.Text = "";
            textPriMax.Text    = "";
            textPriDed.Text    = "";
            textPriDedRem.Text = "";
            textPriUsed.Text   = "";
            textPriPend.Text   = "";
            textPriRem.Text    = "";
            textSecMax.Text    = "";
            textSecDed.Text    = "";
            textSecDedRem.Text = "";
            textSecUsed.Text   = "";
            textSecPend.Text   = "";
            textSecRem.Text    = "";
            if (_patCur == null)
            {
                return;
            }
            double         maxFam = 0;
            double         maxInd = 0;
            double         ded    = 0;
            double         dedFam = 0;
            double         dedRem = 0;
            double         remain = 0;
            double         pend   = 0;
            double         used   = 0;
            InsPlan        PlanCur;
            InsSub         SubCur;
            List <PatPlan> PatPlanList = PatPlans.Refresh(_patCur.PatNum);

            if (!PatPlans.IsPatPlanListValid(PatPlanList))
            {
                //PatPlans had invalid references and need to be refreshed.
                PatPlanList = PatPlans.Refresh(_patCur.PatNum);
            }
            List <InsSub>        subList     = InsSubs.RefreshForFam(_famCur);
            List <InsPlan>       InsPlanList = InsPlans.RefreshForSubList(subList);
            List <Benefit>       BenefitList = Benefits.Refresh(PatPlanList, subList);
            List <Claim>         ClaimList   = Claims.Refresh(_patCur.PatNum);
            List <ClaimProcHist> HistList    = ClaimProcs.GetHistList(_patCur.PatNum, BenefitList, PatPlanList, InsPlanList, DateTimeOD.Today, subList);

            if (PatPlanList.Count > 0)
            {
                SubCur  = InsSubs.GetSub(PatPlanList[0].InsSubNum, subList);
                PlanCur = InsPlans.GetPlan(SubCur.PlanNum, InsPlanList);
                pend    = InsPlans.GetPendingDisplay(HistList, DateTimeOD.Today, PlanCur, PatPlanList[0].PatPlanNum,
                                                     -1, _patCur.PatNum, PatPlanList[0].InsSubNum, BenefitList);
                used = InsPlans.GetInsUsedDisplay(HistList, DateTimeOD.Today, PlanCur.PlanNum, PatPlanList[0].PatPlanNum,
                                                  -1, InsPlanList, BenefitList, _patCur.PatNum, PatPlanList[0].InsSubNum);
                textPriPend.Text = pend.ToString("F");
                textPriUsed.Text = used.ToString("F");
                maxFam           = Benefits.GetAnnualMaxDisplay(BenefitList, PlanCur.PlanNum, PatPlanList[0].PatPlanNum, true);
                maxInd           = Benefits.GetAnnualMaxDisplay(BenefitList, PlanCur.PlanNum, PatPlanList[0].PatPlanNum, false);
                if (maxFam == -1)
                {
                    textFamPriMax.Text = "";
                }
                else
                {
                    textFamPriMax.Text = maxFam.ToString("F");
                }
                if (maxInd == -1)               //if annual max is blank
                {
                    textPriMax.Text = "";
                    textPriRem.Text = "";
                }
                else
                {
                    remain = maxInd - used - pend;
                    if (remain < 0)
                    {
                        remain = 0;
                    }
                    //textFamPriMax.Text=max.ToString("F");
                    textPriMax.Text = maxInd.ToString("F");
                    textPriRem.Text = remain.ToString("F");
                }
                //deductible:
                ded    = Benefits.GetDeductGeneralDisplay(BenefitList, PlanCur.PlanNum, PatPlanList[0].PatPlanNum, BenefitCoverageLevel.Individual);
                dedFam = Benefits.GetDeductGeneralDisplay(BenefitList, PlanCur.PlanNum, PatPlanList[0].PatPlanNum, BenefitCoverageLevel.Family);
                if (ded != -1)
                {
                    textPriDed.Text = ded.ToString("F");
                    dedRem          = InsPlans.GetDedRemainDisplay(HistList, DateTimeOD.Today, PlanCur.PlanNum, PatPlanList[0].PatPlanNum,
                                                                   -1, InsPlanList, _patCur.PatNum, ded, dedFam);
                    textPriDedRem.Text = dedRem.ToString("F");
                }
                if (dedFam != -1)
                {
                    textFamPriDed.Text = dedFam.ToString("F");
                }
            }
            if (PatPlanList.Count > 1)
            {
                SubCur  = InsSubs.GetSub(PatPlanList[1].InsSubNum, subList);
                PlanCur = InsPlans.GetPlan(SubCur.PlanNum, InsPlanList);
                pend    = InsPlans.GetPendingDisplay(HistList, DateTimeOD.Today, PlanCur, PatPlanList[1].PatPlanNum,
                                                     -1, _patCur.PatNum, PatPlanList[1].InsSubNum, BenefitList);
                textSecPend.Text = pend.ToString("F");
                used             = InsPlans.GetInsUsedDisplay(HistList, DateTimeOD.Today, PlanCur.PlanNum, PatPlanList[1].PatPlanNum,
                                                              -1, InsPlanList, BenefitList, _patCur.PatNum, PatPlanList[1].InsSubNum);
                textSecUsed.Text = used.ToString("F");
                //max=Benefits.GetAnnualMaxDisplay(BenefitList,PlanCur.PlanNum,PatPlanList[1].PatPlanNum);
                maxFam = Benefits.GetAnnualMaxDisplay(BenefitList, PlanCur.PlanNum, PatPlanList[1].PatPlanNum, true);
                maxInd = Benefits.GetAnnualMaxDisplay(BenefitList, PlanCur.PlanNum, PatPlanList[1].PatPlanNum, false);
                if (maxFam == -1)
                {
                    textFamSecMax.Text = "";
                }
                else
                {
                    textFamSecMax.Text = maxFam.ToString("F");
                }
                if (maxInd == -1)               //if annual max is blank
                {
                    textSecMax.Text = "";
                    textSecRem.Text = "";
                }
                else
                {
                    remain = maxInd - used - pend;
                    if (remain < 0)
                    {
                        remain = 0;
                    }
                    //textFamSecMax.Text=max.ToString("F");
                    textSecMax.Text = maxInd.ToString("F");
                    textSecRem.Text = remain.ToString("F");
                }
                //deductible:
                ded    = Benefits.GetDeductGeneralDisplay(BenefitList, PlanCur.PlanNum, PatPlanList[1].PatPlanNum, BenefitCoverageLevel.Individual);
                dedFam = Benefits.GetDeductGeneralDisplay(BenefitList, PlanCur.PlanNum, PatPlanList[1].PatPlanNum, BenefitCoverageLevel.Family);
                if (ded != -1)
                {
                    textSecDed.Text = ded.ToString("F");
                    dedRem          = InsPlans.GetDedRemainDisplay(HistList, DateTimeOD.Today, PlanCur.PlanNum, PatPlanList[1].PatPlanNum,
                                                                   -1, InsPlanList, _patCur.PatNum, ded, dedFam);
                    textSecDedRem.Text = dedRem.ToString("F");
                }
                if (dedFam != -1)
                {
                    textFamSecDed.Text = dedFam.ToString("F");
                }
            }
        }