public ActionResult CreatePatient(PatientDetails model) { if (ModelState.IsValid) { // Attempt to register the user try { PatientClient c = new PatientClient(); var result = c.CreatePatient(model.ExternalId, model.Email, model.Email, model.Title, model.FirstName, model.LastName, model.DateOfBirth.Value, model.PhoneNumber); if (result.Succeeded) { return(RedirectToAction("Patient", new { patientId = result.Data })); } else { ModelState.AddModelError("", result.ErrorMessages); } } catch (Exception) { ModelState.AddModelError("", "An error has occurred trying to create your account. Please try again"); } } // If we got this far, something failed, redisplay form return(View(model)); }
public Message CreatePatientAppointment(PatientAppointment patient) { if (MessageStore.WasMessageReceived(patient.messageReference)) { return new Message() { success = true, messageReference = DateTime.Now.ToString() } } ; // TODO Check if message was already received PatientClient uc = new PatientClient(); var result = uc.CreatePatient(patient.Id, patient.Email, patient.Email, patient.Title, patient.FirstName, patient.LastName, patient.DateOfBirth, patient.Mobile); if (result.Succeeded) { PatientEpisodeClient uec = new PatientEpisodeClient(); var result2 = uec.AssignEpisode(result.Data, patient.BasicCondition, patient.AppointmentDate, null, patient.PractitionerId); if (result2.Succeeded) { MessageStore.MessageReceived(patient.messageReference, patient.Xml, DateTime.Now); return(new Message() { success = true }); } return(new Message() { success = false, ErrorMessage = result2.ErrorMessages }); } return(new Message() { success = false, ErrorMessage = result.ErrorMessages }); } }