Ejemplo n.º 1
0
        /// <summary>
        /// Retrieve the patients for an experiment
        /// </summary>
        /// <param name="criteria">Patient criteria to match</param>
        /// <returns></returns>
        public IEnumerable<Patient> GetPatientsForExperiment(ExperimentCriteria criteria)
        {
            // Need to get all of the patients here in the database and return the list
            char delimiter = '.';
            string genderString = delimiter.ToString(), raceString = delimiter.ToString(),
                ethnicityString = delimiter.ToString(), locationString = delimiter.ToString();

            foreach (string str in criteria.selectedGenders)
            {
                genderString += str + delimiter.ToString();
            }
            foreach (string str in criteria.selectedRaces)
            {
                raceString += str + delimiter.ToString();
            }
            foreach (string str in criteria.selectedEthnicities)
            {
                ethnicityString += str + delimiter.ToString();
            }
            foreach (string str in criteria.selectedLocations)
            {
                locationString += str + delimiter.ToString();
            }

            IEnumerable<Patient> patientList;
            patientList = _patientRepository.GetAll().Where(p => genderString.Contains(delimiter.ToString() + Enum.GetName(typeof(PatientGender), p.Gender) + delimiter.ToString()))
                .Where(p => raceString.Contains(delimiter.ToString() + Enum.GetName(typeof(PatientRace), p.Race) + delimiter.ToString()))
                .Where(p => ethnicityString.Contains(delimiter.ToString() + Enum.GetName(typeof(PatientEthnicity), p.Ethnicity) + delimiter.ToString()))
                .Where(p => locationString.Contains(delimiter.ToString() + Enum.GetName(typeof(Location), p.Location) + delimiter.ToString()))
                .Where(p => ((DateTime.Now-p.Birthdate).Days <= (365*criteria.ageRangeEnd)) &&
                ((DateTime.Now-p.Birthdate).Days >= (365*criteria.ageRangeStart)))
                .Where(p => ((p.Height <= criteria.heightRangeEnd) && (p.Height >= criteria.heightRangeBegin)))
                .Where(p => ((p.Weight <= criteria.weightRangeEnd) && (p.Weight >= criteria.weightRangeBegin)));

            return patientList;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Copy the members of the model to an ExperimentCriteria object
        /// </summary>
        /// <param name="model">Model</param>
        /// <returns></returns>
        private ExperimentCriteria CopyModelToCriteria(ExperimentViewModel model)
        {
            ExperimentCriteria criteria = new ExperimentCriteria();

            criteria.ageRangeEnd = model.ageRangeEnd;
            criteria.ageRangeStart = model.ageRangeStart;
            criteria.heightRangeEnd = model.heightRangeEnd;
            criteria.heightRangeBegin = model.heightRangeBegin;
            criteria.weightRangeBegin = model.weightRangeBegin;
            criteria.weightRangeEnd = model.weightRangeEnd;
            criteria.selectedGenders = model.selectedGenders;
            criteria.selectedRaces = model.selectedRaces;
            criteria.selectedEthnicities = model.selectedEthnicities;
            criteria.selectedLocations = model.selectedLocations;

            return criteria;
        }