public void FilterAndJoin() { //filter subjects by arms if (Arms.Any()) { Subjects = Subjects.FindAll(s => Arms.Select(a => a.Id).Contains(s.StudyArmId)).ToList(); } Debug.WriteLine(Subjects.Count, " AFTER ARMS"); //filter subjects by studies if (Studies.Any()) { Subjects = Subjects.FindAll(subj => Studies.Select(st => st.Id).Contains(subj.StudyId)).ToList(); } Debug.WriteLine(Subjects.Count, " AFTER Studies"); //filter subjects by subCharacteristics if (SubjChars.Any()) { Subjects = Subjects.FindAll(s => SubjChars.Select(sc => sc.SubjectId).Contains(s.Id)).ToList(); } Debug.WriteLine(Subjects.Count, " AFTER SubjChars"); //filter by visits //TODO //TODO : WILL RETRIEVE SUBJECTS THAT HAVE SAME UNIQUE IDS ACROSS PROJECTS (i.e. need to load observations to Mongo with //TODO: DB subjectId //filter observations for filtered subjects Observations = Observations?.FindAll(o => Subjects.Select(s => s.UniqueSubjectId).Contains(o.USubjId)); //filter subjects by selected observations if (Observations.Any() && ObservationsFiltered) { Subjects = Subjects.FindAll(s => Observations.Select(o => o.USubjId).Contains(s.UniqueSubjectId)); } Debug.WriteLine(Subjects.Count, " AFTER syncing with observations"); //FILTER SAMPLES BY SELECTED AND FILTERED SAMPLE CHARACTERISTICS if (SampleCharacteristics.Any()) { Samples = Samples.FindAll(s => SampleCharacteristics.Select(sc => sc.SampleId).Contains(s.Id)).ToList(); } //TODO: TEMP FILTERING BY COLLECTION STUDY DAY //SYNCHRONIZE SAMPLES AND SUBJECTS if (Samples.Any()) { Samples = Samples.FindAll(s => Subjects.Select(sc => sc.Id).Contains(s.SubjectId)).ToList(); Subjects = Subjects.FindAll(sb => Samples.Select(sp => sp.SubjectId).Contains(sb.Id)).ToList(); } }