public async Task<IActionResult> SignHIPAANotice( SignHIPAANoticeViewModel vm ) { if ( !ModelState.IsValid ) return NotFound(); // If patient hasn't agreed to privacy notice, we need to stay here: if ( !vm.IAgree || vm.HIPAAPrivacyNotice == null ) return View( vm ); var notice = _hipaa.ReadNewest(); // Create the record of the signed notice in the sytem: var signedNotice = new PatientSignedHIPAANotice //vm.GetNewPatientSignedHIPAANotice(); { HIPAAPrivacyNoticeId = notice.Id, HIPAAPrivacyNotice = notice, PatientId = User.Identity.Name, Patient = await _pat.ReadAsync( User.Identity.Name ), Signed = true, SignedAt = DateTime.Now, UpdatedAt = DateTime.Now }; signedNotice = await _patientSignedHIPAA.CreateAsync( signedNotice ); // Attach the signed notice to the patient signing it: Patient patient = await _pat.ReadAsync(User.Identity.Name); patient.PatientSignedHIPAANotice = signedNotice; await _pat.UpdateAsync( patient.UserName, patient ); // Once signed, proceed to the main index: return RedirectToAction( nameof( Index ) ); } // SignHIPAANotice
} // Index public async Task<IActionResult> SignHIPAANotice() { SignHIPAANoticeViewModel vm = new SignHIPAANoticeViewModel(); vm.HIPAAPrivacyNotice = _hipaa.ReadNewest(); vm.Patient = await _pat.ReadAsync( User.Identity.Name ); if ( vm.Patient == null ) return RedirectToAction( nameof( Index ) ); return View( vm ); } // SignHIPAANotice