private void GetPatientEducationItemList(PatientEducationIndex model) { // *** Get patient education items *** PatientEducationItemsResult edResult = this.DashboardRepository.Education.GetPatientItems( model.Patient.Dfn, "", DateTime.MinValue, DateTime.MinValue, EducationItemType.Unknown, 1, 1000 ); if (!edResult.Success) { this.Error(edResult.Message); } else { if (edResult.Items != null) { foreach (PatientEducationItem patEdItem in edResult.Items) { PatientEducationChecklistItem newItem = new PatientEducationChecklistItem(); newItem.PatientEducationItem = patEdItem; model.ItemList.Add(newItem); } } model.ItemList.Sort(delegate(PatientEducationChecklistItem x, PatientEducationChecklistItem y) { return(x.CompareDate.CompareTo(y.CompareDate)); }); } }
private void GetMergedList(PatientEducationIndex model, PregnancyDetails preg) { PregnancyChecklistItemsResult result = this.DashboardRepository.Checklist.GetPregnancyItems(model.Patient.Dfn, preg.Ien, ""); if (!result.Success) { this.Error(result.Message); } else { // *** Create view items *** if (result.Items != null) { foreach (PregnancyChecklistItem item in result.Items) { if (item.ItemType == DsioChecklistItemType.EducationItem) { PatientEducationChecklistItem newItem = new PatientEducationChecklistItem(); newItem.PregnancyChecklistItem = item; model.ItemList.Add(newItem); } } } // *** Get patient education items *** PatientEducationItemsResult edResult = this.DashboardRepository.Education.GetPatientItems( model.Patient.Dfn, "", DateTime.MinValue, DateTime.MinValue, EducationItemType.Unknown, 1, 1000 ); if (!edResult.Success) { this.Error(edResult.Message); } else { Dictionary <string, PatientEducationItem> patEdItems = new Dictionary <string, PatientEducationItem>(); // *** Place patient education items in dictionary for lookup *** if (edResult.Items != null) { foreach (PatientEducationItem patEdItem in edResult.Items) { patEdItems.Add(patEdItem.Ien, patEdItem); } } // *** Go through checklist to find links to patient education *** foreach (PatientEducationChecklistItem finalItem in model.ItemList) { if (finalItem.PregnancyChecklistItem != null) { if (finalItem.PregnancyChecklistItem.CompletionStatus == DsioChecklistCompletionStatus.Complete) { if (!string.IsNullOrWhiteSpace(finalItem.PregnancyChecklistItem.CompletionLink)) { if (patEdItems.ContainsKey(finalItem.PregnancyChecklistItem.CompletionLink)) { // *** If found add to final *** finalItem.PatientEducationItem = patEdItems[finalItem.PregnancyChecklistItem.CompletionLink]; // *** Remove since already added *** patEdItems.Remove(finalItem.PregnancyChecklistItem.CompletionLink); } } } } } // *** Now that we've added all items that are linked, add remainder *** foreach (PatientEducationItem patEdItem in patEdItems.Values) { PatientEducationChecklistItem newItem = new PatientEducationChecklistItem(); newItem.PatientEducationItem = patEdItem; model.ItemList.Add(newItem); } // *** Finally get education items linked by a checklist but incomplete *** foreach (PatientEducationChecklistItem finalItem in model.ItemList) { if (finalItem.PregnancyChecklistItem != null) { if (finalItem.PregnancyChecklistItem.CompletionStatus != DsioChecklistCompletionStatus.Complete) { if (!string.IsNullOrWhiteSpace(finalItem.Link)) { EducationItemsResult edItemsResult = this.DashboardRepository.Education.GetEducationItems(finalItem.Link, "", EducationItemType.Unknown, 0, 0, EducationItemSort.Type); if (edItemsResult.Success) { if (edItemsResult.EducationItems != null) { if (edItemsResult.EducationItems.Count > 0) { finalItem.EducationItem = edItemsResult.EducationItems[0]; } } } } } } } } model.ItemList.AddPregnancyDates(preg.EDD, preg.EndDate); model.ItemList.Sort(delegate(PatientEducationChecklistItem x, PatientEducationChecklistItem y) { return(x.CompareDate.CompareTo(y.CompareDate)); }); } }