public ReferralModel(mp_referral referral) { id = referral.id; clinician_id = referral.clinician_id; profile_id = referral.profile_id; created_at = referral.created_at; created_by = referral.created_by; profile_match_id = referral.profile_match_id; referred_by = ProfileUtil.get_profile_name(referral.created_by, "role"); clinician = new DoctorModel(referral.clinician_); profile = new MemberModel(referral.profile_); profile_match = new ProfileMatchModel(referral.profile_match_); }
public async Task <IActionResult> PostReferral(IFormCollection collection) { var user_id = _userManager.GetUserId(HttpContext.User); var clinician = _clinicianService.Get().FirstOrDefault(e => e.user_id == user_id); var appointment_type_id = Convert.ToInt32(collection["appointment_type"]); var appointment_activity_id = Convert.ToInt32(collection["appointment_category"]); var appointment_activity_sub_id = Convert.ToInt32(collection["appointment_category_sub"]); var profile_id = Guid.Parse(collection["profile_id"]); var clinician_id = Guid.Parse(collection["clinician_id"]); var profile = _profileService.Get(profile_id); var profile_match = new mp_profile_match { appointment_type_id = appointment_type_id, appointment_activity_id = appointment_activity_id, appointment_activity_sub_id = appointment_activity_sub_id, clinician_id = clinician_id, profile_id = profile_id }; var profile_match_id = _profileMatchService.Add(profile_match); var referral = new mp_referral { profile_id = profile_id, clinician_id = clinician.id, profile_match_id = profile_match_id, created_by = user_id }; _referralService.Add(referral); //notify all the parties involved var notification = new mp_notification { created_by = "sys_admin", created_by_name = "System Admin", notification_type = 5, read = 0, user_id = profile.user_id, notification = "Hi " + profile.last_name + " " + profile.first_name + ", You have been referred to a provider for some services, check your referrals for more information", title = "New Referral" }; NotificationUtil.Add(notification); await _emailSender.SendEmailAsync(profile.email, "New Referral - MySpace MyTime", $"Hi " + profile.last_name + " " + profile.first_name + ", You have been referred to a provider for some services, login to your account and check your referrals for more information"); notification = new mp_notification { created_by = "sys_admin", created_by_name = "System Admin", notification_type = 5, read = 0, user_id = clinician.user_id, notification = "Hi " + clinician.last_name + " " + clinician.first_name + ", you have successfully referred" + profile.last_name + " " + profile.first_name + " to another provider for additional services. More information about this is available in your referrals.", title = "New Referral" }; NotificationUtil.Add(notification); await _emailSender.SendEmailAsync(clinician.email, "New Referral - MySpace MyTime", $"Hi " + clinician.last_name + " " + clinician.first_name + ", you have successfully referred" + profile.last_name + " " + profile.first_name + " to another provider for additional services. More information about this is available in your referrals when you login to your account"); return(Ok(200)); }
public void Add(mp_referral referral) { referral.created_at = DateTime.Now; _context.mp_referral.Add(referral); _context.SaveChanges(); }