Exemple #1
0
        public static Observation GetDsioObservation(string patientDfn, string pregIen, EddItem item)
        {
            Observation returnVal = new Observation();

            string twoPartFormat   = "{0}|{1}";
            string threePartFormat = "{0}|{1}|{2}";

            returnVal.PatientDfn   = patientDfn;
            returnVal.PregnancyIen = pregIen;
            //returnVal.Date = DateTime.Now.ToString(VistaDates.VistADateFormatFour);
            returnVal.EntryDate   = DateTime.Now;
            returnVal.Description = item.Criteria;
            returnVal.Category    = "EDD";

            item.EventDate = VistaDates.StandardizeDateFormat(item.EventDate);
            item.EDD       = VistaDates.StandardizeDateFormat(item.EDD);

            switch (item.ItemType)
            {
            case EddItemType.Conception:
                returnVal.Code       = ConceptionDateCode;
                returnVal.CodeSystem = CodingSystem.Loinc;     //DsioObservation.LoincCodeSystem;
                returnVal.Value      = string.Format(twoPartFormat, item.EventDate, item.IsFinal);
                break;

            case EddItemType.LMP:
                // *** Create an EDD from LMP observation ***
                returnVal.Code        = EddFromLMPCode;
                returnVal.CodeSystem  = CodingSystem.Loinc;
                returnVal.Value       = string.Format(twoPartFormat, item.EDD, item.IsFinal);
                returnVal.Description = EddFromLMPDescription;
                break;

            case EddItemType.Ultrasound:
                returnVal.Description = EstimateGestationalAgeDescription;
                returnVal.Code        = EstimatedGestationalAgeCode;
                returnVal.CodeSystem  = CodingSystem.Loinc;
                returnVal.Value       = string.Format(threePartFormat, item.EventDate, item.IsFinal, item.GestationalAgeTotalDays);
                break;

            case EddItemType.Embryo:
                returnVal.Code       = EmbryoTransferCode;
                returnVal.CodeSystem = CodingSystem.Other;
                returnVal.Value      = string.Format(twoPartFormat, item.EventDate, item.IsFinal);
                break;

            case EddItemType.Other:
                returnVal.Code       = OtherEddCode;
                returnVal.CodeSystem = CodingSystem.Other;
                returnVal.Value      = string.Format(threePartFormat, item.EventDate, item.IsFinal, item.GestationalAgeTotalDays);
                break;

            case EddItemType.EddOnly:
                returnVal.Description = EddCodeDescription;
                returnVal.Code        = EddCode;
                returnVal.CodeSystem  = CodingSystem.Loinc;
                returnVal.Value       = string.Format(twoPartFormat, item.EDD, item.IsFinal);
                break;
            }

            return(returnVal);
        }
Exemple #2
0
        public ActionResult Dashboard(Outcomes outcomes)
        {
            DashboardModel model = new DashboardModel();

            // *** Get tracked patients ***
            TrackedPatientsResult trackedResult = this.DashboardRepository.Patients.GetTrackedPatients(1, 9999);

            if (trackedResult.Success)
            {
                // *** Add to the model ***
                model.TrackedPatients = trackedResult.TotalResults;

                // *** Check if we have something to work with ***
                if (trackedResult.Patients != null)
                {
                    // *** Get the day of the week as integer ***
                    int day = (int)DateTime.Now.DayOfWeek;

                    // *** Calculate Babies Due This Week ***
                    DateTime weekStart = DateTime.Now.Date.AddDays(-1 * day);
                    DateTime weekEnd   = DateTime.Now.Date.AddDays(6 - day);

                    model.DueThisWeek = trackedResult.Patients.Count(p => p.EDD.Date >= weekStart && p.EDD.Date <= weekEnd);

                    // *** Calculate number of high-risk pregnancies ***
                    model.HighRisk = trackedResult.Patients.Count(p => p.CurrentPregnancyHighRisk == true);

                    // *** Get data for trimester pie chart ***
                    model.Tri1       = trackedResult.Patients.Count(p => p.Trimester == 1);
                    model.Tri2       = trackedResult.Patients.Count(p => p.Trimester == 2);
                    model.Tri3       = trackedResult.Patients.Count(p => p.Trimester == 3);
                    model.TriUnknown = trackedResult.Patients.Count(p => p.Trimester == -1);

                    // *** Get data for T4B pie chart ***
                    model.T4BEnrolled      = trackedResult.Patients.Count(p => p.Text4BabyStatus == Text4BabyStatus.Enrolled);
                    model.T4BNotInterested = trackedResult.Patients.Count(p => p.Text4BabyStatus == Text4BabyStatus.NotInterested);
                    model.T4BUnknown       = trackedResult.Patients.Count(p => p.Text4BabyStatus == Text4BabyStatus.Unknown);

                    // *** Get 10 patients with items due ***
                    model.NextDueList = trackedResult.Patients
                                        .Where(p => p.NextChecklistDue != DateTime.MinValue)
                                        .OrderBy(p => p.NextChecklistDue)
                                        .Take(10)
                                        .ToList();
                }
            }

            // *** Get count of flagged patients ***
            FlaggedPatientsResult flaggedResult = this.DashboardRepository.Patients.GetFlaggedPatients(1, 1);

            if (flaggedResult.Success)
            {
                model.FlaggedPatients = flaggedResult.TotalResults;
            }

            // *** Get bar chart data ***
            BarData outcomesBarData = GetOutcomesBarData();
            BarData upcomingBarData = GetUpcomingBarData(trackedResult.Patients);
            //BarData historical = GetHistoricalBarData();

            // *** Set up serializer ***
            JsonSerializerSettings settings = new JsonSerializerSettings();

            settings.ContractResolver = new LowerCaseContractResolver();

            // *** Serialize as JSON ***
            model.OutcomesJson            = JsonConvert.SerializeObject(outcomesBarData, settings);
            model.UpcomingPregnanciesJson = JsonConvert.SerializeObject(upcomingBarData, settings);

            DateTime fromDate = DateTime.MinValue;
            DateTime toDate   = DateTime.Now;

            if (outcomes != null)
            {
                if (!outcomes.AllDates)
                {
                    model.Outcomes.FromDate = VistaDates.StandardizeDateFormat(outcomes.FromDate);

                    if (!string.IsNullOrWhiteSpace(model.Outcomes.FromDate))
                    {
                        fromDate = VistaDates.ParseDateString(model.Outcomes.FromDate, VistaDates.VistADateOnlyFormat);
                    }

                    model.Outcomes.ToDate = VistaDates.StandardizeDateFormat(outcomes.ToDate);
                    if (!string.IsNullOrWhiteSpace(model.Outcomes.ToDate))
                    {
                        toDate = VistaDates.ParseDateString(model.Outcomes.ToDate, VistaDates.VistADateOnlyFormat);
                    }
                }

                model.Outcomes.AllDates = outcomes.AllDates;
            }

            PregnancyOutcomeResult pregResult = this.DashboardRepository.Pregnancy.GetPregnancyOutcomes(fromDate, toDate, 1, 1000);

            if (pregResult.Success)
            {
                model.Outcomes.PregnancyOutcomes = pregResult.PregnancyOutcomes;
            }

            return(View(model));
        }
        protected override void ProcessResponse()
        {
            string lmpText       = "LMP: ";
            string eddText       = "EDD: ";
            string enteredByText = "Entered by: ";
            string enteredOnText = "Entered on: ";

            if (this.ProcessSaveResponse())
            {
                //----------------------------------------------------------------
                //Returned message when the Pregnancy status is "Yes"
                //               LMP: Oct 10, 2017
                //               EDD: Jul 17, 2018
                //
                //Entered by: FREY,ALINA
                //Entered on: Mar 05, 2018@10:06

                //----------------------------------------------------------------
                //Returned message when the Pregnancy status is "No"
                //<empty line>
                //Entered by: FREY,ALINA (Physician)
                //Entered on: Mar 08, 2018@15:17

                //----------------------------------------------------------------
                //Returned messages when the the pregnancy status is "Not Applicable"
                //Case 1: "The patient's age is outside of the age range 10 to 52 years old."
                //Case 2: "No data on file." - That seems to be the case when the patient was never pregnant
                //Case 3: The case when the patient is not able to conceive: The returned message is a string containing
                //any combination of the following: Hysterectomy, menopause, permanent female sterilization and
                //other comments, then the Entered by and Entered on lines.
                if (this.Response.Lines != null)
                {
                    foreach (string line in this.Response.Lines)
                    {
                        if (!string.IsNullOrWhiteSpace(line))
                        {
                            if (line.IndexOf(lmpText) > -1)
                            {
                                string lmpDate = Util.Piece(line, lmpText, 2);
                                this.LMP = VistaDates.StandardizeDateFormat(lmpDate);
                            }
                            if (line.IndexOf(eddText) > -1)
                            {
                                string eddDate = Util.Piece(line, eddText, 2);
                                this.EDD = VistaDates.StandardizeDateFormat(eddDate);
                            }
                            if (line.IndexOf(enteredByText) > -1)
                            {
                                this.EnteredBy = Util.Piece(line, enteredByText, 2);
                            }
                            if (line.IndexOf(enteredOnText) > -1)
                            {
                                string enteredOn = Util.Piece(line, enteredOnText, 2);
                                this.Created = VistaDates.ParseDateString(enteredOn, VistaDates.VistADateFormatSeven);
                            }
                        }
                    }
                }

                this.Response.Status = RpcResponseStatus.Success;
            }
        }
Exemple #4
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);
        }