public ActionResult InputMedicalRecord(MedicalRecordModel record) { if (ModelState.IsValid) { // New Record if (record.RecordId == 0) { var date = DateTime.Parse(record.DateString); Db.MedicalRecords.Add(new MedicalRecord { Weight = record.Weight, Height = record.Height, BloodPressure = record.BloodPressure, Pulse = record.Pulse, Description = record.Description, Date = date, LabResult = record.LabResult, PathologyReport = record.PathologyReport, RadiologyReport = record.RadiologyReport, AllegyInformation = record.AllegyInformation, PatientId = record.PatientId }); } else // Update record { var medicalRecord = Db.MedicalRecords.Where(rec => rec.Id == record.RecordId).FirstOrDefault(); if (medicalRecord != null) { var date = DateTime.Parse(record.DateString); medicalRecord.Date = date; medicalRecord.Weight = record.Weight; medicalRecord.Height = record.Height; medicalRecord.BloodPressure = record.BloodPressure; medicalRecord.Pulse = record.Pulse; medicalRecord.Description = record.Description; medicalRecord.LabResult = record.LabResult; medicalRecord.PathologyReport = record.PathologyReport; medicalRecord.RadiologyReport = record.RadiologyReport; medicalRecord.AllegyInformation = record.AllegyInformation; medicalRecord.PatientId = record.PatientId; } } Db.SaveChanges(); return(RedirectToAction("PatientMedicalRecords", "Staff", new { patientId = record.PatientId })); } // model error return(View(record)); }
public bool CancelAppointment(int appointmentId, int patientId) { // Access Control if (!checkAccountExists(patientId) || !isPatientAccess(patientId)) { return(false); } var ap = Db.Appointments.Find(appointmentId); if (ap != null) { Db.Appointments.Remove(ap); Db.SaveChanges(); return(true); } return(false); }
public ActionResult EditPatientProfile(ProfileModel model) { if (!isPatientAccess()) { ViewBag.ErrorMessage = "You don't have permission to edit the profile of patient"; return(View("~/Views/Shared/Error.cshtml")); } if (ModelState.IsValid) { var account = Db.Accounts.OfType <PatientAccount>().FirstOrDefault(acc => acc.AccountId == model.AccountId); if (account != null) { account.Password = model.Password; account.Firstname = model.Firstname; account.Lastname = model.Lastname; account.Phone = model.Phone; account.BillingAddress = model.BillingAddress; account.InsuranceNumber = model.InsuranceNumber; Db.SaveChanges(); } } //return PartialView("_EditProfile", model); return(RedirectToAction("Index")); }
public static void GenerateMonthlyReport() { var database = new HealthcareSystemContext(); DateTime thisMonth = DateTime.Today; thisMonth = thisMonth.AddDays(-thisMonth.Day + 1); //return the first day of month DateTime nextMonth = thisMonth.AddMonths(1); var monthlyReports = database.ServiceStatements.Where(st => st.Date >= thisMonth && st.Date < nextMonth) .GroupBy(st => st.DoctorId).Select(group => new { DoctorId = group.Key, Revenue = group.Sum(st => st.Amount) }) .Join(database.Accounts, st => st.DoctorId, acc => acc.AccountId, (st, acc) => new ReportModel { DoctorId = st.DoctorId, Revenue = st.Revenue, DoctorName = acc.Firstname + " " + acc.Lastname }).ToList(); // Add doctor without any statement generated var doctorList = database.Accounts.OfType <EmployeeAccount>().Where(acc => acc.Role == EmployeeRole.Doctor); foreach (var doctor in doctorList) { if (!monthlyReports.Any(rp => rp.DoctorId == doctor.AccountId)) { monthlyReports.Add(new ReportModel { DoctorId = doctor.AccountId, DoctorName = doctor.Firstname + " " + doctor.Lastname, Revenue = 0 }); } } database.MonthlyReports.AddRange(monthlyReports.Select(x => new MonthlyReport { DoctorId = x.DoctorId, Revenue = x.Revenue, Date = DateTime.Now })); database.SaveChanges(); }
public static void GenerateDailyReport() { var database = new HealthcareSystemContext(); DateTime today = DateTime.Today; DateTime nextDay = today.AddDays(1); var dailyReports = database.ServiceStatements.Where(st => st.Date >= today && st.Date < nextDay) .GroupBy(st => st.DoctorId).Select(group => new { DoctorId = group.Key, Revenue = group.Sum(st => st.Amount) }) .Join(database.Accounts, st => st.DoctorId, acc => acc.AccountId, (st, acc) => new ReportModel { DoctorId = st.DoctorId, Revenue = st.Revenue, DoctorName = acc.Firstname + " " + acc.Lastname }).ToList(); // Add doctor without any statement generated var doctorList = database.Accounts.OfType <EmployeeAccount>().Where(acc => acc.Role == EmployeeRole.Doctor); foreach (var doctor in doctorList) { if (!dailyReports.Any(rp => rp.DoctorId == doctor.AccountId)) { dailyReports.Add(new ReportModel { DoctorId = doctor.AccountId, DoctorName = doctor.Firstname + " " + doctor.Lastname, Revenue = 0 }); } } var yesterday = DateTime.Now.AddDays(-1); database.DailyReports.AddRange(dailyReports.Select(x => new DailyReport { DoctorId = x.DoctorId, Revenue = x.Revenue, Date = yesterday })); database.SaveChanges(); }