public DeleteContactByPatientIdDataResponse DeleteContactByPatientId(DeleteContactByPatientIdDataRequest request) { DeleteContactByPatientIdDataResponse response = null; bool success = false; try { response = new DeleteContactByPatientIdDataResponse(); IContactRepository repo = Factory.GetRepository(request, RepositoryType.Contact); ContactData contact = repo.GetContactByPatientId(request.PatientId) as ContactData; List <ContactWithUpdatedRecentList> contactsWithUpdatedRecentList = null; if (contact != null) { request.Id = contact.Id; repo.Delete(request); response.DeletedId = request.Id; success = true; // Remove this deleted contact(PatientId) from RecentList of other contacts(users logged in). List <ContactData> contactsWithAPatientInRecentList = repo.FindContactsWithAPatientInRecentList(request.PatientId) as List <ContactData>; if (contactsWithAPatientInRecentList != null && contactsWithAPatientInRecentList.Count > 0) { contactsWithUpdatedRecentList = new List <ContactWithUpdatedRecentList>(); contactsWithAPatientInRecentList.ForEach(c => { PutRecentPatientRequest recentPatientRequest = new PutRecentPatientRequest { ContactId = c.Id, Context = request.Context, ContractNumber = request.ContractNumber, UserId = request.UserId, Version = request.Version }; int index = c.RecentsList.IndexOf(request.PatientId); if (c.RecentsList.Remove(request.PatientId)) { if (repo.UpdateRecentList(recentPatientRequest, c.RecentsList)) { contactsWithUpdatedRecentList.Add(new ContactWithUpdatedRecentList { ContactId = recentPatientRequest.ContactId, PatientIndex = index }); success = true; } } }); } } response.ContactWithUpdatedRecentLists = contactsWithUpdatedRecentList; response.Success = success; return(response); } catch (Exception ex) { throw ex; } }
public void DeletePatient() { ContactDataManager cm = new ContactDataManager { Factory = new ContactRepositoryFactory() }; DeleteContactByPatientIdDataRequest request = new DeleteContactByPatientIdDataRequest { PatientId = "5325db70d6a4850adcbba946", UserId = "5325c81f072ef705080d347e", Context = "NG", ContractNumber = "InHealth001", Version = 1.0 }; DeleteContactByPatientIdDataResponse response = cm.DeleteContactByPatientId(request); Assert.IsNotNull(response); }
public void DeleteContactByPatientId_Test() { double version = 1.0; string contractNumber = "InHealth001"; string context = "NG"; string patientId = "5325da9ed6a4850adcbba6ce"; string userId = "000000000000000000000000"; string ddUrl = "http://localhost:8888/Contact"; IRestClient client = new JsonServiceClient(); // [Route("/{Context}/{Version}/{ContractNumber}/Contact/Patient/{PatientId}/Delete", "DELETE")] string url = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/Contact/Patient/{4}/Delete", ddUrl, context, version, contractNumber, patientId), userId); DeleteContactByPatientIdDataResponse response = client.Delete <DeleteContactByPatientIdDataResponse>(url); Assert.IsNotNull(response); }
public DeleteContactByPatientIdDataResponse Delete(DeleteContactByPatientIdDataRequest request) { DeleteContactByPatientIdDataResponse response = new DeleteContactByPatientIdDataResponse(); try { if (string.IsNullOrEmpty(request.UserId)) { throw new UnauthorizedAccessException("ContactDD:ContactDelete()::Unauthorized Access"); } response = Manager.DeleteContactByPatientId(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 Execute() { try { //[Route("/{Context}/{Version}/{ContractNumber}/Contact/Patient/{PatientId}/Delete", "DELETE")] string cUrl = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/Contact/Patient/{4}/Delete", DDContactServiceUrl, "NG", request.Version, request.ContractNumber, request.Id), request.UserId); DeleteContactByPatientIdDataResponse cDDResponse = client.Delete <DeleteContactByPatientIdDataResponse>(cUrl); if (cDDResponse != null && cDDResponse.Success) { deletedId = cDDResponse.DeletedId; contactWithUpdatedRecentLists = cDDResponse.ContactWithUpdatedRecentLists; } } catch (Exception ex) { throw new Exception("AD: ContactCommand Execute::" + ex.Message, ex.InnerException); } }