public HttpResponseMessage UpdatePatient(string token, UpdatePatienModel model) { try { var current = UserHelper.GetPatient(token); if (current == null) { return(Request.CreateResponse(HttpStatusCode.Unauthorized, new { Error = "Unauthorized" })); } new PlatformService().UpdatePatient(model); var patient = new PlatformService().GetPatient(current.PatientId); UserHelper.SetPatient(token, patient); return(Request.CreateResponse(HttpStatusCode.OK, new { Patient = patient })); } catch (Exception e) { return(Request.CreateResponse(HttpStatusCode.OK, new { Error = e.GetBaseException().Message })); } }
public void UpdatePatient(UpdatePatienModel model) { //Build the body of the request var savePPRequestBody = new SavePathwayPatientInformationRequestBody { PatientId = model.PatientId, //patient id created while saving new patient FirstName = model.FirstName, LastName = model.LastName, EmailAddress = model.EmailAddress, DateOfBirth = model.Dob, AddressLine = model.AddressLine, City = model.City, StateId = model.StateId, //Shared with other client data Gender = Gender.Male, PatientPathways = new List <PatientPathwayShortDto>(), //leave empty unless pathway details need to be updated MedicalRecordNumber = model.MedicalRecordNumber, Optins = new List <CommunicationOptinDto>() { new CommunicationOptinDto { CommunicationType = CommunicationType.Email, Optin = true }, new CommunicationOptinDto { CommunicationType = CommunicationType.Phone, Optin = true }, new CommunicationOptinDto { CommunicationType = CommunicationType.Sms, Optin = true } }, CellPhone = model.CellPhone, //updating with new information HomePhone = model.HomePhone, //updating with new information IdentityUserId = ConfigurationSettings.AppSettings["IdentityUserId"], CreatedDate = DateTime.UtcNow.ToString(), CommandId = System.Guid.NewGuid() }; //Build the request var apiRequest = new APIRequest { Source = string.Empty, TrackingId = Guid.NewGuid().ToString(), Type = "SavePathwayPatientInformation", Body = JsonConvert.SerializeObject(savePPRequestBody) }; //Generate the HttpContent var content = new StringContent(JsonConvert.SerializeObject(apiRequest), System.Text.Encoding.UTF8, "application/json"); // post the json content to the service. var response = httpClient.PostAsync(RequestURL, content); response.Wait(); if (response.Result.IsSuccessStatusCode) { var getPatientResult = JsonConvert.DeserializeObject <ApiResponse>(response.Result.Content.ReadAsStringAsync().Result); if (getPatientResult.Success) { return; } throw new Exception($"Failed Updating Existing Patient {getPatientResult.Body}"); } throw new Exception($"Error Response Code from service - {response.Result.ReasonPhrase}"); }