示例#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);
        }
示例#2
0
        ///<summary>Inserts one OrthoSchedule into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(OrthoSchedule orthoSchedule, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                orthoSchedule.OrthoScheduleNum = ReplicationServers.GetKey("orthoschedule", "OrthoScheduleNum");
            }
            string command = "INSERT INTO orthoschedule (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "OrthoScheduleNum,";
            }
            command += "BandingDateOverride,DebondDateOverride,BandingAmount,VisitAmount,DebondAmount,IsActive) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(orthoSchedule.OrthoScheduleNum) + ",";
            }
            command +=
                POut.Date(orthoSchedule.BandingDateOverride) + ","
                + POut.Date(orthoSchedule.DebondDateOverride) + ","
                + "'" + POut.Double(orthoSchedule.BandingAmount) + "',"
                + "'" + POut.Double(orthoSchedule.VisitAmount) + "',"
                + "'" + POut.Double(orthoSchedule.DebondAmount) + "',"
                + POut.Bool(orthoSchedule.IsActive) + ")";
            //SecDateTEdit can only be set by MySQL
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                orthoSchedule.OrthoScheduleNum = Db.NonQ(command, true, "OrthoScheduleNum", "orthoSchedule");
            }
            return(orthoSchedule.OrthoScheduleNum);
        }
示例#3
0
 ///<summary>Returns true if Update(OrthoSchedule,OrthoSchedule) would make changes to the database.
 ///Does not make any changes to the database and can be called before remoting role is checked.</summary>
 public static bool UpdateComparison(OrthoSchedule orthoSchedule, OrthoSchedule oldOrthoSchedule)
 {
     if (orthoSchedule.BandingDateOverride.Date != oldOrthoSchedule.BandingDateOverride.Date)
     {
         return(true);
     }
     if (orthoSchedule.DebondDateOverride.Date != oldOrthoSchedule.DebondDateOverride.Date)
     {
         return(true);
     }
     if (orthoSchedule.BandingAmount != oldOrthoSchedule.BandingAmount)
     {
         return(true);
     }
     if (orthoSchedule.VisitAmount != oldOrthoSchedule.VisitAmount)
     {
         return(true);
     }
     if (orthoSchedule.DebondAmount != oldOrthoSchedule.DebondAmount)
     {
         return(true);
     }
     if (orthoSchedule.IsActive != oldOrthoSchedule.IsActive)
     {
         return(true);
     }
     //SecDateTEdit can only be set by MySQL
     return(false);
 }
示例#4
0
        ///<summary>Updates one OrthoSchedule in the database.</summary>
        public static void Update(OrthoSchedule orthoSchedule)
        {
            string command = "UPDATE orthoschedule SET "
                             + "BandingDateOverride=  " + POut.Date(orthoSchedule.BandingDateOverride) + ", "
                             + "DebondDateOverride =  " + POut.Date(orthoSchedule.DebondDateOverride) + ", "
                             + "BandingAmount      = '" + POut.Double(orthoSchedule.BandingAmount) + "', "
                             + "VisitAmount        = '" + POut.Double(orthoSchedule.VisitAmount) + "', "
                             + "DebondAmount       = '" + POut.Double(orthoSchedule.DebondAmount) + "', "
                             + "IsActive           =  " + POut.Bool(orthoSchedule.IsActive) + " "
                             //SecDateTEdit can only be set by MySQL
                             + "WHERE OrthoScheduleNum = " + POut.Long(orthoSchedule.OrthoScheduleNum);

            Db.NonQ(command);
        }
示例#5
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);
        }
示例#6
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);
        }
示例#7
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);
        }
示例#8
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);
        }
示例#9
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <OrthoSchedule> TableToList(DataTable table)
        {
            List <OrthoSchedule> retVal = new List <OrthoSchedule>();
            OrthoSchedule        orthoSchedule;

            foreach (DataRow row in table.Rows)
            {
                orthoSchedule = new OrthoSchedule();
                orthoSchedule.OrthoScheduleNum    = PIn.Long(row["OrthoScheduleNum"].ToString());
                orthoSchedule.BandingDateOverride = PIn.Date(row["BandingDateOverride"].ToString());
                orthoSchedule.DebondDateOverride  = PIn.Date(row["DebondDateOverride"].ToString());
                orthoSchedule.BandingAmount       = PIn.Double(row["BandingAmount"].ToString());
                orthoSchedule.VisitAmount         = PIn.Double(row["VisitAmount"].ToString());
                orthoSchedule.DebondAmount        = PIn.Double(row["DebondAmount"].ToString());
                orthoSchedule.IsActive            = PIn.Bool(row["IsActive"].ToString());
                orthoSchedule.SecDateTEdit        = PIn.DateT(row["SecDateTEdit"].ToString());
                retVal.Add(orthoSchedule);
            }
            return(retVal);
        }
示例#10
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);
        }
示例#11
0
        ///<summary>Updates one OrthoSchedule in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.  Returns true if an update occurred.</summary>
        public static bool Update(OrthoSchedule orthoSchedule, OrthoSchedule oldOrthoSchedule)
        {
            string command = "";

            if (orthoSchedule.BandingDateOverride.Date != oldOrthoSchedule.BandingDateOverride.Date)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "BandingDateOverride = " + POut.Date(orthoSchedule.BandingDateOverride) + "";
            }
            if (orthoSchedule.DebondDateOverride.Date != oldOrthoSchedule.DebondDateOverride.Date)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DebondDateOverride = " + POut.Date(orthoSchedule.DebondDateOverride) + "";
            }
            if (orthoSchedule.BandingAmount != oldOrthoSchedule.BandingAmount)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "BandingAmount = '" + POut.Double(orthoSchedule.BandingAmount) + "'";
            }
            if (orthoSchedule.VisitAmount != oldOrthoSchedule.VisitAmount)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "VisitAmount = '" + POut.Double(orthoSchedule.VisitAmount) + "'";
            }
            if (orthoSchedule.DebondAmount != oldOrthoSchedule.DebondAmount)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DebondAmount = '" + POut.Double(orthoSchedule.DebondAmount) + "'";
            }
            if (orthoSchedule.IsActive != oldOrthoSchedule.IsActive)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "IsActive = " + POut.Bool(orthoSchedule.IsActive) + "";
            }
            //SecDateTEdit can only be set by MySQL
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE orthoschedule SET " + command
                      + " WHERE OrthoScheduleNum = " + POut.Long(orthoSchedule.OrthoScheduleNum);
            Db.NonQ(command);
            return(true);
        }
示例#12
0
 ///<summary>Inserts one OrthoSchedule into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(OrthoSchedule orthoSchedule)
 {
     return(InsertNoCache(orthoSchedule, false));
 }
示例#13
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;
        }
示例#14
0
        ///<summary>Runs Procedures.ComputeEstimates for given proc and listClaimProcs.
        ///Does not update existing ClaimProcs or insert new ClaimProcs in the database.
        ///Outs new ClaimProcs added by Procedures.ComputeEstimates, listClaimProcs will contain any added claimProcs.</summary>
        private void RecomputeEstimates(Procedure proc, List <ClaimProc> listClaimProcs, out List <ClaimProc> listNewClaimProcs,
                                        OrthoProcLink orthoProcLink, OrthoCase orthoCase, OrthoSchedule orthoSchedule, List <OrthoProcLink> listOrthoProcLinksForOrthoCase)
        {
            List <ClaimProc> listOrigClaimProcs = new List <ClaimProc>(listClaimProcs);
            Patient          pat          = Patients.GetPat(proc.PatNum);
            List <PatPlan>   listPatPlans = PatPlans.GetPatPlansForPat(pat.PatNum);
            List <InsSub>    listInsSubs  = InsSubs.GetMany(listPatPlans.Select(x => x.InsSubNum).ToList());
            List <InsPlan>   listInsPlans = InsPlans.GetByInsSubs(listInsSubs.Select(x => x.InsSubNum).ToList());
            List <Benefit>   listBenefits = Benefits.Refresh(listPatPlans, listInsSubs);      //Same method used in FormProcEdit.Load()->GetLoadData()
            //FormProcEdit uses GetHistList(....,procDate:DateTimeOD.Today,...)
            List <ClaimProcHist> listHist = ClaimProcs.GetHistList(pat.PatNum, listBenefits, listPatPlans, listInsPlans, DateTimeOD.Today, listInsSubs);
            bool isSaveToDb = false;

            //When isSaveToDb is true any estimates that are missing will be inserted into DB and it refreshes listClaimProcs from the Db.
            //Refreshing the list results in losing the changes to ProvNum and ProcDate.
            Procedures.ComputeEstimates(proc, pat.PatNum, ref listClaimProcs, false, listInsPlans, listPatPlans, listBenefits, listHist,
                                        new List <ClaimProcHist> {
            }, isSaveToDb, pat.Age, listInsSubs
                                        , useProcDateOnProc: true,
                                        orthoProcLink: orthoProcLink, orthoCase: orthoCase, orthoSchedule: orthoSchedule, listOrthoProcLinksForOrthoCase: listOrthoProcLinksForOrthoCase);
            listNewClaimProcs = listClaimProcs.Except(listOrigClaimProcs).ToList();
        }