コード例 #1
0
        public IenResult SaveSingletonObservation(Observation observation)
        {
            // *** Singleton observation: only one should exist, retrieve it and update if it does ***

            IenResult returnResult = new IenResult();

            // *** If we already have an ien, use it ***
            if (!string.IsNullOrWhiteSpace(observation.Ien))
            {
                returnResult = this.SaveObservation(observation);
            }
            else
            {
                ObservationListResult listResult = this.GetObservations(observation.PatientDfn, observation.PregnancyIen, observation.BabyIen, "", "", "", observation.Category, 0, 0);

                if (listResult.Success)
                {
                    if (listResult.Observations != null)
                    {
                        foreach (Observation tempObs in listResult.Observations)
                        {
                            if (tempObs.Code == observation.Code)
                            {
                                observation.Ien = tempObs.Ien;
                                break;
                            }
                        }
                    }
                }

                returnResult = this.SaveObservation(observation);
            }

            return(returnResult);
        }
コード例 #2
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);
        }
コード例 #3
0
        public BrokerOperationResult SaveSingletonObservationsByCategory(List <Observation> observationList)
        {
            // *** This method makes the following assumptions:                                   ***
            // ***         All the observations share the same, patient, category, and pregnancy  ***
            // ***         These are singleton observations, only one should exist at any time    ***

            BrokerOperationResult returnResult = new BrokerOperationResult();

            // *** Get all observations for this category ****

            if (observationList != null)
            {
                if (observationList.Count > 0)
                {
                    // *** Use first item to find all that match ***
                    ObservationListResult listResult = GetObservationListByCategory(observationList[0].PatientDfn, observationList[0].PregnancyIen, observationList[0].Category);

                    // *** Get the list or empty ***
                    List <Observation> existingList = (listResult.Success) ? listResult.Observations : new List <Observation>();

                    // *** For all new obs ***
                    foreach (Observation newObs in observationList)
                    {
                        // *** Look for existing match, set ien if found ***
                        foreach (Observation exObs in existingList)
                        {
                            if ((newObs.Code.Equals(exObs.Code ?? "", StringComparison.CurrentCultureIgnoreCase)) && (newObs.BabyIen.Equals(exObs.BabyIen ?? "", StringComparison.CurrentCultureIgnoreCase)))
                            {
                                newObs.Ien = exObs.Ien;
                            }
                        }

                        // *** Save it ***
                        returnResult = this.SaveObservation(newObs);

                        // *** Abort if problem ***
                        if (!returnResult.Success)
                        {
                            break;
                        }
                    }
                }
            }

            return(returnResult);
        }