public override object GetByCompanyId(int id) { var doctorDB = _context.Doctors.Include("User") .Include("User.AddressInfo") .Include("User.ContactInfo") .Include("DoctorSpecialities") .Include("DoctorSpecialities.Specialty") .Include("User.UserCompanyRoles") .Where(p => (p.User.IsDeleted.HasValue == false || (p.User.IsDeleted.HasValue == true && p.User.IsDeleted.Value == false)) && p.User.UserCompanies.Where(p2 => (p2.IsDeleted.HasValue == false || (p2.IsDeleted.HasValue == true && p2.IsDeleted.Value == false))) .Any(p3 => p3.CompanyID == id) && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))) .ToList <Doctor>(); BO.Doctor doctorBO = new BO.Doctor(); List <BO.Doctor> boDoctor = new List <BO.Doctor>(); if (doctorDB == null) { return(new BO.ErrorObject { ErrorMessage = "No record found for this Doctor.", errorObject = "", ErrorLevel = ErrorLevel.Error }); } else { foreach (var EachDoctor in doctorDB) { boDoctor.Add(Convert <BO.Doctor, Doctor>(EachDoctor)); } } return((object)boDoctor); }
public override T Convert <T, U>(U entity) { DoctorSpeciality doctorspecility = entity as DoctorSpeciality; if (doctorspecility == null) { return(default(T)); } BO.DoctorSpeciality doctorspecilityBO = new BO.DoctorSpeciality(); doctorspecilityBO.IsDeleted = doctorspecility.IsDeleted; if (doctorspecilityBO.UpdateByUserID.HasValue) { doctorspecilityBO.UpdateByUserID = doctorspecility.UpdateByUserID.Value; } BO.Doctor boDoctor = new BO.Doctor(); using (DoctorRepository sr = new DoctorRepository(_context)) { boDoctor = sr.Convert <BO.Doctor, Doctor>(doctorspecility.Doctor); doctorspecilityBO.Doctor = boDoctor; } BO.Specialty boSpecliality = new BO.Specialty(); using (SpecialityRepository sr = new SpecialityRepository(_context)) { boSpecliality = sr.Convert <BO.Specialty, Specialty>(doctorspecility.Specialty); doctorspecilityBO.Specialty = boSpecliality; } return((T)(object)doctorspecilityBO); }
public override object Get(int id) { //BO.Doctor acc_ = Convert<BO.Doctor, Doctor>(_context.Doctors.Include("User").Include("User.UserCompanyRoles").Where(p => p.Id == id && p.IsDeleted == false).Include(a => a.User.DoctorSpecialities).FirstOrDefault<Doctor>()); //if (acc_ == null) //{ // return new BO.ErrorObject { ErrorMessage = "No record found for this Specialty.", errorObject = "", ErrorLevel = ErrorLevel.Error }; //} Doctor doctorDB = _context.Doctors.Include("User") .Include("User.AddressInfo") .Include("User.ContactInfo") .Include("DoctorSpecialities") .Include("DoctorSpecialities.Specialty") .Include("User.UserCompanyRoles").Where(p => p.Id == id && p.IsDeleted == false).Include(a => a.DoctorSpecialities).FirstOrDefault <Doctor>(); BO.Doctor doctorBO = new BO.Doctor(); if (doctorDB == null) { return(new BO.ErrorObject { ErrorMessage = "No record found for this Doctor.", errorObject = "", ErrorLevel = ErrorLevel.Error }); } else { doctorBO = Convert <BO.Doctor, Doctor>(doctorDB); } return((object)doctorBO); }
public override List <MIDAS.GBX.BusinessObjects.BusinessValidation> Validate <T>(T entity) { BO.Doctor doctor = (BO.Doctor)(object) entity; var result = doctor.Validate(doctor); return(result); }
public override T ObjectConvert <T, U>(U entity) { Doctor doctor = entity as Doctor; if (doctor == null) { return(default(T)); } BO.Doctor doctorBO = new BO.Doctor(); doctorBO.ID = doctor.Id; doctorBO.LicenseNumber = doctor.LicenseNumber; doctorBO.WCBAuthorization = doctor.WCBAuthorization; doctorBO.WcbRatingCode = doctor.WcbRatingCode; doctorBO.NPI = doctor.NPI; doctorBO.Title = doctor.Title; doctorBO.TaxType = (BO.GBEnums.TaxType)doctor.TaxTypeId; if (doctor.IsDeleted.HasValue) { doctorBO.IsDeleted = doctor.IsDeleted.Value; } if (doctor.UpdateByUserID.HasValue) { doctorBO.UpdateByUserID = doctor.UpdateByUserID.Value; } doctorBO.IsCalendarPublic = doctor.IsCalendarPublic; if (doctor.DoctorSpecialities != null) { List <BO.DoctorSpeciality> lstDoctorSpecility = new List <BO.DoctorSpeciality>(); foreach (var item in doctor.DoctorSpecialities) { if (item.IsDeleted == false) { using (DoctorSpecialityRepository sr = new DoctorSpecialityRepository(_context)) { lstDoctorSpecility.Add(sr.ObjectConvert <BO.DoctorSpeciality, DoctorSpeciality>(item)); } } } doctorBO.DoctorSpecialities = lstDoctorSpecility; } return((T)(object)doctorBO); }
public override T Convert <T, U>(U entity) { DoctorLocationSchedule doctorlocationschedule = entity as DoctorLocationSchedule; if (doctorlocationschedule == null) { return(default(T)); } BO.DoctorLocationSchedule doctorlocationscheduleBO = new BO.DoctorLocationSchedule(); doctorlocationscheduleBO.ID = doctorlocationschedule.id; if (doctorlocationschedule.IsDeleted.HasValue) { doctorlocationscheduleBO.IsDeleted = doctorlocationschedule.IsDeleted.Value; } if (doctorlocationschedule.UpdateByUserID.HasValue) { doctorlocationscheduleBO.UpdateByUserID = doctorlocationschedule.UpdateByUserID.Value; } if (doctorlocationschedule.Doctor != null && (doctorlocationschedule.Doctor.IsDeleted.HasValue == false || (doctorlocationschedule.Doctor.IsDeleted.HasValue == true && doctorlocationschedule.Doctor.IsDeleted.Value == false))) { BO.Doctor boDoctor = new BO.Doctor(); using (DoctorRepository cmp = new DoctorRepository(_context)) { boDoctor = cmp.ObjectConvert <BO.Doctor, Doctor>(doctorlocationschedule.Doctor); if (boDoctor != null && doctorlocationschedule.Doctor != null && doctorlocationschedule.Doctor.User != null) { using (UserRepository userRep = new UserRepository(_context)) { boDoctor.user = userRep.Convert <BO.User, User>(doctorlocationschedule.Doctor.User); } } doctorlocationscheduleBO.doctor = boDoctor; } } if (doctorlocationschedule.Location != null && (doctorlocationschedule.Location.IsDeleted.HasValue == false || (doctorlocationschedule.Location.IsDeleted.HasValue == true && doctorlocationschedule.Location.IsDeleted.Value == false))) { BO.Location boLocation = new BO.Location(); using (LocationRepository cmp = new LocationRepository(_context)) { boLocation = cmp.Convert <BO.Location, Location>(doctorlocationschedule.Location); doctorlocationscheduleBO.location = boLocation; } } if (doctorlocationschedule.Schedule != null && (doctorlocationschedule.Schedule.IsDeleted.HasValue == false || (doctorlocationschedule.Schedule.IsDeleted.HasValue == true && doctorlocationschedule.Schedule.IsDeleted.Value == false))) { BO.Schedule boSchedule = new BO.Schedule(); using (ScheduleRepository cmp = new ScheduleRepository(_context)) { boSchedule = cmp.Convert <BO.Schedule, Schedule>(doctorlocationschedule.Schedule); doctorlocationscheduleBO.schedule = boSchedule; } } return((T)(object)doctorlocationscheduleBO); }
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) { Doctor doctor = entity as Doctor; if (doctor == null) { return(default(T)); } BO.Doctor doctorBO = new BO.Doctor(); doctorBO.ID = doctor.Id; doctorBO.LicenseNumber = doctor.LicenseNumber; doctorBO.WCBAuthorization = doctor.WCBAuthorization; doctorBO.WcbRatingCode = doctor.WcbRatingCode; doctorBO.NPI = doctor.NPI; doctorBO.Title = doctor.Title; doctorBO.TaxType = (BO.GBEnums.TaxType)doctor.TaxTypeId; if (doctor.IsDeleted.HasValue) { doctorBO.IsDeleted = doctor.IsDeleted.Value; } if (doctor.UpdateByUserID.HasValue) { doctorBO.UpdateByUserID = doctor.UpdateByUserID.Value; } doctorBO.IsCalendarPublic = doctor.IsCalendarPublic; if (doctor.User != null) { if (doctor.User.IsDeleted.HasValue == false || (doctor.User.IsDeleted.HasValue == true && doctor.User.IsDeleted.Value == false)) { BO.User boUser = new BO.User(); using (UserRepository sr = new UserRepository(_context)) { boUser = sr.Convert <BO.User, User>(doctor.User); doctorBO.user = boUser; } if (doctor.DoctorSpecialities != null) { List <BO.DoctorSpeciality> lstDoctorSpecility = new List <BO.DoctorSpeciality>(); foreach (var item in doctor.DoctorSpecialities) { if (item.IsDeleted == false) { using (DoctorSpecialityRepository sr = new DoctorSpecialityRepository(_context)) { lstDoctorSpecility.Add(sr.ObjectConvert <BO.DoctorSpeciality, DoctorSpeciality>(item)); } } } doctorBO.DoctorSpecialities = lstDoctorSpecility; } if (doctor.DoctorRoomTestMappings != null) { List <BO.DoctorRoomTestMapping> lstDoctorRoomTestMapping = new List <BO.DoctorRoomTestMapping>(); foreach (var item in doctor.DoctorRoomTestMappings) { if (item.IsDeleted == false) { BO.DoctorRoomTestMapping doctorRoomTestMappingBO = new BO.DoctorRoomTestMapping(); doctorRoomTestMappingBO.ID = item.Id; doctorRoomTestMappingBO.IsDeleted = item.IsDeleted; if (doctorRoomTestMappingBO.UpdateByUserID.HasValue) { doctorRoomTestMappingBO.UpdateByUserID = item.UpdateByUserID.Value; } if (item.RoomTest != null && (item.RoomTest.IsDeleted.HasValue == false || (item.RoomTest.IsDeleted.HasValue == true && item.RoomTest.IsDeleted.Value == false))) { BO.RoomTest boRoomTest = new BO.RoomTest(); using (RoomTestRepository sr = new RoomTestRepository(_context)) { boRoomTest = sr.Convert <BO.RoomTest, RoomTest>(item.RoomTest); doctorRoomTestMappingBO.RoomTest = boRoomTest; } } lstDoctorRoomTestMapping.Add(doctorRoomTestMappingBO); } } doctorBO.DoctorRoomTestMappings = lstDoctorRoomTestMapping; } //if (doctor.User.UserCompanies != null && doctorBO.user.UserCompanies != null && doctorBO.user.UserCompanies.Count <= 0) if (doctor.User.UserCompanies != null) { List <BO.UserCompany> lstUserCompany = new List <BO.UserCompany>(); foreach (var item in doctor.User.UserCompanies) { if (item.IsDeleted.HasValue == false || (item.IsDeleted.HasValue == true && item.IsDeleted.Value == false)) { using (UserCompanyRepository sr = new UserCompanyRepository(_context)) { BO.UserCompany BOUserCompany = new BO.UserCompany(); BOUserCompany = sr.Convert <BO.UserCompany, UserCompany>(item); BOUserCompany.User = null; lstUserCompany.Add(BOUserCompany); } } } doctorBO.user.UserCompanies = lstUserCompany; } if (doctor.DoctorLocationSchedules != null) { List <BO.DoctorLocationSchedule> lstDoctorLocationSchedule = new List <BO.DoctorLocationSchedule>(); foreach (var item in doctor.DoctorLocationSchedules) { if (item.IsDeleted.HasValue == false || (item.IsDeleted.HasValue == true && item.IsDeleted.Value == false)) { using (DoctorLocationScheduleRepository sr = new DoctorLocationScheduleRepository(_context)) { BO.DoctorLocationSchedule BODoctorLocationSchedule = new BO.DoctorLocationSchedule(); BODoctorLocationSchedule = sr.Convert <BO.DoctorLocationSchedule, DoctorLocationSchedule>(item); BODoctorLocationSchedule.doctor = null; BODoctorLocationSchedule.schedule = null; lstDoctorLocationSchedule.Add(BODoctorLocationSchedule); } } } doctorBO.DoctorLocationSchedules = lstDoctorLocationSchedule; } } } return((T)(object)doctorBO); }
public override object Save <T>(T entity) { BO.Doctor doctorBO = (BO.Doctor)(object) entity; BO.ErrorObject errObj = new BO.ErrorObject(); BO.User userBO = new BO.User(); Doctor doctorDB = new Doctor(); User userDB = new User(); List <DoctorSpeciality> lstDoctorSpecility = new List <DoctorSpeciality>(); List <DoctorRoomTestMapping> lstDoctorRoomTestMapping = new List <DoctorRoomTestMapping>(); doctorDB.Id = doctorBO.ID; using (var dbContextTransaction = _context.Database.BeginTransaction()) { ////Find Record By ID User user_ = _context.Users.Include("UserCompanyRoles").Include("AddressInfo").Include("ContactInfo").Where(p => p.id == doctorBO.user.ID).FirstOrDefault <User>(); if (user_ != null) { BO.AddUser updUserBO = new BO.AddUser(); updUserBO.user = doctorBO.user; updUserBO.user.UserName = string.IsNullOrEmpty(user_.UserName) ? user_.UserName : doctorBO.user.UserName; updUserBO.user.FirstName = string.IsNullOrEmpty(user_.FirstName) ? user_.FirstName : doctorBO.user.FirstName; updUserBO.user.LastName = string.IsNullOrEmpty(user_.LastName) ? user_.LastName : doctorBO.user.LastName; updUserBO.user.MiddleName = string.IsNullOrEmpty(user_.MiddleName) ? user_.MiddleName: doctorBO.user.MiddleName; updUserBO.user.Gender = doctorBO.user.Gender; updUserBO.user.UserType = !Enum.IsDefined(typeof(BO.GBEnums.UserType), doctorBO.user.UserType) ? (BO.GBEnums.UserType)user_.UserType : doctorBO.user.UserType; updUserBO.user.ImageLink = string.IsNullOrEmpty(doctorBO.user.ImageLink) ? user_.ImageLink : doctorBO.user.ImageLink; updUserBO.user.C2FactAuthEmailEnabled = doctorBO.user.C2FactAuthEmailEnabled == true || doctorBO.user.C2FactAuthEmailEnabled == false ? doctorBO.user.C2FactAuthEmailEnabled : (bool)user_.C2FactAuthEmailEnabled; updUserBO.user.C2FactAuthEmailEnabled = doctorBO.user.C2FactAuthSMSEnabled == true || doctorBO.user.C2FactAuthSMSEnabled == false ? doctorBO.user.C2FactAuthSMSEnabled : (bool)user_.C2FactAuthSMSEnabled; updUserBO.user.ID = doctorBO.user.ID; updUserBO.user.Roles = doctorBO.user.Roles; updUserBO.company = doctorBO.user.UserCompanies.ToList().Select(p => p.Company).FirstOrDefault(); updUserBO.role = doctorBO.user.Roles.ToArray(); // if (doctorBO.DoctorSpecialities.Count > 0) updUserBO.DoctorSpecialities = doctorBO.user.DoctorSpecialities; if (doctorBO.user.AddressInfo != null && doctorBO.user.AddressInfo.ID > 0) { updUserBO.address = doctorBO.user.AddressInfo; } if (doctorBO.user.ContactInfo != null && doctorBO.user.ContactInfo.ID > 0) { updUserBO.contactInfo = doctorBO.user.ContactInfo; } using (UserRepository userRepo = new UserRepository(_context)) { object obj = userRepo.Save <BO.AddUser>(updUserBO); if (obj.GetType() == errObj.GetType()) { errObj = (BO.ErrorObject)obj; dbContextTransaction.Rollback(); return(new BO.ErrorObject { ErrorMessage = errObj.ErrorMessage, errorObject = "", ErrorLevel = ErrorLevel.Error }); } else { userBO = (BO.User)obj; } doctorDB.User = _context.Users.Include("UserCompanyRoles").Include("UserCompanies").Where(p => p.id == doctorBO.user.ID).FirstOrDefault <User>(); } //_context.Entry(user_).State = System.Data.Entity.EntityState.Modified; } else { BO.AddUser addUserBO = new BO.AddUser(); addUserBO.user = doctorBO.user; // addUserBO.user.DoctorSpecialities = doctorBO.DoctorSpecialities; addUserBO.user.Roles = doctorBO.user.Roles; addUserBO.company = doctorBO.user.UserCompanies.ToList().Select(p => p.Company).FirstOrDefault(); addUserBO.role = doctorBO.user.Roles.ToArray(); addUserBO.address = doctorBO.user.AddressInfo; addUserBO.contactInfo = doctorBO.user.ContactInfo; using (UserRepository userRepo = new UserRepository(_context)) { object obj = userRepo.Save <BO.AddUser>(addUserBO); if (obj.GetType() == errObj.GetType()) { errObj = (BO.ErrorObject)obj; dbContextTransaction.Rollback(); return(new BO.ErrorObject { ErrorMessage = errObj.ErrorMessage, errorObject = "", ErrorLevel = ErrorLevel.Error }); } else { userBO = (BO.User)obj; } doctorBO.user.ID = userBO.ID; doctorDB.User = _context.Users.Include("UserCompanyRoles").Include("UserCompanies").Where(p => p.id == doctorBO.user.ID && p.UserCompanyRoles.Any(x => x.RoleID == (int)BO.GBEnums.RoleType.Doctor)).FirstOrDefault <User>(); } } if (doctorBO.DoctorSpecialities.Count > 0) { _dbSetDocSpecility.RemoveRange(_context.DoctorSpecialities.Where(c => c.DoctorID == doctorBO.user.ID)); _context.SaveChanges(); Specialty specilityDB = null; DoctorSpeciality doctorSpecilityDB = null; foreach (var item in doctorBO.DoctorSpecialities) { BO.DoctorSpeciality doctorSpecialityBO = (BO.DoctorSpeciality)(object) item; specilityDB = new Specialty(); doctorSpecilityDB = new DoctorSpeciality(); doctorSpecilityDB.IsDeleted = doctorSpecialityBO.IsDeleted.HasValue ? doctorSpecialityBO.IsDeleted.Value : false; doctorSpecilityDB.Doctor = doctorDB; //Find Record By ID Specialty speclity = _context.Specialties.Where(p => p.id == doctorSpecialityBO.ID).FirstOrDefault <Specialty>(); if (speclity == null) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { ErrorMessage = "Invalid specility " + item.ToString() + " details.", errorObject = "", ErrorLevel = ErrorLevel.Error }); } if (!lstDoctorSpecility.Select(p => p.Specialty).Contains(speclity)) { doctorSpecilityDB.Specialty = speclity; _context.Entry(speclity).State = System.Data.Entity.EntityState.Modified; lstDoctorSpecility.Add(doctorSpecilityDB); } ; } } doctorDB.DoctorSpecialities = lstDoctorSpecility; if (doctorBO.DoctorRoomTestMappings != null) { if (doctorBO.DoctorRoomTestMappings.Count > 0) { _dbSetDocRoomTestMapping.RemoveRange(_context.DoctorRoomTestMappings.Where(c => c.DoctorId == doctorBO.user.ID)); _context.SaveChanges(); RoomTest roomTestDB = null; DoctorRoomTestMapping doctorRoomTestMappingDB = null; foreach (var item in doctorBO.DoctorRoomTestMappings) { BO.DoctorRoomTestMapping doctorRoomTestMappingBO = (BO.DoctorRoomTestMapping)(object) item; roomTestDB = new RoomTest(); doctorRoomTestMappingDB = new DoctorRoomTestMapping(); doctorRoomTestMappingDB.IsDeleted = doctorRoomTestMappingBO.IsDeleted.HasValue ? doctorRoomTestMappingBO.IsDeleted.Value : false; doctorRoomTestMappingDB.Doctor = doctorDB; //Find Record By ID RoomTest roomTest = _context.RoomTests.Where(p => p.id == doctorRoomTestMappingBO.ID).FirstOrDefault <RoomTest>(); if (roomTest == null) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { ErrorMessage = "Invalid specility " + item.ToString() + " details.", errorObject = "", ErrorLevel = ErrorLevel.Error }); } if (!lstDoctorRoomTestMapping.Select(p => p.RoomTest).Contains(roomTest)) { doctorRoomTestMappingDB.RoomTest = roomTest; _context.Entry(roomTest).State = System.Data.Entity.EntityState.Modified; lstDoctorRoomTestMapping.Add(doctorRoomTestMappingDB); } ; } } doctorDB.DoctorRoomTestMappings = lstDoctorRoomTestMapping; } if (doctorDB.Id > 0) { //Find Doctor By ID Doctor doctor = _context.Doctors.Where(p => p.Id == doctorBO.user.ID && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))).FirstOrDefault <Doctor>(); if (doctor == null) { doctorDB = new Doctor(); } #region Doctor doctorDB.Id = doctorBO.ID; doctorDB.LicenseNumber = string.IsNullOrEmpty(doctorBO.LicenseNumber) ? doctor.LicenseNumber : doctorBO.LicenseNumber; doctorDB.WCBAuthorization = string.IsNullOrEmpty(doctorBO.WCBAuthorization) ? doctor.WCBAuthorization : doctorBO.WCBAuthorization; doctorDB.WcbRatingCode = string.IsNullOrEmpty(doctorBO.WcbRatingCode) ? doctor.WcbRatingCode : doctorBO.WcbRatingCode; doctorDB.NPI = string.IsNullOrEmpty(doctorBO.NPI) ? doctor.NPI : doctorBO.NPI; doctorDB.Title = string.IsNullOrEmpty(doctorBO.Title) ? doctor.Title : doctorBO.Title; doctorDB.TaxTypeId = !Enum.IsDefined(typeof(BO.GBEnums.TaxType), doctorBO.TaxType) ? System.Convert.ToByte((BO.GBEnums.TaxType)doctor.TaxTypeId) : System.Convert.ToByte(doctorBO.TaxType); doctorDB.IsDeleted = doctorBO.IsDeleted.HasValue ? doctorBO.IsDeleted : (doctorBO.IsDeleted.HasValue ? doctor.IsDeleted : false); doctorDB.UpdateDate = doctorBO.UpdateDate; doctorDB.UpdateByUserID = doctorBO.UpdateByUserID; doctorDB.IsCalendarPublic = doctorBO.IsCalendarPublic; #endregion // doctorDB = doctor; // _context.Entry(doctorDB).State = System.Data.Entity.EntityState.Modified; doctorDB = _context.Doctors.Add(doctorDB); //else //{ // dbContextTransaction.Rollback(); // return new BO.ErrorObject { ErrorMessage = "Please pass valid doctor details.", errorObject = "", ErrorLevel = ErrorLevel.Error }; //} } else { doctorDB.LicenseNumber = doctorBO.LicenseNumber; doctorDB.WCBAuthorization = doctorBO.WCBAuthorization; doctorDB.WcbRatingCode = doctorBO.WcbRatingCode; doctorDB.NPI = doctorBO.NPI; doctorDB.Title = doctorBO.Title; doctorDB.TaxTypeId = System.Convert.ToByte(doctorBO.TaxType); doctorDB.IsDeleted = doctorBO.IsDeleted.HasValue ? doctorBO.IsDeleted : false; doctorDB.UpdateDate = doctorBO.UpdateDate; doctorDB.UpdateByUserID = doctorBO.UpdateByUserID; doctorDB.CreateDate = doctorBO.CreateDate; doctorDB.CreateByUserID = doctorBO.CreateByUserID; doctorDB.IsCalendarPublic = doctorBO.IsCalendarPublic; _dbSet.Add(doctorDB); } _context.SaveChanges(); dbContextTransaction.Commit(); } var res = Convert <BO.Doctor, Doctor>(doctorDB); return((object)res); }