Exemplo n.º 1
0
        private void AddPatientButton_Click(object sender, RoutedEventArgs e)
        {
            using (var context = new DataBaseContext())
            {
                var treatmentHistory = new DbTreatmentHistory()
                {
                    PastVaccinations     = new List <DbVaccination>(),
                    RequiredVaccinations = new List <DbVaccination>(),
                    Treatments           = new List <DbTreatment>()
                };
                context.TreatmentHistories.Add(treatmentHistory);
                context.SaveChanges();

                var newPatient = new DbPatient()
                {
                    FirstName         = NameTextBox.Text,
                    LastName          = SurnameTextBox.Text,
                    EmailAdress       = EmailTextBox.Text,
                    DateOfBirth       = BirthdayDatePicker.SelectedDate.Value,
                    NumberPesel       = Convert.ToInt64(PeselTextBox.Text),
                    City              = CityTextBox.Text,
                    StreetAdress      = AdressTextBox.Text,
                    PatientsPronounce = GenderComboBox.SelectedIndex == 0 ? Pronouns.MR : Pronouns.MRS,
                    EmailContact      = GetEmailContact(AdressComboBox.SelectedIndex),
                    TreatmentHistory  = treatmentHistory,
                    Visits            = new List <DbVisit>()
                };
                context.Patients.Add(newPatient);
                context.SaveChanges();
            }
        }
Exemplo n.º 2
0
        public async Task <string> RegisterAccountAsync(AccountRegister accountRegister)
        {
            var user = new DbPatient
            {
                FirstName            = accountRegister.FirstName,
                LastName             = accountRegister.LastName,
                UserName             = accountRegister.PhoneNumber.ToStandardFormatPhoneNumber(),
                Email                = accountRegister.Email,
                PhoneNumber          = accountRegister.PhoneNumber.ToStandardFormatPhoneNumber(),
                PhoneNumberConfirmed = false
            };

            var result = await _userManager.CreateAsync(user, accountRegister.Password);

            if (!result.Succeeded)
            {
                throw new BusinessException(ErrorCodes.IdentityError.ToString(), result.Errors?.FirstOrDefault().Description);
            }

            await _userManager.AddToRoleAsync(user, IdentityRoles.Patient);

            var verifiedToken = await _twoFactorAuthenticationService.RequestVerifiedTokenAsync(user.PhoneNumber);

            return(verifiedToken);
        }
Exemplo n.º 3
0
 private static void AddSingleRelationship(DataBaseContext context, DbVisit visit, DbPatient patient)
 {
     context.Visits.SingleOrDefault(v => v.Id == visit.Id).Patient = context.Patients.SingleOrDefault(p => p.Id == patient.Id);
     context.Patients.SingleOrDefault(p => p.Id == patient.Id).Visits.Add(context.Visits.SingleOrDefault(v => v.Id == visit.Id));
 }
Exemplo n.º 4
0
 public static void AddSingleCompleteRelationships(DataBaseContext context, DbVisit visit, DbMedicalWorker medicalWorker, DbPatient patient, DbSpecialization specialization)
 {
     if (!medicalWorker.Specializations.Contains(context.Specializations.SingleOrDefault(x => x.Id == specialization.Id)))
     {
         throw new Exception("In function AddSingleCompleteRelationships medicalWorker doesn't have required specialization");
     }
     AddSingleRelationship(context, visit, medicalWorker);
     AddSingleRelationship(context, visit, patient);
     AddSingleRelationship(context, visit, specialization);
 }
Exemplo n.º 5
0
 public static void AddSingleRelationship(DataBaseContext context, DbTreatmentHistory treatmentHistory, DbPatient patient)
 {
     context.Patients.SingleOrDefault(p => p.Id == patient.Id).TreatmentHistory = context.TreatmentHistories.SingleOrDefault(th => th.Id == treatmentHistory.Id);
 }