public List <PatientObservationData> GetHistoricalPatientObservations(GetHistoricalPatientObservationsDataRequest request) { try { //var currentPOs = new List<PatientObservationData>(); List <PatientObservationData> po = null; var poRepo = Factory.GetRepository(request, RepositoryType.PatientObservation); var patientObservations = poRepo.FindObservationIdByPatientId(request.PatientId) as List <PatientObservationData>; if (patientObservations == null || patientObservations.Count <= 0) { return(po); } var observationRepo = Factory.GetRepository(request, RepositoryType.Observation); var observations = (List <ObservationData>)observationRepo.GetActiveObservations(); if (observations == null || observations.Count <= 0) { return(po); } CombineCompositeObservations(request.ObservationId, patientObservations); var distinctObservations = patientObservations.Select(a => a.ObservationId).Distinct().ToList(); distinctObservations.ForEach(a => { po = patientObservations.Where(s => s.ObservationId == request.ObservationId).OrderByDescending(o => o.LastUpdatedOn).ToList(); po.ForEach(pod => { var odata = observations.FirstOrDefault(x => x.Id == request.ObservationId); if (odata == null) { return; } pod.GroupId = odata.GroupId; pod.TypeId = odata.ObservationTypeId; pod.Name = odata.CommonName ?? odata.Description; }); }); return(po); } catch (Exception ex) { throw new Exception("DD.DataPatientObservationManager:GetHistoricalPatientObservations()::" + ex.Message, ex.InnerException); } }
public void GetHistoricalPatientObservations_Test() { // Arrange string userId = string.Empty; string contractNumber = "InHealth001"; string context = "NG"; string patientId = "5325db20d6a4850adcbba84e"; GetHistoricalPatientObservationsDataRequest request = new GetHistoricalPatientObservationsDataRequest { PatientId = patientId, Context = context, ContractNumber = contractNumber, UserId = userId, Version = 1, ObservationId = "530c270afe7a592f64473e38" }; PatientObservationDataManager cm = new PatientObservationDataManager { Factory = new PatientObservationRepositoryFactory() }; List <PatientObservationData> response = cm.GetHistoricalPatientObservations(request); Assert.IsNotNull(response); }
public GetHistoricalPatientObservationsDataResponse Get(GetHistoricalPatientObservationsDataRequest request) { GetHistoricalPatientObservationsDataResponse response = new GetHistoricalPatientObservationsDataResponse(); try { if (string.IsNullOrEmpty(request.UserId)) { throw new UnauthorizedAccessException("PatientObservationDD:Get()::Unauthorized Access"); } var data = Omgr.GetHistoricalPatientObservations(request); response.PatientObservationsData = data; response.Version = request.Version; } catch (Exception ex) { CommonFormatter.FormatExceptionResponse(response, base.Response, ex); var aseProcessID = ConfigurationManager.AppSettings.Get("ASEProcessID") ?? "0"; Common.Helper.LogException(int.Parse(aseProcessID), ex); } return(response); }