public async Task <IActionResult> PostPrescription(mp_prescription prescription) { var user_id = _userManager.GetUserId(HttpContext.User); var clinician = _clinicianService.Get().FirstOrDefault(e => e.user_id == user_id); prescription.clinician_id = clinician.id; prescription.created_by = user_id; var prescription_id = _prescriptionService.AddPrescription(prescription); var collection = Request.Form; var drugs = collection["drug"].ToList(); var dosages = collection["dosage"].ToList(); var drug_text = ""; var prescription_drugs = new List <mp_prescription_drug>(); for (var i = 0; i < drugs.Count; i++) { prescription_drugs.Add(new mp_prescription_drug { drug = drugs[i], dosage = dosages[i], prescription_id = prescription_id }); drug_text += drugs[i] + " " + dosages[i] + ","; } _prescriptionService.AddPrescriptionDrugs(prescription_drugs); //get the profile information var profile = _profileService.Get(prescription.profile_id); var notification = new mp_notification { created_by = "sys_admin", created_by_name = "System Admin", notification_type = 7, read = 0, user_id = profile.user_id, notification = "Hi " + profile.last_name + " " + profile.first_name + ", Your prescription information has been updated, check your prescriptions for the details.", title = "New Prescription" }; NotificationUtil.Add(notification); await _emailSender.SendEmailAsync(profile.email, "New Prescription - MySpace MyTime", $"Hi " + profile.last_name + " " + profile.first_name + ", Your prescription information has been updated, check your prescriptions for the details."); if (prescription.pharmacy_id.HasValue) { //get the email of the pharmacy var pharmacy = _pharmacyService.Get().FirstOrDefault(e => e.id == prescription.pharmacy_id.Value); if (pharmacy != null && !string.IsNullOrEmpty(pharmacy.email)) { await _emailSender.SendEmailAsync(profile.email, "New Prescription - MySpace MyTime", $"The following prescriptions have been sent for " + profile.last_name + " " + profile.first_name + " - " + profile.unique_id.ToString("D10") + " .<br/>" + drug_text); } } return(Ok(200)); }
public async Task <ActionResult> Refund(string appointmentid) { try { var appointment_id = Guid.Parse(appointmentid); var appointment = _appointmentService.Get().Include(e => e.mp_credit) .Include(e => e.client_).Include(e => e.clinician_).FirstOrDefault(e => e.id == appointment_id); if (appointment.status != 169 && appointment.status != 234) { return(Ok("This appointment cannot be cancelled.")); } var user_notification = "An appointment that you created was cancelled."; Guid logged_user_id = Guid.Parse(_userManager.GetUserId(HttpContext.User)); var cancelled_by = 298; var profile = _profileService.GetByUserId(logged_user_id); //check if payment has been made for the appointment if (appointment.mp_credit.Any() && appointment.status != 171) { var creditInfo = appointment.mp_credit.FirstOrDefault(x => x.appointment_id == appointment.id); if (creditInfo != null) { var resundResponse = new PayStackHelper(_payStackSettings).Refund(creditInfo.transaction_reference); if (resundResponse) { user_notification += " Your payment will be processed shortly and you will get it back in the next 24 - 48 hours."; //refund the client var refund = new mp_appointment_refund { appointment_id = appointment_id, created_by = logged_user_id.ToString(), amount = appointment.mp_credit.FirstOrDefault().amount, cancelled_by = cancelled_by, status = 296 }; _appointmentRefundService.AddRefund(refund); } } } appointment.status = 171; appointment.cancelled_by = appointment.clinician_id; appointment.cancel_reason = "Cancel and Refund"; _appointmentService.Update(appointment); //notifications to the client and the clinician var notification = new mp_notification { created_by = "sys_admin", created_by_name = "System Admin", notification_type = 5, read = 0, user_id = appointment.client_.user_id, notification = "Hi " + appointment.client_.last_name + " " + appointment.client_.first_name + ", " + user_notification, title = "Appointment cancelled" }; NotificationUtil.Add(notification); await _emailSender.SendEmailAsync(appointment.client_.email, "Appointment cancelled - MySpace MyTime", $"Hi " + appointment.client_.last_name + " " + appointment.client_.first_name + ", " + user_notification); notification = new mp_notification { created_by = "sys_admin", created_by_name = "System Admin", notification_type = 5, read = 0, user_id = appointment.clinician_.user_id, notification = "Hi " + appointment.clinician_.last_name + " " + appointment.clinician_.first_name + ", an appointment scheduled with you have been cancelled.", title = "Appointment cancelled" }; NotificationUtil.Add(notification); await _emailSender.SendEmailAsync(appointment.clinician_.email, "Appointment cancelled - MySpace MyTime", $"Hi " + appointment.clinician_.last_name + " " + appointment.clinician_.first_name + ", an appointment scheduled with you have been cancelled."); return(Ok(200)); } catch (Exception ex) { return(Ok(ex.Message)); } }
public async Task CancelBySystem(string appointmentid) { Guid logged_user_id = Guid.Parse(_userManager.GetUserId(HttpContext.User)); var cancelReason = string.Empty; var appointment_id = Guid.Parse(appointmentid); var appointment = _appointmentService.Get().Include(e => e.mp_credit) .Include(e => e.client_).Include(e => e.clinician_).FirstOrDefault(e => e.id == appointment_id); if (appointment.status == 234) { var user_notification = "An appointment that you created was cancelled."; var cancelled_by = 298; var profile = _profileService.GetByUserId(logged_user_id); Guid?cancelById = null; if (User.IsInRole("client")) { var user_profile = _profileService.GetByUserId(logged_user_id); var bank = _profileBankService.GetProfileBank(user_profile.id); if (bank == null) { bank = new mp_profile_bank(); } cancelled_by = 297; bank.updated_by = logged_user_id.ToString(); bank.created_by = logged_user_id.ToString(); bank.profile_id = profile.id; cancelById = appointment.client_id; _profileBankService.AddOrUpdate(bank); cancelReason = "Clinician not avilable on time."; } if (User.IsInRole("clinician")) { cancelById = appointment.clinician_id; cancelReason = "Client not avilable on time."; } //check if payment has been made for the appointment if (appointment.mp_credit.Any() && appointment.status != 171 && User.IsInRole("clinician")) { var creditInfo = appointment.mp_credit.FirstOrDefault(x => x.appointment_id == appointment.id); if (creditInfo != null) { var resundResponse = new PayStackHelper(_payStackSettings).Refund(creditInfo.transaction_reference); if (resundResponse) { user_notification += " Your payment will be processed shortly and you will get it back in the next 24 - 48 hours."; //refund the client var refund = new mp_appointment_refund { appointment_id = appointment_id, created_by = logged_user_id.ToString(), amount = appointment.mp_credit.FirstOrDefault().amount, cancelled_by = cancelled_by, status = 296 }; _appointmentRefundService.AddRefund(refund); } } } appointment.status = 171; appointment.cancelled_by = cancelById; appointment.cancel_reason = cancelReason; _appointmentService.Update(appointment); //notifications to the client and the clinician var notification = new mp_notification { created_by = "sys_admin", created_by_name = "System Admin", notification_type = 5, read = 0, user_id = appointment.client_.user_id, notification = "Hi " + appointment.client_.last_name + " " + appointment.client_.first_name + ", " + user_notification + ", due to " + cancelReason, title = "Appointment cancelled" }; NotificationUtil.Add(notification); await _emailSender.SendEmailAsync(appointment.client_.email, "Appointment cancelled - MySpace MyTime", $"Hi " + appointment.client_.last_name + " " + appointment.client_.first_name + ", " + user_notification + ", due to " + cancelReason); notification = new mp_notification { created_by = "sys_admin", created_by_name = "System Admin", notification_type = 5, read = 0, user_id = appointment.clinician_.user_id, notification = "Hi " + appointment.clinician_.last_name + " " + appointment.clinician_.first_name + ", an appointment scheduled with you have been cancelled." + ", due to " + cancelReason, title = "Appointment cancelled" }; NotificationUtil.Add(notification); await _emailSender.SendEmailAsync(appointment.clinician_.email, "Appointment cancelled - MySpace MyTime", $"Hi " + appointment.clinician_.last_name + " " + appointment.clinician_.first_name + ", an appointment scheduled with you have been cancelled" + ", due to " + cancelReason); } }
public async Task <IActionResult> Cancel(mp_profile_bank bank) { var collection = Request.Form; var appointment_id = Guid.Parse(collection["appointment_id"]); var appointment = _appointmentService.Get().Include(e => e.mp_credit).Include(e => e.client_).Include(e => e.clinician_).FirstOrDefault(e => e.id == appointment_id); if (appointment.status != 169 && appointment.status != 234) { TempData["AlertType"] = "alert-warning"; TempData["AlertMessage"] = "This appointment cannot be cancelled."; return(RedirectToAction("Details", new { id = appointment_id })); } var user_notification = "An appointment that you created was cancelled."; Guid logged_user_id = Guid.Parse(_userManager.GetUserId(HttpContext.User)); var cancelled_by = 298; var profile = _profileService.GetByUserId(logged_user_id); Guid?cancelById = null; if (User.IsInRole("client")) { cancelled_by = 297; bank.updated_by = logged_user_id.ToString(); bank.created_by = logged_user_id.ToString(); bank.profile_id = profile.id; cancelById = appointment.client_id; _profileBankService.AddOrUpdate(bank); } if (User.IsInRole("clinician")) { cancelById = appointment.clinician_id; } //check if payment has been made for the appointment if (appointment.mp_credit.Any() && appointment.status != 171) { var creditInfo = appointment.mp_credit.FirstOrDefault(x => x.appointment_id == appointment.id); if (creditInfo != null) { var resundResponse = new PayStackHelper(_payStackSettings).Refund(creditInfo.transaction_reference); if (resundResponse) { user_notification += " Your payment will be processed shortly and you will get it back in the next 24 - 48 hours."; //refund the client var refund = new mp_appointment_refund { appointment_id = appointment_id, created_by = logged_user_id.ToString(), amount = appointment.mp_credit.FirstOrDefault().amount, cancelled_by = cancelled_by, status = 296 }; _appointmentRefundService.AddRefund(refund); } } } appointment.status = 171; appointment.cancelled_by = cancelById; appointment.cancel_reason = collection["comment"]; _appointmentService.Update(appointment); //notifications to the client and the clinician var notification = new mp_notification { created_by = "sys_admin", created_by_name = "System Admin", notification_type = 5, read = 0, user_id = appointment.client_.user_id, notification = "Hi " + appointment.client_.last_name + " " + appointment.client_.first_name + ", " + user_notification, title = "Appointment cancelled" }; NotificationUtil.Add(notification); await _emailSender.SendEmailAsync(appointment.client_.email, "Appointment cancelled - MySpace MyTime", $"Hi " + appointment.client_.last_name + " " + appointment.client_.first_name + ", " + user_notification); notification = new mp_notification { created_by = "sys_admin", created_by_name = "System Admin", notification_type = 5, read = 0, user_id = appointment.clinician_.user_id, notification = "Hi " + appointment.clinician_.last_name + " " + appointment.clinician_.first_name + ", an appointment scheduled with you have been cancelled.", title = "Appointment cancelled" }; NotificationUtil.Add(notification); await _emailSender.SendEmailAsync(appointment.clinician_.email, "Appointment cancelled - MySpace MyTime", $"Hi " + appointment.clinician_.last_name + " " + appointment.clinician_.first_name + ", an appointment scheduled with you have been cancelled."); return(RedirectToAction("CancelConfirmation")); }
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 async Task AppointmentScheduled(mp_appointment appointment, IList <ApplicationUser> admins) { var appointment_service = Options.GetAppointmentServices().FirstOrDefault(e => e.id == appointment.appointment_service); var appointment_details = "<strong>Date of appointment:</strong> " + appointment.start_date.ToString("dd MMM, yyyy hh:mm tt") + "<br/>"; appointment_details += "<strong>Appointment type: </strong>" + Options.GetAppointmentTypeName(appointment.appointment_type) + "<br/>"; appointment_details += "<strong>Appointment activity:</strong>" + Options.GetAppointmentSubActivityName(appointment.appointment_activity_sub_id) + "<br/>"; appointment_details += "<strong>Appointment service:</strong>" + appointment_service.name + "<br/>"; appointment_details += "<strong>Duration: </strong>" + appointment_service.time_minutes + " minutes <br/>"; var notification = new mp_notification { created_by = "sys_admin", created_by_name = "System Admin", notification_type = 3, read = 0, user_id = appointment.client_.user_id }; notification.title = "Appointment scheduled successfully"; notification.notification = "Appointment scheduled successfully.<br/><strong>Appointment details </strong><br/>" + appointment_details + "<strong>Provider : </strong>" + appointment.clinician_.last_name + " " + appointment.clinician_.first_name; NotificationUtil.Add(notification); await _emailSender.SendEmailAsync(appointment.client_.email, "Appointment successful - MySpace MyTime", $"Thanks you " + appointment.client_.last_name + " " + appointment.client_.first_name + ". Your appointment has been scheduled successfully.<br/><strong>Appointment details </strong><br/>" + appointment_details + "<strong>Provider : </strong>" + appointment.clinician_.last_name + " " + appointment.clinician_.first_name); notification = new mp_notification { created_by = "sys_admin", created_by_name = "System Admin", notification_type = 4, read = 0, user_id = appointment.clinician_.user_id }; //notification.user_id = appointment.clinician_.user_id; //notification.notification_type = 4; notification.title = "Appointment scheduled successfully"; notification.notification = "Appointment scheduled successfully.<br/><strong>Appointment details </strong><br/>" + appointment_details + "<strong>Member : </strong>" + appointment.client_.last_name + " " + appointment.client_.first_name; NotificationUtil.Add(notification); //NotificationUtil.AddNotification(notification); await _emailSender.SendEmailAsync(appointment.clinician_.email, "New appointment scheduled - MySpace MyTime", $"Hi " + appointment.clinician_.last_name + " " + appointment.clinician_.first_name + ", a new appointment has been scheduled for you.<br/><strong>Appointment details </strong><br/>" + appointment_details + "<strong>Member : </strong>" + appointment.client_.last_name + " " + appointment.client_.first_name); foreach (var admin in admins) { notification = new mp_notification { created_by = "sys_admin", created_by_name = "System Admin", notification_type = 4, read = 0, user_id = admin.Id }; notification.title = "Recieved Payment For An Appointment"; notification.notification = $"Recieved Payment For An Appointment, Clinician is " + appointment.clinician_.last_name + " " + appointment.clinician_.first_name + " and Member is " + appointment.client_.last_name + " " + appointment.client_.first_name; NotificationUtil.Add(notification); } }