protected override List <Operatory> TableToList(DataTable table) { List <Operatory> listOps = Crud.OperatoryCrud.TableToList(table); //The IsInHQView flag is not important enough to cause filling the cache to fail. ODException.SwallowAnyException(() => { for (int i = 0; i < table.Rows.Count; i++) { listOps[i].IsInHQView = PIn.Bool(table.Rows[i]["IsInHQView"].ToString()); } }); //WSNPA operatory defs are important enough that we want this portion to fail if it has problems. //Create a dictionary comprised of Key: OperatoryNum and value: List of definition DefNums. Dictionary <long, List <long> > dictWSNPAOperatoryDefNums = DefLinks.GetDefLinksByType(DefLinkType.Operatory) .GroupBy(x => x.FKey)//FKey for DefLinkType.Operatory is OperatoryNum .ToDictionary(x => x.Key, x => x.Select(y => y.DefNum).ToList()); foreach (long operatoryNum in dictWSNPAOperatoryDefNums.Keys) { Operatory op = listOps.FirstOrDefault(x => x.OperatoryNum == operatoryNum); if (op != null) { op.ListWSNPAOperatoryDefNums = dictWSNPAOperatoryDefNums[operatoryNum]; } } return(listOps); }
///<summary>Returns definitions that are associated to the defCat, fKey, and defLinkType passed in.</summary> public static List <Def> GetDefsByDefLinkFKey(DefCat defCat, long fKey, DefLinkType defLinkType) { //No need to check RemotingRole; no call to db. List <DefLink> listDefLinks = DefLinks.GetDefLinksByType(defLinkType).FindAll(x => x.FKey == fKey); return(Defs.GetDefs(defCat, listDefLinks.Select(x => x.DefNum).Distinct().ToList())); }
///<summary>Returns the appointment type associated to the definition passed in. Returns null if no match found.</summary> public static AppointmentType GetWebSchedNewPatApptTypeByDef(long defNum) { //No need to check RemotingRole; no call to db. List <DefLink> listDefLinks = DefLinks.GetDefLinksByType(DefLinkType.AppointmentType); DefLink defLink = listDefLinks.FirstOrDefault(x => x.DefNum == defNum); if (defLink == null) { return(null); } return(AppointmentTypes.GetFirstOrDefault(x => x.AppointmentTypeNum == defLink.FKey, true)); }
protected override List <Clinic> GetCacheFromDb() { string command = "SELECT * FROM clinic "; if (PrefC.GetBool(PrefName.ClinicListIsAlphabetical)) { command += "ORDER BY Abbr"; } else { command += "ORDER BY ItemOrder"; } List <Clinic> retval = Crud.ClinicCrud.SelectMany(command); Dictionary <long, List <DefLink> > dictClinSpecialties = DefLinks.GetDefLinksByType(DefLinkType.Clinic) .GroupBy(x => x.FKey) .ToDictionary(x => x.Key, x => x.ToList()); List <DefLink> listLinks; retval.ForEach(x => x.ListClinicSpecialtyDefLinks = (dictClinSpecialties.TryGetValue(x.ClinicNum, out listLinks)?listLinks:new List <DefLink>())); return(retval); }