Ejemplo n.º 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);
            }
        }
Ejemplo n.º 2
0
        public GetStandardObservationsResponse Get(GetStandardObservationsRequest request)
        {
            GetStandardObservationsResponse response = new GetStandardObservationsResponse();

            try
            {
                if (string.IsNullOrEmpty(request.UserId))
                {
                    throw new UnauthorizedAccessException("PatientObservationDD:Get()::Unauthorized Access");
                }

                response         = Omgr.GetStandardObservationsByType(request);
                response.Version = request.Version;
            }
            catch (Exception ex)
            {
                CommonFormatter.FormatExceptionResponse(response, base.Response, ex);

                string aseProcessID = ConfigurationManager.AppSettings.Get("ASEProcessID") ?? "0";
                Common.Helper.LogException(int.Parse(aseProcessID), ex);
            }
            return(response);
        }