/// <summary> This method converts <paramref name="patientDto"/> to <c>PatientUser</c> using <c>PatientAdapter</c> and sends it to <c>PatientsRepository</c>. </summary> /// <returns>Returns successfully created patient; otherwise, return <c>null</c></returns> public PatientUser Create(PatientDto patientDto) { PatientUser patient = PatientsRepository.Add(PatientAdapter.PatientDtoToPatient(patientDto)); EmailVerificationService.SendVerificationMail(new MailAddress(patient.email), patient.id); return(patient); }
/// <summary> /// Initializes the service environment. /// </summary> public static void Initialize() { PatientAdapter = new PatientAdapter(); PatientAdapter.FetchInitialPatients(); PubMedAdapter = new PubMedAdapter(); TemplateAdapter = new TemplateAdapter(); }
public List <PatientDto> GetAll() { List <PatientDto> myPatients = new List <PatientDto>(); _dbContext.Patients.ToList().ForEach(patient => myPatients.Add(PatientAdapter.PatientToPatientDto(patient))); return(myPatients); }
public IActionResult Add(Patient patient) { if (_patientService.Add(patient) == null) { return(NotFound()); } return(Ok(PatientAdapter.PatientToPatientDto(patient))); }
/// <summary> This method converts <paramref name="patientDto"/> to <c>PatientUser</c> using <c>PatientAdapter</c> and sends it to <c>PatientsRepository</c>. </summary> /// <returns>Returns successfully created patient; otherwise, return <c>null</c></returns> public PatientUser Create(PatientDto patientDto) { if (PatientsRepository.GetByEmail(patientDto.Email) == null) { PatientUser patient = PatientsRepository.Add(PatientAdapter.PatientDtoToPatient(patientDto)); EmailVerificationService.SendVerificationMail(new MailAddress(patient.Email), patient.Id); return(patient); } return(null); }
public void Add_patient() { PatientDto myPatient = CreatePatient(); Patient convertedPatient = PatientAdapter.PatientDtoToPatient(myPatient); HospitalApp.Controllers.PatientController controller = new HospitalApp.Controllers.PatientController(this.SetupRepository(myPatient, convertedPatient).Object); var actionResult = controller.Add(convertedPatient); ConvertToObject(actionResult).ShouldBeEquivalentTo(myPatient); }
public PatientDto GetById(int patientId) { Patient patient = _dbContext.Patients.SingleOrDefault(p => p.Id == patientId); if (patient == null) { return(null); } return(PatientAdapter.PatientToPatientDto(patient)); }
public PatientDto GetAppointmentPatient(int appointmentId) { Appointment appointment = _dbContext.Appointments.SingleOrDefault(appointment => appointment.Id == appointmentId); Patient myPatient = _dbContext.Patients.SingleOrDefault(patient => patient.Id == appointment.PatientId); if (myPatient == null) { return(null); } return(PatientAdapter.PatientToPatientDto(myPatient)); }
public PatientDto SetGeneralPractitioner(int patientId, int doctorId) { Patient myPatient = _dbContext.Patients.SingleOrDefault(patient => patient.Id == patientId); if (myPatient == null) { return(null); } myPatient.GeneralPractitioner = _dbContext.Doctors.SingleOrDefault(doctor => doctor.Id == doctorId); _dbContext.SaveChanges(); return(PatientAdapter.PatientToPatientDto(myPatient)); }
public void Set_random_general_practitioner() { using (var context = new MyDbContext(_options)) { SetupDatabase(context); HospitalApp.Services.DoctorService doctorService = new HospitalApp.Services.DoctorService(context); HospitalApp.Services.PatientService service = new HospitalApp.Services.PatientService(context, doctorService); PatientDto patient = service.GetById(12); Patient k = PatientAdapter.PatientDtoToPatient(patient); service.GiveRandomGeneralPractitioner(k); Assert.NotNull(k.GeneralPractitionerId); } }
public PatientDto Add(Patient patient) { if (patient == null || patient.Password == null) { return(null); } if (_dbContext.Patients.SingleOrDefault(p => p.Username == patient.Username) != null) { return(null); } GiveRandomGeneralPractitioner(patient); _dbContext.Patients.Add(patient); _dbContext.SaveChanges(); return(PatientAdapter.PatientToPatientDto(patient)); }
public void Setup() { this.uut = new PatientAdapter(); }