public static PregnancyOutcomeType GetPregnancyOutcome(IDashboardRepository repo, string patientDfn, string pregIen)
        {
            PregnancyOutcomeType returnVal = PregnancyOutcomeType.Unknown;

            ObservationListResult obsResult = repo.Observations.GetObservations(patientDfn, pregIen, "", "", "", "", "Outcome", 0, 0);

            if (obsResult.Success)
            {
                if (obsResult.Observations != null)
                {
                    foreach (Observation obs in obsResult.Observations)
                    {
                        if (obs.Code == ObservationsFactory.OutcomeTypeCode)
                        {
                            PregnancyOutcomeType outType = PregnancyOutcomeType.Unknown;
                            if (Enum.TryParse <PregnancyOutcomeType>(obs.Value, true, out outType))
                            {
                                returnVal = outType;
                            }
                        }
                    }
                }
            }

            return(returnVal);
        }
Exemple #2
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 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));
        }
        internal static OutcomeDetails GetOutcomeDetails(IDashboardRepository repo, string dfn, string pregIen, PregnancyOutcomeType outcomeType)
        {
            OutcomeDetails returnDetails = new OutcomeDetails();

            ObservationListResult obsResult;

            switch (outcomeType)
            {
            case PregnancyOutcomeType.SpontaneousAbortion:
                obsResult = repo.Observations.GetObservationListByCategory(dfn, pregIen, returnDetails.SpontaneousAbortionDetails.ObservationCategory);

                if (obsResult.Success)
                {
                    if (obsResult.Observations != null)
                    {
                        returnDetails.SpontaneousAbortionDetails = new Data.Models.Outcomes.SpontaneousAbortionOutcome(obsResult.Observations);
                    }
                }

                break;

            case PregnancyOutcomeType.PregnancyTermination:
                obsResult = repo.Observations.GetObservationListByCategory(dfn, pregIen, returnDetails.TerminationDetails.ObservationCategory);

                if (obsResult.Success)
                {
                    if (obsResult.Observations != null)
                    {
                        returnDetails.TerminationDetails = new Data.Models.Outcomes.PregnancyTerminationOutcome(obsResult.Observations);
                    }
                }
                break;

            case PregnancyOutcomeType.StillBirth:
                obsResult = repo.Observations.GetObservationListByCategory(dfn, pregIen, returnDetails.StillbirthDetails.ObservationCategory);

                if (obsResult.Success)
                {
                    if (obsResult.Observations != null)
                    {
                        returnDetails.StillbirthDetails = new Data.Models.Outcomes.StillbirthOutcome(obsResult.Observations);
                    }
                }
                break;

            case PregnancyOutcomeType.Ectopic:
                obsResult = repo.Observations.GetObservationListByCategory(dfn, pregIen, returnDetails.EctopicDetails.ObservationCategory);

                if (obsResult.Success)
                {
                    if (obsResult.Observations != null)
                    {
                        returnDetails.EctopicDetails = new Data.Models.Outcomes.EctopicOutcome(obsResult.Observations);
                    }
                }

                break;

            case PregnancyOutcomeType.PretermDelivery:
            case PregnancyOutcomeType.FullTermDelivery:

                obsResult = repo.Observations.GetObservationListByCategory(dfn, pregIen, returnDetails.DeliveryDetails.ObservationCategory);

                if (obsResult.Success)
                {
                    if (obsResult.Observations != null)
                    {
                        returnDetails.DeliveryDetails = new Data.Models.Outcomes.DeliveryDetails(obsResult.Observations);
                    }
                }
                break;
            }

            returnDetails.OutcomeType = outcomeType;

            return(returnDetails);
        }
 public static string GetDescription(PregnancyOutcomeType outcomeType)
 {
     return(descriptions[(int)outcomeType]);
 }
Exemple #7
0
        public static List <Observation> CreateOutcomeObservations(string patientDfn, PregnancyOutcomeType outcomeType, string outcomeDate, string pregIen)
        {
            List <Observation> returnList = new List <Observation>();

            Observation obs = new Observation()
            {
                PatientDfn   = patientDfn,
                Category     = OutcomeCategory,
                PregnancyIen = pregIen,
                Code         = OutcomeTypeCode,
                CodeSystem   = CDA.Common.CodingSystem.Other, //Observation.OtherCodeSystem,
                EntryDate    = DateTime.Now,                  //.ToString(VistaDates.VistADateFormatFour),
                Description  = "Pregnancy Outcome",
                Value        = outcomeType.ToString()
            };

            returnList.Add(obs);

            if ((outcomeType == PregnancyOutcomeType.FullTermDelivery) || (outcomeType == PregnancyOutcomeType.PretermDelivery))
            {
                obs = new Observation()
                {
                    PatientDfn   = patientDfn,
                    Category     = OutcomeCategory,
                    PregnancyIen = pregIen,
                    Code         = "75092-7",
                    CodeSystem   = CodingSystem.Loinc, //Observation.LoincCodeSystem,
                    EntryDate    = DateTime.Now,       //.ToString(VistaDates.VistADateFormatFour),
                    Description  = "Birth Date of Fetus",
                    Value        = outcomeDate
                };

                returnList.Add(obs);
            }

            return(returnList);
        }