Exemplo n.º 1
0
        public Model.AlarmEventType GetAlarmEventTypeByEventType(Enums.AlarmEventType alarmEventType)
        {
            int appropriateEventId = Convert.ToInt32(alarmEventType);

            using (var db = new Model.PhysicManagementEntities())
            {
                return(GetAlarmEventTypeById(appropriateEventId));
            }
        }
Exemplo n.º 2
0
        public void AddAlarm(Enums.AlarmEventType alarmEventType, long medicalRecordId, bool NeedSendToDoctor, bool NeedSendToResident, bool NeedSendToPhysist)
        {
            var eventTypeObj  = alarmService.GetAlarmEventTypeById((int)alarmEventType);
            var medicalRecord = MedicalRecordService.GetMedicalRecordById(medicalRecordId);
            var alarmTitle    = eventTypeObj.Title + " " + medicalRecord.PatientFirstName + " " + medicalRecord.PatientLastName + " " + Common.DateUtility.GetPersianDate(DateTime.Now);
            var alarmBody     = alarmTitle + '\n' + " پزشک معالج" + medicalRecord.DoctorLastName + " نوع بیماری" + medicalRecord.CancerTitle;

            if (NeedSendToDoctor)
            {
                alarmService.AddAlarm(new Alarm()
                {
                    AlarmEventTypeId   = Convert.ToInt32(alarmEventType),
                    DoctorId           = medicalRecord.DoctorId,
                    Title              = alarmTitle,
                    Body               = alarmBody,
                    IsDelivered        = false,
                    SendDate           = DateTime.Now,
                    TreatmentProcessId = eventTypeObj.TreatmentProcessStepId
                });
            }
            if (NeedSendToResident)
            {
                var residentList = residentService.GetResidentsByDoctorId((int)medicalRecord.DoctorId);

                foreach (var item in residentList)
                {
                    alarmService.AddAlarm(new Alarm()
                    {
                        AlarmEventTypeId   = Convert.ToInt32(alarmEventType),
                        ResidentId         = item.Id,
                        Title              = alarmTitle,
                        Body               = alarmBody,
                        IsDelivered        = false,
                        SendDate           = DateTime.Now,
                        TreatmentProcessId = eventTypeObj.TreatmentProcessStepId
                    });
                }
            }
            if (NeedSendToPhysist)
            {
                var physictList = physicUserService.GetPhysicUsers();
                foreach (var item in physictList)
                {
                    alarmService.AddAlarm(new Alarm()
                    {
                        AlarmEventTypeId   = Convert.ToInt32(alarmEventType),
                        PhysicUserId       = item.Id,
                        Title              = alarmTitle,
                        Body               = alarmBody,
                        IsDelivered        = false,
                        SendDate           = DateTime.Now,
                        TreatmentProcessId = eventTypeObj.TreatmentProcessStepId
                    });
                }
            }
        }
Exemplo n.º 3
0
        public Model.AlarmConfig GetAlarmConfigByEventTypeId(Enums.AlarmEventType alarmEventType)
        {
            int EventTypeId = (int)alarmEventType;

            using (var db = new Model.PhysicManagementEntities())
            {
                var Entity = db.AlarmConfig.Where(x => x.AlarmEventTypeId == EventTypeId).FirstOrDefault();
                return(Entity);
            }
        }
Exemplo n.º 4
0
        private void SendSMSAlarm(long?medicalRecordId, Enums.AlarmEventType alarmEventType)
        {
            if (medicalRecordId == null)
            {
                return;
            }

            var correspondentMedicalRecord = MedicalRecordService.GetMedicalRecordById((long)medicalRecordId);

            if (correspondentMedicalRecord == null)
            {
                return;
            }

            var doctorId       = correspondentMedicalRecord.DoctorId;
            var alarmConfig    = alarmService.GetAlarmConfigByEventTypeId(alarmEventType);
            var hasDoctorSMS   = alarmConfig.SendDoctorSMS;
            var hasPhysistSMS  = alarmConfig.SendPhysictSMS;
            var hasAdminSMS    = alarmConfig.SendAdminSMS;
            var hasResidentSMS = alarmConfig.SendResidentSMS;
        }
Exemplo n.º 5
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));
                    }
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// الآن وضعیت ارسال آلارم به این صورت است که وقتی یک پرونده ارائه شود متناسب با مرحله ای که بیمار در آن قرار گرفته است و پارامترهایی که به این متد ارسال می شود آلارم برای پزشکان، کارشناسان بخش فیزیک و رزیدنت های مرتبط با پزشک پرونده ارسال می شود
        /// </summary>
        /// <param name="alarmEventType">از جدول AlarmEventType</param>
        /// <param name="patientId">کد بیمار در بانک اطلاعاتی یا همان آیدی بیمار</param>
        /// <param name="NeedSendToDoctor">لازم است به دکتر پرونده آلارم داده شود؟</param>
        /// <param name="NeedSendToResident">لازم است به رزیدنت های پزشک مربوطه آلارم ارسال شود؟</param>
        /// <param name="NeedSendToPhysist">آیا به کل کارشناسان فیزیک لازم است آلارم ارسال شود؟</param>
        public void AddAlarm(Enums.AlarmEventType alarmEventType, int patientId, bool NeedSendToDoctor, bool NeedSendToResident, bool NeedSendToPhysist)
        {
            var eventTypeObj  = alarmService.GetAlarmEventTypeById((int)alarmEventType);
            var medicalRecord = MedicalRecordService.GetMedicalRecordByPatientId(patientId).Last();
            var alarmTitle    = eventTypeObj.Title + " - " + medicalRecord.PatientFirstName + " " + medicalRecord.PatientLastName + " " + Common.DateUtility.GetPersianDate(DateTime.Now);
            var alarmBody     = alarmTitle + '\n' + " پزشک معالج: " + medicalRecord.DoctorLastName + (string.IsNullOrEmpty(medicalRecord.CancerTitle) ? " " : " نوع بیماری" + medicalRecord.CancerTitle);

            if (NeedSendToDoctor)
            {
                alarmService.AddAlarm(new Alarm()
                {
                    AlarmEventTypeId   = Convert.ToInt32(alarmEventType),
                    DoctorId           = medicalRecord.DoctorId,
                    Title              = alarmTitle,
                    Body               = alarmBody,
                    IsDelivered        = false,
                    IsSMS              = false,
                    PatientFullName    = medicalRecord.PatientFirstName + " " + medicalRecord.PatientLastName,
                    TreatmentProcessId = medicalRecord.TreatmentProcessId,
                    SendDate           = DateTime.Now
                });
            }

            if (NeedSendToResident)
            {
                var residentList = residentService.GetResidentsByDoctorId((int)medicalRecord.DoctorId);

                foreach (var item in residentList)
                {
                    alarmService.AddAlarm(new Alarm()
                    {
                        AlarmEventTypeId   = Convert.ToInt32(alarmEventType),
                        ResidentId         = item.Id,
                        Title              = alarmTitle,
                        Body               = alarmBody,
                        IsDelivered        = false,
                        IsSMS              = false,
                        PatientFullName    = medicalRecord.PatientFirstName + " " + medicalRecord.PatientLastName,
                        TreatmentProcessId = medicalRecord.TreatmentProcessId,
                        SendDate           = DateTime.Now
                    });
                }
            }
            if (NeedSendToPhysist)
            {
                var physictList = physicUserService.GetPhysicUsers();
                foreach (var item in physictList)
                {
                    alarmService.AddAlarm(new Alarm()
                    {
                        AlarmEventTypeId   = Convert.ToInt32(alarmEventType),
                        PhysicUserId       = item.Id,
                        Title              = alarmTitle,
                        Body               = alarmBody,
                        IsDelivered        = false,
                        IsSMS              = false,
                        PatientFullName    = medicalRecord.PatientFirstName + " " + medicalRecord.PatientLastName,
                        TreatmentProcessId = medicalRecord.TreatmentProcessId,
                        SendDate           = DateTime.Now
                    });
                }
            }


            //SMS Part
            SendSMSAlarm((int)patientId, alarmEventType);
        }