Exemplo n.º 1
0
        public async Task <IActionResult> AddPatientNote(int id)
        {
            var userId = GetLoggedInUserId();

            if (userId < 1)
            {
                _log.LogError($"Authentication failure. Could not extract User's Id from Claims Principal.");
                Alert("Failed to authorize current User access to the Patient Record", AlertType.danger);
                return(RedirectToAction("Details", "Patient", new { id = id }));
            }

            var medicalPractitioner = await _userAdminSvc.GetUserFullDetailsAsync(userId);

            if (medicalPractitioner == null)
            {
                _log.LogError($"Failed to load Medical Practitioner's account. \"Id\"={userId}");
                Alert("Failed to authorize current User access to the Patient Record", AlertType.danger);
                return(RedirectToAction("Details", "Patient", new { id = id }));
            }

            var newPatientNote = new PatientNoteDto()
            {
                PatientId                    = id,
                MedicalPractitionerId        = userId,
                MedicalPractitionerFirstname = medicalPractitioner.Firstname,
                MedicalPractitionerLastname  = medicalPractitioner.Lastname,
                MedicalPractitionerTitle     = medicalPractitioner.Title.ToString()
            };

            return(View(newPatientNote));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds a new PatientRecordEntry
        /// </summary>
        /// <param name="newPatientRecordEntry"></param>
        /// <returns></returns>
        public async Task <PatientNoteDto> AddPatientRecordEntryAsync(PatientNoteDto newPatientRecordEntry)
        {
            if (newPatientRecordEntry == null)
            {
                throw new ArgumentNullException(nameof(newPatientRecordEntry));
            }

            var newPatientRecordEntryString = JsonSerializer.Serialize(newPatientRecordEntry);
            var encryptedContent            = _cryptoSvc.Encrypt(newPatientRecordEntryString);

            var newPatientNote = new PatientNote()
            {
                PatientId             = newPatientRecordEntry.PatientId,
                MedicalPractitionerId = newPatientRecordEntry.MedicalPractitionerId,
                Timestamp             = newPatientRecordEntry.Timestamp,
                Content = encryptedContent
            };

            var result = await _noteDal.AddAsync(newPatientNote);

            if (result == null)
            {
                return(null);
            }

            newPatientRecordEntry.Id = result.Id;
            return(newPatientRecordEntry);
        }
Exemplo n.º 3
0
        public async Task <IActionResult> AddPatientNote([FromForm] PatientNoteDto newPatientNote)
        {
            if (newPatientNote == null)
            {
                throw new ArgumentNullException(nameof(newPatientNote));
            }

            // Add the timestamp just prior to saving the patient note
            newPatientNote.Timestamp = DateTime.UtcNow;

            var result = await _patientRecordSvc.AddPatientRecordEntryAsync(newPatientNote);

            if (result != null)
            {
                Alert(
                    $"Patient note successfully saved to the patient's record. \"PatientId\"={newPatientNote.PatientId}", AlertType.success);
                return(RedirectToAction("Index", new { id = newPatientNote.PatientId }));
            }

            _log.LogError($"Failed to save new Patient note. \"PatientId\"={newPatientNote.PatientId}, \"MedicalPractitionerId\"={newPatientNote.MedicalPractitionerId}");
            Alert("Failed to save new Patient note.", AlertType.danger);
            return(RedirectToAction("Index", new { id = newPatientNote.PatientId }));
        }