コード例 #1
0
ファイル: OrthoCases.cs プロジェクト: ChemBrain/OpenDental
        ///<summary>Activates an OrthoCase and its associated OrthoSchedule and OrthoPlanLink. Sets all other OrthoCases for Pat inactive.
        ///Returns the refreshed list of OrthoCases.</summary>
        public static List <OrthoCase> Activate(OrthoCase orthoCaseToActivate, long patNum)
        {
            //No need to check RemotingRole; no call to db.
            OrthoPlanLink scheduleOrthoPlanLink = OrthoPlanLinks.GetOneForOrthoCaseByType(orthoCaseToActivate.OrthoCaseNum, OrthoPlanLinkType.OrthoSchedule);
            OrthoSchedule orthoSchedule         = OrthoSchedules.GetOne(scheduleOrthoPlanLink.FKey);

            SetActiveState(orthoCaseToActivate, scheduleOrthoPlanLink, orthoSchedule, true);
            DeactivateOthersForPat(orthoCaseToActivate.OrthoCaseNum, orthoSchedule.OrthoScheduleNum, patNum);
            return(Refresh(patNum));
        }
コード例 #2
0
ファイル: OrthoCases.cs プロジェクト: ChemBrain/OpenDental
        ///<summary>Update the IsActive property for the OrthoCase, OrthoSchedule, and OrthoPlanLink between them.</summary>
        public static void SetActiveState(OrthoCase orthoCase, OrthoPlanLink scheduleOrthoPlanLink, OrthoSchedule orthoSchedule, bool isActive)
        {
            //No remoting role check; no call to db
            OrthoCase     oldOrthoCase             = orthoCase.Copy();
            OrthoSchedule oldOrthoSchedule         = orthoSchedule.Copy();
            OrthoPlanLink oldScheduleOrthoPlanLink = scheduleOrthoPlanLink.Copy();

            orthoCase.IsActive             = isActive;
            orthoSchedule.IsActive         = isActive;
            scheduleOrthoPlanLink.IsActive = isActive;
            Update(orthoCase, oldOrthoCase);
            OrthoSchedules.Update(orthoSchedule, oldOrthoSchedule);
            OrthoPlanLinks.Update(scheduleOrthoPlanLink, oldScheduleOrthoPlanLink);
        }
コード例 #3
0
ファイル: OrthoCases.cs プロジェクト: ChemBrain/OpenDental
 ///<summary>This fills a list of all OrthoProcLinks, a dictionary of OrthoProcLinks, a dictionary of OrthoCases associated to these OrthoProcLinks,
 ///and a dictionary of OrthoSchedules for the OrthoCases.</summary>
 public static void GetDataForAllProcLinks(ref List <OrthoProcLink> listOrthoProcLinksAll,
                                           ref Dictionary <long, OrthoProcLink> dictOrthoProcLinks, ref Dictionary <long, OrthoCase> dictOrthoCases,
                                           ref Dictionary <long, OrthoSchedule> dictOrthoSchedules)
 {
     //No remoting role check; no call to db
     listOrthoProcLinksAll = OrthoProcLinks.GetAll();
     if (listOrthoProcLinksAll.Count > 0)
     {
         dictOrthoProcLinks = listOrthoProcLinksAll.ToDictionary(x => x.ProcNum, x => x);
         dictOrthoCases     = GetMany(dictOrthoProcLinks.Values.Select(x => x.OrthoCaseNum).Distinct().ToList()).ToDictionary(x => x.OrthoCaseNum, x => x);
         Dictionary <long, OrthoPlanLink> dictSchedulePlanLinks =
             OrthoPlanLinks.GetAllForOrthoCasesByType(dictOrthoCases.Keys.ToList(), OrthoPlanLinkType.OrthoSchedule).ToDictionary(x => x.FKey, x => x);
         List <OrthoSchedule> listOrthoSchedules = OrthoSchedules.GetMany(dictSchedulePlanLinks.Keys.ToList());
         dictOrthoSchedules = listOrthoSchedules.ToDictionary(x => dictSchedulePlanLinks[x.OrthoScheduleNum].OrthoCaseNum, x => x);
     }
 }
コード例 #4
0
ファイル: OrthoCases.cs プロジェクト: ChemBrain/OpenDental
 ///<summary>For a list of patNums, this fills dictionaries for OrthoCases, OrthoProcLinks, and OrthoSchedules.</summary>
 public static void GetDataForListPatNums(ref Dictionary <long, OrthoProcLink> dictOrthoProcLinks, ref Dictionary <long, OrthoCase> dictOrthoCases,
                                          ref Dictionary <long, OrthoPlanLink> dictOrthoSchedulePlanLinks, ref Dictionary <long, OrthoSchedule> dictOrthoSchedules, List <long> listPatNums)
 {
     //No remoting role check; no call to db
     dictOrthoCases     = GetManyForPats(listPatNums.Distinct().ToList()).ToDictionary(x => x.OrthoCaseNum, x => x);
     dictOrthoProcLinks = OrthoProcLinks.GetManyByOrthoCases(dictOrthoCases.Keys.ToList()).ToDictionary(x => x.ProcNum, x => x);
     if (dictOrthoProcLinks.Count > 0)
     {
         dictOrthoSchedulePlanLinks =
             OrthoPlanLinks.GetAllForOrthoCasesByType(dictOrthoCases.Keys.ToList(), OrthoPlanLinkType.OrthoSchedule).ToDictionary(x => x.FKey, x => x);
         List <OrthoSchedule> listOrthoSchedules = OrthoSchedules.GetMany(dictOrthoSchedulePlanLinks.Keys.ToList());
         foreach (OrthoSchedule orthoSchedule in listOrthoSchedules)                 //Can't use ref variable in linq statement
         {
             dictOrthoSchedules.Add(dictOrthoSchedulePlanLinks[orthoSchedule.OrthoScheduleNum].OrthoCaseNum, orthoSchedule);
         }
     }
 }
コード例 #5
0
ファイル: OrthoCases.cs プロジェクト: ChemBrain/OpenDental
 ///<summary>For a passed in list of procs, this fills a list of all OrthoProcLinks, a dictionary of OrthoProcLinks associated to procs
 ///in listProcs, a dictionary of OrthoCases associated to these OrthoProcLinks, and a dictionary of OrthoSchedules for the OrthoCases.</summary>
 public static void GetDataForListProcs(ref List <OrthoProcLink> listOrthoProcLinksAllForPats,
                                        ref Dictionary <long, OrthoProcLink> dictOrthoProcLinks, ref Dictionary <long, OrthoCase> dictOrthoCases,
                                        ref Dictionary <long, OrthoSchedule> dictOrthoSchedules, List <Procedure> listProcs)
 {
     //No remoting role check; no call to db and ref parameters.
     dictOrthoCases = GetManyForPats(listProcs.Select(x => x.PatNum).Distinct().ToList()).ToDictionary(x => x.OrthoCaseNum, x => x);
     listOrthoProcLinksAllForPats = OrthoProcLinks.GetManyByOrthoCases(dictOrthoCases.Keys.ToList());
     dictOrthoProcLinks           =
         listOrthoProcLinksAllForPats.Where(x => listProcs.Select(y => y.ProcNum).ToList().Contains(x.ProcNum)).ToDictionary(x => x.ProcNum, x => x);
     if (dictOrthoProcLinks.Count > 0)
     {
         Dictionary <long, OrthoPlanLink> dictSchedulePlanLinks =
             OrthoPlanLinks.GetAllForOrthoCasesByType(dictOrthoCases.Keys.ToList(), OrthoPlanLinkType.OrthoSchedule).ToDictionary(x => x.FKey, x => x);
         List <OrthoSchedule> listOrthoSchedules = OrthoSchedules.GetMany(dictSchedulePlanLinks.Keys.ToList());
         dictOrthoSchedules = listOrthoSchedules.ToDictionary(x => dictSchedulePlanLinks[x.OrthoScheduleNum].OrthoCaseNum, x => x);
     }
 }
コード例 #6
0
ファイル: OrthoCases.cs プロジェクト: ChemBrain/OpenDental
        /////<summary></summary>
        //public static void Update(OrthoCase orthoCase) {
        //	if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
        //		Meth.GetVoid(MethodBase.GetCurrentMethod(),orthoCase);
        //		return;
        //	}
        //	Crud.OrthoCaseCrud.Update(orthoCase);
        //}
        #endregion Update

        #region Delete
        /////<summary>Deletes an OrthoCase from the database, does not delete all items associated to the ortho case, call DeleteAllAssociated.</summary>
        //public static void Delete(long orthoCaseNum) {
        //	if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
        //		Meth.GetVoid(MethodBase.GetCurrentMethod(),orthoCaseNum);
        //		return;
        //	}
        //	Crud.OrthoCaseCrud.Delete(orthoCaseNum);
        //}

        ///<summary>Throws exceptions. Deletes the OrthoCase and all associated items to the ortho case including OrthoSchedule
        ///and all procedure links.</summary>
        public static void Delete(long orthoCaseNum, OrthoSchedule orthoSchedule = null, OrthoPlanLink schedulePlanLink = null
                                  , List <OrthoProcLink> listProcLinks           = null)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)           //checked here to save time below
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), orthoCaseNum, orthoSchedule, schedulePlanLink, listProcLinks);
                return;
            }
            //Get associated objects if they were not passed in.
            if (schedulePlanLink == null)
            {
                schedulePlanLink = OrthoPlanLinks.GetOneForOrthoCaseByType(orthoCaseNum, OrthoPlanLinkType.OrthoSchedule);
            }
            if (schedulePlanLink != null && orthoSchedule == null)
            {
                orthoSchedule = OrthoSchedules.GetOne(schedulePlanLink.FKey);
            }
            if (listProcLinks == null)
            {
                listProcLinks = OrthoProcLinks.GetManyByOrthoCase(orthoCaseNum);
            }
            //Check that all objects are actually associated by primary keys.
            string errorText = "Error: Failed to delete ortho case. Attempted to delete";

            if (schedulePlanLink != null && schedulePlanLink.OrthoCaseNum != orthoCaseNum)
            {
                throw new ApplicationException(Lans.g("OrthoCases", $"{errorText} an ortho plan link that does not belong to the ortho case."));
            }
            if (orthoSchedule != null && orthoSchedule.OrthoScheduleNum != schedulePlanLink.FKey)
            {
                throw new ApplicationException(Lans.g("OrthoCases", $"{errorText} an ortho schedule that does not belong to the ortho case."));
            }
            foreach (OrthoProcLink procLink in listProcLinks)
            {
                if (procLink.OrthoCaseNum != orthoCaseNum)
                {
                    throw new ApplicationException(Lans.g("OrthoCases", $"{errorText} an ortho procedure link that does not belong to the ortho case."));
                }
            }
            //Delete objects
            Crud.OrthoCaseCrud.Delete(orthoCaseNum);
            Crud.OrthoScheduleCrud.Delete(orthoSchedule.OrthoScheduleNum);
            Crud.OrthoPlanLinkCrud.Delete(schedulePlanLink.OrthoPlanLinkNum);
            OrthoProcLinks.DeleteMany(listProcLinks.Select(x => x.OrthoProcLinkNum).ToList());
        }
コード例 #7
0
        ///<summary>Determines whether the passed in procedure is a Banding, Visit, or Debond procedure and
        ///sets the ProcFee accordingly. Does not update the procedure in the database.</summary>
        public static void SetProcFeeForLinkedProc(OrthoCase orthoCase, Procedure proc, OrthoProcType procType, List <OrthoProcLink> listVisitProcLinks,
                                                   OrthoPlanLink scheduleOrthoPlanLink = null, OrthoSchedule orthoSchedule = null)
        {
            //No remoting role check; no call to db
            if (scheduleOrthoPlanLink == null && orthoSchedule == null)
            {
                scheduleOrthoPlanLink = OrthoPlanLinks.GetOneForOrthoCaseByType(orthoCase.OrthoCaseNum, OrthoPlanLinkType.OrthoSchedule);
            }
            if (orthoSchedule == null)
            {
                orthoSchedule = OrthoSchedules.GetOne(scheduleOrthoPlanLink.FKey);
            }
            double procFee = 0;

            switch (procType)
            {
            case OrthoProcType.Banding:
                procFee = orthoSchedule.BandingAmount;
                break;

            case OrthoProcType.Debond:
                procFee = orthoSchedule.DebondAmount;
                break;

            case OrthoProcType.Visit:
                double allVisitsAmount   = Math.Round((orthoCase.Fee - orthoSchedule.BandingAmount - orthoSchedule.DebondAmount) * 100) / 100;
                int    plannedVisitCount = OrthoSchedules.CalculatePlannedVisitsCount(orthoSchedule.BandingAmount, orthoSchedule.DebondAmount
                                                                                      , orthoSchedule.VisitAmount, orthoCase.Fee);
                if (listVisitProcLinks.Count == plannedVisitCount)
                {
                    procFee = Math.Round((allVisitsAmount - orthoSchedule.VisitAmount * (plannedVisitCount - 1)) * 100) / 100;
                }
                else if (listVisitProcLinks.Count < plannedVisitCount)
                {
                    procFee = orthoSchedule.VisitAmount;
                }
                break;
            }
            proc.ProcFee   = procFee;
            proc.BaseUnits = 0;
            proc.UnitQty   = 1;
        }
コード例 #8
0
ファイル: OrthoCases.cs プロジェクト: ChemBrain/OpenDental
        ///<summary>Set all objects related to orthocases for a patient inactive besides the ones passed in.</summary>
        public static void DeactivateOthersForPat(long activeOrthoCaseNum, long activeOrthoScheduleNum, long patNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), activeOrthoCaseNum, activeOrthoScheduleNum, patNum);
                return;
            }
            //Get all orthocase nums to deactivate.
            List <long> listOrthoCaseNums = Refresh(patNum).Where(x => x.OrthoCaseNum != activeOrthoCaseNum).Select(x => x.OrthoCaseNum).ToList();

            if (listOrthoCaseNums.Count <= 0)
            {
                return;
            }
            //Set all other orthocases inactive besides one being activated
            string command = $@"UPDATE orthocase SET orthocase.IsActive={POut.Bool(false)}
				WHERE orthocase.OrthoCaseNum IN({string.Join(",",listOrthoCaseNums)})"                ;

            Db.NonQ(command);
            //Set OrthoPlanLinks inactive
            command = $@"UPDATE orthoplanlink SET orthoplanlink.IsActive={POut.Bool(false)}
				WHERE orthoplanlink.OrthoCaseNum IN({string.Join(",",listOrthoCaseNums)})"                ;
            Db.NonQ(command);
            //Get All OrthoPlanLinks to deactivate
            List <long> listOrthoScheduleNums =
                OrthoPlanLinks.GetAllForOrthoCasesByType(listOrthoCaseNums, OrthoPlanLinkType.OrthoSchedule).Select(x => x.FKey).ToList();

            if (listOrthoScheduleNums.Count <= 0)
            {
                return;
            }
            //Set OrthoSchedules inactive
            command = $@"UPDATE orthoschedule SET orthoschedule.IsActive={POut.Bool(false)}
				WHERE orthoschedule.OrthoScheduleNum IN({string.Join(",",listOrthoScheduleNums)})"                ;
            Db.NonQ(command);
        }
コード例 #9
0
        ///<summary>Changes procFee. Links procedure to an active OrthoCase. Returns new ProcLink if the procedure is linked, else returns null.
        ///Should only be used when a procedure is set complete. This will set the procedure's ProcFee but does not update the procedure in the DB.
        ///This must be done if this function returns true.</summary>
        public static OrthoProcLink LinkProcForActiveOrthoCase(Procedure proc, OrthoCase orthoCase = null, List <OrthoProcLink> listProcLinksForCase = null
                                                               , OrthoPlanLink schedulePlanLink    = null, OrthoSchedule orthoSchedule = null)
        {
            //No remoting role check; no call to db
            if (orthoCase == null)
            {
                orthoCase = OrthoCases.GetActiveForPat(proc.PatNum);
            }
            if (orthoCase == null)           //No active ortho case for pat so return.
            {
                return(null);
            }
            OrthoCase orthoCaseOld = orthoCase.Copy();

            if (listProcLinksForCase == null)
            {
                listProcLinksForCase = GetManyByOrthoCase(orthoCase.OrthoCaseNum);
            }
            List <OrthoProcLink> listAllVisitProcLinks = listProcLinksForCase.Where(x => x.ProcLinkType == OrthoProcType.Visit).ToList();

            //Don't link procs to an OrthoCase with a completed debond procedure
            if (listProcLinksForCase.FirstOrDefault(x => x.ProcLinkType == OrthoProcType.Debond) != null)
            {
                return(null);
            }
            if (!orthoCase.IsTransfer)
            {
                OrthoProcLink bandingProcLink = listProcLinksForCase.FirstOrDefault(x => x.ProcLinkType == OrthoProcType.Banding);
                //If proc being set complete is the banding, it is already linked. We just need to set the fee.
                if (bandingProcLink.ProcNum == proc.ProcNum)
                {
                    SetProcFeeForLinkedProc(orthoCase, proc, OrthoProcType.Banding, listAllVisitProcLinks);
                    orthoCase.BandingDate = proc.ProcDate;
                    OrthoCases.Update(orthoCase, orthoCaseOld);
                    return(bandingProcLink);
                }
                Procedure bandingProc = Procedures.GetOneProc(bandingProcLink.ProcNum, false);
                //If proc is not banding and banding is not complete yet, don't link procedure
                if (bandingProc.ProcStatus != ProcStat.C)
                {
                    return(null);
                }
            }
            if (listProcLinksForCase.Select(x => x.ProcNum).ToList().Contains(proc.ProcNum))
            {
                return(null);               //Procedure is not banding and is already linked so do nothing.
            }
            string        procCode        = ProcedureCodes.GetProcCode(proc.CodeNum).ProcCode;
            List <string> listDebondProcs = OrthoCases.GetListProcTypeProcCodes(PrefName.OrthoDebondCodes);
            List <string> listVisitProcs  = OrthoCases.GetListProcTypeProcCodes(PrefName.OrthoVisitCodes);

            if (listVisitProcs.Contains(procCode) || listDebondProcs.Contains(procCode))
            {
                if (schedulePlanLink == null)
                {
                    schedulePlanLink = OrthoPlanLinks.GetOneForOrthoCaseByType(orthoCase.OrthoCaseNum, OrthoPlanLinkType.OrthoSchedule);
                }
                if (orthoSchedule == null)
                {
                    orthoSchedule = OrthoSchedules.GetOne(schedulePlanLink.FKey);
                }
                //Link visit procedure
                if (listVisitProcs.Contains(procCode))
                {
                    OrthoProcLink newVisitProcLink = CreateHelper(orthoCase.OrthoCaseNum, proc.ProcNum, OrthoProcType.Visit);
                    newVisitProcLink.OrthoProcLinkNum = Insert(newVisitProcLink);
                    listAllVisitProcLinks.Add(newVisitProcLink);
                    listProcLinksForCase.Add(newVisitProcLink);
                    SetProcFeeForLinkedProc(orthoCase, proc, OrthoProcType.Visit, listAllVisitProcLinks, schedulePlanLink, orthoSchedule);
                    return(newVisitProcLink);
                }
                //Link debond procedure
                else if (listDebondProcs.Contains(procCode))
                {
                    OrthoProcLink newDebondProcLink = CreateHelper(orthoCase.OrthoCaseNum, proc.ProcNum, OrthoProcType.Debond);
                    newDebondProcLink.OrthoProcLinkNum = Insert(newDebondProcLink);
                    listProcLinksForCase.Add(newDebondProcLink);
                    OrthoCases.SetActiveState(orthoCase, schedulePlanLink, orthoSchedule, false);                 //deactivate the ortho case
                    SetProcFeeForLinkedProc(orthoCase, proc, OrthoProcType.Debond, listAllVisitProcLinks, schedulePlanLink, orthoSchedule);
                    orthoCase.DebondDate = proc.ProcDate;
                    OrthoCases.Update(orthoCase, orthoCaseOld);
                    return(newDebondProcLink);
                }
            }
            return(null);           //Procedure is not a Banding, Visit, or Debond. Do nothing.
        }