public void Execute() { try { // [Route("/{Context}/{Version}/{ContractNumber}/Program/{Id}/Delete", "DELETE")] string ppUrl = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/Program/{4}/Delete", DDProgramServiceUrl, "NG", request.Version, request.ContractNumber, request.Id), request.UserId); DeletePatientProgramDataResponse ppDDResponse = client.Delete <DeletePatientProgramDataResponse>(ppUrl); if (ppDDResponse != null) { DeletedPatientProgram pp = ppDDResponse.DeletedPatientProgram; deletedPatientPrograms = new List <DeletedPatientProgram>() { pp }; if (!ppDDResponse.Success) { Undo(); throw new Exception("Error occurred during AppDomain: PatientProgramCommand Execute method"); } } } catch (Exception ex) { throw new Exception("AD: PatientProgramCommand Execute::" + ex.Message, ex.InnerException); } }
public void UndoDeletePatientProgram_Test() { double version = 1.0; string contractNumber = "InHealth001"; string context = "NG"; string userId = "000000000000000000000000"; string ddUrl = "http://localhost:8888/Program"; IRestClient client = new JsonServiceClient(); // [Route("/{Context}/{Version}/{ContractNumber}/Program/UndoDelete", "PUT")] string url = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/Program/UndoDelete", ddUrl, context, version, contractNumber), userId); List <DeletedPatientProgram> ids = new List <DeletedPatientProgram>(); DeletedPatientProgram item1 = new DeletedPatientProgram(); item1.Id = "53baa8ccd6a48515f8d74bc2"; item1.PatientProgramAttributeId = "53baa8cdd6a48515f8d75280"; item1.PatientProgramResponsesIds = new List <string> { "53baa8ccd6a48515f8d751eb", "53baa8ccd6a48515f8d751ec", "53baa8ccd6a48515f8d74dcc", "53baa8ccd6a48515f8d74dcd", "53baa8ccd6a48515f8d74dce" }; ids.Add(item1); UndoDeletePatientProgramDataResponse response = client.Put <UndoDeletePatientProgramDataResponse>(url, new UndoDeletePatientProgramDataRequest { Context = context, ContractNumber = contractNumber, Ids = ids, UserId = userId, Version = version }); Assert.IsNotNull(response); }
public DeletePatientProgramDataResponse DeletePatientProgram(DeletePatientProgramDataRequest request) { DeletePatientProgramDataResponse response = null; bool success = false; try { response = new DeletePatientProgramDataResponse(); IProgramRepository ppRepo = Factory.GetRepository(request, RepositoryType.PatientProgram); MEPatientProgram mePP = ppRepo.FindByID(request.Id) as MEPatientProgram; DeletedPatientProgram deletedPatientProgram = null; if (mePP != null) { if (delete(mePP, request, ppRepo, out deletedPatientProgram)) { success = true; } } else { success = true; } response.DeletedPatientProgram = deletedPatientProgram; response.Success = success; return(response); } catch (Exception ex) { throw ex; } }
public DeletePatientProgramByPatientIdDataResponse DeletePatientProgramByPatientId(DeletePatientProgramByPatientIdDataRequest request) { DeletePatientProgramByPatientIdDataResponse response = null; bool success = false; try { response = new DeletePatientProgramByPatientIdDataResponse(); IProgramRepository ppRepo = Factory.GetRepository(request, RepositoryType.PatientProgram); List <MEPatientProgram> meppList = ppRepo.FindByPatientId(request.PatientId) as List <MEPatientProgram>; List <DeletedPatientProgram> deletedPatientPrograms = null; if (meppList != null && meppList.Count > 0) { deletedPatientPrograms = new List <DeletedPatientProgram>(); meppList.ForEach(mePP => { DeletePatientProgramDataRequest req = new DeletePatientProgramDataRequest { Context = request.Context, ContractNumber = request.ContractNumber, UserId = request.UserId, Version = request.Version }; DeletedPatientProgram deletedPatientProgram = null; if (delete(mePP, req, ppRepo, out deletedPatientProgram)) { deletedPatientPrograms.Add(deletedPatientProgram); success = true; } }); response.DeletedPatientPrograms = deletedPatientPrograms; } else { success = true; } response.Success = success; return(response); } catch (Exception ex) { throw ex; } }
private bool delete(MEPatientProgram mePP, DeletePatientProgramDataRequest request, IProgramRepository ppRepo, out DeletedPatientProgram deletedProgram) { DeletedPatientProgram deletedPatientProgram = null; List <string> deletedResponsesIds = null; bool success = false; try { if (mePP != null) { IProgramRepository ppAttributesRepo = Factory.GetRepository(request, RepositoryType.PatientProgramAttribute); IProgramRepository ppResponsesRepo = Factory.GetRepository(request, RepositoryType.PatientProgramResponse); #region PatientProgram request.Id = mePP.Id.ToString(); ppRepo.Delete(request); deletedPatientProgram = new DeletedPatientProgram { Id = request.Id }; success = true; deletedResponsesIds = new List <string>(); #endregion #region PPAttributes MEProgramAttribute pa = ppAttributesRepo.FindByPlanElementID(request.Id) as MEProgramAttribute; if (pa != null) { DeletePatientProgramAttributesDataRequest deletePPAttrDataRequest = new DeletePatientProgramAttributesDataRequest { Context = request.Context, ContractNumber = request.ContractNumber, Id = pa.Id.ToString(), UserId = request.UserId, Version = request.Version }; ppAttributesRepo.Delete(deletePPAttrDataRequest); deletedPatientProgram.PatientProgramAttributeId = deletePPAttrDataRequest.Id; success = true; } #endregion #region PPResponses List <Module> modules = mePP.Modules; if (modules != null && modules.Count > 0) { modules.ForEach(m => { List <MongoDB.DTO.Action> actions = m.Actions; if (actions != null && actions.Count > 0) { actions.ForEach(a => { List <Step> steps = a.Steps; if (steps != null && steps.Count > 0) { steps.ForEach(s => { List <MEPatientProgramResponse> meResponses = ppResponsesRepo.FindByStepId(s.Id.ToString()) as List <MEPatientProgramResponse>; if (meResponses != null && meResponses.Count > 0) { meResponses.ForEach(r => { DeletePatientProgramResponsesDataRequest deletePPResponsesRequest = new DeletePatientProgramResponsesDataRequest { Context = request.Context, ContractNumber = request.ContractNumber, Id = r.Id.ToString(), UserId = request.UserId, Version = request.Version }; ppResponsesRepo.Delete(deletePPResponsesRequest); deletedResponsesIds.Add(deletePPResponsesRequest.Id); success = true; deletedPatientProgram.PatientProgramResponsesIds = deletedResponsesIds; }); } }); } }); } }); } #endregion } } catch (Exception ex) { success = false; string aseProcessID = ConfigurationManager.AppSettings.Get("ASEProcessID") ?? "0"; Common.Helper.LogException(int.Parse(aseProcessID), ex); } deletedProgram = deletedPatientProgram; return(success); }