public Guid MatchProfile(mp_profile_match profile_match) { var user_id = _userManager.GetUserId(HttpContext.User); var profile = _profileService.GetProfileByUserId(user_id); profile_match.profile_id = profile.id; var match_id = _profileMatchService.Add(profile_match); return(match_id); }
public ProfileMatchModel(mp_profile_match match) { profile_id = match.profile_id; clinician_id = match.clinician_id; appointment_type_id = match.appointment_type_id; appointment_type = match.appointment_type_.name; appointment_activity_id = match.appointment_activity_id; appointment_activity = match.appointment_activity_.name; appointment_activity_sub_id = match.appointment_activity_sub_id; appointment_activity_sub = match.appointment_activity_sub_.name; created_at = match.created_at; clinician = new DoctorModel(match.clinician_); profile = new MemberModel(match.profile_); }
public Guid Add(mp_profile_match profile_match) { //check if the match already exists var old = _context.mp_profile_match.FirstOrDefault(e => e.profile_id == profile_match.profile_id && e.clinician_id == profile_match.clinician_id && e.appointment_type_id == profile_match.appointment_type_id && e.appointment_activity_id == profile_match.appointment_activity_id && e.appointment_activity_sub_id == profile_match.appointment_activity_sub_id); if (old != null) { return(old.id); } profile_match.id = Guid.NewGuid(); profile_match.created_at = DateTime.Now; _context.mp_profile_match.Add(profile_match); _context.SaveChanges(); return(profile_match.id); }
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)); }