Example #1
0
        public async Task <IActionResult> PostAsync(Transfer_Patient patient)
        {
            try
            {
                _logger.LogInformation($"Adding new patient.");
                var checkPatient = new CheckerClass(_patientRepository, _insuranceRepository);
                checkPatient.CheckPatient(patient);
                Inner_Patient transformedPatient = new Inner_Patient
                {
                    PatientId          = 0,
                    PatientFirstName   = patient.PatientFirstName,
                    PatientLastName    = patient.PatientLastName,
                    PatientPassword    = patient.PatientPassword,
                    PatientAddress1    = patient.PatientAddress1,
                    PatientCity        = patient.PatientCity,
                    PatientState       = patient.PatientState,
                    PatientZipcode     = patient.PatientZipcode,
                    PatientBirthDay    = patient.PatientBirthDay,
                    PatientPhoneNumber = patient.PatientPhoneNumber,
                    PatientEmail       = patient.PatientEmail,
                    Insurance          = await _insuranceRepository.GetInsuranceByIdAsync(patient.InsuranceId)
                };
                await _patientRepository.AddPatientAsync(transformedPatient);

                return(CreatedAtAction(nameof(GetByIdAsync), new { id = patient.PatientId }, patient));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Example #2
0
 public Task AddPatientAsync(Patient patientModel)
 {
     return(_patientRepository.AddPatientAsync(new Domain.Patient()
     {
         Id = patientModel.Id,
         DAmicoScore = patientModel.DAmicoScore,
         GleasonScore = patientModel.GleasonScore,
         DateOfSurgery = patientModel.DateOfSurgery,
         Psa = patientModel.Psa,
         Tnm = patientModel.Tnm,
         YearOfBirth = patientModel.YearOfBirth,
         Ptnm = patientModel.Ptnm
     }));
 }
        public async Task <PatientModel> AddNewPatientAsync(PatientModel patientModel)
        {
            var newPatient = await _patientRepository.AddPatientAsync(patientModel);

            if (newPatient != null)
            {
                if (_patientRepository.SaveChanges())
                {
                    return(newPatient);
                }
                else
                {
                    throw new Exception($"Failed to save patient to database, patient name: {patientModel.FirstName}");
                }
            }
            else
            {
                throw new Exception($"Failed to create patient, patient name: {patientModel.FirstName}");
            }
        }
Example #4
0
        /// <summary>
        /// This method does the following operations :
        ///Takes the patient records, converts it to XML and calls the repository for saving the information.
        ///
        /// </summary>
        /// <param name="patientDetailViewModel"></param>
        /// <returns></returns>
        public async Task <ApiBaseResponse> AddPatientAsync(PatientDetailViewModel patientDetailViewModel)
        {
            var response = new ApiBaseResponse();

            try
            {
                var patientDetail = new PatientDetail
                {
                    Record = patientDetailViewModel.SerializeObject()
                };
                await _patientRepository.AddPatientAsync(patientDetail);

                response.StatusCode = HttpStatusCode.OK;
            }
            catch (Exception ex)
            {
                response.StatusCode = HttpStatusCode.BadRequest;
                response.Error      = "Error Occured while saving patient information";
                _logger.LogError("Error Occured while saving patient information", ex);
            }
            return(response);
        }