Пример #1
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (textProcDate.errorProvider1.GetError(textProcDate) != "" ||
                textAmount.errorProvider1.GetError(textAmount) != "")
            {
                MsgBox.Show(this, "Please fix data entry errors first.");
                return;
            }
            if (textProcDate.Text == "")
            {
                MsgBox.Show(this, "Please enter a date first.");
                return;
            }
            if (_procCur.ProcStatus == ProcStat.C && PIn.Date(textProcDate.Text).Date > DateTime.Today.Date && !PrefC.GetBool(PrefName.FutureTransDatesAllowed))
            {
                MsgBox.Show(this, "Completed procedures cannot be set for future dates.");
                return;
            }
            if (textAmount.Text == "")
            {
                MsgBox.Show(this, "Please enter an amount.");
                return;
            }
            if (comboProv.GetSelectedProvNum() != _procOld.ProvNum && PrefC.GetBool(PrefName.ProcProvChangesClaimProcWithClaim))
            {
                List <ClaimProc> listClaimProc = ClaimProcs.GetForProc(ClaimProcs.Refresh(_procOld.PatNum), _procOld.ProcNum);
                if (listClaimProc.Any(x => x.Status == ClaimProcStatus.Received ||
                                      x.Status == ClaimProcStatus.Supplemental ||
                                      x.Status == ClaimProcStatus.CapClaim))
                {
                    MsgBox.Show(this, "The provider cannot be changed when this procedure is attached to a claim.");
                    return;
                }
            }
            _procCur.ProcDate    = PIn.Date(textProcDate.Text);
            _procCur.ProcFee     = PIn.Double(textAmount.Text);
            _procCur.Note        = textChartNotes.Text;
            _procCur.BillingNote = textAccountNotes.Text;
            _procCur.ProvNum     = comboProv.GetSelectedProvNum();
            _procCur.ClinicNum   = comboClinic.SelectedClinicNum;
            Procedures.Update(_procCur, _procOld);
            ProcedureCode procedureCode = ProcedureCodes.GetProcCode(_procCur.CodeNum);
            string        logText       = procedureCode.ProcCode + " (" + _procCur.ProcStatus + "), " + Lan.g(this, "Fee") + ": " + _procCur.ProcFee.ToString("c") + ", " + procedureCode.Descript;

            SecurityLogs.MakeLogEntry(IsNew ? Permissions.ProcComplCreate : Permissions.ProcComplEdit, _procCur.PatNum, logText);
            DialogResult = DialogResult.OK;
        }
Пример #2
0
        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 (!ContrAccount.CheckClearinghouseDefaults())
            {
                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>();
            //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");
            for (int i = 0; i < gridMain.Rows.Count; i++)                         //Loop through gridMain to construct listNotBilledProcs.
            {
                long      procNumCur = PIn.Long(gridMain.Rows[i].Tag.ToString()); //Tag is set to procNum in fillGrid().
                Procedure procCur    = Procedures.GetOneProc(procNumCur, false);
                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
                //Logic copied from AccountModules.GetAccount(...) line 857.
                double qty = (procCur.UnitQty + procCur.BaseUnits);
                if (qty == 0)
                {
                    qty = 1;
                }
                double writeOffCapSum = listPatClaimProcs.Where(x => x.Status == ClaimProcStatus.CapComplete).Select(y => y.WriteOff).ToList().Sum();
                row["chargesDouble"] = (procCur.ProcFee * qty) - 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).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 (!MsgBox.Show(this, true, "Clicking continue 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.  Would you like to proceed?"))
            {
                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.
                }
                ContrAccount.toolBarButIns_Click(false, patCur, Patients.GetFamily(patCur.PatNum), gridMain, table,
                                                 procNotBilled.HasPriClaim, procNotBilled.HasSecClaim);
                string errorTitle = patCur.PatNum + " " + patCur.GetNameLFnoPref() + " - ";
                if (patNumOld == patCur.PatNum && !string.IsNullOrEmpty(ContrAccount.ClaimErrorsCur))
                {
                    claimErrors += "\t\t" + ContrAccount.ClaimErrorsCur + "\r\n";
                }
                else if (!string.IsNullOrEmpty(ContrAccount.ClaimErrorsCur))
                {
                    claimErrors += errorTitle + ContrAccount.ClaimErrorsCur + "\r\n";
                }
                claimCreatedCount += ContrAccount.ClaimCreatedCount;
                patNumOld          = patCur.PatNum;
            }
            FillGrid();
            if (!string.IsNullOrEmpty(claimErrors))
            {
                MsgBoxCopyPaste form = new MsgBoxCopyPaste(claimErrors);
                form.ShowDialog();
            }
            MessageBox.Show(Lan.g(this, "Number of claims created") + ": " + claimCreatedCount);
        }
Пример #3
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            RepeatCharge[] chargeList  = RepeatCharges.Refresh(0);         //Gets all repeating charges for all patients, they may be disabled
            int            countAdded  = 0;
            int            claimsAdded = 0;
            DateTime       startDate;
            Procedure      proc;

            for (int i = 0; i < chargeList.Length; i++)
            {
                if (!chargeList[i].IsEnabled)                 //first make sure it is not disabled
                {
                    continue;
                }
                if (chargeList[i].DateStart > DateTime.Today)              //not started yet
                {
                    continue;
                }
                //if(chargeList[i].DateStop.Year>1880//not blank
                //	&& chargeList[i].DateStop<DateTime.Today)//but already ended
                //{
                //	continue;
                //}
                //get a list dates of all completed procedures with this Code and patNum
                ArrayList ALdates = RepeatCharges.GetDates(ProcedureCodes.GetCodeNum(chargeList[i].ProcCode), chargeList[i].PatNum);
                startDate = chargeList[i].DateStart;
                //This is the repeating date using the old methodology.  It is necessary for checking if the repeating procedure was already added using the old methodology.
                DateTime possibleDateOld = startDate;
                //This is a more accurate repeating date which will allow procedures to be added on the 28th and later.
                DateTime possibleDateNew = startDate;
                int      countMonths     = 0;
                //start looping through possible dates, beginning with the start date of the repeating charge
                while (possibleDateNew <= DateTime.Today)
                {
                    //Only allow back dating up to one month and 20 days.
                    if (possibleDateNew < DateTime.Today.AddDays(-50))
                    {
                        possibleDateOld = possibleDateOld.AddMonths(1);
                        countMonths++;
                        possibleDateNew = startDate.AddMonths(countMonths);
                        continue;                        //don't go back more than one month and 20 days
                    }
                    //check to see if the possible date is present in the list
                    if (ALdates.Contains(possibleDateNew) ||
                        ALdates.Contains(possibleDateOld))
                    {
                        possibleDateOld = possibleDateOld.AddMonths(1);
                        countMonths++;
                        possibleDateNew = startDate.AddMonths(countMonths);
                        continue;
                    }
                    if (chargeList[i].DateStop.Year > 1880 &&              //not blank
                        chargeList[i].DateStop < possibleDateNew)                           //but already ended
                    {
                        break;
                    }
                    //otherwise, insert a procedure to db
                    proc                = new Procedure();
                    proc.CodeNum        = ProcedureCodes.GetCodeNum(chargeList[i].ProcCode);
                    proc.DateEntryC     = DateTimeOD.Today;
                    proc.PatNum         = chargeList[i].PatNum;
                    proc.ProcDate       = possibleDateNew;
                    proc.DateTP         = possibleDateNew;
                    proc.ProcFee        = chargeList[i].ChargeAmt;
                    proc.ProcStatus     = ProcStat.C;
                    proc.ProvNum        = PrefC.GetLong(PrefName.PracticeDefaultProv);
                    proc.MedicalCode    = ProcedureCodes.GetProcCode(proc.CodeNum).MedicalCode;
                    proc.BaseUnits      = ProcedureCodes.GetProcCode(proc.CodeNum).BaseUnits;
                    proc.DiagnosticCode = PrefC.GetString(PrefName.ICD9DefaultForNewProcs);
                    //Check if the repeating charge has been flagged to copy it's note into the billing note of the procedure.
                    if (chargeList[i].CopyNoteToProc)
                    {
                        proc.BillingNote = chargeList[i].Note;
                    }
                    Procedures.Insert(proc);                    //no recall synch needed because dental offices don't use this feature
                    countAdded++;
                    possibleDateOld = possibleDateOld.AddMonths(1);
                    countMonths++;
                    possibleDateNew = startDate.AddMonths(countMonths);
                    if (chargeList[i].CreatesClaim && !ProcedureCodes.GetProcCode(chargeList[i].ProcCode).NoBillIns)
                    {
                        List <PatPlan>   patPlanList = PatPlans.Refresh(chargeList[i].PatNum);
                        List <InsSub>    subList     = InsSubs.RefreshForFam(Patients.GetFamily(chargeList[i].PatNum));
                        List <InsPlan>   insPlanList = InsPlans.RefreshForSubList(subList);;
                        List <Benefit>   benefitList = Benefits.Refresh(patPlanList, subList);
                        Claim            claimCur;
                        List <Procedure> procCurList = new List <Procedure>();
                        procCurList.Add(proc);
                        if (patPlanList.Count == 0)                       //no current insurance, do not create a claim
                        {
                            continue;
                        }
                        //create the claimprocs
                        Procedures.ComputeEstimates(proc, proc.PatNum, new List <ClaimProc>(), true, insPlanList, patPlanList, benefitList, Patients.GetPat(proc.PatNum).Age, subList);
                        //get claimprocs for this proc, may be more than one
                        List <ClaimProc> claimProcList = ClaimProcs.GetForProc(ClaimProcs.Refresh(proc.PatNum), proc.ProcNum);
                        string           claimType     = "P";
                        if (patPlanList.Count == 1 && PatPlans.GetOrdinal(PriSecMed.Medical, patPlanList, insPlanList, subList) > 0)                  //if there's exactly one medical plan
                        {
                            claimType = "Med";
                        }
                        claimCur      = CreateClaim(claimType, patPlanList, insPlanList, claimProcList, proc, subList);
                        claimProcList = ClaimProcs.Refresh(proc.PatNum);
                        if (claimCur.ClaimNum == 0)
                        {
                            continue;
                        }
                        claimsAdded++;
                        ClaimL.CalculateAndUpdate(procCurList, insPlanList, claimCur, patPlanList, benefitList, Patients.GetPat(proc.PatNum).Age, subList);
                        if (PatPlans.GetOrdinal(PriSecMed.Secondary, patPlanList, insPlanList, subList) > 0 &&                //if there exists a secondary plan
                            !CultureInfo.CurrentCulture.Name.EndsWith("CA"))                               //and not canada (don't create secondary claim for canada)
                        {
                            claimCur = CreateClaim("S", patPlanList, insPlanList, claimProcList, proc, subList);
                            if (claimCur.ClaimNum == 0)
                            {
                                continue;
                            }
                            claimsAdded++;
                            claimProcList        = ClaimProcs.Refresh(proc.PatNum);
                            claimCur.ClaimStatus = "H";
                            ClaimL.CalculateAndUpdate(procCurList, insPlanList, claimCur, patPlanList, benefitList, Patients.GetPat(proc.PatNum).Age, subList);
                        }
                    }
                }
            }
            //MessageBox.Show(countAdded.ToString()+" "+Lan.g(this,"procedures added."));
            MessageBox.Show(countAdded.ToString() + " " + Lan.g(this, "procedures added.") + "\r\n" + claimsAdded.ToString() + " " + Lan.g(this, "claims added."));
            DialogResult = DialogResult.OK;
        }
Пример #4
0
        private void butOK_Click(object sender, EventArgs e)
        {
            if (!EntriesAreValid())
            {
                return;
            }
            //This list should only contain a single patNum, but just in case.
            List <long> listDistinctPatNums = ProcList.Select(x => x.PatNum).Distinct().ToList();
            DateTime    procDate            = DateTime.MinValue;

            if (textDate.Text != "" && ProcList.Any(x => x.ProcDate != PIn.Date(textDate.Text)))
            {
                procDate = PIn.Date(textDate.Text);
            }
            #region Update ProcList and DB to reflect selections
            List <ClaimProc> listClaimProcsAll = ClaimProcs.RefreshForProcs(ProcList.Select(x => x.ProcNum).ToList());
            //Get data for any OrthoCases that may be linked to procs in ProcList
            List <OrthoProcLink>             listOrthoProcLinksAllForPat   = new List <OrthoProcLink>();
            Dictionary <long, OrthoProcLink> dictOrthoProcLinksForProcList = new Dictionary <long, OrthoProcLink>();
            Dictionary <long, OrthoCase>     dictOrthoCases     = new Dictionary <long, OrthoCase>();
            Dictionary <long, OrthoSchedule> dictOrthoSchedules = new Dictionary <long, OrthoSchedule>();
            OrthoCases.GetDataForListProcs(ref listOrthoProcLinksAllForPat, ref dictOrthoProcLinksForProcList, ref dictOrthoCases, ref dictOrthoSchedules, ProcList);
            OrthoCase            orthoCase     = null;
            OrthoSchedule        orthoSchedule = null;
            List <OrthoProcLink> listOrthoProcLinksForOrthoCase = null;
            foreach (Procedure proc in ProcList)
            {
                bool             hasChanged            = false;
                bool             hasDateChanged        = false;
                List <ClaimProc> listClaimProcsForProc = ClaimProcs.GetForProc(listClaimProcsAll, proc.ProcNum);
                Procedure        procOld = _procOldList.Find(x => x.ProcNum == proc.ProcNum); //this shouldn't fail, it needs to be in this list.
                if (procDate != DateTime.MinValue && proc.ProcDate != procDate)               //Using value entered in the textbox.
                {
                    proc.ProcDate = procDate;
                    //ClaimProc.ProcDate will be "synched" in Procedures.ComputeEstimates(), but only if not attached to a claim.  Mimics FormprocEdit.
                    hasDateChanged = true;
                    hasChanged     = true;
                }
                if (comboProv.GetSelected <Provider>() != null && comboProv.GetSelected <Provider>().ProvNum != proc.ProvNum)           //Using selection
                {
                    proc.ProvNum = comboProv.GetSelected <Provider>().ProvNum;
                    //Mimics FormProcEdit, uses different criteria than Procedures.ComputeEstimates().
                    ClaimProcs.TrySetProvFromProc(proc, listClaimProcsForProc);
                    hasChanged = true;
                }
                if (comboClinic.GetSelected <Clinic>() != null && comboClinic.GetSelected <Clinic>().ClinicNum != proc.ClinicNum)           //Using selection
                {
                    proc.ClinicNum = comboClinic.GetSelected <Clinic>().ClinicNum;
                    listClaimProcsForProc.ForEach(x => x.ClinicNum = proc.ClinicNum);
                    hasChanged = true;
                }
                if (hasChanged)
                {
                    Procedures.Update(proc, procOld);
                    if (hasDateChanged)
                    {
                        List <ClaimProc> listNewClaimProcs;
                        dictOrthoProcLinksForProcList.TryGetValue(proc.ProcNum, out OrthoProcLink orthoProcLink);
                        //If proc is linked to an OrthoCase, update dates for OrthoCase.
                        if (orthoProcLink != null)
                        {
                            OrthoCases.UpdateDatesByLinkedProc(orthoProcLink, proc);
                        }
                        OrthoCases.FillOrthoCaseObjectsForProc(proc.ProcNum, ref orthoProcLink, ref orthoCase, ref orthoSchedule, ref listOrthoProcLinksForOrthoCase,
                                                               dictOrthoProcLinksForProcList, dictOrthoCases, dictOrthoSchedules, listOrthoProcLinksAllForPat);
                        RecomputeEstimates(proc, listClaimProcsForProc, out listNewClaimProcs, orthoProcLink, orthoCase, orthoSchedule, listOrthoProcLinksForOrthoCase);
                        ClaimProcs.InsertMany(listNewClaimProcs);                        //Only insert claimProcs that were newly added.
                    }
                }
            }
            ClaimProcs.UpdateMany(listClaimProcsAll);            //Does not contain new claimProcs.
            foreach (long patNum in listDistinctPatNums)         //Should be a single patient.
            {
                Recalls.Synch(patNum);
            }
            #endregion
            #region Security Log Entries
            string logTextProcComplete = "";       //To make security log for procs that were C (specific permission)
            string logTextProcExisting = "";       //To make a security log for procs that were EO,EC (specific permission)
            string logTextProcOther    = "";       //All other procedures (general permission)
            foreach (long patNum in listDistinctPatNums)
            {
                foreach (Procedure proc in ProcList)                 //necessary because of different original values
                {
                    Procedure procOld = _procOldList.FirstOrDefault(x => x.ProcNum == proc.ProcNum);
                    if (procOld == null)
                    {
                        continue;
                    }
                    //If proc has not been changed then a blank string will be returned.
                    //Only changed procs will be reflected in security log entries.
                    switch (procOld.ProcStatus)
                    {
                    case ProcStat.C:
                        logTextProcComplete += ConstructSecurityLogForProcType(proc, procOld);
                        break;

                    case ProcStat.EO:
                    case ProcStat.EC:
                        logTextProcExisting += ConstructSecurityLogForProcType(proc, procOld);
                        break;

                    default:
                        logTextProcOther += ConstructSecurityLogForProcType(proc, procOld);
                        break;
                    }
                }
                if (logTextProcComplete != "")
                {
                    SecurityLogs.MakeLogEntry(Permissions.ProcComplEdit, patNum, logTextProcComplete);
                }
                if (logTextProcExisting != "")
                {
                    SecurityLogs.MakeLogEntry(Permissions.ProcExistingEdit, patNum, logTextProcExisting);
                }
                if (logTextProcOther != "")
                {
                    SecurityLogs.MakeLogEntry(Permissions.ProcEdit, patNum, logTextProcOther);
                }
            }
            #endregion
            DialogResult = DialogResult.OK;
        }
Пример #5
0
        private bool EntriesAreValid()
        {
            //Get a new recent list of claimprocs for pat to be able to validate for provider and procedure status change.
            if (textDate.Text != "" && textDate.errorProvider1.GetError(textDate) != "")
            {
                //Either loaded blank or user deleted date. Either way blank will not make it to DB.
                MsgBox.Show(this, "Please fix data entry errors first.");
                return(false);
            }
            DateTime procDate = PIn.Date(textDate.Text);

            if (textDate.Text != "" && ProcList.Any(x => x.ProcDate != procDate))
            {
                if (!IsUserAuthorizedForProcDate(procDate))                 //Do not allow new ProcDate outside of date limitations.  Mimics behavior in FormProcEdit.
                {
                    return(false);
                }
                Appointment apt;
                foreach (Procedure proc in ProcList)                //first validate for all dates.
                {
                    #region Future dating completed procedures validation.
                    if (!PrefC.GetBool(PrefName.FutureTransDatesAllowed) && proc.ProcStatus == ProcStat.C && procDate > DateTime.Today)
                    {
                        MsgBox.Show(this, "Completed procedures cannot have future dates.");
                        return(false);
                    }
                    #endregion
                    #region Procedures attached to appointments date validation.
                    if (proc.AptNum == 0)
                    {
                        continue;
                    }
                    apt = Appointments.GetOneApt(proc.AptNum);
                    if (proc.ProcDate.Date != apt.AptDateTime.Date)
                    {
                        string error = Lan.g(this, "Date does not match appointment date for a procedure dated:") + " " + proc.ProcDate.ToShortDateString()
                                       + "\r\n" + Lan.g(this, "Continue anyway?");
                        if (MessageBox.Show(error, "", MessageBoxButtons.YesNo) == DialogResult.No)
                        {
                            return(false);
                        }
                        break;
                    }
                    #endregion
                }
            }
            List <ClaimProc> listClaimProcsForPat = ClaimProcs.RefreshForProcs(ProcList.Select(x => x.ProcNum).ToList());
            foreach (Procedure proc in ProcList)
            {
                if (proc.IsLocked)
                {
                    MsgBox.Show(this, "Locked procedures cannot be edited.");
                    return(false);
                }
                #region Provider change validation.
                List <ClaimProc> listClaimProcsForProc = ClaimProcs.GetForProc(listClaimProcsForPat, proc.ProcNum);
                long             selectedProvNum       = (comboProv.GetSelected <Provider>()?.ProvNum ?? 0);//0 if no selection made
                if (selectedProvNum != 0 && !ProcedureL.ValidateProvider(listClaimProcsForProc, selectedProvNum, proc.ProvNum))
                {
                    return(false);
                }
                #endregion
            }
            return(true);
        }