Пример #1
0
        public PutUpdatePatientObservationsDataResponse UpdatePatientObservations(PutUpdatePatientObservationsDataRequest request)
        {
            try
            {
                PutUpdatePatientObservationsDataResponse response       = new PutUpdatePatientObservationsDataResponse();
                List <PatientObservationData>            returnDataList = null;
                bool result = false;
                IPatientObservationRepository repo = Factory.GetRepository(request, RepositoryType.PatientObservation);

                // update
                if (request.PatientObservationsRecordData != null && request.PatientObservationsRecordData.Count != 0)
                {
                    returnDataList = new List <PatientObservationData>();
                    foreach (PatientObservationRecordData poData in request.PatientObservationsRecordData)
                    {
                        if (!string.IsNullOrEmpty(poData.Id))
                        {
                            PutUpdateObservationDataRequest putUpdateObservationDataRequest = new PutUpdateObservationDataRequest {
                                Context                = request.Context,
                                ContractNumber         = request.ContractNumber,
                                PatientId              = request.PatientId,
                                PatientObservationData = poData,
                                UserId  = request.UserId,
                                Version = request.Version
                            };
                            result = (bool)repo.Update(putUpdateObservationDataRequest);
                            //fetch & return the update object.
                            PatientObservationData pod = (PatientObservationData)repo.FindByID(poData.Id, true);
                            returnDataList.Add(pod);
                        }
                    }
                    IPatientObservationRepository observationRepo = Factory.GetRepository(request, RepositoryType.Observation);
                    List <ObservationData>        observations    = (List <ObservationData>)observationRepo.GetActiveObservations();
                    if (observations != null && observations.Count > 0)
                    {
                        List <string> distinctObservations = returnDataList.Select(a => a.ObservationId).Distinct().ToList();
                        // added this to take care of composite observations like BP
                        distinctObservations.ForEach(o => CombineCompositeObservations(o, returnDataList));
                        returnDataList.ForEach(r =>
                        {
                            ObservationData odata = observations.Where(x => x.Id == r.ObservationId).FirstOrDefault();
                            if (odata != null)
                            {
                                r.TypeId   = odata.ObservationTypeId;
                                r.Name     = odata.CommonName == null ? odata.Description : odata.CommonName;
                                r.Standard = odata.Standard;
                            }
                        });
                    }
                }
                response.PatientObservationsData = returnDataList;
                response.Result = result;
                return(response);
            }
            catch (Exception ex)
            {
                throw new Exception("DD.DataPatientObservationManager:UpdatePatientObservations()::" + ex.Message, ex.InnerException);
            }
        }
Пример #2
0
        public GetAdditionalObservationDataItemResponse GetAdditionalObservationItemById(GetAdditionalObservationDataItemRequest request)
        {
            try
            {
                GetAdditionalObservationDataItemResponse result = new GetAdditionalObservationDataItemResponse();
                IPatientObservationRepository            repo   = Factory.GetRepository(request, RepositoryType.Observation);

                ObservationData        od  = (ObservationData)repo.FindByID(request.ObservationId);
                PatientObservationData pod = MakeAdditionalObservation(request, repo, od);

                result.Observation = pod;

                return(result);
            }
            catch (Exception ex)
            {
                throw new Exception("DD.DataPatientObservationManager:GetAdditionalObservationItemById()::" + ex.Message, ex.InnerException);
            }
        }
Пример #3
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;
            }
        }