예제 #1
0
        public GetStandardObservationsResponse GetStandardObservationsByType(GetStandardObservationsRequest request)
        {
            try
            {
                GetStandardObservationsResponse result = new GetStandardObservationsResponse();

                // get list of observations
                IPatientObservationRepository repo = Factory.GetRepository(request, RepositoryType.Observation);

                List <ObservationData>        odl  = (List <ObservationData>)repo.GetObservationsByType(request.TypeId, true, true);
                List <PatientObservationData> podl = new List <PatientObservationData>();

                // load and initialize each observation
                string initSetId = ObjectId.GenerateNewId().ToString();
                foreach (ObservationData od in odl)
                {
                    PatientObservationData pod = new PatientObservationData
                    {
                        Id            = ObjectId.GenerateNewId().ToString(),
                        ObservationId = od.Id,
                        Name          = od.CommonName ?? od.Description,
                        Order         = od.Order,
                        Standard      = od.Standard,
                        GroupId       = od.GroupId,
                        Units         = od.Units,
                        Values        = new List <ObservationValueData>(),
                        TypeId        = od.ObservationTypeId,
                        PatientId     = request.PatientId,
                        Source        = od.Source
                    };

                    // do an insert here and get an id from mongo
                    ObservationValueData ovd = InitializePatientObservation(request, request.PatientId, pod.Values, od, initSetId);

                    if (od.GroupId != null)
                    {
                        if (Util.GroupExists(podl, od.GroupId))
                        {
                            Util.FindAndInsert(podl, od.GroupId, ovd);
                        }
                        else
                        {
                            podl.Add(pod);
                        }
                    }
                    else
                    {
                        podl.Add(pod);
                    }
                }

                result.StandardObservations = podl;

                return(result);
            }
            catch (Exception ex)
            {
                throw new Exception("DD.DataPatientObservationManager:GetStandardObservationsByType()::" + ex.Message, ex.InnerException);
            }
        }
예제 #2
0
        public void GetPreviousValuesForObservation(ObservationValueData ovd, string patientId, string observationTypeId, IDataDomainRequest request)
        {
            try
            {
                IPatientObservationRepository repo = Factory.GetRepository(request, RepositoryType.PatientObservation);

                PatientObservationData val = (PatientObservationData)repo.FindRecentObservationValue(observationTypeId, patientId);

                if (val != null)
                {
                    ovd.PreviousValue = new PreviousValueData
                    {
                        EndDate   = val.EndDate,
                        Source    = val.Source,
                        StartDate = val.StartDate,
                        Unit      = val.Units,
                        Value     = Util.GetPreviousValues(val.Values)
                    };
                }
            }
            catch (Exception ex)
            {
                throw new Exception("DD.DataPatientObservationManager:GetPreviousValuesForObservation()::" + ex.Message, ex.InnerException);
            }
        }
예제 #3
0
 public void FindAndInsert(List <PatientObservationData> podl, string gid, ObservationValueData ovd)
 {
     try
     {
         if (podl != null && podl.Count > 0)
         {
             foreach (PatientObservationData p in podl)
             {
                 if (p.GroupId != null)
                 {
                     if (p.GroupId.Equals(gid))
                     {
                         if (!p.Values.Exists(x => x.Id == ovd.Id))
                         {
                             p.Values.Add(ovd);
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
예제 #4
0
        public PatientObservationData MakeAdditionalObservation(GetAdditionalObservationDataItemRequest request, IPatientObservationRepository repo, ObservationData od)
        {
            try
            {
                PatientObservationData pod = CreatePatientObservationData(request, od);
                ObservationValueData   ovd = InitializePatientObservation(request, request.PatientId, pod.Values, od, request.SetId);

                // account for composite BP observation
                if (pod.GroupId != null && pod.GroupId.Equals("530cb50dfe7a591ee4a58c51"))
                {
                    string observationId = string.Empty;
                    observationId = od.Id.Equals("530c26fcfe7a592f64473e37") ? "530c270afe7a592f64473e38" : "530c26fcfe7a592f64473e37";
                    ObservationData        od2  = (ObservationData)repo.FindByID(observationId);
                    PatientObservationData pod2 = CreatePatientObservationData(request, od2);
                    ObservationValueData   ovd2 = InitializePatientObservation(request, request.PatientId, pod.Values, od2, request.SetId);
                }
                return(pod);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #5
0
        public ObservationValueData InitializePatientObservation(IDataDomainRequest request, string patientId, List <ObservationValueData> list, ObservationData od, string initSetId)
        {
            try
            {
                IPatientObservationRepository repo = Factory.GetRepository(request, RepositoryType.PatientObservation);

                PutInitializeObservationDataRequest req = new PutInitializeObservationDataRequest
                {
                    PatientId      = patientId,
                    ObservationId  = od.Id,
                    Context        = request.Context,
                    ContractNumber = request.ContractNumber,
                    UserId         = request.UserId,
                    Version        = request.Version,
                    SetId          = initSetId
                };

                ObservationValueData ovd = new ObservationValueData();

                // get last value for each observation data
                GetPreviousValuesForObservation(ovd, patientId, od.Id, request);

                PatientObservationData pod = (PatientObservationData)repo.Initialize(req);

                ovd.Id    = pod.Id;
                ovd.Text  = od.Description;
                ovd.Value = string.Empty; // changed to initialize the value.

                list.Add(ovd);

                return(ovd);
            }
            catch (Exception ex)
            {
                throw new Exception("DD.DataPatientObservationManager:InitializePatientObservation()::" + ex.Message, ex.InnerException);
            }
        }