public ConsultationEntity GetConsultationsById(int id)
        {
            Consultation daConsultation = _dataAccessService.ConsultationRepository.GetItemById(id);

            if (daConsultation == null)
            {
                return(null);
            }
            return(DTOMapper.Convert(daConsultation));
        }
        /// <summary>
        /// Return a patient entity for a given ID
        /// </summary>
        /// <param name="id">Patient ID</param>
        /// <returns></returns>
        public PatientEntity GetPatientById(int id)
        {
            var daPatient = _dataAccessService.GetPatientById(id);

            if (daPatient == null)
            {
                return(null);
            }

            //convert Patient to PatientEntity
            return(DTOMapper.Convert(daPatient));
        }
        public List <ConsultationEntity> GetConsultationsByConsultaionDate(DateTime consultaionDate)
        {
            List <Consultation> daConsultations = _dataAccessService.GetAllConsultationsByConsultaionDate(consultaionDate);

            if (daConsultations == null)
            {
                return(null);
            }

            if (daConsultations.Count == 0)
            {
                return(new List <ConsultationEntity>());
            }

            return(DTOMapper.Convert(daConsultations));
        }
        /// <summary>
        /// Get all patients
        /// </summary>
        /// <returns></returns>
        public List <PatientEntity> GetAllPatients()
        {
            List <Patient> daPatients = _dataAccessService.GetAllPatients();

            if (daPatients == null)
            {
                return(null);
            }

            if (daPatients.Count == 0)
            {
                return(new List <PatientEntity>());
            }

            //convert List<Patient> to List<PatientEntity>
            return(DTOMapper.Convert(daPatients));
        }
        /// <summary>
        /// Insert a patient
        /// </summary>
        /// <param name="newPatient"></param>
        /// <returns></returns>
        public PatientEntity AddPatient(PatientEntity newPatient)
        {
            if (newPatient == null)
            {
                throw new ArgumentNullException();
            }
            try
            {
                var daPatient = _dataAccessService.AddPatient(DTOMapper.Convert(newPatient));

                if (daPatient == null)
                {
                    throw new Exception("Create patient failed");
                }

                return(DTOMapper.Convert(daPatient));
            }
            catch
            {
                //log the error
                throw;
            }
        }