Esempio n. 1
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);
            }
        }
Esempio n. 2
0
        internal static PatientTask PostUpdateTaskRequest(PostPatientTaskRequest request)
        {
            try
            {
                PatientTask task = null;

                if (request.Task == null)
                {
                    throw new Exception("The Task property is null in the request.");
                }

                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.PatientGoalId, request.Id), request.UserId);

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

                if (response != null && response.TaskData != null)
                {
                    //Make a call to AttributeLibrary to get attributes details for Goal and Task.
                    List <CustomAttribute> taskAttributesLibrary = GoalsEndpointUtil.GetAttributesLibraryByType(request, 2);
                    task = GoalsUtil.ConvertToTask(response.TaskData, taskAttributesLibrary);
                }
                return(task);
            }
            catch (WebServiceException ex)
            {
                throw new WebServiceException("AD:PostUpdateTaskRequest()::" + ex.Message, ex.InnerException);
            }
        }
Esempio n. 3
0
        public static List <PatientIntervention> ConvertToInterventions(IAppDomainRequest request, IRestClient client, List <PatientInterventionData> list)
        {
            List <PatientIntervention> interventionList = null;

            try
            {
                if (list != null && list.Count > 0)
                {
                    interventionList = new List <PatientIntervention>();
                    foreach (PatientInterventionData i in list)
                    {
                        PatientIntervention pi = ConvertToIntervention(i);
                        if (pi != null)
                        {
                            // Call Patient DD to get patient details.
                            pi.PatientDetails = GoalsEndpointUtil.GetPatientDetails(request.Version, request.ContractNumber, request.UserId, client, i.PatientId);
                            pi.PatientId      = i.PatientId;
                            interventionList.Add(pi);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("AD:GetInterventions()::" + ex.Message, ex.InnerException);
            }
            return(interventionList);
        }
Esempio n. 4
0
        internal static PatientGoal GetPatientGoalForInitialize(GetInitializeGoalRequest request, PatientGoalData pgd)
        {
            PatientGoal pg = null;

            try
            {
                if (pgd != null)
                {
                    pg = new PatientGoal
                    {
                        CustomAttributes = GoalsEndpointUtil.GetAttributesLibraryByType(request, 1), //GetAttributesForInitialize(pgd.Attributes), // change this call when attributes are ready
                        EndDate          = pgd.EndDate,
                        Id          = pgd.Id,
                        Name        = pgd.Name,
                        PatientId   = pgd.PatientId,
                        SourceId    = pgd.SourceId,
                        StartDate   = pgd.StartDate,
                        StatusId    = pgd.StatusId,
                        TargetDate  = pgd.TargetDate,
                        TargetValue = pgd.TargetValue,
                        TypeId      = pgd.TypeId
                    };
                }
            }
            catch (Exception ex)
            {
                throw new Exception("AD:GetPatientGoalForInitialize()::" + ex.Message, ex.InnerException);
            }
            return(pg);
        }
Esempio n. 5
0
        internal static PatientTask GetPatientTaskForInitialize(GetInitializeTaskRequest request, PatientTaskData ptd)
        {
            PatientTask pt = null;

            try
            {
                if (ptd != null)
                {
                    pt = new PatientTask
                    {
                        CustomAttributes = GoalsEndpointUtil.GetAttributesLibraryByType(request, 2),
                        Id          = ptd.Id,
                        StartDate   = ptd.StartDate,
                        StatusId    = ptd.StatusId,
                        TargetDate  = ptd.TargetDate,
                        TargetValue = ptd.TargetValue,
                        DeleteFlag  = ptd.DeleteFlag,
                        Details     = ptd.Details
                    };
                }
            }
            catch (Exception ex)
            {
                throw new Exception("AD:GetPatientTaskForInitialize()::" + ex.Message, ex.InnerException);
            }
            return(pt);
        }
Esempio n. 6
0
        public static List <PatientTask> GetTasks(GetTasksRequest request)
        {
            List <PatientTask> tasks = null;

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

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

                if (ddResponse != null && ddResponse.TasksData != null)
                {
                    tasks = new List <PatientTask>();
                    List <PatientTaskData> dataList = ddResponse.TasksData;
                    foreach (PatientTaskData n in dataList)
                    {
                        //Make a call to AttributeLibrary to get attributes details for Goal and Task.
                        List <CustomAttribute> taskAttributesLibrary = GoalsEndpointUtil.GetAttributesLibraryByType(request, 2);
                        PatientTask            i = GoalsUtil.ConvertToTask(n, taskAttributesLibrary);
                        tasks.Add(i);
                    }
                }
            }
            catch
            {
                throw;
            }
            return(tasks);
        }
Esempio n. 7
0
        public PostDeletePatientGoalResponse DeletePatientGoal(PostDeletePatientGoalRequest request)
        {
            try
            {
                PostDeletePatientGoalResponse pgr = new PostDeletePatientGoalResponse();
                bool result = false;

                // we can thread here if we want!
                // save goals
                GoalsEndpointUtil.DeleteGoalRequest(request);

                // save barriers
                GoalsUtil.DeletePatientGoalBarriers(request);

                // save tasks
                GoalsUtil.DeletePatientGoalTasks(request);

                // save interventions
                GoalsUtil.DeletePatientGoalInterventions(request);

                pgr.Result = result;

                return(pgr);
            }
            catch (Exception ex)
            {
                throw new Exception("AD:DeletePatientGoal()::" + ex.Message, ex.InnerException);
            }
        }
Esempio n. 8
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);
            }
        }
Esempio n. 9
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);
            }
        }
Esempio n. 10
0
 public PostPatientBarrierResponse SavePatientBarrier(PostPatientBarrierRequest request)
 {
     try
     {
         PostPatientBarrierResponse response = new PostPatientBarrierResponse();
         response.Barrier = GoalsEndpointUtil.PostUpdateBarrierRequest(request);
         response.Version = request.Version;
         return(response);
     }
     catch (Exception ex)
     {
         throw new Exception("AD:SavePatientBarrier()::" + ex.Message, ex.InnerException);
     }
 }
Esempio n. 11
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);
     }
 }
Esempio n. 12
0
 public GetPatientGoalResponse GetPatientGoal(GetPatientGoalRequest request)
 {
     try
     {
         GetPatientGoalResponse response = new GetPatientGoalResponse();
         response.Goal    = GoalsEndpointUtil.GetPatientGoal(request);
         response.Version = request.Version;
         return(response);
     }
     catch (Exception ex)
     {
         throw new Exception("AD:GetPatientGoal()::" + ex.Message, ex.InnerException);
     }
 }
Esempio n. 13
0
 public GetTasksResponse GetTasks(GetTasksRequest request)
 {
     try
     {
         GetTasksResponse response = new GetTasksResponse();
         response.Tasks   = GoalsEndpointUtil.GetTasks(request);
         response.Version = request.Version;
         return(response);
     }
     catch (WebServiceException ex)
     {
         throw new WebServiceException("AD:GetTasks()::" + ex.Message, ex.InnerException);
     }
 }
Esempio n. 14
0
        internal static bool DeletePatientGoalInterventions(PostDeletePatientGoalRequest request)
        {
            bool result = false;

            try
            {
                result = GoalsEndpointUtil.DeleteInterventionRequest(request, request.PatientGoalId);
                return(result);
            }
            catch (Exception ex)
            {
                throw new Exception("AD:DeletePatientGoalInterventions()::" + ex.Message, ex.InnerException);
            }
        }
Esempio n. 15
0
 public GetInitializeGoalResponse GetInitialGoalRequest(GetInitializeGoalRequest request)
 {
     try
     {
         GetInitializeGoalResponse response = new GetInitializeGoalResponse();
         PatientGoalData           pg       = (PatientGoalData)GoalsEndpointUtil.GetInitialGoalRequest(request);
         response.Goal    = GoalsUtil.GetPatientGoalForInitialize(request, pg);
         response.Version = request.Version;
         return(response);
     }
     catch (Exception ex)
     {
         throw new Exception("AD:GetInitialGoalRequest()::" + ex.Message, ex.InnerException);
     }
 }
Esempio n. 16
0
 public GetInitializeBarrierResponse GetInitialBarrierRequest(GetInitializeBarrierRequest request)
 {
     try
     {
         GetInitializeBarrierResponse response = new GetInitializeBarrierResponse();
         string id = GoalsEndpointUtil.GetInitialBarrierRequest(request);
         response.Id      = id;
         response.Version = request.Version;
         return(response);
     }
     catch (Exception ex)
     {
         throw new Exception("AD:GetInitialBarrierRequest()::" + ex.Message, ex.InnerException);
     }
 }
Esempio n. 17
0
 public GetInitializeInterventionResponse GetInitialIntervention(GetInitializeInterventionRequest request)
 {
     try
     {
         GetInitializeInterventionResponse itr = new GetInitializeInterventionResponse();
         string id = GoalsEndpointUtil.GetInitialInterventionRequest(request);
         itr.Id      = id;
         itr.Version = request.Version;
         return(itr);
     }
     catch (Exception ex)
     {
         throw new Exception("AD:GetInitialIntervention()::" + ex.Message, ex.InnerException);
     }
 }
Esempio n. 18
0
 public GetInitializeTaskResponse GetInitialTask(GetInitializeTaskRequest request)
 {
     try
     {
         GetInitializeTaskResponse itr = new GetInitializeTaskResponse();
         PatientTaskData           ptd = (PatientTaskData)GoalsEndpointUtil.GetInitialTaskRequest(request);
         PatientTask task = GoalsUtil.GetPatientTaskForInitialize(request, ptd);
         itr.Task    = task;
         itr.Version = request.Version;
         return(itr);
     }
     catch (Exception ex)
     {
         throw new Exception("AD:GetInitialTask()::" + ex.Message, ex.InnerException);
     }
 }
Esempio n. 19
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);
            }
        }
Esempio n. 20
0
        public static PatientGoal GetPatientGoal(GetPatientGoalRequest request)
        {
            try
            {
                PatientGoal result = null;
                //[Route("/{Context}/{Version}/{ContractNumber}/Patient/{PatientId}/Goal/{Id}", "GET")]
                IRestClient client = new JsonServiceClient();

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

                GetPatientGoalDataResponse ddResponse = client.Get <GetPatientGoalDataResponse>(
                    url);

                if (ddResponse != null && ddResponse.GoalData != null)
                {
                    //Make a call to AttributeLibrary to get attributes details for Goal and Task.
                    List <CustomAttribute> goalAttributesLibrary = GoalsEndpointUtil.GetAttributesLibraryByType(request, 1);
                    List <CustomAttribute> taskAttributesLibrary = GoalsEndpointUtil.GetAttributesLibraryByType(request, 2);

                    result               = GoalsUtil.ConvertToGoal(ddResponse.GoalData, goalAttributesLibrary);
                    result.Barriers      = GoalsUtil.ConvertToBarriers(ddResponse.GoalData.BarriersData);
                    result.Tasks         = GoalsUtil.ConvertToTasks(ddResponse.GoalData.TasksData, taskAttributesLibrary);
                    result.Interventions = GoalsUtil.ConvertToInterventions(request, client, ddResponse.GoalData.InterventionsData);
                }
                return(result);
            }
            catch (WebServiceException ex)
            {
                throw new WebServiceException("AD:GetPatientGoal()::" + ex.Message, ex.InnerException);
            }
        }