///<summary>Inserts one OrthoProcLink into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(OrthoProcLink orthoProcLink, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO orthoproclink (";

            if (!useExistingPK && isRandomKeys)
            {
                orthoProcLink.OrthoProcLinkNum = ReplicationServers.GetKeyNoCache("orthoproclink", "OrthoProcLinkNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "OrthoProcLinkNum,";
            }
            command += "OrthoCaseNum,ProcNum,SecDateTEntry,SecUserNumEntry,ProcLinkType) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(orthoProcLink.OrthoProcLinkNum) + ",";
            }
            command +=
                POut.Long(orthoProcLink.OrthoCaseNum) + ","
                + POut.Long(orthoProcLink.ProcNum) + ","
                + DbHelper.Now() + ","
                + POut.Long(orthoProcLink.SecUserNumEntry) + ","
                + POut.Int((int)orthoProcLink.ProcLinkType) + ")";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                orthoProcLink.OrthoProcLinkNum = Db.NonQ(command, true, "OrthoProcLinkNum", "orthoProcLink");
            }
            return(orthoProcLink.OrthoProcLinkNum);
        }
示例#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));
        }
示例#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);
        }
        ///<summary>Updates one OrthoProcLink in the database.</summary>
        public static void Update(OrthoProcLink orthoProcLink)
        {
            string command = "UPDATE orthoproclink SET "
                             + "OrthoCaseNum    =  " + POut.Long(orthoProcLink.OrthoCaseNum) + ", "
                             + "ProcNum         =  " + POut.Long(orthoProcLink.ProcNum) + ", "
                             //SecDateTEntry not allowed to change
                             + "SecUserNumEntry =  " + POut.Long(orthoProcLink.SecUserNumEntry) + ", "
                             + "ProcLinkType    =  " + POut.Int((int)orthoProcLink.ProcLinkType) + " "
                             + "WHERE OrthoProcLinkNum = " + POut.Long(orthoProcLink.OrthoProcLinkNum);

            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);
        }
        ///<summary>Updates one OrthoProcLink 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(OrthoProcLink orthoProcLink, OrthoProcLink oldOrthoProcLink)
        {
            string command = "";

            if (orthoProcLink.OrthoCaseNum != oldOrthoProcLink.OrthoCaseNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "OrthoCaseNum = " + POut.Long(orthoProcLink.OrthoCaseNum) + "";
            }
            if (orthoProcLink.ProcNum != oldOrthoProcLink.ProcNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ProcNum = " + POut.Long(orthoProcLink.ProcNum) + "";
            }
            //SecDateTEntry not allowed to change
            if (orthoProcLink.SecUserNumEntry != oldOrthoProcLink.SecUserNumEntry)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "SecUserNumEntry = " + POut.Long(orthoProcLink.SecUserNumEntry) + "";
            }
            if (orthoProcLink.ProcLinkType != oldOrthoProcLink.ProcLinkType)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ProcLinkType = " + POut.Int((int)orthoProcLink.ProcLinkType) + "";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE orthoproclink SET " + command
                      + " WHERE OrthoProcLinkNum = " + POut.Long(orthoProcLink.OrthoProcLinkNum);
            Db.NonQ(command);
            return(true);
        }
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <OrthoProcLink> TableToList(DataTable table)
        {
            List <OrthoProcLink> retVal = new List <OrthoProcLink>();
            OrthoProcLink        orthoProcLink;

            foreach (DataRow row in table.Rows)
            {
                orthoProcLink = new OrthoProcLink();
                orthoProcLink.OrthoProcLinkNum = PIn.Long(row["OrthoProcLinkNum"].ToString());
                orthoProcLink.OrthoCaseNum     = PIn.Long(row["OrthoCaseNum"].ToString());
                orthoProcLink.ProcNum          = PIn.Long(row["ProcNum"].ToString());
                orthoProcLink.SecDateTEntry    = PIn.DateT(row["SecDateTEntry"].ToString());
                orthoProcLink.SecUserNumEntry  = PIn.Long(row["SecUserNumEntry"].ToString());
                orthoProcLink.ProcLinkType     = (OpenDentBusiness.OrthoProcType)PIn.Int(row["ProcLinkType"].ToString());
                retVal.Add(orthoProcLink);
            }
            return(retVal);
        }
 ///<summary>Returns true if Update(OrthoProcLink,OrthoProcLink) 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(OrthoProcLink orthoProcLink, OrthoProcLink oldOrthoProcLink)
 {
     if (orthoProcLink.OrthoCaseNum != oldOrthoProcLink.OrthoCaseNum)
     {
         return(true);
     }
     if (orthoProcLink.ProcNum != oldOrthoProcLink.ProcNum)
     {
         return(true);
     }
     //SecDateTEntry not allowed to change
     if (orthoProcLink.SecUserNumEntry != oldOrthoProcLink.SecUserNumEntry)
     {
         return(true);
     }
     if (orthoProcLink.ProcLinkType != oldOrthoProcLink.ProcLinkType)
     {
         return(true);
     }
     return(false);
 }
示例#9
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();
        }
示例#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);
        }
 ///<summary>Inserts one OrthoProcLink into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(OrthoProcLink orthoProcLink)
 {
     return(InsertNoCache(orthoProcLink, false));
 }