public IActionResult Add(ReferralDto referralDto)
        {
            if (_referralService.Add(referralDto) == null)
            {
                return(NotFound());
            }

            return(Ok(referralDto));
        }
Beispiel #2
0
 public async Task <IActionResult> AddReferralInformation(ReferralDto referral)
 {
     return(await GenerateApiResponse(() => _referralService.Add(referral)));
 }
        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));
        }