예제 #1
0
        public void GetFilteredInterventions_MyClosedList_Success()
        {
            var mockPatientInterventionDataList = new List <PatientInterventionData>();

            for (int i = 1; i <= 10; i++)
            {
                mockPatientInterventionDataList.Add(new PatientInterventionData()
                {
                    CreatedById  = "1",
                    AssignedToId = "1",
                    StatusId     = 2
                });
            }
            mockPatientInterventionDataList[0].AssignedToId = "2";
            mockPatientInterventionDataList[1].AssignedToId = "2";

            GetInterventionsRequest request = new GetInterventionsRequest()
            {
                UserId = "1",
                InterventionFilterType = InterventionFilterType.MyClosedList
            };

            Assert.IsTrue(GoalsEndpointUtil.GetFilteredInterventions(mockPatientInterventionDataList, request)
                          .Count == 8);
        }
예제 #2
0
        public static List <PatientIntervention> GetInterventions(GetInterventionsRequest request)
        {
            List <PatientIntervention> interventions = null;

            try
            {
                //[Route("/{Context}/{Version}/{ContractNumber}/Goal/Interventions", "POST")]
                IRestClient client = new JsonServiceClient();
                string      url    = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/Goal/Interventions",
                                                                          DDPatientGoalsServiceUrl,
                                                                          "NG",
                                                                          request.Version,
                                                                          request.ContractNumber), request.UserId);

                GetPatientInterventionsDataResponse ddResponse =
                    client.Post <GetPatientInterventionsDataResponse>(url, new GetPatientInterventionsDataRequest
                {
                    Context        = "NG",
                    ContractNumber = request.ContractNumber,
                    Version        = request.Version,
                    UserId         = request.UserId,
                    AssignedToId   = request.AssignedToId,
                    CreatedById    = request.CreatedById,
                    PatientId      = request.PatientId,
                    StatusIds      = request.StatusIds
                } as object);

                if (ddResponse != null && ddResponse.InterventionsData != null)
                {
                    var filteredInterventions = ddResponse.InterventionsData;
                    if (request.InterventionFilterType != 0)
                    {
                        filteredInterventions = GetFilteredInterventions(ddResponse.InterventionsData, request);
                    }
                    interventions = new List <PatientIntervention>();
                    var patientIds      = filteredInterventions.Select(x => x.PatientId).ToList();
                    var patientsDetails = GetPatientsDetails(request.Version, request.ContractNumber, request.UserId, client, patientIds);

                    foreach (PatientInterventionData n in filteredInterventions)
                    {
                        PatientIntervention i = GoalsUtil.ConvertToIntervention(n);
                        i.PatientDetails = patientsDetails.FirstOrDefault(x => x.Id == n.PatientId);
                        i.PatientId      = n.PatientId;
                        interventions.Add(i);
                    }
                }
            }
            catch
            {
                throw;
            }
            return(interventions);
        }
예제 #3
0
 public GetInterventionsResponse GetInterventions(GetInterventionsRequest request)
 {
     try
     {
         GetInterventionsResponse response = new GetInterventionsResponse();
         response.Interventions = GoalsEndpointUtil.GetInterventions(request);
         response.Version       = request.Version;
         return(response);
     }
     catch (WebServiceException ex)
     {
         throw new WebServiceException("AD:GetInterventions()::" + ex.Message, ex.InnerException);
     }
 }
예제 #4
0
        public List <PatientIntervention> GetInterventions(GetInterventionsRequest request)
        {
            List <PatientIntervention> interventions = null;

            try
            {
                //[Route("/{Context}/{Version}/{ContractNumber}/Goal/Interventions", "POST")]
                IRestClient client = new JsonServiceClient();
                string      url    = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/Goal/Interventions",
                                                                          DDPatientGoalsServiceUrl,
                                                                          "NG",
                                                                          request.Version,
                                                                          request.ContractNumber), request.UserId);

                GetPatientInterventionsDataResponse ddResponse =
                    client.Post <GetPatientInterventionsDataResponse>(url, new GetPatientInterventionsDataRequest
                {
                    Context        = "NG",
                    ContractNumber = request.ContractNumber,
                    Version        = request.Version,
                    UserId         = request.UserId,
                    AssignedToId   = request.AssignedToId,
                    CreatedById    = request.CreatedById,
                    PatientId      = request.PatientId,
                    StatusIds      = request.StatusIds
                } as object);

                if (ddResponse != null && ddResponse.InterventionsData != null)
                {
                    interventions = new List <PatientIntervention>();
                    List <PatientInterventionData> dataList = ddResponse.InterventionsData;
                    foreach (PatientInterventionData n in dataList)
                    {
                        PatientIntervention i = GoalsUtil.ConvertToIntervention(n);
                        // Call Patient DD to get patient details.
                        i.PatientDetails = GetPatientDetails(request.Version, request.ContractNumber, request.UserId, client, n.PatientId);
                        i.PatientId      = n.PatientId;
                        interventions.Add(i);
                    }
                }
            }
            catch
            {
                throw;
            }
            return(interventions);
        }
예제 #5
0
        public void GetInterventions_Test()
        {
            GetInterventionsRequest request = new GetInterventionsRequest();

            request.ContractNumber = "InHealth001";
            request.Version        = 1;
            // request.AssignedToId = "5325c821072ef705080d3488";
            // request.CreatedById = "5325c821072ef705080d3488";
            request.StatusIds = new List <int> {
                1, 2, 3
            };
            request.PatientId = "5481dbbd231e250160a0e9d1";
            request.UserId    = "531f2df5072ef727c4d2a3bc";

            GoalsManager             gManager = new GoalsManager();
            GetInterventionsResponse response = gManager.GetInterventions(request);

            Assert.IsNotNull(response);
        }
예제 #6
0
        public GetInterventionsResponse Post(GetInterventionsRequest request)
        {
            GetInterventionsResponse response = new GetInterventionsResponse();
            GoalsManager             gm       = new GoalsManager();
            ValidateTokenResponse    result   = null;

            try
            {
                request.Token = base.Request.Headers["Token"] as string;
                result        = Security.IsUserValidated(request.Version, request.Token, request.ContractNumber);
                if (result.UserId.Trim() != string.Empty)
                {
                    request.UserId = result.UserId;
                    response       = gm.GetInterventions(request);
                }
                else
                {
                    throw new UnauthorizedAccessException();
                }
            }
            catch (Exception ex)
            {
                CommonFormatter.FormatExceptionResponse(response, base.Response, ex);
                if ((ex is WebServiceException) == false)
                {
                    gm.LogException(ex);
                }
            }
            finally
            {
                if (result != null)
                {
                    AuditHelper.LogAuditData(request, result.SQLUserId, null, System.Web.HttpContext.Current.Request, request.GetType().Name);
                }
            }
            return(response);
        }
예제 #7
0
        public static List <PatientInterventionData> GetFilteredInterventions(List <PatientInterventionData> interventionsData, GetInterventionsRequest request)
        {
            if (interventionsData == null || request == null)
            {
                throw new ArgumentNullException();
            }

            var res = new List <PatientInterventionData>();

            switch (request.InterventionFilterType)
            {
            case InterventionFilterType.AssignedToOthers:
                res = interventionsData.Where(
                    x => x.CreatedById == request.UserId && x.AssignedToId != request.UserId && x.StatusId == (int)InterventionStatus.Open).ToList();
                break;

            case InterventionFilterType.ClosedByOthers:
                res = interventionsData.Where(
                    x => x.CreatedById == request.UserId && x.AssignedToId != request.UserId && x.StatusId != (int)InterventionStatus.Open).ToList();
                break;

            case InterventionFilterType.MyClosedList:
                res = interventionsData.Where(
                    x => x.AssignedToId == request.UserId && x.StatusId != (int)InterventionStatus.Open).ToList();
                break;

            case InterventionFilterType.MyOpenList:
            default:
                res = interventionsData.Where(
                    x => x.AssignedToId == request.UserId && x.StatusId == (int)InterventionStatus.Open).ToList();
                break;
            }
            return(res);
        }
예제 #8
0
 public List <PatientIntervention> GetInterventions(GetInterventionsRequest request)
 {
     throw new NotImplementedException();
 }