/// <summary>
        /// Convert a report from a db object to a domain model object.
        /// </summary>
        /// <remarks>
        /// Will not get patient or vitals.
        /// </remarks>
        /// <param name="report">The report from the db</param>
        /// <returns></returns>
        public static Models.PatientReport MapReport(DataModel.PatientReport report)
        {
            if (report is null)
            {
                throw new ArgumentNullException("MapReport Report is null.");
            }

            Models.PatientReport modelreport = new Models.PatientReport(report.Id, report.Information);

            modelreport.Time      = report.ReportTime;
            modelreport.PatientId = report.PatientId;

            return(modelreport);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Add a patient report to the database
        /// </summary>
        /// <param name="report">The report to be added tp the database</param>
        public Models.PatientReport AddPatientReport(Models.PatientReport report)
        {
            var newPatientReport = new DataModel.PatientReport
            {
                PatientId   = report.PatientId,
                ReportTime  = report.Time,
                Information = report.Info
                              //add vitals id for datamodel??
            };

            _context.Add(newPatientReport);
            _context.SaveChanges();
            report.Id = newPatientReport.Id;
            return(report);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Add a patient report to the database
        /// </summary>
        /// <param name="report">The report to be added tp the database</param>
        public async Task <Models.PatientReport> AddPatientReportAsync(Models.PatientReport report)
        {
            var newPatientReport = new DataModel.PatientReport
            {
                PatientId   = report.PatientId,
                ReportTime  = report.Time,
                Information = report.Info
            };

            await _context.AddAsync(newPatientReport);

            await _context.SaveChangesAsync();

            report.Id = newPatientReport.Id;
            return(report);
        }
Ejemplo n.º 4
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);
        }