Ejemplo n.º 1
0
        public async Task <Models.Prescription> GetPrescriptionAsync(int PrescriptionId)
        {
            var script = await _context.Prescriptions.FindAsync(PrescriptionId);

            if (script is not null)
            {
                return(DB_DomainMapper.MapPrescription(script));
            }
            else
            {
                throw new ArgumentException($"Prescription, {PrescriptionId}, not found.");
            }
        }
Ejemplo n.º 2
0
        public async Task <Models.Patient> GetPatientByIDAsync(int patientId)
        {
            var DBPatient = await _context.Patients.FindAsync(patientId);

            if (DBPatient is not null)
            {
                return(DB_DomainMapper.MapPatient(DBPatient));
            }
            else
            {
                throw new ArgumentException("Patient Not found in DB.");
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Get's a specific patient based on their ID
        /// </summary>
        /// <exception cref="ArgumentException">
        /// Throws an argument exception if there is no patient with that ID in the DB.
        /// </exception>
        /// <param name="patientId">The patient's ID in the database.</param>
        /// <returns>A model representation of that patient.</returns>
        public Models.Patient GetPatientByID(int patientId)
        {
            var DBPatient = _context.Patients.Find(patientId);

            if (DBPatient is not null)
            {
                return(DB_DomainMapper.MapPatient(DBPatient));
            }
            else
            {
                throw new ArgumentException("Patient Not found in DB.");
            }
        }
Ejemplo n.º 4
0
        /*    _____                         _       _   _
         *   |  __ \                       (_)     | | (_)
         *   | |__) | __ ___  ___  ___ _ __ _ _ __ | |_ _  ___  _ __  ___
         *   |  ___/ '__/ _ \/ __|/ __| '__| | '_ \| __| |/ _ \| '_ \/ __|
         *   | |   | | |  __/\__ \ (__| |  | | |_) | |_| | (_) | | | \__ \
         *   |_|   |_|  \___||___/\___|_|  |_| .__/ \__|_|\___/|_| |_|___/
         *                                   | |
         *                                   |_|
         */
        #region Prescriptions
        /// <summary>
        /// Get's a specific prescription by it's ID
        /// </summary>
        /// <exception cref="ArgumentException">
        /// Throws an argument exception if there is no perscription with that ID in the DB.
        /// </exception>
        /// <param name="PerscriptionId">The ID of the desired prescription</param>
        /// <returns>The prescription with the given ID.</returns>
        public Models.Prescription GetPrescription(int PrescriptionId)
        {
            var script = _context.Prescriptions.Find(PrescriptionId);

            if (script is not null)
            {
                return(DB_DomainMapper.MapPrescription(script));
            }
            else
            {
                throw new ArgumentException($"Prescription, {PrescriptionId}, not found.");
            }
        }
Ejemplo n.º 5
0
        public async Task <IEnumerable <Models.Prescription> > GetPatientPrescriptionsAsync(int patientID)
        {
            var DbPerscriptions = await _context.Prescriptions
                                  .Where(p => p.PatientId == patientID)
                                  .ToListAsync();

            List <Models.Prescription> modelPresciptions = new List <Models.Prescription>();

            foreach (var script in DbPerscriptions)
            {
                modelPresciptions.Add(DB_DomainMapper.MapPrescription(script));
            }

            return(modelPresciptions);
        }
Ejemplo n.º 6
0
        public async Task <IEnumerable <Models.PatientReport> > GetPatientReportsAsync(int PatientId)
        {
            List <DataModel.PatientReport> reports = await _context.PatientReports
                                                     .Where(report => report.PatientId == PatientId)
                                                     .ToListAsync();

            List <Models.PatientReport> modelreports = new List <Models.PatientReport>();

            foreach (var r in reports)
            {
                modelreports.Add(DB_DomainMapper.MapReport(r));
            }

            return(modelreports);
        }
Ejemplo n.º 7
0
        public async Task <IEnumerable <Models.Patient> > GetPatientsAsync()
        {
            var DBPatients = await _context.Patients
                             .Include(thing => thing.PatientReports)
                             .ToListAsync();

            List <Models.Patient> ModelPatients = new List <Models.Patient>();

            foreach (var dbpatient in DBPatients)
            {
                ModelPatients.Add(DB_DomainMapper.MapPatient(dbpatient));
            }

            return(ModelPatients);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Get's all of a single patient's reports.
        /// </summary>
        /// <param name="PatientId">The ID of the patient who's reports are desired.</param>
        /// <returns>All reports of the given patient.</returns>
        public IEnumerable <Models.PatientReport> GetPatientReports(int PatientId)
        {
            List <DataModel.PatientReport> reports = _context.PatientReports
                                                     .Where(report => report.PatientId == PatientId)
                                                     .ToList();

            List <Models.PatientReport> modelreports = new List <Models.PatientReport>();

            foreach (var r in reports)
            {
                r.PatientId = PatientId;
                modelreports.Add(DB_DomainMapper.MapReport(r));
            }

            return(modelreports);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Given a report id, gets the report with the given id.
        /// </summary>
        /// <remarks>
        /// will not fill in the references to patient.
        /// </remarks>
        /// <param name="ReportID">The id value of the report in the DB</param>
        /// <returns>The patient report with the given ID</returns>
        public async Task <Models.PatientReport> GetPatientReportByIDAsync(int ReportId)
        {
            DataModel.PatientReport report = await _context.PatientReports.FindAsync(ReportId);

            if (report is null)
            {
                //then no report with that id exists in the DB
                throw new ArgumentException($"Patient Report ID {ReportId} Not Found in DB.");
            }

            var modelreport = DB_DomainMapper.MapReport(report);

            //technically could be null, but shouldn't be because this ID comes from DB information.

            if (report.VitalsId is not null)
            {
                modelreport.Vitals = DB_DomainMapper.MapVitals(_context.Vitals.Find(report.VitalsId));
            }

            return(modelreport);
        }
Ejemplo n.º 10
0
        /*    _    _      _
         *   | |  | |    | |
         *   | |__| | ___| |_ __   ___ _ __ ___
         *   |  __  |/ _ \ | '_ \ / _ \ '__/ __|
         *   | |  | |  __/ | |_) |  __/ |  \__ \
         *   |_|  |_|\___|_| .__/ \___|_|  |___/
         *                 | |
         *                 |_|
         */
        #region PrivateHelpers
        /// <summary>
        /// Takes a list of db timeslots and converts them to apointments
        /// </summary>
        /// <param name="timeslots">List of DB timeslots</param>
        /// <returns>List of model timeslots</returns>
        private static List <Models.Timeslot> ConvertTimeslots(List <DataModel.Timeslot> timeslots, bool AllowNullApointmentsFlag = false)
        {
            List <Models.Timeslot> modelTimeslots = new List <Models.Timeslot>();

            foreach (var DBTimeSlot in timeslots)
            {
                Models.Timeslot modelts = DB_DomainMapper.MapTimeslot(DBTimeSlot);

                //does not fill in dr or patient
                if (DBTimeSlot.Appointment is not null)
                {
                    modelts.Appointment = DB_DomainMapper.MapApointment(DBTimeSlot.Appointment);
                }
                else if (AllowNullApointmentsFlag)
                {
                    throw new NullReferenceException("A timeslot has a null apointment reference");
                }

                modelTimeslots.Add(modelts);
            }

            return(modelTimeslots);
        }