示例#1
0
        ///<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);
        }
示例#2
0
        ///<summary>Sets the BandingDate or DebondDate for an OrthoCase.</summary>
        public static void UpdateDatesByLinkedProc(OrthoProcLink procLink, Procedure proc)
        {
            //No remoting role check; no call to db
            if (procLink.ProcLinkType == OrthoProcType.Visit)
            {
                return;
            }
            OrthoCase orthoCase    = GetOne(procLink.OrthoCaseNum);
            OrthoCase oldOrthoCase = orthoCase.Copy();

            //Update banding date only if banding proc is complete or it is treatment planned and attached to an appointment.
            if (procLink.ProcLinkType == OrthoProcType.Banding && proc.ProcStatus == ProcStat.C || (proc.ProcStatus == ProcStat.TP && proc.AptNum != 0))
            {
                orthoCase.BandingDate = proc.ProcDate;
            }
            else if (procLink.ProcLinkType == OrthoProcType.Debond)
            {
                orthoCase.DebondDate = proc.ProcDate;
            }
            Update(orthoCase, oldOrthoCase);
        }
示例#3
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.
        }