Beispiel #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);
        }
Beispiel #2
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; }
        }