Пример #1
0
 ///<summary>Update only data that is different in newOrthoPlanLink.</summary>
 public static void Update(OrthoPlanLink newOrthoPlanLink, OrthoPlanLink oldOrthoPlanLink)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         Meth.GetVoid(MethodBase.GetCurrentMethod(), newOrthoPlanLink, oldOrthoPlanLink);
         return;
     }
     Crud.OrthoPlanLinkCrud.Update(newOrthoPlanLink, oldOrthoPlanLink);
 }
Пример #2
0
 ///<summary>Inserts a OrthoPlanLink into the database. Returns the OrthoPlanLinkNum</summary>
 public static long Insert(OrthoPlanLink orthoPlanLink)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         orthoPlanLink.OrthoPlanLinkNum = Meth.GetLong(MethodBase.GetCurrentMethod(), orthoPlanLink);
         return(orthoPlanLink.OrthoPlanLinkNum);
     }
     return(Crud.OrthoPlanLinkCrud.Insert(orthoPlanLink));
 }
Пример #3
0
        ///<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));
        }
Пример #4
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);
        }
Пример #5
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;
        }
Пример #6
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.
        }
Пример #7
0
        /////<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());
        }