public async Task <IActionResult> AddPrescriptions(AddPrescriptionInputModel model) { var doctor = this.doctorsService.GetDoctorByUserId(this.User.FindFirst(ClaimTypes.NameIdentifier).Value); model.Doctor = doctor; await this.prescriptionsService.AddPrescriptionToPatient(model); return(this.RedirectToAction("GetDoctorsPatients", "Patients")); }
public IActionResult AddPrescriptions(string patientId) { var viewModel = new AddPrescriptionInputModel() { PatientId = patientId, }; return(this.View(viewModel)); }
public async Task GettingPatientsPrescriptionsShouldReturnTheCorrectNumberOfPrescriptions() { var user1 = new ApplicationUser() { UserName = "******", Email = "*****@*****.**" }; var user2 = new ApplicationUser() { UserName = "******", Email = "*****@*****.**" }; var patient = new Patient() { LastName = "Test", UserId = user1.Id, User = user1, }; await this.PatientsRepository.AddAsync(patient); var doctor = new Doctor() { Name = "Test", User = user2, UserId = user2.Id, }; await this.DoctorsRepository.AddAsync(doctor); var prescription = new AddPrescriptionInputModel() { Doctor = doctor, DoctorId = doctor.Id, Patient = patient, PatientId = patient.Id, Instructions = "Test", MedicamentName = "Test", Quantity = "Test123", }; await this.PrescriptionsService.AddPrescriptionToPatient(prescription); var prescriptions = this.PrescriptionsService.GetPatientsPrescriptions <AddPrescriptionInputModel>(patient.Id); var prescriptionsCount = prescriptions.Count(); Assert.Equal(1, prescriptionsCount); }
public async Task AddPrescriptionToPatient(AddPrescriptionInputModel model) { var prescription = new Prescription() { Doctor = model.Doctor, DoctorId = model.Doctor.Id, Patient = model.Patient, PatientId = model.PatientId, Instructions = model.Instructions, Quantity = model.Quantity, MedicamentName = model.MedicamentName, }; await this.prescriptionsRepository.AddAsync(prescription); await this.prescriptionsRepository.SaveChangesAsync(); }
public async Task CreatingPrescriptionShouldAddItToTheDb() { var prescription = new AddPrescriptionInputModel() { Doctor = new Doctor(), DoctorId = "test", Patient = new Patient(), PatientId = "test", Instructions = "Test", MedicamentName = "Test", Quantity = "Test123", }; await this.PrescriptionsService.AddPrescriptionToPatient(prescription); var prescriptionFromService = this.PrescribtionsRepository.All().First(); Assert.Equal(prescription.Quantity, prescriptionFromService.Quantity); }