Example #1
0
        public ActionResult AddMedicalRecords(int id, int?y, int?m, int?d)
        {
            var patient = this.db.Patients.SingleOrDefault(p => p.Id == id && p.DoctorId == this.Doctor.Id);

            if (patient == null)
            {
                return(new StatusCodeResult(HttpStatusCode.NotFound, "Patient not found"));
            }

            // Only the doctor and the patient can see the medical records.
            var canAccessMedicalRecords = this.DbUser.Id == patient.Doctor.Users.Single().Id;

            this.ViewBag.CanAccessMedicalRecords = canAccessMedicalRecords;

            var localDateFilter = DateTimeHelper.CreateDate(y, m, d) ?? this.GetPracticeLocalNow().Date;
            var utcDateFilter   = ConvertToUtcDateTime(this.DbPractice, localDateFilter);

            // Creating the view-model object.
            var model = GetViewModel(this, patient, false, false, false);

            model.Sessions = GetSessionViewModels(this.DbPractice, patient, DateTimeInterval.FromDateAndDays(utcDateFilter, 1));

            this.ViewBag.RecordDate = localDateFilter;

            return(this.View(model));
        }