Example #1
0
        public void UndoDeletePatientGoal_Test()
        {
            double      version        = 1.0;
            string      contractNumber = "InHealth001";
            string      context        = "NG";
            string      userId         = "000000000000000000000000";
            string      ddUrl          = "http://localhost:8888/PatientGoal";
            IRestClient client         = new JsonServiceClient();

            //[Route("/{Context}/{Version}/{ContractNumber}/PatientGoal/UndoDelete", "PUT")]
            string url = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/PatientGoal/UndoDelete",
                                                              ddUrl,
                                                              context,
                                                              version,
                                                              contractNumber), userId);
            List <DeletedPatientGoal> ids   = new List <DeletedPatientGoal>();
            DeletedPatientGoal        item1 = new DeletedPatientGoal();

            item1.Id = "53c6f7ddd6a48506ecc5b7c1";
            item1.PatientBarrierIds = new List <string> {
                "53c6f810d6a48506ecc5b8ff", "53c6f805d6a48506ecc5b8a3"
            };
            item1.PatientTaskIds = new List <string> {
                "53c6f7edd6a48506ecc5b7ff", "53c6f7f7d6a48506ecc5b847"
            };
            ids.Add(item1);

            DeletedPatientGoal item2 = new DeletedPatientGoal();

            item2.Id = "53c45133d6a48506ecc4d856";
            item2.PatientBarrierIds = new List <string> {
                "53c4517dd6a48506ecc4da86", "53c45183d6a48506ecc4dae2"
            };
            item2.PatientInterventionIds = new List <string> {
                "53c4518ad6a48506ecc4db52", "53c4518fd6a48506ecc4dbcc"
            };
            item2.PatientTaskIds = new List <string> {
                "53c45162d6a48506ecc4d922", "53c45174d6a48506ecc4da2a"
            };
            ids.Add(item2);
            UndoDeletePatientGoalDataResponse response = client.Put <UndoDeletePatientGoalDataResponse>(url, new UndoDeletePatientGoalDataRequest
            {
                Ids            = ids,
                Context        = context,
                ContractNumber = contractNumber,
                UserId         = userId,
                Version        = version
            });

            Assert.IsNotNull(response);
        }
Example #2
0
        public UndoDeletePatientGoalDataResponse Put(UndoDeletePatientGoalDataRequest request)
        {
            UndoDeletePatientGoalDataResponse response = new UndoDeletePatientGoalDataResponse();

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

                response         = Manager.UndoDeletePatientGoals(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);
        }
Example #3
0
 public void Undo()
 {
     try
     {
         //[Route("/{Context}/{Version}/{ContractNumber}/PatientGoal/UndoDelete", "PUT")]
         string url = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/PatientGoal/UndoDelete",
                                                           DDPatientGoalsServiceUrl,
                                                           "NG",
                                                           request.Version,
                                                           request.ContractNumber), request.UserId);
         UndoDeletePatientGoalDataResponse response = client.Put <UndoDeletePatientGoalDataResponse>(url, new UndoDeletePatientGoalDataRequest
         {
             Ids            = deletedPatientGoals,
             Context        = "NG",
             ContractNumber = request.ContractNumber,
             UserId         = request.UserId,
             Version        = request.Version
         } as object);
     }
     catch (Exception ex)
     {
         throw new Exception("AD: PatientGoalCommand Undo::" + ex.Message, ex.InnerException);
     }
 }
Example #4
0
        public UndoDeletePatientGoalDataResponse UndoDeletePatientGoals(UndoDeletePatientGoalDataRequest request)
        {
            UndoDeletePatientGoalDataResponse response = null;

            try
            {
                response = new UndoDeletePatientGoalDataResponse();
                IGoalRepository repo = Factory.GetRepository(request, RepositoryType.PatientGoal);
                if (request.Ids != null && request.Ids.Count > 0)
                {
                    request.Ids.ForEach(u =>
                    {
                        request.PatientGoalId = u.Id;
                        repo.UndoDelete(request);

                        #region Delete Barriers
                        if (u.PatientBarrierIds != null && u.PatientBarrierIds.Count > 0)
                        {
                            IGoalRepository barrierRepo = Factory.GetRepository(request, RepositoryType.PatientBarrier);
                            u.PatientBarrierIds.ForEach(b =>
                            {
                                UndoDeleteBarrierDataRequest barrierRequest = new UndoDeleteBarrierDataRequest
                                {
                                    BarrierId      = b,
                                    Context        = request.Context,
                                    ContractNumber = request.ContractNumber,
                                    UserId         = request.UserId,
                                    Version        = request.Version
                                };
                                barrierRepo.UndoDelete(barrierRequest);
                            });
                        }

                        #endregion

                        #region Delete Tasks
                        if (u.PatientTaskIds != null && u.PatientTaskIds.Count > 0)
                        {
                            IGoalRepository taskRepo = Factory.GetRepository(request, RepositoryType.PatientTask);
                            u.PatientTaskIds.ForEach(t =>
                            {
                                UndoDeleteTaskDataRequest taskRequest = new UndoDeleteTaskDataRequest
                                {
                                    TaskId         = t,
                                    Context        = request.Context,
                                    ContractNumber = request.ContractNumber,
                                    UserId         = request.UserId,
                                    Version        = request.Version
                                };
                                taskRepo.UndoDelete(taskRequest);
                            });
                        }
                        #endregion

                        #region Delete Interventions
                        if (u.PatientInterventionIds != null && u.PatientInterventionIds.Count > 0)
                        {
                            IGoalRepository interventionRepo = Factory.GetRepository(request, RepositoryType.PatientIntervention);
                            u.PatientInterventionIds.ForEach(i =>
                            {
                                UndoDeleteInterventionDataRequest interventionRequest = new UndoDeleteInterventionDataRequest
                                {
                                    InterventionId = i,
                                    Context        = request.Context,
                                    ContractNumber = request.ContractNumber,
                                    UserId         = request.UserId,
                                    Version        = request.Version
                                };
                                interventionRepo.UndoDelete(interventionRequest);
                            });
                        }
                        #endregion
                    });
                }
                response.Success = true;
                return(response);
            }
            catch (Exception ex) { throw ex; }
        }