Esempio n. 1
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. 2
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);
            }
        }
Esempio n. 3
0
        public PutUpdateTaskResponse UpdatePatientTask(PutUpdateTaskRequest request)
        {
            try
            {
                PutUpdateTaskResponse result = new PutUpdateTaskResponse();

                IGoalRepository repo = Factory.GetRepository(request, RepositoryType.PatientTask);

                if (request.TaskIdsList != null && request.TaskIdsList.Count > 0)
                {
                    List <PatientTaskData> ptd          = (List <PatientTaskData>)repo.Find(request.PatientGoalId);
                    List <string>          dbTaskIdList = GetTaskIds(ptd);

                    // update existing task entries with a delete
                    List <string> excludes = dbTaskIdList.Except(request.TaskIdsList).ToList <string>();
                    excludes.ForEach(ex =>
                    {
                        // create delete task request to insert
                        DeleteTaskDataRequest dtr = new DeleteTaskDataRequest {
                            TaskId = ex, UserId = request.UserId
                        };
                        repo.Delete(dtr);
                    });
                }
                if (request.Task != null && request.Task.Id != "0")
                {
                    bool status = (bool)repo.Update(request);
                    if (status)
                    {
                        PatientTaskData data = repo.FindByID(request.Task.Id) as PatientTaskData;
                        result.TaskData = data;
                    }
                }
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 4
0
        public PutUpdateTaskResponse Put(PutUpdateTaskRequest request)
        {
            PutUpdateTaskResponse response = new PutUpdateTaskResponse();

            try
            {
                if (string.IsNullOrEmpty(request.UserId))
                {
                    throw new UnauthorizedAccessException("PatientGoalDD:Put()::Unauthorized Access");
                }

                response         = Manager.UpdatePatientTask(request);
                response.Version = request.Version;
            }
            catch (Exception ex)
            {
                CommonFormatter.FormatExceptionResponse(response, base.Response, ex);

                string aseProcessID = ConfigurationManager.AppSettings.Get("ASEProcessID") ?? "0";
                Common.Helper.LogException(int.Parse(aseProcessID), ex);
            }
            return(response);
        }
        public void Update_Patient_Task()
        {
            string      url            = "http://localhost:8888/PatientGoal";
            string      patientId      = "52a0da34fe7a5915485bdfd6";
            string      contractNumber = "InHealth001";
            string      context        = "NG";
            string      version        = "v1";
            string      id             = "52fd4832fe7a5912b0050354";
            string      patientGoaldId = "52fd1aa2fe7a592d04b9d567";
            IRestClient client         = new JsonServiceClient();

            PutUpdateTaskResponse response = client.Put <PutUpdateTaskResponse>(
                string.Format("{0}/{1}/{2}/{3}/Patient/{4}/Goal/{5}/Task/{6}/Update",
                              url,
                              context,
                              version,
                              contractNumber,
                              patientId,
                              patientGoaldId,
                              id),
                new PutUpdateTaskRequest
            {
                Task = new PatientTaskData
                {
                    Id               = id,
                    PatientGoalId    = patientGoaldId,
                    Description      = "Roumel Testing This!!",
                    StartDate        = System.DateTime.UtcNow,
                    StatusId         = 2,
                    StatusDate       = System.DateTime.UtcNow,
                    TargetDate       = System.DateTime.UtcNow.AddDays(7),
                    TargetValue      = "!!This is a task update test",
                    CustomAttributes = GetAttributes(),
                    BarrierIds       = GetBarriers()
                }
            } as object);
        }