Example #1
0
        public void SavePatientGoal_Test()
        {
            PostPatientGoalRequest request = new PostPatientGoalRequest();

            request.ContractNumber = "InHealth001";
            request.Version        = 1;
            request.UserId         = "531f2df5072ef727c4d2a3bc";
            request.PatientId      = "5325db62d6a4850adcbba91e";
            request.PatientGoalId  = "5438563484ac050d1cb15617";
            request.Goal           = new PatientGoal
            {
                Id = "5438563484ac050d1cb15617",
                //FocusAreaIds = new List<string> { "532be4771e60150ce42f8a30" },
                Name      = "Snehal 3",
                PatientId = "5325db62d6a4850adcbba91e",
                SourceId  = "52fa57c9d433231dd0775011",
                StatusId  = 2,
                StartDate = DateTime.UtcNow,
            };

            GoalsManager            gManager = new GoalsManager();
            PostPatientGoalResponse response = gManager.SavePatientGoal(request);

            Assert.IsNotNull(response);
        }
Example #2
0
        public static bool SavePatientGoalBarriers(PostPatientGoalRequest request)
        {
            bool result = false;

            try
            {
                if (request.Goal.Barriers != null && request.Goal.Barriers.Count > 0)
                {
                    List <PatientBarrierData> pbd = new List <PatientBarrierData>();
                    request.Goal.Barriers.ForEach(b =>
                    {
                        PatientBarrierData data = ConvertToPatientBarrierData(b);
                        pbd.Add(ConvertToPatientBarrierData(b));
                    });

                    pbd.ForEach(bd =>
                    {
                        result = GoalsEndpointUtil.PostUpdateBarrierRequest(request, bd);
                    });
                }
                else if (request.Goal.Barriers.Count == 0)
                {
                    PatientBarrierData pbd = new PatientBarrierData {
                        Id = "0", PatientGoalId = request.PatientGoalId
                    };
                    result = GoalsEndpointUtil.PostUpdateBarrierRequest(request, pbd);
                }
                return(result);
            }
            catch (Exception ex)
            {
                throw new Exception("AD:SavePatientGoalBarriers()::" + ex.Message, ex.InnerException);
            }
        }
Example #3
0
        internal static bool PostUpdateTaskRequest(PostPatientGoalRequest request, PatientTaskData td)
        {
            try
            {
                bool result = false;

                List <string> taskIds = GetTaskIdsForRequest(request.Goal.Tasks);

                IRestClient client = new JsonServiceClient();

                string url = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/Patient/{4}/Goal/{5}/Task/{6}/Update", DDPatientGoalsServiceUrl, "NG", request.Version, request.ContractNumber, request.PatientId, request.Goal.Id, td.Id), request.UserId);

                PutUpdateTaskResponse response = client.Put <PutUpdateTaskResponse>(url, new PutUpdateTaskRequest {
                    Task = td, TaskIdsList = taskIds, UserId = request.UserId
                } as object);

                if (response != null)
                {
                    result = true;
                }

                return(result);
            }
            catch (WebServiceException ex)
            {
                throw new WebServiceException("AD:PostUpdateTaskRequest()::" + ex.Message, ex.InnerException);
            }
        }
Example #4
0
        public static bool SavePatientGoalInterventions(PostPatientGoalRequest request)
        {
            bool result = false;

            try
            {
                if (request.Goal.Interventions != null && request.Goal.Interventions.Count > 0)
                {
                    List <PatientInterventionData> pid = new List <PatientInterventionData>();
                    request.Goal.Interventions.ForEach(i =>
                    {
                        PatientInterventionData data = ConvertToInterventionData(i);
                        pid.Add(data);
                    });

                    pid.ForEach(pi =>
                    {
                        result = GoalsEndpointUtil.PostUpdateInterventionRequest(request, pi);
                    });
                }
                else if (request.Goal.Interventions.Count == 0)
                {
                    // just delete all of them
                    PatientInterventionData pbd = new PatientInterventionData {
                        Id = "0", PatientGoalId = request.PatientGoalId
                    };
                    result = GoalsEndpointUtil.PostUpdateInterventionRequest(request, pbd);
                }
                return(result);
            }
            catch (Exception ex)
            {
                throw new Exception("AD:SavePatientGoalInterventions()::" + ex.Message, ex.InnerException);
            }
        }
Example #5
0
        public static bool SavePatientGoalTasks(PostPatientGoalRequest request)
        {
            bool result = false;

            try
            {
                if (request.Goal.Tasks != null && request.Goal.Tasks.Count > 0)
                {
                    List <PatientTaskData> ptd = new List <PatientTaskData>();
                    request.Goal.Tasks.ForEach(t =>
                    {
                        PatientTaskData data = ConvertToPatientTaskData(t);
                        ptd.Add(data);
                    });

                    ptd.ForEach(td =>
                    {
                        GoalsEndpointUtil.PostUpdateTaskRequest(request, td);
                    });
                }
                else if (request.Goal.Tasks.Count == 0)
                {
                    PatientTaskData pbd = new PatientTaskData {
                        Id = "0", PatientGoalId = request.PatientGoalId
                    };
                    result = GoalsEndpointUtil.PostUpdateTaskRequest(request, pbd);
                }
                return(result);
            }
            catch (Exception ex)
            {
                throw new Exception("AD:SavePatientGoalTasks()::" + ex.Message, ex.InnerException);
            }
        }
Example #6
0
 public PostPatientGoalResponse SavePatientGoal(PostPatientGoalRequest request)
 {
     try
     {
         PostPatientGoalResponse pgr = new PostPatientGoalResponse();
         pgr.Goal    = GoalsEndpointUtil.PostUpdateGoalRequest(request);
         pgr.Version = request.Version;
         return(pgr);
     }
     catch (Exception ex)
     {
         throw new Exception("AD:SavePatientGoal()::" + ex.Message, ex.InnerException);
     }
 }
Example #7
0
        public PatientGoal PostUpdateGoalRequest(PostPatientGoalRequest request)
        {
            try
            {
                PatientGoal goal = null;

                if (request.Goal == null)
                {
                    throw new Exception("The Goal property is null in the request.");
                }
                else if (string.IsNullOrEmpty(request.Goal.Name) || string.IsNullOrEmpty(request.Goal.SourceId))
                {
                    throw new Exception("The goal name and source are required fields.");
                }

                IRestClient client = new JsonServiceClient();

                string url = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/Patient/{4}/Goal/{5}/Update",
                                                                  DDPatientGoalsServiceUrl,
                                                                  "NG",
                                                                  request.Version,
                                                                  request.ContractNumber,
                                                                  request.PatientId,
                                                                  request.Goal.Id), request.UserId);

                PutUpdateGoalDataResponse response = client.Put <PutUpdateGoalDataResponse>(
                    url, new PutUpdateGoalDataRequest {
                    Goal = convertToPatientGoalData(request.Goal), UserId = request.UserId
                } as object);

                if (response != null && response.GoalData != null)
                {
                    //Make a call to AttributeLibrary to get attributes details for Goal.
                    List <CustomAttribute> goalAttributesLibrary = GoalsEndpointUtil.GetAttributesLibraryByType(request, 1);
                    goal = GoalsUtil.ConvertToGoal(response.GoalData, goalAttributesLibrary);
                }

                return(goal);
            }
            catch (WebServiceException ex)
            {
                throw new WebServiceException("AD:PostUpdateGoalRequest()::" + ex.Message, ex.InnerException);
            }
        }
Example #8
0
        public PostPatientGoalResponse Post(PostPatientGoalRequest request)
        {
            PostPatientGoalResponse response = new PostPatientGoalResponse();
            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.SavePatientGoal(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);
        }
Example #9
0
 public bool PostUpdateTaskRequest(PostPatientGoalRequest request, PatientTaskData td)
 {
     throw new NotImplementedException();
 }
Example #10
0
 public bool PostUpdateBarrierRequest(PostPatientGoalRequest request, PatientBarrierData bd)
 {
     throw new NotImplementedException();
 }
Example #11
0
 public bool PostUpdateInterventionRequest(PostPatientGoalRequest request, PatientInterventionData pi)
 {
     throw new NotImplementedException();
 }
Example #12
0
 public PatientGoal PostUpdateGoalRequest(PostPatientGoalRequest request)
 {
     return(new PatientGoal());
 }