/// <summary> /// 保存患教 /// </summary> /// <param name="input">患教输入</param> /// <returns>是否保存成功</returns> public async Task <OutputBase> Add(AddPatientEduInput input) { var doctor = await _doctorRepository.GetDoctorById(input.DoctorId); if (doctor == null) { return(OutputBase.Fail("医生Id参数不正确,该医护人员不存在")); } if (input.PatientIds.Count < 1) { return(OutputBase.Fail("患者Id数组参数个数不能为0")); } if (input.CourseList.Count < 1) { return(OutputBase.Fail("课程列表参数个数不能为0")); } string content = string.Format("{0}医生向您发送了新的课程", doctor.Name); var patientEduList = new List <PatientEducation>(); foreach (var patientId in input.PatientIds) { var batchNumber = DateTime.Now.ToString(CommConstant.FullTimeFormatString); foreach (var course in input.CourseList) { _repository.Add(course, patientId, input.DoctorId, batchNumber); } var messageEntity = new Message { IsRead = false, OuterId = batchNumber + input.DoctorId.ToString().PadLeft(18, '0') + patientId.ToString().PadLeft(18, '0'), Content = content, ReceiveId = patientId, Title = "患教课程", Type = (int)MessageTypeEnum.患教课程, SendId = input.DoctorId, SendName = doctor.Name, Url = string.Empty, AppType = (int)AppTypeEnum.Patient }; _messageRepository.Add(messageEntity); #region 异步发送JPush Notification、Message ThreadPool.QueueUserWorkItem(delegate { new JPushMessage(AppTypeEnum.Patient, (int)JPushKeyEnum.PatientEducation, patientId.ToString(), content, messageEntity.OuterId, _optionsAccessor.IsDevModel).SendPush(); new JPushNotification(AppTypeEnum.Patient, (int)JPushKeyEnum.PatientEducation, patientId.ToString(), content, messageEntity.OuterId, _optionsAccessor.IsDevModel).SendPush(); }); #endregion } return(_unitWork.Commit() ? OutputBase.Success("保存成功") : OutputBase.Fail("保存失败")); }
/// <summary> /// 确认报警记录 /// </summary> /// <param name="input">确认报警记录输入</param> /// <returns>是否成功</returns> public async Task <OutputBase> ConfirmAlarm(ConfirmAlarmInput input) { var alarm = await _repository.GetAlarmById(input.AlarmId); if (alarm == null) { return(OutputBase.Fail("该报警记录不存在")); } var doctor = await _doctorRepository.GetDoctorById(input.DoctorId); if (doctor == null) { return(OutputBase.Fail("确认的医护人员不存在")); } await _repository.ConfirmAlarm(input.AlarmId); string content = string.Format("{0}医生确认了您的体重预警", doctor.Name); var entity = new Message { IsRead = false, Content = content, ReceiveId = alarm.PatientId, Title = "确认体重预警", Type = (int)MessageTypeEnum.确认体重预警, SendId = input.DoctorId, SendName = doctor.Name, Url = string.Empty, OuterId = input.AlarmId.ToString(), AppType = (int)AppTypeEnum.Patient }; _messageRepository.Add(entity); if (!_unitWork.Commit()) { return(OutputBase.Fail("确认失败")); } #region 异步发送JPush Notification、Message ThreadPool.QueueUserWorkItem(delegate { new JPushMessage(AppTypeEnum.Patient, (int)JPushKeyEnum.ConfirmAlarm, alarm.PatientId.ToString(), content, entity.OuterId, _optionsAccessor.IsDevModel).SendPush(); new JPushNotification(AppTypeEnum.Patient, (int)JPushKeyEnum.ConfirmAlarm, alarm.PatientId.ToString(), content, entity.OuterId, _optionsAccessor.IsDevModel).SendPush(); }); #endregion return(OutputBase.Success("确认成功")); }
/// <summary> /// 根据医护人员Id获取医护人员(后台)详情 /// </summary> /// <param name="id">医护人员Id</param> /// <returns>医护人员</returns> public async Task <DoctorViewDto> GetAdminDetailDoctorById(long id) { var doctor = await _repository.GetDoctorById(id); return(Mapper.Map <Doctor, DoctorViewDto>(doctor)); }