Beispiel #1
0
        private void SendSMSAlarm(int?patientId, Enums.AlarmEventType alarmEventType)
        {
            if (patientId == null)
            {
                return;
            }

            var correspondentMedicalRecord = MedicalRecordService.GetMedicalRecordByPatientId((int)patientId).LastOrDefault();

            if (correspondentMedicalRecord == null)
            {
                return;
            }

            var doctorId = (int)correspondentMedicalRecord.DoctorId;
            var doctor   = new DoctorService().GetDoctorById(doctorId);


            var alarmConfig = alarmService.GetAlarmConfigByEventTypeId(alarmEventType);
            var alarmObject = alarmService.GetAlarmEventTypeByEventType(alarmEventType);

            var hasDoctorSMS = alarmConfig.SendDoctorSMS;

            if ((bool)hasDoctorSMS)
            {
                var alarmRecord = alarmService.GetDoctorAlarmByDoctorId(doctorId);
                if (CheckUserCanRecieveSMS(doctor))
                {
                    //Send
                    StringBuilder smsText = new StringBuilder();
                    smsText.Append("نام بیمار: ");
                    smsText.AppendLine(correspondentMedicalRecord.PatientFirstName + " " + correspondentMedicalRecord.PatientLastName);
                    smsText.AppendLine("نوع اقدام: " + alarmObject.ShortTitle);
                    smsText.AppendLine("تاریخ: " + Common.DateUtility.GetPersianDate(DateTime.Now));
                    smsText.Append("مرکز رادیوتراپی شهدای تجریش");

                    SMSWebService.SendSMS(doctor.Mobile, smsText.ToString());
                }
            }


            var hasPhysistSMS = alarmConfig.SendPhysictSMS;

            if ((bool)hasPhysistSMS)
            {
                List <PhysicUserAlarm> alarmRecord    = alarmService.GetPhysicUserAlarmList();
                List <PhysicUser>      physicUserList = physicUserService.GetPhysicUsers();

                foreach (var user in physicUserList)
                {
                    if (CheckUserCanRecieveSMS(user))
                    {
                        //Send
                        SMSWebService.SendSMS(user.Mobile, "بیمار با نام " + correspondentMedicalRecord.PatientFirstName + " " + correspondentMedicalRecord.PatientLastName + " پذیرش شد" + " " + "تاریخ پذیرش " + Common.DateUtility.GetPersianDate(DateTime.Now));
                    }
                }
            }


            var hasAdminSMS    = alarmConfig.SendAdminSMS;
            var hasResidentSMS = alarmConfig.SendResidentSMS;

            if ((bool)hasResidentSMS)
            {
                List <ResidentAlarm> alarmRecord  = alarmService.GetResidentAlarmList();
                List <Resident>      residentList = residentService.GetResidentsByDoctorId(doctorId);

                foreach (var user in residentList)
                {
                    if (CheckUserCanRecieveSMS(user))
                    {
                        //Send
                        SMSWebService.SendSMS(user.Mobile, "بیمار با نام " + correspondentMedicalRecord.PatientFirstName + " " + correspondentMedicalRecord.PatientLastName + " پذیرش شد" + " " + "تاریخ پذیرش " + Common.DateUtility.GetPersianDate(DateTime.Now));
                    }
                }
            }
        }