public bool ProcessNotificationToPatientAboutDoctorAndAmbulance(int userId = 0) { var notificationInfo = _unitOfWork.PushNotificationRepository.GetManyQueryable(y => y.USERINFORMATIONID == userId).FirstOrDefault(); var userDetails = _unitOfWork.UserInformationRepository.GetByID(userId); var notificationToBeSentList = new List <NotificationWithMessageBody>(); if (notificationInfo != null && notificationInfo.AMBULATORYCONFIRMSTATUS == "Y") { var ambulanceDetails = _unitOfWork.AmbulanceServiceRepository.GetFirst(y => y.AMBULATORYID == notificationInfo.AMBULATORYID); NotificationWithMessageBody notContent = new NotificationWithMessageBody(); notContent.MobileNumber = userDetails.PRIMARYCONTACTNO; notContent.MessageBody = string.Format("Dear Patient,Please find ambulance Live Location and his Number,His location is \"https://goo.gl/maps/gzNMmTaAyM5rNZUS6\" + Number" + ambulanceDetails.AMBULATORYTELEPHONE); notificationToBeSentList.Add(notContent); } if (notificationInfo != null && notificationInfo.PHYSICIANCONFIRMSTATUS == "Y") { var physician = _unitOfWork.PhysicanInfoRepository.GetFirst(y => y.PHYSICIANID == notificationInfo.PHYSICIANID); NotificationWithMessageBody notContent = new NotificationWithMessageBody(); notContent.MobileNumber = userDetails.PRIMARYCONTACTNO; notContent.MessageBody = string.Format("Dear Patient,Please find ambulance Live Location and his Number,His location is \"https://goo.gl/maps/gzNMmTaAyM5rNZUS6\" + Number" + physician.TELEPHONE); notificationToBeSentList.Add(notContent); } foreach (var notificationToSent in notificationToBeSentList) { SendMessage(notificationToSent.MobileNumber, notificationToSent.MessageBody); } return(true); }
// this method is primary used to send the notification to respective autority public bool ProcessNotificationToDoctorAndAmbulance(int userInfoId) { if (userInfoId > 0) { _pushNotificationServices.updateNotoficationAlert(userInfoId); } List <NotificationWithMessageBody> notificationToBeSentList = new List <NotificationWithMessageBody>(); // Assumeing all the ambulance , doctor and provider (hospital) would be near by (filtered using LATITUDE and LONGITUDE) var notificationId = _unitOfWork.PushNotificationRepository.GetFirst(y => y.USERINFORMATIONID == userInfoId); if (notificationId.AMBULATORYCONFIRMSTATUS == "N") { var getNotificationDetailsForAmbulance = _unitOfWork.AmbulanceServiceRepository.GetAll().Take(3); foreach (var ambulance in getNotificationDetailsForAmbulance) { NotificationWithMessageBody notContent = new NotificationWithMessageBody(); notContent.MobileNumber = ambulance.AMBULATORYTELEPHONE; notContent.MessageBody = string.Format("Dear Ambulance,Please Accept the request of patient Emergency Hospitalization,His location is \"https://goo.gl/maps/gzNMmTaAyM5rNZUS6\" + Click" + baseAddess + notificationId + "/Ambulance" + "/" + ambulance.AMBULATORYID + " to Accept It"); notificationToBeSentList.Add(notContent); } } if (notificationId.PHYSICIANCONFIRMSTATUS == "N") { var getNotificationDetailsForDoctor = _unitOfWork.PhysicanInfoRepository.GetManyQueryable(y => y.TREATMENTTYPESPECIALIST == "3").Take(3); foreach (var doctor in getNotificationDetailsForDoctor) { NotificationWithMessageBody notContent = new NotificationWithMessageBody(); notContent.MobileNumber = doctor.TELEPHONE; notContent.MessageBody = string.Format("Dear Doctor,Please Accept the request of patient Emergency Hospitalization,His location is \"https://goo.gl/maps/gzNMmTaAyM5rNZUS6\" + Click" + baseAddess + notificationId + "/Ambulance" + "/" + doctor.PHYSICIANID + " to Accept It"); notificationToBeSentList.Add(notContent); } } if (notificationId.PROVIDERCONFIRMSTATUS == "N") { var getNotificationDetailsForProvider = _unitOfWork.ProviderInfoRepository.GetManyQueryable(y => y.SPECIALISTTYPE == "3").Take(3); foreach (var hospital in getNotificationDetailsForProvider) { NotificationWithMessageBody notContent = new NotificationWithMessageBody(); notContent.MobileNumber = hospital.TELEPHONE; notContent.MessageBody = string.Format("Dear Hospital Provider,Please Accept the request of patient Emergency Hospitalization,His location is \"https://goo.gl/maps/gzNMmTaAyM5rNZUS6\" + Click" + baseAddess + notificationId + "/Ambulance" + "/" + hospital.PROVIDERNO + " to Accept It"); notificationToBeSentList.Add(notContent); } } if (notificationId.PROVIDERCONFIRMSTATUS == "N") { var getNotificationDetailsForDrugCentre = _unitOfWork.DrugCentreRepository.GetAll().Take(3); foreach (var drugCenter in getNotificationDetailsForDrugCentre) { NotificationWithMessageBody notContent = new NotificationWithMessageBody(); notContent.MobileNumber = drugCenter.DRUGCENTRECONTACTNO; notContent.MessageBody = string.Format("Dear Drug Center,For Case Id {0},Please check the patient History and drug Details and keep it ready.Also Connect to Doctor for Case.", userInfoId); notificationToBeSentList.Add(notContent); } } foreach (var notificationToSent in notificationToBeSentList) { SendMessage(notificationToSent.MobileNumber, notificationToSent.MessageBody); } // this is the place where we have to send the notification to Dr and Ambulance // get unnotified patient and // 1. collect near By dr and Ambulance details //2. create message or call notification and send them return(true); }