Exemplo n.º 1
0
        public async Task <IActionResult> Register([FromForm] PatientForRegistration newPatientDetails)
        {
            if (newPatientDetails == null)
            {
                Alert("Failed to receive new patient details for registration");
                throw new ArgumentNullException(nameof(newPatientDetails));
            }

            // Send the newPatientDetails to the Patient service to be processed
            var result = await _patientSvc.RegisterPatientAsync(newPatientDetails);

            if (result != null)
            {
                Alert(
                    "New patient registered successfully. " +
                    $"Name={newPatientDetails.Firstname + " " + newPatientDetails.Lastname}. PatientId={result.Id}",
                    AlertType.success);
                return(View("Details", result));
            }

            Alert(
                $"Failed to register new patient. Name={newPatientDetails.Firstname + " " + newPatientDetails.Lastname}",
                AlertType.danger);
            return(View("Register", newPatientDetails));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Accepts the PatientForRegistration dto and converts it to a Patient and sends to the db to be persisted
        /// </summary>
        /// <param name="newPatientDetails"></param>
        /// <returns></returns>
        public Task <Patient> AddAsync(PatientForRegistration newPatientDetails)
        {
            if (newPatientDetails == null)
            {
                throw new ArgumentNullException(nameof(newPatientDetails));
            }

            var patient = new Patient
            {
                Title         = newPatientDetails.Title,
                Firstname     = newPatientDetails.Firstname,
                Lastname      = newPatientDetails.Lastname,
                DateOfBirth   = newPatientDetails.DateOfBirth,
                HealthAndCare = newPatientDetails.HealthAndCare,
                Address1      = newPatientDetails.Address1,
                Address2      = newPatientDetails.Address2,
                City          = newPatientDetails.City,
                County        = newPatientDetails.County,
                PostCode      = newPatientDetails.PostCode,
                PhoneNumber   = newPatientDetails.PhoneNumber,
                MobilePhone   = newPatientDetails.MobilePhone,
                Email         = newPatientDetails.Email,
                Status        = newPatientDetails.Status
            };

            return(base.AddAsync(patient));
        }
        /// <summary>
        /// Creates a new Patient from the details provided
        /// </summary>
        /// <param name="newPatientDetails"></param>
        /// <returns></returns>
        public async Task <PatientDetailsDto> RegisterPatientAsync(PatientForRegistration newPatientDetails)
        {
            if (newPatientDetails == null)
            {
                throw new ArgumentNullException(nameof(newPatientDetails));
            }

            var patient = await _patientDal.AddAsync(newPatientDetails);

            return(patient != null ? new PatientDetailsDto(patient) : null);
        }