///<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>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); }