/// <summary> /// Gets the name of all staff by location key and staff type well known. /// </summary> /// <param name="locationKey">The location key.</param> /// <param name="staffTypeWellKnownNames">The staff type well known names.</param> /// <returns> /// An IList<Staff> /// </returns> public IList <Staff> GetAllStaffByLocationKeyAndStaffTypeWellKnownName(long locationKey, params string[] staffTypeWellKnownNames) { //TODO: This query needs be revisited after the AgencyModule update is settled down // Probably it seems that there is no such thing of Staff search by location. Instead should search by Agency // TODO: research alternative Linq approaches that won't use a correlated sub-query var results = from staff in LinqExtensionMethods.Query <Staff>(Session) where staffTypeWellKnownNames.Contains(staff.StaffProfile.StaffType.WellKnownName) && staff.Agency.Locations.Any(l => l.Key == locationKey) select staff; return(results.ToList()); }
/// <summary> /// Finds the duplicate staff. /// </summary> /// <param name="firstName">The first name.</param> /// <param name="middleInitial">The middle initial.</param> /// <param name="lastName">The last name.</param> /// <returns> /// A Staff object. /// </returns> public Staff FindDuplicateStaff(string firstName, string middleInitial, string lastName) { var result = from staff in LinqExtensionMethods.Query <Staff>(Session) where staff.StaffProfile.StaffName.First == firstName && staff.StaffProfile.StaffName.Last == lastName select staff; if (!string.IsNullOrEmpty(middleInitial)) { result = result.Where(s => s.StaffProfile.StaffName.Middle.StartsWith(middleInitial)); } return(result.FirstOrDefault()); }
/// <summary> /// Gets all staff by agency key. /// </summary> /// <param name="agencyKey">The agency key.</param> /// <returns> /// An IList<Staff> /// </returns> public IList <Staff> GetAllStaffByAgencyKey(long agencyKey) { var staffQuery = from staff in LinqExtensionMethods.Query <Staff>(Session) where staff.Agency.Key == agencyKey select staff; return(staffQuery.ToList()); }
/// <summary> /// Gets all medications by patient key. /// </summary> /// <param name="patientKey">The patient key.</param> /// <returns> /// A IList<Medication> /// </returns> public IList <Medication> GetAllMedicationsByPatientKey(long patientKey) { IQueryable <Medication> medications = LinqExtensionMethods.Query <Medication> (Session).Where(p => p.Patient.Key == patientKey); return(medications.ToList()); }