public async Task AddPatientAsync_Database_Test() { using var connection = Database_init(); var options = new DbContextOptionsBuilder <ClinicDbContext>().UseSqlite(connection).Options; using var context = new ClinicDbContext(options); var repo = new ClinicRepository(context, new NullLogger <ClinicRepository>()); var patient = new VirtualClinic.Domain.Models.Patient("Billy Mays", DateTime.Now) { SSN = "293-38-0071", InsuranceProvider = "Umbrella Corp", PrimaryDoctor = repo.GetDoctorByID(1) }; await repo.AddPatientAsync(patient); using var context2 = new ClinicDbContext(options); DataModel.Patient patientActual = context2.Patients .Single(l => l.Name == "Billy Mays"); Assert.Equal(patient.Name, patientActual.Name); Assert.Equal(patient.SSN, patientActual.Ssn); Assert.Equal(patient.InsuranceProvider, patientActual.Insurance); }
internal static Models.Patient MapPatient(DataModel.Patient dBPatient) { var patient = new Models.Patient(dBPatient.Id, dBPatient.Name, dBPatient.Dob, dBPatient.Ssn, dBPatient.Insurance); patient.InsuranceProvider = dBPatient.Insurance; patient.SSN = dBPatient.Ssn; //create lists for these. patient.Timeslots = new List <Models.Timeslot>(); patient.Prescriptions = new List <Models.Prescription>(); patient.PatientReports = new List <Models.PatientReport>(); return(patient); }
/// <summary> /// Add a patient to the database /// </summary> /// <param name="patient">A patient to be added to the database</param> public Models.Patient AddPatient(Models.Patient patient) { //todo: replace with mapper var newPatient = new DataModel.Patient { Name = patient.Name, Dob = patient.DateOfBirth, DoctorId = patient.PrimaryDoctor.Id, Ssn = patient.SSN, Insurance = patient.InsuranceProvider }; _context.Patients.Add(newPatient); _context.SaveChanges(); patient.Id = newPatient.Id; return(patient); }
/// <summary> /// Add a patient to the database /// </summary> /// <param name="patient">A patient to be added to the database</param> public async Task <Models.Patient> AddPatientAsync(Models.Patient patient) { if (patient.PrimaryDoctor is null) { var dr = _context.Doctors.First(); var patientdr = new Domain.Models.Doctor(dr.Id, dr.Name); patient.PrimaryDoctor = patientdr; } var newPatient = new DataModel.Patient { Name = patient.Name, Dob = patient.DateOfBirth, DoctorId = patient.PrimaryDoctor.Id, Ssn = patient.SSN, Insurance = patient.InsuranceProvider }; await _context.Patients.AddAsync(newPatient); await _context.SaveChangesAsync(); patient.Id = newPatient.Id; return(patient); }
public Patient() { _patient = new DataModel.Patient(); }