Ejemplo n.º 1
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.º 2
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.º 3
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);
        }