예제 #1
0
        public void UnMapAppointmentTest()
        {
            // same method, but reverse.

            Inner_Appointment sampleAppointmentL = new Inner_Appointment
            {
                AppointmentId   = 200,
                AppointmentDate = new DateTime(2000, 1, 1),
                Patient         = new Inner_Patient
                {
                    PatientId = 200
                },
                Provider = new Inner_Provider
                {
                    ProviderId = 200
                }
            };

            Data_Appointment sampleAppointmentD = new Data_Appointment
            {
                AppointmentId   = 200,
                AppointmentDate = new DateTime(2000, 1, 1),
                PatientId       = 200,
                ProviderId      = 200
            };

            Data_Appointment resultAppointmentD = Mapper.UnMapAppointment(sampleAppointmentL);

            Assert.True(compareAppointmentD(resultAppointmentD, sampleAppointmentD));
        }
        /// <summary> Updates one existing appointment in the database
        /// <param name="appointment"> Inner_Appointment Object - represents the fields of a Appointment in the database </param>
        /// <returns> no return </returns>
        /// </summary>
        public async Task UpdateAppointmentAsync(Inner_Appointment appointment)
        {
            Data_Appointment currentEntity = await _context.Appointments.FindAsync(appointment.AppointmentId);

            Data_Appointment newEntity = Mapper.UnMapAppointment(appointment);

            _context.Entry(currentEntity).CurrentValues.SetValues(newEntity);
            await Save();
        }
예제 #3
0
 public static Data_Appointment UnMapAppointment(Inner_Appointment appointment)
 {
     return(new Data_Appointment
     {
         AppointmentId = appointment.AppointmentId,
         AppointmentDate = appointment.AppointmentDate,
         PatientId = appointment.Patient.PatientId,
         ProviderId = appointment.Provider.ProviderId
     });
 }
        public void APIAppointment_Behavior()
        {
            var apiMapper = this.MakeMapper();
            Inner_Appointment appointment = new Inner_Appointment
            {
                AppointmentDate = new DateTime(),
                AppointmentId   = 1
            };

            var outcome = Mapper.MapAppointments(appointment);

            Assert.True(true);
            this.mockRepo.VerifyAll();
        }
예제 #5
0
 private bool compareAppointmentL(Inner_Appointment x, Inner_Appointment y)
 {
     // checks to make sure all the field of the two input object match
     // returns false (fails test) if they don't match
     if (
         x.AppointmentDate != y.AppointmentDate ||
         x.AppointmentId != y.AppointmentId ||
         x.Patient.PatientId != y.Patient.PatientId ||
         x.Provider.ProviderId != y.Provider.ProviderId
         )
     {
         return(false);
     }
     return(true);
 }
예제 #6
0
// ! ***********************************
// ! ********* Appointments ************
// ! ***********************************
        public static Transfer_Appointment MapAppointments(Inner_Appointment appointment)
        {
            return(new Transfer_Appointment
            {
                AppointmentId = appointment.AppointmentId,
                AppointmentDate = appointment.AppointmentDate,
                PatientId = appointment.Patient.PatientId,
                PatientFirstName = appointment.Patient.PatientFirstName,
                PatientLastName = appointment.Patient.PatientLastName,
                PatientPhoneNumber = appointment.Patient.PatientPhoneNumber,
                ProviderId = appointment.Provider.ProviderId,
                ProviderFirstName = appointment.Provider.ProviderFirstName,
                ProviderLastName = appointment.Provider.ProviderLastName,
                ProviderPhoneNumber = appointment.Provider.ProviderPhoneNumber
            });
        }
        /// <summary> Add one appointment to the database
        /// <param name="appointment"> Inner_Appointment Object - represents the fields of a Appointment in the database </param>
        /// <returns> Returns inputted (and formatted) Appointment </returns>
        /// </summary>
        public async Task <Inner_Appointment> AddAppointmentAsync(Inner_Appointment appointment)
        {
            try
            {
                var newAppointment = Mapper.UnMapAppointment(appointment);
                newAppointment.AppointmentId = (await GetAppointmentAsync()).Max(p => p.AppointmentId) + 1;
                _context.Appointments.Add(newAppointment);
                await Save();

                return(Mapper.MapAppointment(newAppointment));
            }
            catch (Exception ex)
            {
                _logger.LogCritical(ex.Message);
                throw ex;
            }
        }
예제 #8
0
        public async Task <IActionResult> PostAsync(Transfer_Appointment appointment)
        {
            try
            {
                _logger.LogInformation($"Adding new appointment.");
                var myChecker = new CheckerClass(_patientRepository, _providerRepository, _appointmentRepository);
                myChecker.CheckAppointment(appointment);
                Inner_Appointment transformedAppointment = new Inner_Appointment
                {
                    AppointmentId   = 0,
                    AppointmentDate = (DateTime)appointment.AppointmentDate,
                    Patient         = await _patientRepository.GetPatientByIdAsync(appointment.PatientId),
                    Provider        = await _providerRepository.GetProviderByIdAsync(appointment.ProviderId)
                };
                await _appointmentRepository.AddAppointmentAsync(transformedAppointment);

                return(CreatedAtAction(nameof(GetByIdAsync), new { id = appointment.AppointmentId }, appointment));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
예제 #9
0
        public void MapAppointmentTest()
        {
            //this is the sample input
            //It looks pretty complicated, but only because both the data object and the inner object have sub-objects inside them
            //Notice when filling the dummy objects I only fill the info that the mapper will need (the id and any sub-objects)
            Data_Appointment sampleAppointmentD = new Data_Appointment
            {
                AppointmentId   = 100,
                AppointmentDate = new DateTime(2000, 1, 1),
                Patient         = new Data_Patient
                {
                    PatientId = 100,
                    Insurance = new Data_Insurance
                    {
                        InsuranceId = 100
                    }
                },
                Provider = new Data_Provider
                {
                    ProviderId = 100,
                    Facility   = new Data_Facility
                    {
                        FacilityId = 100
                    },
                    Specialty = new Data_Specialty
                    {
                        SpecialtyId = 100
                    }
                }
            };

            //this is the predicted output. notice I only filled in the field that matter when making the new object
            Inner_Appointment sampleAppointmentL = new Inner_Appointment
            {
                AppointmentId   = 100,
                AppointmentDate = new DateTime(2000, 1, 1),
                Patient         = new Inner_Patient
                {
                    PatientId = 100,
                    Insurance = new Inner_Insurance
                    {
                        InsuranceId = 100
                    }
                },
                Provider = new Inner_Provider
                {
                    ProviderId = 100,
                    Facility   = new Inner_Facility
                    {
                        FacilityId = 100
                    },
                    Specialty = new Inner_Specialty
                    {
                        SpecialtyId = 100
                    }
                }
            };

            // this is the actual coverage part. It runs our input object through the real mapper
            Inner_Appointment resultAppointmentL = Mapper.MapAppointment(sampleAppointmentD);

            // this uses a 2nd method to make sure that the real mapper output the same thing as our predicted result
            Assert.True(compareAppointmentL(resultAppointmentL, sampleAppointmentL));
        }