Esempio n. 1
0
        public void OrthoCases_Delete_DeleteOrthoCaseAndAssociatedObjects()
        {
            Prefs.UpdateString(PrefName.OrthoBandingCodes, "D8080");
            Prefs.UpdateString(PrefName.OrthoDebondCodes, "D8070");
            Prefs.UpdateString(PrefName.OrthoVisitCodes, "D8060");
            Userod user = UserodT.CreateUser();

            Security.CurUser = user;
            Patient   pat          = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name);
            Procedure bandingProc  = ProcedureT.CreateProcedure(pat, "D8080", ProcStat.C, "", 0);
            Procedure visitProc    = ProcedureT.CreateProcedure(pat, "D8060", ProcStat.C, "", 0);
            Procedure debondProc   = ProcedureT.CreateProcedure(pat, "D8070", ProcStat.C, "", 0);
            long      orthoCaseNum = OrthoCaseT.InsertForFormOrthoCase(pat.PatNum, 2000, 1200, 0, 800, DateTime.Today, false, DateTime.Today.AddMonths(12), 1000, 400, 60, bandingProc);

            OrthoProcLinks.LinkProcForActiveOrthoCase(visitProc);
            OrthoProcLinks.LinkProcForActiveOrthoCase(debondProc);
            OrthoCase            orthoCase        = OrthoCases.GetOne(orthoCaseNum);
            OrthoPlanLink        schedulePlanLink = OrthoPlanLinks.GetOneForOrthoCaseByType(orthoCaseNum, OrthoPlanLinkType.OrthoSchedule);
            long                 orthoscheduleNum = schedulePlanLink.FKey;
            OrthoSchedule        orthoSchedule    = OrthoSchedules.GetOne(schedulePlanLink.FKey);
            List <OrthoProcLink> listAllProcLinks = OrthoProcLinks.GetManyByOrthoCase(orthoCaseNum);

            OrthoCases.Delete(orthoCase.OrthoCaseNum, orthoSchedule, schedulePlanLink, listAllProcLinks);
            orthoCase        = OrthoCases.GetOne(orthoCaseNum);
            schedulePlanLink = OrthoPlanLinks.GetOneForOrthoCaseByType(orthoCaseNum, OrthoPlanLinkType.OrthoSchedule);
            orthoSchedule    = OrthoSchedules.GetOne(orthoscheduleNum);
            listAllProcLinks = OrthoProcLinks.GetManyByOrthoCase(orthoCaseNum);
            Assert.AreEqual(orthoCase, null);
            Assert.AreEqual(schedulePlanLink, null);
            Assert.AreEqual(orthoSchedule, null);
            Assert.AreEqual(listAllProcLinks.Count, 0);
        }
Esempio n. 2
0
        public void OrthoCases_UpdateDatesByLinkedProc_UpdateBandingAndDebondDates()
        {
            Prefs.UpdateString(PrefName.OrthoDebondCodes, "D8070");
            Userod user = UserodT.CreateUser();

            Security.CurUser = user;
            Patient   pat          = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name);
            Procedure bandingProc  = ProcedureT.CreateProcedure(pat, "D8080", ProcStat.C, "", 0);
            Procedure debondProc   = ProcedureT.CreateProcedure(pat, "D8070", ProcStat.C, "", 0, procDate: DateTime.Today.AddDays(2));
            long      orthoCaseNum = OrthoCaseT.InsertForFormOrthoCase(pat.PatNum, 2000, 1200, 0, 800, DateTime.Today, false, DateTime.Today.AddMonths(12), 1000, 400, 60, bandingProc);

            OrthoProcLinks.LinkProcForActiveOrthoCase(debondProc);
            OrthoProcLink bandingProcLink = OrthoProcLinks.GetByType(orthoCaseNum, OrthoProcType.Banding);
            OrthoProcLink debondProcLink  = OrthoProcLinks.GetByType(orthoCaseNum, OrthoProcType.Debond);
            OrthoCase     orthoCase       = OrthoCases.GetOne(orthoCaseNum);

            Assert.AreEqual(orthoCase.BandingDate, DateTime.Today);
            bandingProc.ProcDate = DateTime.Today.AddDays(1);
            OrthoCases.UpdateDatesByLinkedProc(bandingProcLink, bandingProc);
            orthoCase = OrthoCases.GetOne(orthoCaseNum);
            Assert.AreEqual(orthoCase.BandingDate, DateTime.Today.AddDays(1));
            Assert.AreEqual(orthoCase.DebondDate, DateTime.Today.AddDays(2));
            debondProc.ProcDate = DateTime.Today.AddDays(3);
            OrthoCases.UpdateDatesByLinkedProc(debondProcLink, debondProc);
            orthoCase = OrthoCases.GetOne(orthoCaseNum);
            Assert.AreEqual(orthoCase.BandingDate, DateTime.Today.AddDays(1));
            Assert.AreEqual(orthoCase.DebondDate, DateTime.Today.AddDays(3));
        }
Esempio n. 3
0
        public void OrthoProcLinks_LinkProcForActiveOrthoCase_LinkCompletedProcsToOrthoCase()
        {
            Prefs.UpdateString(PrefName.OrthoBandingCodes, "D8080");
            Prefs.UpdateString(PrefName.OrthoDebondCodes, "D8070");
            Prefs.UpdateString(PrefName.OrthoVisitCodes, "D8060");
            Patient   pat          = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name);
            Procedure bandingProc  = ProcedureT.CreateProcedure(pat, "D8080", ProcStat.C, "", 0);
            Procedure visitProc    = ProcedureT.CreateProcedure(pat, "D8060", ProcStat.C, "", 0);
            Procedure debondProc   = ProcedureT.CreateProcedure(pat, "D8070", ProcStat.C, "", 0);
            long      orthoCaseNum = OrthoCaseT.InsertForFormOrthoCase(pat.PatNum, 2000, 1200, 0, 800, DateTime.Today, false, DateTime.Today.AddMonths(12), 1000, 400, 60, bandingProc);

            OrthoProcLinks.LinkProcForActiveOrthoCase(visitProc);
            OrthoProcLinks.LinkProcForActiveOrthoCase(debondProc);
            OrthoCase            orthoCase          = OrthoCases.GetOne(orthoCaseNum);
            List <OrthoProcLink> listAllProcLinks   = OrthoProcLinks.GetManyByOrthoCase(orthoCaseNum);
            List <OrthoProcLink> listVisitProcLinks = OrthoProcLinks.GetVisitLinksForOrthoCase(orthoCaseNum);
            OrthoProcLink        debondProcLink     = OrthoProcLinks.GetByType(orthoCaseNum, OrthoProcType.Debond);

            Assert.AreEqual(orthoCase.IsActive, false);
            Assert.AreEqual(listAllProcLinks.Count, 3);
            Assert.AreEqual(debondProcLink.ProcNum, debondProc.ProcNum);
            Assert.AreEqual(debondProcLink.SecUserNumEntry, Security.CurUser.UserNum);
            Assert.AreEqual(listVisitProcLinks.Count, 1);
            Assert.AreEqual(listVisitProcLinks[0].ProcNum, visitProc.ProcNum);
            Assert.AreEqual(listVisitProcLinks[0].SecUserNumEntry, Security.CurUser.UserNum);
        }
Esempio n. 4
0
        ///<summary>Updates the OrthoCase, OrthoSchedule, and banding OrthoProcLink for an Ortho Case.</summary>
        public static void UpdateForFormOrthoCase(OrthoCase oldOrthoCase, OrthoSchedule oldOrthoSchedule, double fee, double feeInsPrimary
                                                  , double feeInsSecondary, double feePat, DateTime bandingDate, bool isTransfer, DateTime debondDateExpected, double bandingAmount, double debondAmount
                                                  , double visitAmount, Procedure bandingProc, Procedure debondProc, OrthoProcLink bandingProcLink)
        {
            //No remoting role check; no call to db
            OrthoCase newOrthoCase = oldOrthoCase.Copy();

            //OrthoCase
            newOrthoCase.Fee             = fee;
            newOrthoCase.FeeInsPrimary   = feeInsPrimary;
            newOrthoCase.FeeInsSecondary = feeInsSecondary;
            newOrthoCase.FeePat          = feePat;
            newOrthoCase.BandingDate     = bandingDate;
            newOrthoCase.IsTransfer      = isTransfer;
            if (debondProc == null)
            {
                newOrthoCase.DebondDateExpected = debondDateExpected;
                newOrthoCase.DebondDate         = DateTime.MinValue;
            }
            if (isTransfer && bandingProcLink != null)           //OrthoCase has been changed to a transfer. Delete linked banding proc if it exists.
            {
                OrthoProcLinks.Delete(bandingProcLink.OrthoProcLinkNum);
            }
            else if (!isTransfer)
            {
                if (bandingProcLink == null)               //OrthoCase has been changed to a non-transfer. Link banding proc.
                {
                    OrthoProcLinks.Insert(OrthoProcLinks.CreateHelper(newOrthoCase.OrthoCaseNum, bandingProc.ProcNum, OrthoProcType.Banding));
                }
                else                  //OrthoCase is still a non-transfer, but banding proc linked may have changed so update.
                {
                    OrthoProcLink newBandingProcLink = bandingProcLink.Copy();
                    newBandingProcLink.ProcNum = bandingProc.ProcNum;
                    OrthoProcLinks.Update(newBandingProcLink, bandingProcLink);
                }
                if (bandingProc != null && bandingProc.AptNum != 0)             //Banding proc may have changed, so check to see if it is scheduled and update bandingDate.
                {
                    newOrthoCase.BandingDate = bandingProc.ProcDate;
                }
            }
            OrthoCases.Update(newOrthoCase, oldOrthoCase);
            //OrthoSchedule
            OrthoSchedule newOrthoSchedule = oldOrthoSchedule.Copy();

            newOrthoSchedule.BandingAmount = bandingAmount;
            newOrthoSchedule.DebondAmount  = debondAmount;
            newOrthoSchedule.VisitAmount   = visitAmount;
            OrthoSchedules.Update(newOrthoSchedule, oldOrthoSchedule);
        }
Esempio n. 5
0
        ///<summary>Inserts the OrthoCase, OrthoSchedule, Schedule OrthoPlanLink, and banding OrthoProcLink for an Ortho Case.</summary>
        public static long InsertForFormOrthoCase(long patNum, double fee, double feeInsPrimary, double feeInsSecondary, double feePat, DateTime bandingDate
                                                  , bool isTransfer, DateTime debondDateExpected, double bandingAmount, double debondAmount, double visitAmount, Procedure bandingProc)
        {
            //No remoting role check; no call to db
            //Ortho Case
            OrthoCase newOrthoCase = new OrthoCase();

            newOrthoCase.PatNum             = patNum;
            newOrthoCase.Fee                = fee;
            newOrthoCase.FeeInsPrimary      = feeInsPrimary;
            newOrthoCase.FeeInsSecondary    = feeInsSecondary;
            newOrthoCase.FeePat             = feePat;
            newOrthoCase.BandingDate        = bandingDate;
            newOrthoCase.DebondDateExpected = debondDateExpected;
            newOrthoCase.IsTransfer         = isTransfer;
            newOrthoCase.SecUserNumEntry    = Security.CurUser.UserNum;
            newOrthoCase.IsActive           = true; //New Ortho Cases can only be added if there are no other active ones. So we automatically set a new ortho case as active.
            if (bandingProc.AptNum != 0)            //If banding is scheduled save the appointment date instead.
            {
                newOrthoCase.BandingDate = bandingProc.ProcDate;
            }
            long orthoCaseNum = OrthoCases.Insert(newOrthoCase);
            //Ortho Schedule
            OrthoSchedule newOrthoSchedule = new OrthoSchedule();

            newOrthoSchedule.BandingAmount = bandingAmount;
            newOrthoSchedule.DebondAmount  = debondAmount;
            newOrthoSchedule.VisitAmount   = visitAmount;
            newOrthoSchedule.IsActive      = true;
            long orthoScheduleNum = OrthoSchedules.Insert(newOrthoSchedule);
            //Ortho Plan Link
            OrthoPlanLink newOrthoPlanLink = new OrthoPlanLink();

            newOrthoPlanLink.OrthoCaseNum    = orthoCaseNum;
            newOrthoPlanLink.LinkType        = OrthoPlanLinkType.OrthoSchedule;
            newOrthoPlanLink.FKey            = orthoScheduleNum;
            newOrthoPlanLink.IsActive        = true;
            newOrthoPlanLink.SecUserNumEntry = Security.CurUser.UserNum;
            OrthoPlanLinks.Insert(newOrthoPlanLink);
            //Banding Proc Link
            if (!newOrthoCase.IsTransfer)
            {
                OrthoProcLinks.Insert(OrthoProcLinks.CreateHelper(orthoCaseNum, bandingProc.ProcNum, OrthoProcType.Banding));
            }
            return(orthoCaseNum);
        }
Esempio n. 6
0
        public void OrthoCases_Activate_ActivateAnOrthoCaseAndDeactivateOthersForPat()
        {
            Userod user = UserodT.CreateUser();

            Security.CurUser = user;
            Patient       pat               = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name);
            Procedure     bandingProc1      = ProcedureT.CreateProcedure(pat, "D8080", ProcStat.TP, "", 0);
            Procedure     bandingProc2      = ProcedureT.CreateProcedure(pat, "D8080", ProcStat.TP, "", 0);
            long          orthoCaseNum1     = OrthoCaseT.InsertForFormOrthoCase(pat.PatNum, 2000, 1200, 0, 800, DateTime.Today, false, DateTime.Today.AddMonths(12), 1000, 400, 60, bandingProc1);
            long          orthoCaseNum2     = OrthoCaseT.InsertForFormOrthoCase(pat.PatNum, 2000, 1200, 0, 800, DateTime.Today, false, DateTime.Today.AddMonths(12), 1000, 400, 60, bandingProc2);
            OrthoCase     orthoCase2        = OrthoCases.GetOne(orthoCaseNum2);
            OrthoPlanLink schedulePlanLink2 = OrthoPlanLinks.GetOneForOrthoCaseByType(orthoCaseNum2, OrthoPlanLinkType.OrthoSchedule);
            OrthoSchedule orthoSchedule2    = OrthoSchedules.GetOne(schedulePlanLink2.FKey);

            //Set one OrthoCase inactive. Now orthoCase1 is active and orthoCase2 is inactive.
            OrthoCases.SetActiveState(orthoCase2, schedulePlanLink2, orthoSchedule2, false);
            OrthoCase     orthoCase1        = OrthoCases.GetOne(orthoCaseNum1);
            OrthoPlanLink schedulePlanLink1 = OrthoPlanLinks.GetOneForOrthoCaseByType(orthoCaseNum1, OrthoPlanLinkType.OrthoSchedule);
            OrthoSchedule orthoSchedule1    = OrthoSchedules.GetOne(schedulePlanLink1.FKey);

            orthoCase2        = OrthoCases.GetOne(orthoCaseNum2);
            schedulePlanLink2 = OrthoPlanLinks.GetOneForOrthoCaseByType(orthoCaseNum2, OrthoPlanLinkType.OrthoSchedule);
            orthoSchedule2    = OrthoSchedules.GetOne(schedulePlanLink2.FKey);
            Assert.AreEqual(orthoCase1.IsActive, true);
            Assert.AreEqual(schedulePlanLink1.IsActive, true);
            Assert.AreEqual(orthoSchedule1.IsActive, true);
            Assert.AreEqual(orthoCase2.IsActive, false);
            Assert.AreEqual(schedulePlanLink2.IsActive, false);
            Assert.AreEqual(orthoSchedule2.IsActive, false);
            //Active orthoCase2 which should inactivate orthoCase1
            OrthoCases.Activate(orthoCase2, pat.PatNum);
            orthoCase1        = OrthoCases.GetOne(orthoCaseNum1);
            schedulePlanLink1 = OrthoPlanLinks.GetOneForOrthoCaseByType(orthoCaseNum1, OrthoPlanLinkType.OrthoSchedule);
            orthoSchedule1    = OrthoSchedules.GetOne(schedulePlanLink1.FKey);
            orthoCase2        = OrthoCases.GetOne(orthoCaseNum2);
            schedulePlanLink2 = OrthoPlanLinks.GetOneForOrthoCaseByType(orthoCaseNum2, OrthoPlanLinkType.OrthoSchedule);
            orthoSchedule2    = OrthoSchedules.GetOne(schedulePlanLink2.FKey);
            Assert.AreEqual(orthoCase1.IsActive, false);
            Assert.AreEqual(schedulePlanLink1.IsActive, false);
            Assert.AreEqual(orthoSchedule1.IsActive, false);
            Assert.AreEqual(orthoCase2.IsActive, true);
            Assert.AreEqual(schedulePlanLink2.IsActive, true);
            Assert.AreEqual(orthoSchedule2.IsActive, true);
        }
Esempio n. 7
0
        public void OrthoProcLinks_SetProcFeeForLinkedProc_SetFeeForEachProcType()
        {
            Patient              pat                = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name);
            Procedure            bandingProc        = ProcedureT.CreateProcedure(pat, "D8080", ProcStat.C, "", 0);
            Procedure            visitProc          = ProcedureT.CreateProcedure(pat, "D8060", ProcStat.C, "", 0);
            Procedure            debondProc         = ProcedureT.CreateProcedure(pat, "D8070", ProcStat.C, "", 0);
            long                 orthoCaseNum       = OrthoCaseT.InsertForFormOrthoCase(pat.PatNum, 2000, 1200, 0, 800, DateTime.Today, false, DateTime.Today.AddMonths(12), 1000, 400, 60, new Procedure());
            OrthoCase            orthoCase          = OrthoCases.GetOne(orthoCaseNum);
            OrthoPlanLink        schedulePlanLink   = OrthoPlanLinks.GetOneForOrthoCaseByType(orthoCaseNum, OrthoPlanLinkType.OrthoSchedule);
            OrthoSchedule        orthoSchedule      = OrthoSchedules.GetOne(schedulePlanLink.FKey);
            List <OrthoProcLink> listVisitProcLinks = OrthoProcLinks.GetVisitLinksForOrthoCase(orthoCaseNum);

            OrthoProcLinks.SetProcFeeForLinkedProc(orthoCase, bandingProc, OrthoProcType.Banding, listVisitProcLinks, schedulePlanLink, orthoSchedule);
            OrthoProcLinks.SetProcFeeForLinkedProc(orthoCase, visitProc, OrthoProcType.Visit, listVisitProcLinks, schedulePlanLink, orthoSchedule);
            OrthoProcLinks.SetProcFeeForLinkedProc(orthoCase, debondProc, OrthoProcType.Debond, listVisitProcLinks, schedulePlanLink, orthoSchedule);
            Assert.AreEqual(bandingProc.ProcFee, 1000);
            Assert.AreEqual(debondProc.ProcFee, 400);
            Assert.AreEqual(visitProc.ProcFee, 60);
        }
Esempio n. 8
0
        public void ClaimProcs_ComputeEstimatesByOrthoCase_SetClaimProcForEachProcType()
        {
            Prefs.UpdateString(PrefName.OrthoBandingCodes, "D8080");
            Prefs.UpdateString(PrefName.OrthoDebondCodes, "D8070");
            Prefs.UpdateString(PrefName.OrthoVisitCodes, "D8060");
            Patient       pat              = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name);
            Procedure     bandingProc      = ProcedureT.CreateProcedure(pat, "D8080", ProcStat.C, "", 0);
            PatPlan       patPlan          = PatPlanT.CreatePatPlan(1, pat.PatNum, 0);
            ClaimProc     bandingClaimProc = ClaimProcT.CreateClaimProc(pat.PatNum, bandingProc.ProcNum, 0, 0, bandingProc.ProcDate, 1, 1, 1);
            Procedure     visitProc        = ProcedureT.CreateProcedure(pat, "D8060", ProcStat.C, "", 0);
            ClaimProc     visitClaimProc   = ClaimProcT.CreateClaimProc(pat.PatNum, visitProc.ProcNum, 0, 0, visitProc.ProcDate, 1, 1, 1);
            Procedure     debondProc       = ProcedureT.CreateProcedure(pat, "D8070", ProcStat.C, "", 0);
            ClaimProc     debondClaimProc  = ClaimProcT.CreateClaimProc(pat.PatNum, debondProc.ProcNum, 0, 0, debondProc.ProcDate, 1, 1, 1);
            long          orthoCaseNum     = OrthoCaseT.InsertForFormOrthoCase(pat.PatNum, 2000, 1200, 0, 800, DateTime.Today, false, DateTime.Today.AddMonths(12), 1000, 400, 60, bandingProc);
            OrthoCase     orthoCase        = OrthoCases.GetOne(orthoCaseNum);
            OrthoPlanLink schedulePlanLink = OrthoPlanLinks.GetOneForOrthoCaseByType(orthoCaseNum, OrthoPlanLinkType.OrthoSchedule);
            OrthoSchedule orthoSchedule    = OrthoSchedules.GetOne(schedulePlanLink.FKey);

            OrthoProcLinks.LinkProcForActiveOrthoCase(bandingProc);
            OrthoProcLinks.LinkProcForActiveOrthoCase(visitProc);
            OrthoProcLinks.LinkProcForActiveOrthoCase(debondProc);
            List <OrthoProcLink> allProcLinks      = OrthoProcLinks.GetManyByOrthoCase(orthoCaseNum);
            OrthoProcLink        bandingLink       = allProcLinks.FirstOrDefault(x => x.ProcLinkType == OrthoProcType.Banding);
            OrthoProcLink        debondLink        = allProcLinks.FirstOrDefault(x => x.ProcLinkType == OrthoProcType.Debond);
            OrthoProcLink        visitLink         = allProcLinks.FirstOrDefault(x => x.ProcLinkType == OrthoProcType.Visit);
            List <ClaimProc>     listAllClaimProcs = new List <ClaimProc>()
            {
                bandingClaimProc, visitClaimProc, debondClaimProc
            };
            List <OrthoProcLink> listAllOrthoProcLinks = new List <OrthoProcLink>()
            {
                bandingLink, visitLink, debondLink
            };
            List <PatPlan> listPatPlans = new List <PatPlan>()
            {
                patPlan
            };

            ClaimProcs.ComputeEstimatesByOrthoCase(bandingProc, bandingLink, orthoCase, orthoSchedule, true, listAllClaimProcs,
                                                   new List <ClaimProc>()
            {
                bandingClaimProc
            }, listPatPlans, listAllOrthoProcLinks);
            ClaimProcs.ComputeEstimatesByOrthoCase(debondProc, debondLink, orthoCase, orthoSchedule, true, listAllClaimProcs,
                                                   new List <ClaimProc>()
            {
                debondClaimProc
            }, listPatPlans, listAllOrthoProcLinks);
            ClaimProcs.ComputeEstimatesByOrthoCase(visitProc, visitLink, orthoCase, orthoSchedule, true, listAllClaimProcs,
                                                   new List <ClaimProc>()
            {
                visitClaimProc
            }, listPatPlans, listAllOrthoProcLinks);
            Assert.AreEqual(bandingClaimProc.AllowedOverride, 0);
            Assert.AreEqual(bandingClaimProc.CopayOverride, 0);
            Assert.AreEqual(bandingClaimProc.PercentOverride, 0);
            Assert.AreEqual(bandingClaimProc.PaidOtherInsOverride, 0);
            Assert.AreEqual(bandingClaimProc.WriteOffEstOverride, 0);
            Assert.AreEqual(bandingClaimProc.InsEstTotalOverride, 600);
            Assert.AreEqual(debondClaimProc.AllowedOverride, 0);
            Assert.AreEqual(debondClaimProc.CopayOverride, 0);
            Assert.AreEqual(debondClaimProc.PercentOverride, 0);
            Assert.AreEqual(debondClaimProc.PaidOtherInsOverride, 0);
            Assert.AreEqual(debondClaimProc.WriteOffEstOverride, 0);
            Assert.AreEqual(debondClaimProc.InsEstTotalOverride, 240);
            Assert.AreEqual(visitClaimProc.AllowedOverride, 0);
            Assert.AreEqual(visitClaimProc.CopayOverride, 0);
            Assert.AreEqual(visitClaimProc.PercentOverride, 0);
            Assert.AreEqual(visitClaimProc.PaidOtherInsOverride, 0);
            Assert.AreEqual(visitClaimProc.WriteOffEstOverride, 0);
            Assert.AreEqual(visitClaimProc.InsEstTotalOverride, 36);
        }
Esempio n. 9
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;
        }