///<summary>Gets the data necessary to load FormProcEdit.</summary> public static LoadData GetLoadData(Procedure proc, Patient pat, Family fam) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <LoadData>(MethodBase.GetCurrentMethod(), proc, pat, fam)); } LoadData data = new LoadData(); data.ListPatPlans = PatPlans.Refresh(pat.PatNum); if (!PatPlans.IsPatPlanListValid(data.ListPatPlans)) //PatPlans had invalid references and need to be refreshed. { data.ListPatPlans = PatPlans.Refresh(pat.PatNum); } data.ListInsSubs = InsSubs.RefreshForFam(fam); data.ListInsPlans = InsPlans.RefreshForSubList(data.ListInsSubs); data.ListClaims = Claims.Refresh(pat.PatNum); data.ListClaimProcsForProc = ClaimProcs.RefreshForProc(proc.ProcNum); data.ListBenefits = Benefits.Refresh(data.ListPatPlans, data.ListInsSubs); data.ListRefAttaches = RefAttaches.RefreshFiltered(proc.PatNum, false, proc.ProcNum); data.ArrPaySplits = PaySplits.Refresh(proc.PatNum); List <long> listPayNums = data.ArrPaySplits.Where(x => x.ProcNum == proc.ProcNum).Select(x => x.PayNum).ToList(); data.ListPaymentsForProc = Payments.GetPayments(listPayNums); data.ArrAdjustments = Adjustments.Refresh(proc.PatNum); data.OrthoProcedureLink = OrthoProcLinks.GetByProcNum(proc.ProcNum); return(data); }
///<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); } }
///<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); } }
///<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); } } }
/////<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()); }