Example #1
0
        public DeleteBarrierDataResponse DeleteBarrier(DeleteBarrierDataRequest request)
        {
            try
            {
                DeleteBarrierDataResponse result = new DeleteBarrierDataResponse();

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

                List <PatientBarrierData> pbd        = (List <PatientBarrierData>)repo.Find(request.PatientGoalId);
                List <string>             deletedIds = null;
                if (pbd != null && pbd.Count > 0)
                {
                    deletedIds = new List <string>();
                    pbd.ForEach(b =>
                    {
                        request.BarrierId = b.Id;
                        repo.Delete(request);
                        deletedIds.Add(request.BarrierId);
                    });
                }
                result.DeletedIds = deletedIds;
                result.Success    = true;
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #2
0
        public DeleteInterventionDataResponse DeleteIntervention(DeleteInterventionDataRequest request)
        {
            try
            {
                DeleteInterventionDataResponse result = new DeleteInterventionDataResponse();

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

                List <PatientInterventionData> pid = (List <PatientInterventionData>)repo.Find(request.PatientGoalId);
                List <string> deletedIds           = null;
                if (pid != null && pid.Count > 0)
                {
                    deletedIds = new List <string>();
                    pid.ForEach(i =>
                    {
                        request.InterventionId = i.Id;
                        repo.Delete(request);
                        deletedIds.Add(request.InterventionId);
                    });
                }
                result.DeletedIds = deletedIds;
                result.Success    = true;
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #3
0
        public GetPatientTasksDataResponse GetTasks(GetPatientTasksDataRequest request)
        {
            try
            {
                var result = new GetPatientTasksDataResponse();

                IGoalRepository taskRepo = Factory.GetRepository(request, RepositoryType.PatientTask);
                taskRepo.UserId = request.UserId;
                IGoalRepository goalRepo = Factory.GetRepository(request, RepositoryType.PatientGoal);
                // Get all the goals associated to the patient in the request object.
                if (!string.IsNullOrEmpty(request.PatientId))
                {
                    List <PatientGoalViewData> goalViewDataList = goalRepo.Find(request.PatientId) as List <PatientGoalViewData>;
                    List <string> patientGoalIds = goalViewDataList.Select(a => a.Id).ToList();
                    if (patientGoalIds != null && patientGoalIds.Count > 0)
                    {
                        result.TasksData = (List <PatientTaskData>)taskRepo.Search(request, patientGoalIds);
                    }
                }
                else
                {
                    result.TasksData = (List <PatientTaskData>)taskRepo.Search(request, null);
                }

                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #4
0
        private List <PatientInterventionData> getInterventionsByPatientGoalId(IDataDomainRequest request, string patientGoalId)
        {
            IGoalRepository repo = Factory.GetRepository(request, RepositoryType.PatientIntervention);

            List <PatientInterventionData> interventionDataList = repo.Find(patientGoalId) as List <PatientInterventionData>;

            return(interventionDataList);
        }
Example #5
0
        private List <PatientTaskData> getTasksByPatientGoalId(IDataDomainRequest request, string patientGoalId)
        {
            IGoalRepository repo = Factory.GetRepository(request, RepositoryType.PatientTask);

            List <PatientTaskData> taskDataList = repo.Find(patientGoalId) as List <PatientTaskData>;

            return(taskDataList);
        }
Example #6
0
        private List <PatientBarrierData> getBarriersByPatientGoalId(IDataDomainRequest request, string patientGoalId)
        {
            IGoalRepository repo = Factory.GetRepository(request, RepositoryType.PatientBarrier);

            List <PatientBarrierData> barrierDataList = repo.Find(patientGoalId) as List <PatientBarrierData>;

            return(barrierDataList);
        }
Example #7
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;
            }
        }
Example #8
0
        public DeletePatientGoalByPatientIdDataResponse DeletePatientGoalByPatientId(DeletePatientGoalByPatientIdDataRequest request)
        {
            DeletePatientGoalByPatientIdDataResponse response = null;
            bool success = false;

            try
            {
                response = new DeletePatientGoalByPatientIdDataResponse();
                IGoalRepository goalRepo = Factory.GetRepository(request, RepositoryType.PatientGoal);

                List <PatientGoalViewData> goalViewDataList    = goalRepo.Find(request.PatientId) as List <PatientGoalViewData>;
                List <DeletedPatientGoal>  deletedPatientGoals = null;
                if (goalViewDataList != null && goalViewDataList.Count > 0)
                {
                    deletedPatientGoals = new List <DeletedPatientGoal>();
                    goalViewDataList.ForEach(u =>
                    {
                        DeletePatientGoalDataRequest deletePatientGoalDataRequest = new DeletePatientGoalDataRequest
                        {
                            Context        = request.Context,
                            ContractNumber = request.ContractNumber,
                            PatientGoalId  = u.Id,
                            PatientId      = request.PatientId,
                            UserId         = request.UserId,
                            Version        = request.Version
                        };
                        goalRepo.Delete(deletePatientGoalDataRequest);
                        success = true;
                        DeletedPatientGoal deletedPatientGoal = new DeletedPatientGoal {
                            Id = deletePatientGoalDataRequest.PatientGoalId
                        };

                        #region Delete Barriers
                        DeleteBarrierDataResponse deleteBarrierDataResponse = DeleteBarrier(new DeleteBarrierDataRequest
                        {
                            Context        = request.Context,
                            ContractNumber = request.ContractNumber,
                            PatientGoalId  = deletePatientGoalDataRequest.PatientGoalId,
                            PatientId      = request.PatientId,
                            UserId         = request.UserId,
                            Version        = request.Version
                        });
                        if (deleteBarrierDataResponse.Success)
                        {
                            deletedPatientGoal.PatientBarrierIds = deleteBarrierDataResponse.DeletedIds;
                            success = true;
                        }

                        #endregion

                        #region Delete Tasks
                        DeleteTaskDataResponse deleteTaskDataResponse = DeleteTask(new DeleteTaskDataRequest
                        {
                            Context        = request.Context,
                            ContractNumber = request.ContractNumber,
                            PatientGoalId  = deletePatientGoalDataRequest.PatientGoalId,
                            PatientId      = request.PatientId,
                            UserId         = request.UserId,
                            Version        = request.Version
                        });
                        if (deleteTaskDataResponse.Success)
                        {
                            deletedPatientGoal.PatientTaskIds = deleteTaskDataResponse.DeletedIds;
                            success = true;
                        }
                        #endregion

                        #region Delete Interventions
                        DeleteInterventionDataResponse deleteInterventionDataResponse = DeleteIntervention(new DeleteInterventionDataRequest
                        {
                            Context        = request.Context,
                            ContractNumber = request.ContractNumber,
                            PatientGoalId  = deletePatientGoalDataRequest.PatientGoalId,
                            PatientId      = request.PatientId,
                            UserId         = request.UserId,
                            Version        = request.Version
                        });
                        if (deleteInterventionDataResponse.Success)
                        {
                            deletedPatientGoal.PatientInterventionIds = deleteInterventionDataResponse.DeletedIds;
                            success = true;
                        }
                        #endregion

                        deletedPatientGoals.Add(deletedPatientGoal);
                    });
                    response.DeletedPatientGoals = deletedPatientGoals;
                }
                else
                {
                    success = true;
                }
                response.Success = success;
                return(response);
            }
            catch (Exception ex) { throw ex; }
        }
Example #9
0
        public GetAllPatientGoalsDataResponse GetPatientGoalList(GetAllPatientGoalsDataRequest request)
        {
            GetAllPatientGoalsDataResponse result = null;

            try
            {
                result = new GetAllPatientGoalsDataResponse();
                IGoalRepository goalRepo = Factory.GetRepository(request, RepositoryType.PatientGoal);

                List <PatientGoalViewData> goalViewDataList = goalRepo.Find(request.PatientId) as List <PatientGoalViewData>;
                List <PatientGoalViewData> goalDataView     = null;
                if (goalViewDataList != null && goalViewDataList.Count > 0)
                {
                    goalDataView = new List <PatientGoalViewData>();
                    foreach (PatientGoalViewData p in goalViewDataList)
                    {
                        string contractNumber = request.ContractNumber;
                        string context        = request.Context;

                        PatientGoalViewData view = new PatientGoalViewData();
                        view = p;

                        //Barriers
                        List <ChildViewData>      barrierChildView = null;
                        List <PatientBarrierData> barrierData      = getBarriersByPatientGoalId(request, p.Id);
                        if (barrierData != null && barrierData.Count > 0)
                        {
                            barrierChildView = new List <ChildViewData>();
                            foreach (PatientBarrierData b in barrierData)
                            {
                                barrierChildView.Add(new ChildViewData {
                                    Id = b.Id, PatientGoalId = b.PatientGoalId, Name = b.Name, StatusId = ((int)(b.StatusId))
                                });
                                barrierChildView = barrierChildView.OrderBy(o => o.Name).ToList();
                            }
                        }
                        view.BarriersData = barrierChildView;

                        //Tasks
                        List <ChildViewData>   taskChildView = null;
                        List <PatientTaskData> taskData      = getTasksByPatientGoalId(request, p.Id);
                        if (taskData != null && taskData.Count > 0)
                        {
                            taskChildView = new List <ChildViewData>();
                            foreach (PatientTaskData b in taskData)
                            {
                                taskChildView.Add(new ChildViewData {
                                    Id = b.Id, PatientGoalId = b.PatientGoalId, Description = b.Description, StatusId = ((int)(b.StatusId))
                                });
                                taskChildView = taskChildView.OrderBy(o => o.Description).ToList();
                            }
                        }
                        view.TasksData = taskChildView;

                        //Interventions
                        List <ChildViewData>           interChildView = null;
                        List <PatientInterventionData> interData      = getInterventionsByPatientGoalId(request, p.Id);
                        if (interData != null && interData.Count > 0)
                        {
                            interChildView = new List <ChildViewData>();
                            foreach (PatientInterventionData b in interData)
                            {
                                interChildView.Add(new ChildViewData {
                                    Id = b.Id, PatientGoalId = b.PatientGoalId, Description = b.Description, StatusId = ((int)(b.StatusId))
                                });
                                interChildView.OrderBy(o => o.Description).ToList();
                            }
                        }
                        view.InterventionsData = interChildView;
                        goalDataView.Add(view);
                    }
                }

                result.PatientGoalsData = goalDataView;
                result.Version          = request.Version;
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }