Exemplo n.º 1
0
        public ActionResult Index(string dfn, string filter, string page)
        {
            // *** Show list of dashboard notes by patient

            NoteListModel model = new NoteListModel();

            model.Patient = this.CurrentPatient;

            int pageVal = this.GetPage(page);

            if (!model.Patient.NotFound)
            {
                // *** Set up the pregnancy list filter ***

                // *** Get the pregnancies ***
                List <PregnancyDetails> pregList = PregnancyUtilities.GetPregnancies(this.DashboardRepository, dfn);

                // *** Get the selection ***
                model.PregnancyFilters = PregnancyUtilities.GetPregnanciesSelection(pregList, true);

                // *** Get valid filter ***
                model.CurrentPregnancyFilter = PregnancyUtilities.GetValidatedPregnancyFilter(pregList, filter);

                // *** Set up pregIen for repo ***
                string pregIen = "";
                int    tempIen = -1;
                if (int.TryParse(model.CurrentPregnancyFilter, out tempIen))
                {
                    pregIen = model.CurrentPregnancyFilter;
                }

                // *** Build a list of titles ***
                List <TiuNoteTitle> titlesToInclude = new List <TiuNoteTitle>();
                foreach (object val in Enum.GetValues(typeof(TiuNoteTitle)))
                {
                    titlesToInclude.Add((TiuNoteTitle)val);
                }

                NoteListResult notesResult = this.DashboardRepository.Notes.GetNotesByTitle(titlesToInclude, dfn, pageVal, ItemsPerPage, pregIen);

                if (!notesResult.Success)
                {
                    this.Error(notesResult.Message);
                }
                else
                {
                    model.ProgressNotes = notesResult.Notes;

                    model.ProgressNotePaging.SetPagingData(ItemsPerPage, pageVal, notesResult.TotalResults);

                    model.ProgressNotePaging.BaseUrl = Url.Action("Index", new { dfn = dfn, filter = model.CurrentPregnancyFilter, page = "" });

                    TempData[ReturnUrl] = Url.Action("Index", new { dfn = dfn, filter = model.CurrentPregnancyFilter, page = pageVal });
                }

                model.DetailAction = "Details";
            }

            return(View(model));
        }
        public ActionResult Details(string dfn, string page)
        {
            // *** Show details of a flagged patient ***

            FlaggedPatientDetail model = new FlaggedPatientDetail();

            // *** Get patient demographics ***
            model.Patient = this.CurrentPatient;

            // *** Check for success ***
            if (!model.Patient.NotFound)
            {
                // *** Get patient flags ***
                TrackingHistoryResult trackingResult = this.DashboardRepository.TrackingHistory.GetPatientEntries(dfn);

                // *** Set tracking entries if successful ***
                if (trackingResult.Success)
                {
                    model.TrackingEntries = trackingResult.TrackingEntries;
                }

                NoteListResult notesResult = this.DashboardRepository.Notes.GetList(dfn);

                int pageNum = this.GetPage(page);

                if (notesResult.Success)
                {
                    // *** Add current page's patients ***
                    int startIdx = (pageNum - 1) * ProgNotesPerPage;
                    int endIdx   = startIdx + ProgNotesPerPage - 1;
                    if (endIdx >= notesResult.Notes.Count)
                    {
                        endIdx = notesResult.Notes.Count - 1;
                    }

                    for (int i = startIdx; i <= endIdx; i++)
                    {
                        model.ProgressNotes.Add(notesResult.Notes[i]);
                    }

                    model.ProgressNotePaging.SetPagingData(ProgNotesPerPage, pageNum, notesResult.Notes.Count);
                    model.ProgressNotePaging.BaseUrl = Url.Action("Details", "FlaggedPatients", new { dfn = dfn, page = "" });
                }
                else
                {
                    model.ProgressNotes = new List <TiuNote>();
                }
            }

            // *** Set return url ***
            if (TempData.ContainsKey(ReturnUrl))
            {
                model.ReturnUrl     = TempData[ReturnUrl].ToString();
                TempData[ReturnUrl] = TempData[ReturnUrl];
            }

            // *** Indicate proper action for details link ***
            model.DetailAction = "ProgressNote";

            return(View(model));
        }