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 PatientIndex(string dfn, string page)
        {
            // TODO: Make education items pregnancy specific?
            // TODO: Allow passed in pregnancy

            PatientEducationIndex model = new PatientEducationIndex();

            model.Patient = this.CurrentPatient;

            //PregnancyUtilities util = new PregnancyUtilities(this.DashboardRepository);

            PregnancyDetails preg = PregnancyUtilities.GetWorkingPregnancy(this.DashboardRepository, dfn, "");

            if (preg != null)
            {
                if ((preg.EDD != DateTime.MinValue) || (preg.EndDate != DateTime.MinValue))
                {
                    GetMergedList(model, preg);
                }
                else
                {
                    GetPatientEducationItemList(model);
                }
            }
            else
            {
                GetPatientEducationItemList(model);
            }

            return(View(model));
        }
        public ActionResult CreateNote(string dfn)
        {
            // *** Create a new dashboard note ***

            TiuNoteModel model = new TiuNoteModel();

            model.Patient = this.CurrentPatient;

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

            // *** Get pregnancy selection dictionary ***
            model.Pregnancies = PregnancyUtilities.GetPregnanciesSelection(pregList, false);

            // *** Default to current pregnancy ***
            foreach (PregnancyDetails preg in pregList)
            {
                if (preg.RecordType == PregnancyRecordType.Current)
                {
                    model.Note.PregnancyIen = preg.Ien;
                }
            }

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

            return(View(model));
        }
        public ActionResult PregnancyIndex(string dfn, string pregIen, string page)
        {
            PregnancyChecklistIndex model = new PregnancyChecklistIndex();

            model.Patient = this.CurrentPatient;

            // TODO: In future add ability to view checklist for a specific pregnancy passed in as parameter
            //       Add a pregnancy selection and display
            //PregnancyDetails preg = PregnancyUtilities.GetWorkingPregnancy(this.DashboardRepository, dfn, pregIen);

            PregnancyDetails preg = PregnancyUtilities.GetWorkingPregnancy(this.DashboardRepository, dfn, "");

            if (preg == null)
            {
                model.NoPregnancies = true;
            }
            else
            {
                if ((preg.EDD == DateTime.MinValue) && (preg.EndDate == DateTime.MinValue))
                {
                    model.NoPregnancyDate = true;
                }

                model.Pregnancy = preg;

                //PregnancyChecklistItemsResult result = this.DashboardRepository.Checklist.GetPregnancyItems(dfn, preg.Ien, "");

                //if (!result.Success)
                //    this.Error(result.Message);
                //else
                //{
                //    model.Items = new PregnancyChecklistItemList();
                //    model.Items.AddRange(result.Items);

                //    model.Items.AddPregnancyDates(preg.EDD, preg.EndDate);

                //    model.Items.Sort(delegate(PregnancyChecklistItem x, PregnancyChecklistItem y)
                //    {
                //        return x.DueDate.CompareTo(y.DueDate);
                //    });
                //}

                PregnancyChecklistItemsResult result = ChecklistUtility.GetSortedPregnancyChecklist(this.DashboardRepository, dfn, preg, DsioChecklistCompletionStatus.Unknown);

                if (!result.Success)
                {
                    this.Error(result.Message);
                }
                else
                {
                    model.Items.AddRange(result.Items);
                }
            }

            // TODO: Paging...

            return(View(model));
        }
        public ActionResult CreateNote(TiuNoteModel model)
        {
            // *** Post data ***

            ActionResult returnResult;

            bool needPatDemo = false;

            if (ModelState.IsValid)
            {
                BrokerOperationResult result = this.DashboardRepository.Notes.CreateNote(TiuNoteTitle.MccDashboardNote, model.Patient.Dfn, model.Note.NoteText, model.Note.Subject, new Dictionary <string, string>(), model.Note.PregnancyIen);

                if (!result.Success)
                {
                    this.Error(result.Message);

                    returnResult = View(model);

                    needPatDemo = true;
                }
                else
                {
                    this.Information("Dashboard Note Created");
                    returnResult = RedirectToAction("Index", new { dfn = model.Patient.Dfn, filter = model.Note.PregnancyIen, page = "1" });
                    needPatDemo  = false;
                }
            }
            else
            {
                this.Error("Please enter note details");
                returnResult = View(model);
                needPatDemo  = true;
            }

            // *** Get patient demographics ***
            if (needPatDemo)
            {
                this.CurrentPatientDfn = model.Patient.Dfn;
                model.Patient          = this.CurrentPatient;

                // *** Pregnancies are needed also ***
                // *** Get a list of pregnancies ***
                List <PregnancyDetails> pregList = PregnancyUtilities.GetPregnancies(this.DashboardRepository, this.CurrentPatientDfn);

                // *** Get pregnancy selection dictionary ***
                model.Pregnancies = PregnancyUtilities.GetPregnanciesSelection(pregList, false);
            }

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

            return(returnResult);
        }
        public static Dictionary <string, string> GetPregnanciesSelection(IDashboardRepository repo, string dfn)
        {
            Dictionary <string, string> returnVal = new Dictionary <string, string>();

            List <PregnancyDetails> pregList = PregnancyUtilities.GetPregnancies(repo, dfn);

            returnVal = PregnancyUtilities.GetPregnanciesSelection(pregList, false);

            return(returnVal);
        }
        public ActionResult Edit(string dfn, string ien)
        {
            // *** Create a new dashboard note ***

            TiuNoteModel model = new TiuNoteModel();

            model.Patient = this.CurrentPatient;

            if (!model.Patient.NotFound)
            {
                TiuNoteResult headerResult = this.DashboardRepository.Notes.GetNoteHeader(dfn, ien);

                if (headerResult.Success)
                {
                    model.Note = headerResult.Note;
                    TiuNoteResult noteResult = this.DashboardRepository.Notes.GetNoteBody(ien);

                    if (!noteResult.Success)
                    {
                        this.Error(noteResult.Message);
                    }
                    else
                    {
                        model.Note.NoteText = noteResult.Note.NoteText;
                    }
                }
                else
                {
                    this.Error(headerResult.Message);
                }
            }

            // *** Get pregnancies ***
            model.Pregnancies = PregnancyUtilities.GetPregnanciesSelection(this.DashboardRepository, dfn);

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

            return(View("CreateNote", model));
        }
Exemple #8
0
        public ActionResult AddEdit(string dfn, string pregIen)
        {
            // *** Create the model ***
            PatientOutcomeAddEdit model = new PatientOutcomeAddEdit();

            // *** Make sure patient is set ***
            model.Patient = this.CurrentPatient;

            if (!string.IsNullOrWhiteSpace(pregIen))
            {
                // *** Keep pregnancy ien in model ***
                model.PregnancyIen = pregIen;

                // *** Get the outcome type ***
                PregnancyOutcomeType outcomeType = PregnancyUtilities.GetPregnancyOutcome(this.DashboardRepository, dfn, pregIen);

                // *** Get the outcome details ***
                model.OutcomeDetails = PregnancyUtilities.GetOutcomeDetails(this.DashboardRepository, dfn, pregIen, outcomeType);

                // *** Add outcome type to the model ***
                model.OutcomeDetails.OutcomeType = outcomeType;

                // *** Get the pregnancy details ***
                PregnancyDetails pregDetails = PregnancyUtilities.GetPregnancy(this.DashboardRepository, dfn, pregIen);

                // *** Set the outcome date ***
                if (pregDetails != null)
                {
                    model.OutcomeDetails.OutcomeDate = pregDetails.DisplayEndDate;

                    // *** This is needed for GA in delivery details ***
                    model.Edd = pregDetails.EDD;
                }
            }

            return(View(model));
        }
        public ActionResult Stop(string dfn)
        {
            // *** Show stop tracking page ***

            ActionResult returnResult;

            CreateTrackingEntry model = GetNewModel(TrackingEntryType.Stop, dfn);

            // model.Pregnancy = PregnancyUtilities.GetPregnancy(this.DashboardRepository, dfn, pregIen);

            PregnancyResult results = this.DashboardRepository.Pregnancy.GetCurrentOrMostRecentPregnancy(dfn);

            if (results.Success)
            {
                if (results.Pregnancy != null)
                {
                    string pregIen = results.Pregnancy.Ien;

                    // *** Get the outcome type ***
                    PregnancyOutcomeType outcomeType = PregnancyUtilities.GetPregnancyOutcome(this.DashboardRepository, dfn, pregIen);

                    model.Outcome = PregnancyUtilities.GetOutcomeDetails(this.DashboardRepository, dfn, pregIen, outcomeType);

                    model.Outcome.OutcomeType = outcomeType;

                    model.Outcome.OutcomeDate = results.Pregnancy.DisplayEndDate;
                }
            }



            returnResult = View("~/Views/Track/Stop.cshtml", model);
            //returnResult = View(model);

            return(returnResult);
        }
        public ActionResult Details(string dfn, string ien)
        {
            // *** Show details of a dashboard note ***

            TiuNoteModel model = new TiuNoteModel();

            model.Patient = this.CurrentPatient;

            if (!model.Patient.NotFound)
            {
                TiuNoteResult headerResult = this.DashboardRepository.Notes.GetNoteHeader(dfn, ien);

                if (headerResult.Success)
                {
                    if (headerResult.Note == null)
                    {
                        this.Error("Could not retrieve note data");
                    }
                    else
                    {
                        model.Note = headerResult.Note;

                        TiuNoteResult noteResult = this.DashboardRepository.Notes.GetNote(ien);

                        if (!noteResult.Success)
                        {
                            this.Error(noteResult.Message);
                        }
                        else
                        {
                            model.Note.NoteText = noteResult.Note.NoteText;
                        }
                    }
                }
                else
                {
                    this.Error(headerResult.Message);
                }
            }

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

            // *** Get pregnancy description ***
            if (!string.IsNullOrWhiteSpace(model.Note.PregnancyIen))
            {
                foreach (PregnancyDetails preg in pregList)
                {
                    if (preg.Ien == model.Note.PregnancyIen)
                    {
                        model.PregnancyDescription = preg.Description;
                    }
                }
            }

            // *** Set default description ***
            if (string.IsNullOrWhiteSpace(model.PregnancyDescription))
            {
                model.PregnancyDescription = PregnancyUtilities.NotAssociatedMessage;
            }

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

            return(View(model));
        }
        public ActionResult Enroll(string dfn)
        {
            Text4BabyModel model = new Text4BabyModel();

            // *** Set patient ***
            model.Patient = this.CurrentPatient;

            // *** Add values to enrollment ***
            model.Enrollment.FirstName           = model.Patient.FirstName;
            model.Enrollment.MenstrualPeriodDate = this.CurrentPatient.Lmp;
            model.Enrollment.MobileNumber        = this.CurrentPatient.MobilePhone;
            model.Enrollment.ZipCode             = this.CurrentPatient.ZipCode;
            model.Enrollment.EmailAddress        = this.CurrentPatient.Email;

            // *** Get most recent pregnancy ***
            PregnancyResult pregResult = this.DashboardRepository.Pregnancy.GetCurrentOrMostRecentPregnancy(dfn);

            // *** Check Result ***
            if (pregResult.Success)
            {
                if (pregResult.Pregnancy != null)
                {
                    if (pregResult.Pregnancy.RecordType == PregnancyRecordType.Current)
                    {
                        // *** If current preg has EDD, add data to enrollment ***
                        if (pregResult.Pregnancy.EDD != DateTime.MinValue)
                        {
                            model.Enrollment.DueDateKnown     = true;
                            model.Enrollment.PregnancyDueDate = pregResult.Pregnancy.EDD;
                            model.Enrollment.ParticipantType  = Text4BabyParticipantType.Pregnant;
                        }
                    }
                    else
                    {
                        // *** Get the outcome type ***
                        PregnancyOutcomeType outcomeType = PregnancyUtilities.GetPregnancyOutcome(this.DashboardRepository, dfn, pregResult.Pregnancy.Ien);

                        // *** Display most recent pregnancy outcome ***
                        string outcomeMessage = string.Format("This patient's most recent pregnancy outcome: {0}", PregnancyOutcomeUtility.GetDescription(outcomeType));

                        switch (outcomeType)
                        {
                        case PregnancyOutcomeType.FullTermDelivery:
                        case PregnancyOutcomeType.PretermDelivery:
                        case PregnancyOutcomeType.Unknown:
                            model.Enrollment.ParticipantType = Text4BabyParticipantType.NewMom;
                            model.EnrollmentInfo             = outcomeMessage;
                            break;

                        default:
                            model.EnrollmentWarning = outcomeMessage;
                            break;
                        }

                        if (pregResult.Pregnancy.EndDate != DateTime.MinValue)
                        {
                            model.Enrollment.BabyDateOfBirth = pregResult.Pregnancy.EndDate;
                        }
                    }
                }
            }


            return(View(model));
        }
        public ActionResult Summary(string dfn)
        {
            // *** Create new model ***
            PatientSummary model = new PatientSummary();

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

            // *** Check for success ***
            if (!model.Patient.NotFound)
            {
                PregnancyResult pregResult = this.DashboardRepository.Pregnancy.GetCurrentOrMostRecentPregnancy(dfn);

                if (pregResult.Success)
                {
                    if (pregResult.Pregnancy != null)
                    {
                        if (pregResult.Pregnancy.RecordType == PregnancyRecordType.Current)
                        {
                            model.CurrentPregnancy = pregResult.Pregnancy;

                            PregnancyDetails tempDetails = PregnancyUtilities.GetPregnancyObservationData(this.DashboardRepository, dfn, model.CurrentPregnancy.Ien);

                            model.CurrentPregnancy.Lmp            = tempDetails.Lmp;
                            model.CurrentPregnancy.FetusBabyCount = tempDetails.FetusBabyCount;

                            model.CurrentPregnancy.EddBasis   = tempDetails.EddBasis;
                            model.CurrentPregnancy.EddIsFinal = tempDetails.EddIsFinal;
                        }
                        else
                        {
                            // TODO: Show most recent pregnancy ?
                        }

                        // *** Get pregnancy checklist ***
                        UpdateChecklistSummary(model, dfn, pregResult);
                    }
                }

                // *** Get Pregnancy History ***
                PregnancyHistoryResult histResult = this.DashboardRepository.Pregnancy.GetPregnancyHistory(dfn);

                if (histResult.Success)
                {
                    model.PregnancyHistory = histResult.PregnancyHistory;
                }
                else
                {
                    model.PregnancyHistory = new PregnancyHistory();
                    this.Error(histResult.Message);
                }
            }

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

                TempData.Keep(LastPatientListUrl);

                // *** Indicate how to get back here ***
                TempData[ReturnUrl] = Url.Action("Summary", "Patient", new { dfn = dfn });
            }

            return(View("Summary2", model));
        }
Exemple #13
0
        public ActionResult AddEdit(PatientOutcomeAddEdit model)
        {
            ActionResult returnResult = null;

            // *** Make sure patient is current ***
            this.CurrentPatientDfn = model.Patient.Dfn;
            model.Patient          = this.CurrentPatient;

            bool ok = true;

            // *** Add pregnancy record if it does not exist ***
            if (string.IsNullOrWhiteSpace(model.PregnancyIen))
            {
                PregnancyDetails newDetails = new PregnancyDetails()
                {
                    PatientDfn = this.CurrentPatientDfn, RecordType = PregnancyRecordType.Historical
                };

                IenResult saveResult = this.DashboardRepository.Pregnancy.SavePregnancy(newDetails);

                if (saveResult.Success)
                {
                    model.PregnancyIen = saveResult.Ien;
                }
                else
                {
                    this.Error(saveResult.Message);
                }
            }

            if (!string.IsNullOrWhiteSpace(model.PregnancyIen))
            {
                string normalizedOutcomeDate = "";
                if (!string.IsNullOrWhiteSpace(model.OutcomeDetails.OutcomeDate))
                {
                    normalizedOutcomeDate = VistaDates.StandardizeDateFormat(model.OutcomeDetails.OutcomeDate);
                }

                // *** Update outcome observation ***
                List <Observation> outcomeList = ObservationsFactory.CreateOutcomeObservations
                                                 (
                    model.Patient.Dfn,
                    model.OutcomeDetails.OutcomeType,
                    normalizedOutcomeDate,
                    model.PregnancyIen
                                                 );

                BrokerOperationResult obsResult = this.DashboardRepository.Observations.SaveSingletonObservations(outcomeList);

                if (!obsResult.Success)
                {
                    this.Error(obsResult.Message);
                    ok = false;
                }

                if (ok)
                {
                    if (!string.IsNullOrWhiteSpace(normalizedOutcomeDate))
                    {
                        // *** Update pregnancy end date ***
                        PregnancyDetails preg = PregnancyUtilities.GetPregnancy(this.DashboardRepository, model.Patient.Dfn, model.PregnancyIen);

                        if (preg != null)
                        {
                            // *** Update date ***
                            preg.DisplayEndDate = normalizedOutcomeDate;

                            // *** Save updated pregnancy ***
                            BrokerOperationResult savePregResult = this.DashboardRepository.Pregnancy.SavePregnancy(preg);

                            // *** Check result ***
                            if (!savePregResult.Success)
                            {
                                this.Error(savePregResult.Message);
                                ok = false;
                            }
                        }
                    }
                }

                // *** Get observations from the model ***
                ObservationConstructable details = model.OutcomeDetails.SelectedDetails;

                if (details != null)
                {
                    List <Observation> obsList = details.GetObservations(model.Patient.Dfn, model.PregnancyIen, "");

                    if (obsList != null)
                    {
                        if (obsList.Count > 0)
                        {
                            // *** If we have any, save them ***
                            BrokerOperationResult result = this.DashboardRepository.Observations.SaveSingletonObservationsByCategory(obsList);

                            if (!result.Success)
                            {
                                this.Error(result.Message);
                                ok = false;
                            }
                        }
                    }
                }
            }

            if (ok)
            {
                returnResult = RedirectToAction("PregnancyView", "Pregnancy", new { dfn = model.Patient.Dfn, pregIen = model.PregnancyIen });
            }
            else
            {
                returnResult = View(model);
            }

            return(returnResult);
        }