public override T Convert <T, U>(U entity) { if (entity is AttorneyVisit) { AttorneyVisit AttorneyVisitDB = entity as AttorneyVisit; if (AttorneyVisitDB == null) { return(default(T)); } BO.AttorneyVisit AttorneyVisitBO = new BO.AttorneyVisit(); AttorneyVisitBO.ID = AttorneyVisitDB.Id; AttorneyVisitBO.CalendarEventId = AttorneyVisitDB.CalendarEventId; AttorneyVisitBO.CaseId = AttorneyVisitDB.CaseId; AttorneyVisitBO.PatientId = AttorneyVisitDB.PatientId; AttorneyVisitBO.CompanyId = AttorneyVisitDB.CompanyId; AttorneyVisitBO.AttorneyId = AttorneyVisitDB.AttorneyId; AttorneyVisitBO.EventStart = AttorneyVisitDB.EventStart; AttorneyVisitBO.EventEnd = AttorneyVisitDB.EventEnd; AttorneyVisitBO.Subject = AttorneyVisitDB.Subject; AttorneyVisitBO.VisitStatusId = AttorneyVisitDB.VisitStatusId; AttorneyVisitBO.ContactPerson = AttorneyVisitDB.ContactPerson; AttorneyVisitBO.Agenda = AttorneyVisitDB.Agenda; AttorneyVisitBO.IsDeleted = AttorneyVisitDB.IsDeleted; AttorneyVisitBO.CreateByUserID = AttorneyVisitDB.CreateByUserID; AttorneyVisitBO.UpdateByUserID = AttorneyVisitDB.UpdateByUserID; if (AttorneyVisitDB.Patient != null) { BO.Patient PatientBO = new BO.Patient(); using (PatientRepository patientRepo = new PatientRepository(_context)) { PatientBO = patientRepo.Convert <BO.Patient, Patient>(AttorneyVisitDB.Patient); AttorneyVisitBO.Patient = PatientBO; //if (AttorneyVisitDB.Patient.PatientInsuranceInfoes != null && AttorneyVisitDB.Patient.PatientInsuranceInfoes.Count > 0) //{ // List<BO.PatientInsuranceInfo> PatientInsuranceInfoBOList = new List<BO.PatientInsuranceInfo>(); // using (PatientInsuranceInfoRepository patientInsuranceInfoRepo = new PatientInsuranceInfoRepository(_context)) // { // foreach (PatientInsuranceInfo eachPatientInsuranceInfo in AttorneyVisitDB.Patient.PatientInsuranceInfoes) // { // if (eachPatientInsuranceInfo.IsDeleted.HasValue == false || (eachPatientInsuranceInfo.IsDeleted.HasValue == true && eachPatientInsuranceInfo.IsDeleted.Value == false)) // { // PatientInsuranceInfoBOList.Add(patientInsuranceInfoRepo.Convert<BO.PatientInsuranceInfo, PatientInsuranceInfo>(eachPatientInsuranceInfo)); // } // } // AttorneyVisitBO.Patient.PatientInsuranceInfoes = PatientInsuranceInfoBOList; // } //} } } if (AttorneyVisitDB.Case != null) { BO.Case CaseBO = new BO.Case(); using (CaseRepository caseRepo = new CaseRepository(_context)) { CaseBO = caseRepo.Convert <BO.Case, Case>(AttorneyVisitDB.Case); AttorneyVisitBO.Case = CaseBO; if (AttorneyVisitDB.Case.PatientAccidentInfoes != null && AttorneyVisitDB.Case.PatientAccidentInfoes.Count > 0) { List <BO.PatientAccidentInfo> PatientAccidentInfoBOList = new List <BO.PatientAccidentInfo>(); using (PatientAccidentInfoRepository patientAccidentInfoRepo = new PatientAccidentInfoRepository(_context)) { foreach (PatientAccidentInfo eachPatientInsuranceInfo in AttorneyVisitDB.Case.PatientAccidentInfoes) { if (eachPatientInsuranceInfo.IsDeleted.HasValue == false || (eachPatientInsuranceInfo.IsDeleted.HasValue == true && eachPatientInsuranceInfo.IsDeleted.Value == false)) { PatientAccidentInfoBOList.Add(patientAccidentInfoRepo.Convert <BO.PatientAccidentInfo, PatientAccidentInfo>(eachPatientInsuranceInfo)); } } AttorneyVisitBO.Case.PatientAccidentInfoes = PatientAccidentInfoBOList; } } } } if (AttorneyVisitDB.Company != null) { BO.Company boCompany = new BO.Company(); using (CompanyRepository cmp = new CompanyRepository(_context)) { boCompany = cmp.Convert <BO.Company, Company>(AttorneyVisitDB.Company); AttorneyVisitBO.Company = boCompany; } } if (AttorneyVisitDB.CalendarEvent != null) { AttorneyVisitBO.CalendarEvent = new BO.CalendarEvent(); using (CalendarEventRepository calEventRep = new CalendarEventRepository(_context)) { AttorneyVisitBO.CalendarEvent = calEventRep.Convert <BO.CalendarEvent, CalendarEvent>(AttorneyVisitDB.CalendarEvent); } } return((T)(object)AttorneyVisitBO); } else if (entity is CalendarEvent) { CalendarEvent CalendarEventDB = entity as CalendarEvent; if (CalendarEventDB == null) { return(default(T)); } BO.CalendarEvent CalendarEvent = new BO.CalendarEvent(); using (CalendarEventRepository calEventRep = new CalendarEventRepository(_context)) { CalendarEvent = calEventRep.Convert <BO.CalendarEvent, CalendarEvent>(CalendarEventDB); } return((T)(object)CalendarEvent); } return(default(T)); }
public T ConvertIMEvisit <T, U>(U entity) { if (entity is IMEVisit) { IMEVisit IMEVisit = entity as IMEVisit; if (IMEVisit == null) { return(default(T)); } BO.IMEVisit IMEVisitBO = new BO.IMEVisit(); IMEVisitBO.ID = IMEVisit.ID; IMEVisitBO.CalendarEventId = IMEVisit.CalendarEventId; IMEVisitBO.CaseId = IMEVisit.CaseId; IMEVisitBO.PatientId = IMEVisit.PatientId; IMEVisitBO.EventStart = IMEVisit.EventStart; IMEVisitBO.EventEnd = IMEVisit.EventEnd; IMEVisitBO.Notes = IMEVisit.Notes; IMEVisitBO.VisitStatusId = IMEVisit.VisitStatusId; IMEVisitBO.TransportProviderId = IMEVisit.TransportProviderId; IMEVisitBO.DoctorName = IMEVisit.DoctorName; IMEVisitBO.VisitCreatedByCompanyId = IMEVisit.VisitCreatedByCompanyId; IMEVisitBO.IsDeleted = IMEVisit.IsDeleted; IMEVisitBO.CreateByUserID = IMEVisit.CreateByUserID; IMEVisitBO.UpdateByUserID = IMEVisit.UpdateByUserID; if (IMEVisit.Patient != null) { BO.Patient PatientBO = new BO.Patient(); using (PatientRepository patientRepo = new PatientRepository(_context)) { PatientBO = patientRepo.Convert <BO.Patient, Patient>(IMEVisit.Patient); IMEVisitBO.Patient = PatientBO; } } if (IMEVisit.TransportProviderId != null) { BO.Company CompanyBO = new BO.Company(); using (PatientRepository patientRepo = new PatientRepository(_context)) { CompanyBO = patientRepo.Convert <BO.Company, Company>(IMEVisit.Company); IMEVisitBO.Company = CompanyBO; } } if (IMEVisit.CalendarEvent != null) { IMEVisitBO.CalendarEvent = new BO.CalendarEvent(); using (CalendarEventRepository calEventRep = new CalendarEventRepository(_context)) { IMEVisitBO.CalendarEvent = calEventRep.Convert <BO.CalendarEvent, CalendarEvent>(IMEVisit.CalendarEvent); } } return((T)(object)IMEVisitBO); } return(default(T)); }
public override object SaveIMEVisit <T>(T entity) { BO.IMEVisit IMEVisitBO = (BO.IMEVisit)(object) entity; BO.CalendarEvent CalendarEventBO = IMEVisitBO.CalendarEvent; string patientUserName = string.Empty; bool sendNotification = false; bool sendMessage = false; //CalenderEventBO if (CalendarEventBO != null) { List <BO.FreeSlots> currentEventSlots = new List <BO.FreeSlots>(); CalendarEventRepository calEventRepo = new CalendarEventRepository(_context); currentEventSlots = calEventRepo.GetBusySlotsByCalendarEvent(CalendarEventBO) as List <BO.FreeSlots>; if (currentEventSlots.Count > 0) { DateTime dtStartDate = currentEventSlots.Min(p => p.ForDate); DateTime dtEndDate = currentEventSlots.Max(p => p.ForDate).AddDays(1); List <BO.StartAndEndTime> busySlots = new List <BO.StartAndEndTime>(); if (IMEVisitBO.PatientId != null) { var result = calEventRepo.GetBusySlotsForPatients(IMEVisitBO.PatientId.Value, dtStartDate, dtEndDate); if (result is BO.ErrorObject) { return(result); } else { busySlots = result as List <BO.StartAndEndTime>; } } if (busySlots != null && busySlots.Count > 0) { foreach (var eachDayEventSlot in currentEventSlots) { DateTime ForDate = eachDayEventSlot.ForDate; foreach (var eachEventSlot in eachDayEventSlot.StartAndEndTimes) { DateTime StartTime = eachEventSlot.StartTime; DateTime EndTime = eachEventSlot.EndTime; var StartAndEndTimesForDate = busySlots.Where(p => p.StartTime.Date == ForDate).ToList(); if (StartAndEndTimesForDate.Count > 0) { var StartAndEndTimes = StartAndEndTimesForDate.Where(p => p.StartTime >= StartTime && p.StartTime < EndTime).ToList(); if (StartAndEndTimes.Count > 0) { DateTime?checkContinuation = null; foreach (var eachSlot in StartAndEndTimes.Distinct().OrderBy(p => p.StartTime)) { if (checkContinuation.HasValue == false) { checkContinuation = eachSlot.EndTime; } else { if (checkContinuation.Value != eachSlot.StartTime) { return(new BO.ErrorObject { errorObject = "", ErrorMessage = "The patient dosent have continued free slots on the planned visit time of " + checkContinuation.Value.ToString() + ".", ErrorLevel = ErrorLevel.Error }); } else { checkContinuation = eachSlot.EndTime; } } } } else { //return new BO.ErrorObject { errorObject = "", ErrorMessage = "The patient dosent have free slots on the planned visit time of " + ForDate.ToShortDateString() + " (" + StartTime.ToShortTimeString() + " - " + EndTime.ToShortTimeString() + ").", ErrorLevel = ErrorLevel.Error }; } } else { //return new BO.ErrorObject { errorObject = "", ErrorMessage = "The patient is not availabe on " + ForDate.ToShortDateString() + ".", ErrorLevel = ErrorLevel.Error }; } } } } } } IMEVisit IMEVisitDB = new IMEVisit(); using (var dbContextTransaction = _context.Database.BeginTransaction()) { bool IsEditMode = false; bool IsAddModeCalendarEvent = false; IsEditMode = (IMEVisitBO != null && IMEVisitBO.ID > 0) ? true : false; string patientContactNumber = null; User patientuser = null; if (IMEVisitBO.PatientId == null && IMEVisitBO.ID > 0) { var IMEvisitData = _context.IMEVisits.Where(p => p.ID == IMEVisitBO.ID).Select(p => new { p.PatientId, p.CaseId }).FirstOrDefault(); patientuser = _context.Users.Where(usr => usr.id == IMEvisitData.PatientId).Include("ContactInfo").FirstOrDefault(); } else if (IMEVisitBO.PatientId != null && IMEVisitBO.PatientId > 0) { patientuser = _context.Users.Where(usr => usr.id == IMEVisitBO.PatientId).Include("ContactInfo").FirstOrDefault(); } if (patientuser != null) { patientUserName = patientuser.UserName; patientContactNumber = patientuser.ContactInfo.CellPhone; } CalendarEvent CalendarEventDB = new CalendarEvent(); #region Calendar Event if (CalendarEventBO != null) { bool Add_CalendarEventDB = false; CalendarEventDB = _context.CalendarEvents.Where(p => p.Id == CalendarEventBO.ID && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))) .FirstOrDefault(); if (CalendarEventDB == null && CalendarEventBO.ID <= 0) { CalendarEventDB = new CalendarEvent(); Add_CalendarEventDB = true; } else if (CalendarEventDB == null && CalendarEventBO.ID > 0) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { errorObject = "", ErrorMessage = "Calendar Event details dosent exists.", ErrorLevel = ErrorLevel.Error }); } //if (string.IsNullOrWhiteSpace(patientUserName) == false && dictionary.ContainsKey(patientUserName)) //{ // if (CalendarEventDB.EventStart != CalendarEventBO.EventStart.Value) sendNotification = true; //} CalendarEventDB.Name = IsEditMode == true && CalendarEventBO.Name == null ? CalendarEventDB.Name : CalendarEventBO.Name; CalendarEventDB.EventStart = IsEditMode == true && CalendarEventBO.EventStart.HasValue == false ? CalendarEventDB.EventStart : CalendarEventBO.EventStart.Value; CalendarEventDB.EventEnd = IsEditMode == true && CalendarEventBO.EventEnd.HasValue == false ? CalendarEventDB.EventEnd : CalendarEventBO.EventEnd.Value; CalendarEventDB.TimeZone = CalendarEventBO.TimeZone; CalendarEventDB.Description = CalendarEventBO.Description; CalendarEventDB.RecurrenceId = CalendarEventBO.RecurrenceId; CalendarEventDB.RecurrenceRule = IsEditMode == true && CalendarEventBO.RecurrenceRule == null ? CalendarEventDB.RecurrenceRule : CalendarEventBO.RecurrenceRule; CalendarEventDB.RecurrenceException = IsEditMode == true && CalendarEventBO.RecurrenceException == null ? CalendarEventDB.RecurrenceException : CalendarEventBO.RecurrenceException; CalendarEventDB.IsAllDay = CalendarEventBO.IsAllDay; if (IsEditMode == false) { CalendarEventDB.CreateByUserID = CalendarEventBO.CreateByUserID; CalendarEventDB.CreateDate = DateTime.UtcNow; } else { CalendarEventDB.UpdateByUserID = CalendarEventBO.UpdateByUserID; CalendarEventDB.UpdateDate = DateTime.UtcNow; } if (Add_CalendarEventDB == true) { CalendarEventDB = _context.CalendarEvents.Add(CalendarEventDB); } _context.SaveChanges(); //#region send SMS notification //try //{ // if (sendNotification) // { // if (patientContactNumber != null && patientContactNumber != string.Empty) // { // string to = patientContactNumber; // //string body = "Your appointment has been scheduled at " + CalendarEventBO.EventStart.Value + " in " + _context.Locations.Where(loc => loc.id == patientVisitBO.LocationId).Select(lc => lc.Name).FirstOrDefault(); // string body = ""; // string msgid = SMSGateway.SendSMS(to, body); // } // } //} //catch (Exception) { } //#endregion } else { if (IsEditMode == false && IMEVisitBO.CalendarEventId <= 0) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { errorObject = "", ErrorMessage = "Please pass valid Calendar Event details.", ErrorLevel = ErrorLevel.Error }); } CalendarEventDB = null; } #endregion #region IME Visit if (IMEVisitBO != null && ((IMEVisitBO.ID <= 0 && IMEVisitBO.PatientId.HasValue == true) || (IMEVisitBO.ID > 0))) { bool Add_IMEVisitDB = false; IMEVisitDB = _context.IMEVisits.Where(p => p.ID == IMEVisitBO.ID && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))) .FirstOrDefault(); if (IMEVisitDB == null && IMEVisitBO.ID <= 0) { IMEVisitDB = new IMEVisit(); Add_IMEVisitDB = true; sendMessage = true; } else if (IMEVisitDB == null && IMEVisitBO.ID > 0) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { errorObject = "", ErrorMessage = "Patient Visit doesn't exists.", ErrorLevel = ErrorLevel.Error }); } IMEVisitDB.CalendarEventId = (CalendarEventDB != null && CalendarEventDB.Id > 0) ? CalendarEventDB.Id : ((IMEVisitBO.CalendarEventId.HasValue == true) ? IMEVisitBO.CalendarEventId.Value : IMEVisitDB.CalendarEventId); if (IsEditMode == false && IMEVisitBO.CaseId.HasValue == false) { int CaseId = _context.Cases.Where(p => p.PatientId == IMEVisitBO.PatientId.Value && p.CaseStatusId == 1 && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))) .Select(p => p.Id) .FirstOrDefault <int>(); if (CaseId == 0) { return(new BO.ErrorObject { errorObject = "", ErrorMessage = "No open case exists for given patient.", ErrorLevel = ErrorLevel.Error }); } else if (IMEVisitBO.CaseId.HasValue == true && IMEVisitBO.CaseId.Value != CaseId) { return(new BO.ErrorObject { errorObject = "", ErrorMessage = "Case id dosent match with open case is for the given patient.", ErrorLevel = ErrorLevel.Error }); } else { IMEVisitDB.CaseId = CaseId; } } else { IMEVisitDB.CaseId = IMEVisitBO.CaseId.HasValue == false ? IMEVisitDB.CaseId : IMEVisitBO.CaseId.Value; } IMEVisitDB.PatientId = IsEditMode == true && IMEVisitBO.PatientId.HasValue == false ? IMEVisitDB.PatientId : (IMEVisitBO.PatientId.HasValue == false ? IMEVisitDB.PatientId : IMEVisitBO.PatientId.Value); IMEVisitDB.EventStart = IMEVisitBO.EventStart; IMEVisitDB.EventEnd = IMEVisitBO.EventEnd; IMEVisitDB.Notes = IMEVisitBO.Notes; IMEVisitDB.VisitStatusId = IMEVisitBO.VisitStatusId; IMEVisitDB.TransportProviderId = IMEVisitBO.TransportProviderId; IMEVisitDB.DoctorName = IMEVisitBO.DoctorName; IMEVisitDB.VisitCreatedByCompanyId = IsEditMode == true ? IMEVisitDB.VisitCreatedByCompanyId : IMEVisitBO.VisitCreatedByCompanyId.Value; if (IsEditMode == false) { IMEVisitDB.CreateByUserID = IMEVisitBO.CreateByUserID; IMEVisitDB.CreateDate = DateTime.UtcNow; } else { IMEVisitDB.UpdateByUserID = IMEVisitBO.UpdateByUserID; IMEVisitDB.UpdateDate = DateTime.UtcNow; } if (Add_IMEVisitDB == true) { IMEVisitDB = _context.IMEVisits.Add(IMEVisitDB); } _context.SaveChanges(); } else { if (IsEditMode == false && IsAddModeCalendarEvent == false) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { errorObject = "", ErrorMessage = "Please pass valid Patient Visit details.", ErrorLevel = ErrorLevel.Error }); } IMEVisitDB = null; } _context.SaveChanges(); #endregion dbContextTransaction.Commit(); if (IMEVisitDB != null) { IMEVisitDB = _context.IMEVisits.Include("CalendarEvent") .Include("Patient").Include("Patient.Cases") .Include("Patient.User").Include("Patient.User.UserCompanies") .Where(p => p.ID == IMEVisitDB.ID && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))) .FirstOrDefault <IMEVisit>(); } else if (CalendarEventDB != null) { IMEVisitDB = _context.IMEVisits.Include("CalendarEvent") .Where(p => p.CalendarEvent.Id == CalendarEventDB.Id && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))) .FirstOrDefault <IMEVisit>(); } } if (sendMessage == true) { try { IdentityHelper identityHelper = new IdentityHelper(); User AdminUser = _context.Users.Include("ContactInfo").Include("UserCompanies").Include("UserCompanies.company") .Where(p => p.UserName == identityHelper.Email && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))) .FirstOrDefault(); User patientInfo = _context.Users.Include("ContactInfo").Include("UserCompanies").Include("UserCompanies.company") .Where(p => p.id == IMEVisitBO.PatientId && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))) .FirstOrDefault(); User ancillaryInfo = _context.Users.Include("ContactInfo").Include("UserCompanies").Include("UserCompanies.company") .Where(p => p.UserType == 5 && p.UserCompanies.Where(p1 => p1.CompanyID == IMEVisitBO.TransportProviderId && (p1.IsDeleted.HasValue == false || (p1.IsDeleted.HasValue == true && p1.IsDeleted.Value == false))).Any() == true && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))).FirstOrDefault(); List <User> lstStaff = _context.Users.Include("ContactInfo").Include("UserCompanies").Include("UserCompanies.company") .Where(p => p.UserType == 2 && p.UserCompanies.Where(p1 => p1.CompanyID == IMEVisitBO.VisitCreatedByCompanyId && (p1.IsDeleted.HasValue == false || (p1.IsDeleted.HasValue == true && p1.IsDeleted.Value == false))).Any() && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))) .ToList <User>(); //string VerificationLink = "<a href='" + Utility.GetConfigValue("PatientVerificationLink") + "/" + invitationDB_UniqueID + "' target='_blank'>" + Utility.GetConfigValue("PatientVerificationLink") + "/" + invitationDB_UniqueID + "</a>"; string MailMessageForPatient = "<B> New Appointment Scheduled</B></ BR >Medical provider has schedule a patient visit with Doctor: " + IMEVisitBO.DoctorName + "<br><br>Thanks"; string MailMessageForAdmin = "<B> New Appointment Scheduled</B></BR>A new Appointment schedule for patient : " + patientInfo.FirstName + " " + patientInfo.LastName + " is schedule with doctor:" + IMEVisitBO.DoctorName + "<br><br>Thanks"; string MailMessageForAncillary = "<B> New Appointment Scheduled</B></BR>A new Appointment schedule for patient : " + patientInfo.FirstName + " " + patientInfo.LastName + " is schedule with doctor:" + IMEVisitBO.DoctorName + "<br><br>Thanks"; string NotificationForPatient = "Medical provider has schedule a patient visit with Doctor: " + IMEVisitBO.DoctorName; string NotificationForAdmin = "New Appointment schedule for patient : " + patientInfo.FirstName + " " + patientInfo.LastName + " is schedule with doctor:" + IMEVisitBO.DoctorName; string NotificationForAncillary = "New Appointment schedule for patient : " + patientInfo.FirstName + " " + patientInfo.LastName + " is schedule with doctor:" + IMEVisitBO.DoctorName; string SmsMessageForPatient = "<B> New Appointment Scheduled</B></ BR >Medical provider has schedule a patient visit with Doctor: " + IMEVisitBO.DoctorName + "<br><br>Thanks"; string SmsMessageForAdmin = "<B> New Appointment Scheduled</B></BR>A new Appointment schedule for patient : " + patientInfo.FirstName + " " + patientInfo.LastName + " is schedule with doctor:" + IMEVisitBO.DoctorName + "<br><br>Thanks"; string SmsMessageForAncillary = "<B> New Appointment Scheduled</B></BR>A new Appointment schedule for patient : " + patientInfo.FirstName + " " + patientInfo.LastName + " is schedule with doctor:" + IMEVisitBO.DoctorName + "<br><br>Thanks"; string MailMessageForStaff = "<B> New Appointment Scheduled</B></BR>A new Appointment schedule for patient : " + patientInfo.FirstName + " " + patientInfo.LastName + "<br><br>Thanks"; string NotificationForStaff = "New Appointment schedule for patient : " + patientInfo.FirstName + " " + patientInfo.LastName; string SmsMessageForStaff = "<B> New Appointment Scheduled</B></BR>A new Appointment schedule for patient : " + patientInfo.FirstName + " " + patientInfo.LastName + "<br><br>Thanks"; #region patient mail object BO.EmailMessage emPatient = new BO.EmailMessage(); if (patientInfo != null) { emPatient.ApplicationName = "Midas"; emPatient.ToEmail = patientInfo.UserName;; emPatient.EMailSubject = "MIDAS Notification"; emPatient.EMailBody = MailMessageForPatient; } #endregion #region patient sms object BO.SMS smsPatient = new BO.SMS(); if (patientInfo != null) { smsPatient.ApplicationName = "Midas"; smsPatient.ToNumber = patientInfo.ContactInfo.CellPhone; smsPatient.Message = SmsMessageForPatient; } #endregion #region admin mail object BO.EmailMessage emAdmin = new BO.EmailMessage(); if (identityHelper != null) { emAdmin.ApplicationName = "Midas"; emAdmin.ToEmail = identityHelper.Email; emAdmin.EMailSubject = "MIDAS Notification"; emAdmin.EMailBody = MailMessageForAdmin; } #endregion #region admin sms object BO.SMS smsAdmin = new BO.SMS(); if (AdminUser != null) { smsAdmin.ApplicationName = "Midas"; smsAdmin.ToNumber = AdminUser.ContactInfo.CellPhone; smsAdmin.Message = SmsMessageForAdmin; } #endregion #region Ancillary mail object BO.EmailMessage emAncillary = new BO.EmailMessage(); if (ancillaryInfo != null) { emAdmin.ApplicationName = "Midas"; emAdmin.ToEmail = ancillaryInfo.UserName; emAdmin.EMailSubject = "MIDAS Notification"; emAdmin.EMailBody = MailMessageForAncillary; } #endregion #region Ancillary sms object BO.SMS smsAncillary = new BO.SMS(); if (ancillaryInfo != null) { smsAdmin.ApplicationName = "Midas"; smsAdmin.ToNumber = ancillaryInfo.ContactInfo.CellPhone; smsAdmin.Message = SmsMessageForAncillary; } #endregion NotificationHelper nh = new NotificationHelper(); MessagingHelper mh = new MessagingHelper(); #region Patient nh.PushNotification(patientInfo.UserName, patientInfo.UserCompanies.Select(p => p.Company.id).FirstOrDefault(), NotificationForPatient, "New Appointment Schedule"); mh.SendEmailAndSms(patientInfo.UserName, patientInfo.UserCompanies.Select(p => p.Company.id).FirstOrDefault(), emPatient, smsPatient); #endregion #region admin and staff if (AdminUser.UserType == 4 || AdminUser.UserType == 3) { nh.PushNotification(AdminUser.UserName, AdminUser.UserCompanies.Select(p => p.Company.id).FirstOrDefault(), NotificationForAdmin, "New Appointment Schedule"); mh.SendEmailAndSms(AdminUser.UserName, AdminUser.UserCompanies.Select(p => p.Company.id).FirstOrDefault(), emAdmin, smsAdmin); foreach (var item in lstStaff) { #region staff mail object BO.EmailMessage emStaff = new BO.EmailMessage(); emAdmin.ApplicationName = "Midas"; emAdmin.ToEmail = item.UserName; emAdmin.EMailSubject = "MIDAS Notification"; emAdmin.EMailBody = MailMessageForStaff; #endregion #region admin sms object BO.SMS smsStaff = new BO.SMS(); smsAdmin.ApplicationName = "Midas"; smsAdmin.ToNumber = item.ContactInfo.CellPhone; smsAdmin.Message = SmsMessageForStaff; #endregion nh.PushNotification(item.UserName, AdminUser.UserCompanies.Select(p => p.Company.id).FirstOrDefault(), NotificationForStaff, "New Appointment Schedule"); mh.SendEmailAndSms(item.UserName, AdminUser.UserCompanies.Select(p => p.Company.id).FirstOrDefault(), emStaff, smsStaff); } } else { foreach (var item in lstStaff) { #region staff mail object BO.EmailMessage emStaff = new BO.EmailMessage(); emAdmin.ApplicationName = "Midas"; emAdmin.ToEmail = item.UserName; emAdmin.EMailSubject = "MIDAS Notification"; emAdmin.EMailBody = MailMessageForStaff; #endregion #region admin sms object BO.SMS smsStaff = new BO.SMS(); smsAdmin.ApplicationName = "Midas"; smsAdmin.ToNumber = item.ContactInfo.CellPhone; smsAdmin.Message = SmsMessageForStaff; #endregion nh.PushNotification(item.UserName, AdminUser.UserCompanies.Select(p => p.Company.id).FirstOrDefault(), NotificationForStaff, "New Appointment Schedule"); mh.SendEmailAndSms(item.UserName, AdminUser.UserCompanies.Select(p => p.Company.id).FirstOrDefault(), emStaff, smsStaff); } } #endregion #region Ancillary if (IMEVisitBO.TransportProviderId != null) { nh.PushNotification(ancillaryInfo.UserName, ancillaryInfo.UserCompanies.Select(p => p.Company.id).FirstOrDefault(), NotificationForAncillary, "New Appointment Schedule"); mh.SendEmailAndSms(ancillaryInfo.UserName, ancillaryInfo.UserCompanies.Select(p => p.Company.id).FirstOrDefault(), emAncillary, smsAncillary); } #endregion } catch (Exception ex) { } } var res = ConvertIMEvisit <BO.IMEVisit, IMEVisit>(IMEVisitDB); return((object)res); }
public T ConvertEOvisit <T, U>(U entity) { if (entity is EOVisit) { EOVisit EOVisit = entity as EOVisit; if (EOVisit == null) { return(default(T)); } BO.EOVisit EOVisitBO = new BO.EOVisit(); EOVisitBO.ID = EOVisit.ID; EOVisitBO.CalendarEventId = EOVisit.CalendarEventId; EOVisitBO.DoctorId = EOVisit.DoctorId; EOVisitBO.PatientId = EOVisit.PatientId; EOVisitBO.VisitCreatedByCompanyId = EOVisit.PatientId; EOVisitBO.InsuranceProviderId = EOVisit.InsuranceProviderId; EOVisitBO.VisitStatusId = EOVisit.VisitStatusId; EOVisitBO.EventStart = EOVisit.EventStart; EOVisitBO.EventEnd = EOVisit.EventEnd; EOVisitBO.Notes = EOVisit.Notes; EOVisitBO.IsDeleted = EOVisit.IsDeleted; EOVisitBO.CreateByUserID = EOVisit.CreateByUserID; EOVisitBO.UpdateByUserID = EOVisit.UpdateByUserID; if (EOVisit.Doctor != null) { BO.Doctor doctorBO = new BO.Doctor(); using (DoctorRepository patientRepo = new DoctorRepository(_context)) { doctorBO = patientRepo.Convert <BO.Doctor, Doctor>(EOVisit.Doctor); EOVisitBO.Doctor = doctorBO; } } if (EOVisit.Patient != null) { BO.Patient PatientBO = new BO.Patient(); using (PatientRepository patientRepo = new PatientRepository(_context)) { PatientBO = patientRepo.Convert <BO.Patient, Patient>(EOVisit.Patient); EOVisitBO.Patient = PatientBO; } } if (EOVisit.Company != null) { BO.Company CompanyBO = new BO.Company(); using (CompanyRepository companyRepo = new CompanyRepository(_context)) { CompanyBO = companyRepo.Convert <BO.Company, Company>(EOVisit.Company); EOVisitBO.Company = CompanyBO; } } if (EOVisit.InsuranceMaster != null) { BO.InsuranceMaster InsuranceMasterBO = new BO.InsuranceMaster(); using (InsuranceMasterRepository InsuranceMasterRepo = new InsuranceMasterRepository(_context)) { InsuranceMasterBO = InsuranceMasterRepo.ObjectConvert <BO.InsuranceMaster, InsuranceMaster>(EOVisit.InsuranceMaster); EOVisitBO.InsuranceMaster = InsuranceMasterBO; } } if (EOVisit.CalendarEvent != null) { EOVisitBO.CalendarEvent = new BO.CalendarEvent(); using (CalendarEventRepository calEventRep = new CalendarEventRepository(_context)) { EOVisitBO.CalendarEvent = calEventRep.Convert <BO.CalendarEvent, CalendarEvent>(EOVisit.CalendarEvent); } } return((T)(object)EOVisitBO); } return(default(T)); }
public override object SaveEOVisit <T>(T entity) { BO.EOVisit EOVisitBO = (BO.EOVisit)(object) entity; BO.CalendarEvent CalendarEventBO = EOVisitBO.CalendarEvent; BO.Doctor DoctorBO = EOVisitBO.Doctor; string doctorUserName = string.Empty; bool sendNotification = false; bool sendMessage = false; //CalenderEventBO if (CalendarEventBO != null) { List <BO.FreeSlots> currentEventSlots = new List <BO.FreeSlots>(); CalendarEventRepository calEventRepo = new CalendarEventRepository(_context); currentEventSlots = calEventRepo.GetBusySlotsByCalendarEvent(CalendarEventBO) as List <BO.FreeSlots>; if (currentEventSlots.Count > 0) { DateTime dtStartDate = currentEventSlots.Min(p => p.ForDate); DateTime dtEndDate = currentEventSlots.Max(p => p.ForDate).AddDays(1); List <BO.StartAndEndTime> busySlots = new List <BO.StartAndEndTime>(); if (EOVisitBO.DoctorId != null) { var result = calEventRepo.GetBusySlotsForDoctors(EOVisitBO.DoctorId.Value, dtStartDate, dtEndDate); if (result is BO.ErrorObject) { return(result); } else { busySlots = result as List <BO.StartAndEndTime>; } } foreach (var eachDayEventSlot in currentEventSlots) { DateTime ForDate = eachDayEventSlot.ForDate; foreach (var eachEventSlot in eachDayEventSlot.StartAndEndTimes) { DateTime StartTime = eachEventSlot.StartTime; DateTime EndTime = eachEventSlot.EndTime; var StartAndEndTimesForDate = busySlots.Where(p => p.StartTime.Date == ForDate).ToList(); if (StartAndEndTimesForDate.Count > 0) { var StartAndEndTimes = StartAndEndTimesForDate.Where(p => p.StartTime >= StartTime && p.StartTime < EndTime).ToList(); if (StartAndEndTimes.Count > 0) { return(new BO.ErrorObject { errorObject = "", ErrorMessage = "The Doctor dosent have free slots for EO visit time on " + ForDate.ToShortDateString() + " (" + StartTime.ToShortTimeString() + " - " + EndTime.ToShortTimeString() + ").", ErrorLevel = ErrorLevel.Error }); } } } } } } EOVisit EOVisitDB = new EOVisit(); using (var dbContextTransaction = _context.Database.BeginTransaction()) { bool IsEditMode = false; bool IsAddModeCalendarEvent = false; IsEditMode = (EOVisitBO != null && EOVisitBO.ID > 0) ? true : false; string doctorContactNumber = null; User doctoruser = null; if (EOVisitBO.DoctorId == null && EOVisitBO.ID > 0) { var EOvisitData = _context.EOVisits.Where(p => p.ID == EOVisitBO.ID).Select(p => new { p.DoctorId }).FirstOrDefault(); doctoruser = _context.Users.Where(usr => usr.id == EOvisitData.DoctorId).Include("ContactInfo").FirstOrDefault(); } else if (EOVisitBO.DoctorId != null && EOVisitBO.DoctorId > 0) { doctoruser = _context.Users.Where(usr => usr.id == EOVisitBO.DoctorId).Include("ContactInfo").FirstOrDefault(); } if (doctoruser != null) { doctorUserName = doctoruser.UserName; doctorContactNumber = doctoruser.ContactInfo.CellPhone; } CalendarEvent CalendarEventDB = new CalendarEvent(); #region Calendar Event if (CalendarEventBO != null) { bool Add_CalendarEventDB = false; CalendarEventDB = _context.CalendarEvents.Where(p => p.Id == CalendarEventBO.ID && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))) .FirstOrDefault(); if (CalendarEventDB == null && CalendarEventBO.ID <= 0) { CalendarEventDB = new CalendarEvent(); Add_CalendarEventDB = true; } else if (CalendarEventDB == null && CalendarEventBO.ID > 0) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { errorObject = "", ErrorMessage = "Calendar Event details dosent exists.", ErrorLevel = ErrorLevel.Error }); } //if (string.IsNullOrWhiteSpace(doctorUserName) == false && dictionary.ContainsKey(doctorUserName)) //{ // if (CalendarEventDB.EventStart != CalendarEventBO.EventStart.Value) sendNotification = true; //} CalendarEventDB.Name = IsEditMode == true && CalendarEventBO.Name == null ? CalendarEventDB.Name : CalendarEventBO.Name; CalendarEventDB.EventStart = IsEditMode == true && CalendarEventBO.EventStart.HasValue == false ? CalendarEventDB.EventStart : CalendarEventBO.EventStart.Value; CalendarEventDB.EventEnd = IsEditMode == true && CalendarEventBO.EventEnd.HasValue == false ? CalendarEventDB.EventEnd : CalendarEventBO.EventEnd.Value; CalendarEventDB.TimeZone = CalendarEventBO.TimeZone; CalendarEventDB.Description = CalendarEventBO.Description; CalendarEventDB.RecurrenceId = CalendarEventBO.RecurrenceId; CalendarEventDB.RecurrenceRule = IsEditMode == true && CalendarEventBO.RecurrenceRule == null ? CalendarEventDB.RecurrenceRule : CalendarEventBO.RecurrenceRule; CalendarEventDB.RecurrenceException = IsEditMode == true && CalendarEventBO.RecurrenceException == null ? CalendarEventDB.RecurrenceException : CalendarEventBO.RecurrenceException; CalendarEventDB.IsAllDay = CalendarEventBO.IsAllDay; if (IsEditMode == false) { CalendarEventDB.CreateByUserID = CalendarEventBO.CreateByUserID; CalendarEventDB.CreateDate = DateTime.UtcNow; } else { CalendarEventDB.UpdateByUserID = CalendarEventBO.UpdateByUserID; CalendarEventDB.UpdateDate = DateTime.UtcNow; } if (Add_CalendarEventDB == true) { CalendarEventDB = _context.CalendarEvents.Add(CalendarEventDB); } _context.SaveChanges(); #region send SMS notification //try //{ // if (sendNotification) // { // if (doctorContactNumber != null && doctorContactNumber != string.Empty) // { // string to = doctorContactNumber; // string body = "Your appointment has been scheduled at. "; // string msgid = SMSGateway.SendSMS(to, body); // } // } //} //catch (Exception) { } #endregion } else { if (IsEditMode == false && EOVisitBO.CalendarEventId <= 0) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { errorObject = "", ErrorMessage = "Please pass valid Calendar Event details.", ErrorLevel = ErrorLevel.Error }); } CalendarEventDB = null; } #endregion #region EO Visit if (EOVisitBO != null && ((EOVisitBO.ID <= 0 && (EOVisitBO.DoctorId.HasValue == true || EOVisitBO.PatientId.HasValue == true)) || (EOVisitBO.ID > 0))) { bool Add_EOVisitDB = false; EOVisitDB = _context.EOVisits.Where(p => p.ID == EOVisitBO.ID && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))) .FirstOrDefault(); if (EOVisitDB == null && EOVisitBO.ID <= 0) { EOVisitDB = new EOVisit(); Add_EOVisitDB = true; sendMessage = true; } else if (EOVisitDB == null && EOVisitBO.ID > 0) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { errorObject = "", ErrorMessage = "Patient Visit doesn't exists.", ErrorLevel = ErrorLevel.Error }); } EOVisitDB.CalendarEventId = (CalendarEventDB != null && CalendarEventDB.Id > 0) ? CalendarEventDB.Id : ((EOVisitBO.CalendarEventId.HasValue == true) ? EOVisitBO.CalendarEventId.Value : EOVisitDB.CalendarEventId); EOVisitDB.DoctorId = IsEditMode == true && EOVisitBO.DoctorId.HasValue == false ? EOVisitDB.DoctorId : (EOVisitBO.DoctorId.HasValue == false ? EOVisitDB.DoctorId : EOVisitBO.DoctorId.Value); EOVisitDB.PatientId = IsEditMode == true && EOVisitBO.PatientId.HasValue == false ? EOVisitDB.PatientId : (EOVisitBO.PatientId.HasValue == false ? EOVisitDB.PatientId : EOVisitBO.PatientId.Value); EOVisitDB.InsuranceProviderId = IsEditMode == true && EOVisitBO.InsuranceProviderId.HasValue == false ? EOVisitDB.InsuranceProviderId : (EOVisitBO.InsuranceProviderId.HasValue == false ? EOVisitDB.InsuranceProviderId : EOVisitBO.InsuranceProviderId.Value); EOVisitDB.EventStart = EOVisitBO.EventStart; EOVisitDB.EventEnd = EOVisitBO.EventEnd; EOVisitDB.Notes = EOVisitBO.Notes; EOVisitDB.VisitStatusId = EOVisitBO.VisitStatusId; EOVisitDB.VisitCreatedByCompanyId = IsEditMode == true ? EOVisitDB.VisitCreatedByCompanyId : EOVisitBO.VisitCreatedByCompanyId.Value; if (IsEditMode == false) { EOVisitDB.CreateByUserID = EOVisitBO.CreateByUserID; EOVisitDB.CreateDate = DateTime.UtcNow; } else { EOVisitDB.UpdateByUserID = EOVisitBO.UpdateByUserID; EOVisitDB.UpdateDate = DateTime.UtcNow; } if (Add_EOVisitDB == true) { EOVisitDB = _context.EOVisits.Add(EOVisitDB); } _context.SaveChanges(); } else { if (IsEditMode == false && IsAddModeCalendarEvent == false) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { errorObject = "", ErrorMessage = "Please pass valid Patient Visit details.", ErrorLevel = ErrorLevel.Error }); } EOVisitDB = null; } _context.SaveChanges(); #endregion dbContextTransaction.Commit(); if (EOVisitDB != null) { EOVisitDB = _context.EOVisits.Include("CalendarEvent") .Include("Doctor") .Include("Patient") .Include("Company") .Include("InsuranceMaster") .Where(p => p.ID == EOVisitDB.ID && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))) .FirstOrDefault <EOVisit>(); } else if (CalendarEventDB != null) { EOVisitDB = _context.EOVisits.Include("CalendarEvent") .Where(p => p.CalendarEvent.Id == CalendarEventDB.Id && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))) .FirstOrDefault <EOVisit>(); } } if (sendMessage == true) { try { IdentityHelper identityHelper = new IdentityHelper(); User AdminUser = _context.Users.Include("ContactInfo").Include("UserCompanies").Include("UserCompanies.company") .Where(p => p.UserName == identityHelper.Email && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))) .FirstOrDefault(); int currentCompanyType = _context.Companies.Where(p => p.id == EOVisitBO.VisitCreatedByCompanyId).Select(p1 => p1.CompanyType).FirstOrDefault(); List <User> lstStaff = _context.Users.Include("ContactInfo").Include("UserCompanies").Include("UserCompanies.company") .Where(p => p.UserType == 2 && p.UserCompanies.Where(p1 => p1.CompanyID == EOVisitBO.VisitCreatedByCompanyId && (p1.IsDeleted.HasValue == false || (p1.IsDeleted.HasValue == true && p1.IsDeleted.Value == false))).Any() && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))) .ToList <User>(); User patientInfo = _context.Users.Include("ContactInfo").Include("UserCompanies").Include("UserCompanies.company") .Where(p => p.id == EOVisitBO.PatientId && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))) .FirstOrDefault(); User doctorInfo = _context.Users.Include("ContactInfo").Include("UserCompanies").Include("UserCompanies.company") .Where(p => p.id == EOVisitBO.DoctorId && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))).FirstOrDefault(); InsuranceMaster insuranceInfo = _context.InsuranceMasters .Where(p => p.Id == EOVisitBO.InsuranceProviderId && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))).FirstOrDefault(); string MailMessageForPatient = "<B> New Appointment Scheduled</B></ BR >Medical provider has scheduled a visit with Insurance Company: " + insuranceInfo.CompanyName + "<br><br>Thanks"; string NotificationForPatient = "Medical provider has scheduled a visit with Insurance Company: " + insuranceInfo.CompanyName; string SmsMessageForPatient = "<B> New Appointment Scheduled</B></ BR >Medical provider has scheduled a visit with Insurance Company: " + insuranceInfo.CompanyName + "<br><br>Thanks"; string MailMessageForDoctor = "Appointment has been scheduled with Insurance Company: " + insuranceInfo.CompanyName + "<br><br>Thanks"; string NotificationForDoctor = "Appointment has been scheduled with Insurance Company: " + insuranceInfo.CompanyName; string SmsMessageForDoctor = "Appointment has been scheduled with Insurance Company: " + insuranceInfo.CompanyName + "<br><br>Thanks"; string MailMessageForStaff = ""; string NotificationForStaff = ""; string SmsMessageForStaff = ""; if (currentCompanyType == 2) { MailMessageForStaff = "<B> New Appointment Scheduled</B></BR>A new Appointment schedule for patient : " + patientInfo.FirstName + " " + patientInfo.LastName + " with Insurance Company" + insuranceInfo.CompanyName + "<br><br>Thanks"; NotificationForStaff = "New Appointment schedule for patient : " + patientInfo.FirstName + " " + patientInfo.LastName + " with Insurance Company" + insuranceInfo.CompanyName; SmsMessageForStaff = "<B> New Appointment Scheduled</B></BR>A new Appointment schedule for patient : " + patientInfo.FirstName + " " + patientInfo.LastName + " with Insurance Company" + insuranceInfo.CompanyName + "<br><br>Thanks"; } else { MailMessageForStaff = "<B> New Appointment Scheduled</B></BR>A new Appointment schedule for doctor : " + doctorInfo.FirstName + " " + doctorInfo.LastName + " with Insurance Company" + insuranceInfo.CompanyName + "<br><br>Thanks"; NotificationForStaff = "New Appointment schedule for doctor : " + doctorInfo.FirstName + " " + doctorInfo.LastName + " with Insurance Company" + insuranceInfo.CompanyName; SmsMessageForStaff = "<B> New Appointment Scheduled</B></BR>A new Appointment schedule for doctor : " + doctorInfo.FirstName + " " + doctorInfo.LastName + " with Insurance Company" + insuranceInfo.CompanyName + "<br><br>Thanks"; } #region patient mail object BO.EmailMessage emPatient = new BO.EmailMessage(); if (patientInfo != null) { emPatient.ApplicationName = "Midas"; emPatient.ToEmail = patientInfo.UserName; //patientInfo.UserName; emPatient.EMailSubject = "MIDAS Notification"; emPatient.EMailBody = MailMessageForPatient; } #endregion #region patient sms object BO.SMS smsPatient = new BO.SMS(); if (patientInfo != null) { smsPatient.ApplicationName = "Midas"; smsPatient.ToNumber = patientInfo.ContactInfo.CellPhone; smsPatient.Message = SmsMessageForPatient; } #endregion #region doctor mail object BO.EmailMessage emDoctor = new BO.EmailMessage(); if (doctorInfo != null) { emDoctor.ApplicationName = "Midas"; emDoctor.ToEmail = doctorInfo.UserName; //doctorInfo.UserName; emDoctor.EMailSubject = "MIDAS Notification"; emDoctor.EMailBody = MailMessageForDoctor; } #endregion #region doctor sms object BO.SMS smsDoctor = new BO.SMS(); if (doctorInfo != null) { smsDoctor.ApplicationName = "Midas"; smsDoctor.ToNumber = doctorInfo.ContactInfo.CellPhone; smsDoctor.Message = SmsMessageForDoctor; } #endregion NotificationHelper nh = new NotificationHelper(); MessagingHelper mh = new MessagingHelper(); if (currentCompanyType == 2) // 2 attorney { #region Patient nh.PushNotification(patientInfo.UserName, AdminUser.UserCompanies.Select(p => p.Company.id).FirstOrDefault(), NotificationForPatient, "New Patient Registration"); //patientInfo.UserName for Patient user email mh.SendEmailAndSms(patientInfo.UserName, AdminUser.UserCompanies.Select(p => p.Company.id).FirstOrDefault(), emPatient, smsPatient); #endregion foreach (var item in lstStaff) { #region staff mail object BO.EmailMessage emStaff = new BO.EmailMessage(); emStaff.ApplicationName = "Midas"; emStaff.ToEmail = item.UserName; emStaff.EMailSubject = "MIDAS Notification"; emStaff.EMailBody = MailMessageForStaff; #endregion #region admin sms object BO.SMS smsStaff = new BO.SMS(); smsStaff.ApplicationName = "Midas"; smsStaff.ToNumber = item.ContactInfo.CellPhone; smsStaff.Message = SmsMessageForStaff; #endregion nh.PushNotification(item.UserName, item.UserCompanies.Select(p => p.Company.id).FirstOrDefault(), NotificationForStaff, "New Appointment Schedule"); //item.UserName mh.SendEmailAndSms(item.UserName, item.UserCompanies.Select(p => p.Company.id).FirstOrDefault(), emStaff, smsStaff); } } else // medical provider { #region Doctor nh.PushNotification(doctorInfo.UserName, AdminUser.UserCompanies.Select(p => p.Company.id).FirstOrDefault(), NotificationForDoctor, "New Appointment Schedule"); //doctorInfo.UserName mh.SendEmailAndSms(doctorInfo.UserName, AdminUser.UserCompanies.Select(p => p.Company.id).FirstOrDefault(), emDoctor, smsDoctor); #endregion foreach (var item in lstStaff) { #region staff mail object BO.EmailMessage emStaff = new BO.EmailMessage(); emStaff.ApplicationName = "Midas"; emStaff.ToEmail = item.UserName; emStaff.EMailSubject = "MIDAS Notification"; emStaff.EMailBody = MailMessageForStaff; #endregion #region staff sms object BO.SMS smsStaff = new BO.SMS(); smsStaff.ApplicationName = "Midas"; smsStaff.ToNumber = item.ContactInfo.CellPhone; smsStaff.Message = SmsMessageForStaff; #endregion nh.PushNotification(item.UserName, item.UserCompanies.Select(p => p.Company.id).FirstOrDefault(), NotificationForStaff, "New Appointment Schedule"); mh.SendEmailAndSms(item.UserName, item.UserCompanies.Select(p => p.Company.id).FirstOrDefault(), emStaff, smsStaff); } } } catch (Exception ex) { } } var res = ConvertEOvisit <BO.EOVisit, EOVisit>(EOVisitDB); return((object)res); }
public override T Convert <T, U>(U entity) { if (entity is Notification) { Notification notification = entity as Notification; if (notification == null) { return(default(T)); } BO.Notification notificationBO = new BO.Notification(); notificationBO.ID = notification.Id; notificationBO.CompanyId = notification.CompanyId; notificationBO.LocationId = notification.LocationId; notificationBO.StartDate = notification.StartDate; notificationBO.EndDate = notification.EndDate; notificationBO.IsViewed = notification.IsViewed; notificationBO.CreateByUserID = notification.CreateByUserID; if (notification.IsDeleted.HasValue) { notificationBO.IsDeleted = notification.IsDeleted.Value; } if (notification.UpdateByUserID.HasValue) { notificationBO.UpdateByUserID = notification.UpdateByUserID.Value; } //if (notification.Company != null) //{ // BO.Company boCompany = new BO.Company(); // using (CompanyRepository cmp = new CompanyRepository(_context)) // { // boCompany = cmp.Convert<BO.Company, Company>(notification.Company); // notificationBO.Company = boCompany; // } //} //if (notification.Location != null) //{ // BO.Location boLocation = new BO.Location(); // using (LocationRepository cmp = new LocationRepository(_context)) // { // boLocation = cmp.Convert<BO.Location, Location>(notification.Location); // notificationBO.Location = boLocation; // } //} return((T)(object)notificationBO); } else if (entity is CalendarEvent) { CalendarEvent CalendarEventDB = entity as CalendarEvent; if (CalendarEventDB == null) { return(default(T)); } BO.CalendarEvent CalendarEvent = new BO.CalendarEvent(); using (CalendarEventRepository calEventRep = new CalendarEventRepository(_context)) { CalendarEvent = calEventRep.Convert <BO.CalendarEvent, CalendarEvent>(CalendarEventDB); } return((T)(object)CalendarEvent); } return(default(T)); }