Exemple #1
0
        public ObservationListResult GetObservations(string patientDfn, string pregnancyIen, string babyIen, string tiuIen, string fromDate, string toDate, string category, int page, int itemsPerPage)
        {
            // *** Get a list of observations matching criteria ***

            ObservationListResult result = new ObservationListResult();

            // *** Create command ***
            DsioGetObservationsCommand command = new DsioGetObservationsCommand(this.broker);

            // *** Add command arguments ***
            command.AddCommandArguments(patientDfn, "", pregnancyIen, babyIen, tiuIen, fromDate, toDate, category, page, itemsPerPage);

            // *** Execute ***
            RpcResponse response = command.Execute();

            // *** Add response to result ***
            result.Success = response.Status == RpcResponseStatus.Success;
            result.Message = response.InformationalMessage;

            // *** Add observations ***
            if (result.Success)
            {
                result.TotalResults = command.TotalResults;

                if (result.TotalResults > 0)
                {
                    //result.Observations.AddRange(command.ObservationsList);
                    foreach (DsioObservation dsioObs in command.ObservationsList)
                    {
                        Observation obs = ObservationUtility.GetObservation(dsioObs);

                        if (obs != null)
                        {
                            result.Observations.Add(obs);
                        }
                    }

                    // *** Default sort oldest to newest ***
                    //result.Observations.Sort(delegate(DsioObservation o, DsioObservation p)
                    //{
                    //    DateTime oDate = VistaDates.ParseDateString(o.Date, VistaDates.VistADateFormatFour);
                    //    DateTime pDate = VistaDates.ParseDateString(p.Date, VistaDates.VistADateFormatFour);

                    //    return oDate.CompareTo(pDate);
                    //});

                    result.Observations.Sort((x, y) => DateTime.Compare(x.EntryDate, y.EntryDate));
                }
            }

            return(result);
        }
        public ObservationListResult GetObservations(string patientDfn, string pregnancyIen, string babyIen, string fromDate, string toDate, string category, int page, int itemsPerPage)
        {
            // *** Get a list of observations matching criteria ***

            ObservationListResult result = new ObservationListResult();

            // *** Create command ***
            DsioGetObservationsCommand command = new DsioGetObservationsCommand(this.broker);

            // *** Add command arguments ***
            command.AddCommandArguments(patientDfn, "", pregnancyIen, babyIen, "", fromDate, toDate, category, page, itemsPerPage);

            // *** Execute ***
            RpcResponse response = command.Execute();

            // *** Add response to result ***
            result.Success = response.Status == RpcResponseStatus.Success;
            result.Message = response.InformationalMessage;

            // *** Add observations ***
            if (result.Success)
            {
                result.TotalResults = command.TotalResults;

                if (command.ObservationsList != null)
                {
                    if (command.ObservationsList.Count > 0)
                    {
                        //result.Observations.AddRange(command.ObservationsList);

                        foreach (DsioObservation dsioObs in command.ObservationsList)
                        {
                            Observation obs = ObservationUtility.GetObservation(dsioObs);

                            if (obs != null)
                            {
                                result.Observations.Add(obs);
                            }
                        }
                    }
                }
            }

            return(result);
        }
        public PregnancyHistoryResult GetPregnancyHistory(string patientDfn)
        {
            // *** Gets pregnancy history ***

            PregnancyHistoryResult result = new PregnancyHistoryResult();

            // *** Create the command ***
            DsioGetObservationsCommand command = new DsioGetObservationsCommand(this.broker);

            // *** Add command arguments ***
            command.AddCommandArguments(patientDfn, "", "", "", "", "", "", "Pregnancy History", 1, 1000);

            // *** Execute command ***
            RpcResponse response = command.Execute();

            // *** Add results to return ***
            result.Success = response.Status == RpcResponseStatus.Success;
            result.Message = response.InformationalMessage;

            // *** Create pregnancy history ***
            if (result.Success)
            {
                // *** Check that there are observations ***
                if (command.ObservationsList != null)
                {
                    if (command.ObservationsList.Count > 0)
                    {
                        // *** Create a dictionary to hold only most recent ***
                        Dictionary <string, DsioObservation> mostRecentList = new Dictionary <string, DsioObservation>();

                        // *** Loop through the list, if it does not exist add it, or if it is newer, replace ***
                        foreach (DsioObservation dsioObservation in command.ObservationsList)
                        {
                            if (!mostRecentList.ContainsKey(dsioObservation.Code.Code))
                            {
                                mostRecentList.Add(dsioObservation.Code.Code, dsioObservation);
                            }
                            else
                            {
                                // *** Get dates to compare ***
                                DateTime existingDate = VistaDates.ParseDateString(mostRecentList[dsioObservation.Code.Code].EntryDate, VistaDates.VistADateFormatTwo);
                                DateTime newDate      = VistaDates.ParseDateString(dsioObservation.EntryDate, VistaDates.VistADateFormatTwo);

                                // *** If newer replace ***
                                if (newDate > existingDate)
                                {
                                    mostRecentList[dsioObservation.Code.Code] = dsioObservation;
                                }
                            }
                        }

                        // *** Loop through most recent and add to pregnancy history ***
                        foreach (DsioObservation dsioObservation in mostRecentList.Values)
                        {
                            if (!string.IsNullOrWhiteSpace(dsioObservation.Code.Code))
                            {
                                Observation tempObs = ObservationUtility.GetObservation(dsioObservation);
                                result.PregnancyHistory.Observations[dsioObservation.Code.Code] = tempObs;
                                //result.PregnancyHistory.SetValue(dsioObservation.Code, dsioObservation.Value);
                            }
                        }
                    }
                }
            }

            return(result);
        }