public void createPatientAndTieToMP(PatientCreationRequest patientRequest) { var response = new HttpResponseMessage(); try { using (var context = new HackathonEntities()) { var exists = userRespository.checkIfUserExists(patientRequest.email); if (exists != null && exists.email.Length > 0) { response = Request.CreateErrorResponse(HttpStatusCode.BadRequest, "An account with this email already exists."); throw new HttpResponseException(response); } else { medicalProfessionalRepository.CreateNewPatientAndMPRecord(patientRequest); } } } catch (Exception e) { throw new HttpResponseException(response); } }
public void createNewUserPatient(PatientCreationRequest request) { userRepository.createNewUser(request); var user = userRepository.getUserInfo(request.email); createNewPatient(request, user.id); }
public void createNewPatient(PatientCreationRequest request, int userId) { using (var context = new HackathonEntities()) { var patient = new Patient() { DOB = request.DOB, Gender = request.Gender, AtRisk = request.AtRisk, SocialSecurity = request.SocialSecurity, UserId = userId }; context.Patients.Add(patient); context.SaveChanges(); context.Dispose(); } }
public void CreateNewPatientAndMPRecord(PatientCreationRequest patientRequest) { using (var context = new HackathonEntities()) { userRepository.createNewUser(patientRequest); var user = userRepository.getUserInfo(patientRequest.email); patientRepository.createNewPatient(patientRequest, user.id); var patient = patientRepository.getPatientInfo(user.id); var mpToPatient = new MpToPatient() { MPId = patientRequest.MPId, PatientId = patient.PatientId }; context.MpToPatients.Add(mpToPatient); context.SaveChanges(); context.Dispose(); } }
public IHttpActionResult createPatient(PatientCreationRequest request) { var response = new HttpResponseMessage(); try { using (var context = new HackathonEntities()) { var exists = userRepository.checkIfUserExists(request.email); if (exists != null && exists.email.Length > 0) { response = Request.CreateErrorResponse(HttpStatusCode.BadRequest, "An account with this email already exists."); throw new HttpResponseException(response); } patientRepository.createNewUserPatient(request); } return(Ok("success")); } catch (Exception e) { throw new HttpResponseException(response); } }