parent
8f903b1c4d
commit
6ff41f617b
@ -0,0 +1,160 @@ |
|||||||
|
<?php |
||||||
|
declare(strict_types = 1); |
||||||
|
|
||||||
|
namespace App\Http\Controllers\Message; |
||||||
|
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller; |
||||||
|
use App\Http\Logics\Message\TriggerLogic; |
||||||
|
use Illuminate\Http\JsonResponse; |
||||||
|
use Illuminate\Http\Request; |
||||||
|
use Illuminate\Support\Facades\Validator; |
||||||
|
use Symfony\Component\HttpFoundation\Response; |
||||||
|
|
||||||
|
class TriggerController extends Controller |
||||||
|
{ |
||||||
|
|
||||||
|
protected TriggerLogic $trigger_logic; |
||||||
|
|
||||||
|
/** |
||||||
|
* Patient Construct. |
||||||
|
*/ |
||||||
|
public function __construct() |
||||||
|
{ |
||||||
|
$this->trigger_logic = new TriggerLogic(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 挂号停诊消息 |
||||||
|
* @param Request $request |
||||||
|
* @return JsonResponse |
||||||
|
*/ |
||||||
|
public function registerStopRemind(Request $request): JsonResponse |
||||||
|
{ |
||||||
|
$validated = Validator::make($request->all(), [ |
||||||
|
'patient_id' => 'required', |
||||||
|
'reg_date' => 'required|date_format:Y-m-d', |
||||||
|
'begin_time' => 'required|date_format:H:i', |
||||||
|
'end_time' => 'required|date_format:H:i', |
||||||
|
'dept_name' => 'required', |
||||||
|
'doctor_name' => 'required', |
||||||
|
'tips' => 'required|max:20', |
||||||
|
],[ |
||||||
|
'patient_id.required' => '请传入患者ID', |
||||||
|
'reg_date.required' => '请传入看诊日期', |
||||||
|
'reg_date.date_format' => '请传入正确的看诊日期', |
||||||
|
'begin_time.required' => '请传入看诊开始时间段', |
||||||
|
'begin_time.date_format' => '请传入正确的看诊开始时间段', |
||||||
|
'end_time.required' => '请传入看诊结束时间段', |
||||||
|
'end_time.date_format' => '请传入正确的看诊结束时间段', |
||||||
|
'dept_name.required' => '请传入科室名称', |
||||||
|
'doctor_name.required' => '请传入医生名称', |
||||||
|
'tips.required' => '请传入提示信息', |
||||||
|
'tips.max' => '提示信息长度不得超过20', |
||||||
|
]); |
||||||
|
|
||||||
|
if ($validated->fails()) { |
||||||
|
return jsonResponseToHis(Response::HTTP_OK, 1, $validated->errors()->first()); |
||||||
|
} |
||||||
|
|
||||||
|
$validated = $request->safe()->only(['patient_id', 'reg_date', 'begin_time', 'end_time', 'dept_name', 'doctor_name', 'tips']); |
||||||
|
|
||||||
|
[$result, $message] = $this->trigger_logic->registerStopRemind( |
||||||
|
$validated['patient_id'], |
||||||
|
$validated['reg_date'], |
||||||
|
$validated['begin_time'], |
||||||
|
$validated['end_time'], |
||||||
|
$validated['dept_name'], |
||||||
|
$validated['doctor_name'], |
||||||
|
$validated['tips'], |
||||||
|
); |
||||||
|
|
||||||
|
return jsonResponseToHis(Response::HTTP_OK, $result, $message); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 待缴费提醒 |
||||||
|
* @param Request $request |
||||||
|
* @return JsonResponse |
||||||
|
*/ |
||||||
|
public function pendingPaymentRemind(Request $request): JsonResponse |
||||||
|
{ |
||||||
|
$validated = Validator::make($request->all(), [ |
||||||
|
'patient_id' => 'required', |
||||||
|
'dept_name' => 'required', |
||||||
|
'fee' => 'required|numeric', |
||||||
|
'fee_type' => 'required', |
||||||
|
'tips_message' => 'required|max:20', |
||||||
|
],[ |
||||||
|
'patient_id.required' => '请传入患者ID', |
||||||
|
'dept_name.required' => '请传入科室名称', |
||||||
|
'fee.required' => '请传入待缴纳处方费用', |
||||||
|
'fee.numeric' => '待缴纳处方费用必须传入数字', |
||||||
|
'fee_type.required' => '请传入待缴纳处方类型', |
||||||
|
'tips_message.required' => '请传入提示信息', |
||||||
|
'tips.max' => '提示信息长度不得超过20', |
||||||
|
]); |
||||||
|
|
||||||
|
if ($validated->fails()) { |
||||||
|
return jsonResponseToHis(Response::HTTP_OK, 1, $validated->errors()->first()); |
||||||
|
} |
||||||
|
|
||||||
|
$validated = $request->safe()->only(['patient_id', 'dept_name', 'fee', 'fee_type', 'tips_message']); |
||||||
|
|
||||||
|
[$result, $message] = $this->trigger_logic->pendingPaymentRemind( |
||||||
|
$validated['patient_id'], |
||||||
|
$validated['dept_name'], |
||||||
|
$validated['fee'], |
||||||
|
$validated['fee_type'], |
||||||
|
$validated['tips'], |
||||||
|
); |
||||||
|
|
||||||
|
return jsonResponseToHis(Response::HTTP_OK, $result, $message); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 报告发布提醒 |
||||||
|
* @param Request $request |
||||||
|
* @return JsonResponse |
||||||
|
*/ |
||||||
|
public function reportReleaseRemind(Request $request): JsonResponse |
||||||
|
{ |
||||||
|
$validated = Validator::make($request->all(), [ |
||||||
|
'patient_id' => 'required', |
||||||
|
'report_type' => 'required|in:1,2', |
||||||
|
'item_name' => 'required', |
||||||
|
'report_time' => 'required|date_format:Y-m-d H:i:s', |
||||||
|
'report_serial_no' => 'required', |
||||||
|
'dept_name' => 'required', |
||||||
|
'remark' => 'required|max:20', |
||||||
|
],[ |
||||||
|
'patient_id.required' => '请传入患者ID', |
||||||
|
'report_type.required' => '请传入报告类型', |
||||||
|
'report_type.in' => '请传入正确的报告类型', |
||||||
|
'item_name.required' => '请传入报告名称', |
||||||
|
'report_time.required' => '请传入报告时间', |
||||||
|
'report_time.date_format' => '报告时间格式错误', |
||||||
|
'report_serial_no.required' => '请传入报告流水号', |
||||||
|
'remark.required' => '请传入备注信息', |
||||||
|
'remark.max' => '备注信息长度不得超过20', |
||||||
|
]); |
||||||
|
|
||||||
|
if ($validated->fails()) { |
||||||
|
return jsonResponseToHis(Response::HTTP_OK, 1, $validated->errors()->first()); |
||||||
|
} |
||||||
|
|
||||||
|
$validated = $request->safe()->only(['patient_id', 'report_type', 'item_name', 'report_time', 'report_serial_no', 'dept_name', 'remark']); |
||||||
|
|
||||||
|
[$result, $message] = $this->trigger_logic->reportReleaseRemind( |
||||||
|
$validated['patient_id'], |
||||||
|
$validated['report_type'], |
||||||
|
$validated['item_name'], |
||||||
|
$validated['report_time'], |
||||||
|
$validated['report_serial_no'], |
||||||
|
$validated['dept_name'], |
||||||
|
$validated['remark'] |
||||||
|
); |
||||||
|
|
||||||
|
return jsonResponseToHis(Response::HTTP_OK, $result, $message); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,94 @@ |
|||||||
|
<?php |
||||||
|
declare(strict_types = 1); |
||||||
|
|
||||||
|
namespace App\Http\Logics\Message; |
||||||
|
|
||||||
|
use App\Exceptions\GeneralException; |
||||||
|
use App\Models\Patient; |
||||||
|
use App\Utils\Traits\Logger; |
||||||
|
use App\Utils\Traits\SendSubscribeMessage; |
||||||
|
use Illuminate\Http\JsonResponse; |
||||||
|
use Symfony\Component\HttpFoundation\Response; |
||||||
|
|
||||||
|
class TriggerLogic |
||||||
|
{ |
||||||
|
use Logger; |
||||||
|
use SendSubscribeMessage; |
||||||
|
|
||||||
|
private Patient $patient_model; |
||||||
|
|
||||||
|
/** |
||||||
|
* TriggerLogic Construct |
||||||
|
*/ |
||||||
|
public function __construct(){ |
||||||
|
$this->patient_model = new Patient(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 挂号停诊 |
||||||
|
* @param string $patient_id |
||||||
|
* @param string $reg_date |
||||||
|
* @param string $begin_time |
||||||
|
* @param string $end_time |
||||||
|
* @param string $dept_name |
||||||
|
* @param string $doctor_name |
||||||
|
* @param string $tips_message |
||||||
|
* @return array |
||||||
|
*/ |
||||||
|
public function registerStopRemind(string $patient_id, string $reg_date, string $begin_time, string $end_time, string $dept_name, string $doctor_name, string $tips_message): array |
||||||
|
{ |
||||||
|
$info = $this->patient_model->getPatientInfoByPatientId($patient_id); |
||||||
|
if (empty($info)) { |
||||||
|
return [false, '未找到该患者绑定信息']; |
||||||
|
} |
||||||
|
|
||||||
|
$this->sendRegistrationStopRemindMessage($info, $reg_date, $begin_time, $end_time, $dept_name, $doctor_name, $tips_message); |
||||||
|
|
||||||
|
return [true, '成功,已加入推送队列。']; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 待缴费提醒 |
||||||
|
* @param string $patient_id |
||||||
|
* @param string $dept_name |
||||||
|
* @param string $fee |
||||||
|
* @param string $fee_type |
||||||
|
* @param string $tips_message |
||||||
|
* @return array |
||||||
|
*/ |
||||||
|
public function pendingPaymentRemind(string $patient_id, string $dept_name, string $fee, string $fee_type, string $tips_message): array |
||||||
|
{ |
||||||
|
$info = $this->patient_model->getPatientInfoByPatientId($patient_id); |
||||||
|
if (empty($info)) { |
||||||
|
return [false, '未找到该患者绑定信息']; |
||||||
|
} |
||||||
|
|
||||||
|
$this->sendPendingPaymentRemindMessage($info, $dept_name, $fee, $fee_type, $tips_message); |
||||||
|
|
||||||
|
return [true, '成功,已加入推送队列。']; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 报告发布提醒 |
||||||
|
* @param string $patient_id |
||||||
|
* @param int $report_type |
||||||
|
* @param string $item_name |
||||||
|
* @param string $report_time |
||||||
|
* @param string $report_serial_no |
||||||
|
* @param string $dept_name |
||||||
|
* @param string $remark |
||||||
|
* @return array |
||||||
|
*/ |
||||||
|
public function reportReleaseRemind(string $patient_id, int $report_type, string $item_name, string $report_time, string $report_serial_no, string $dept_name, string $remark = ''): array |
||||||
|
{ |
||||||
|
$info = $this->patient_model->getPatientInfoByPatientId($patient_id); |
||||||
|
if (empty($info)) { |
||||||
|
return [false, '未找到该患者绑定信息']; |
||||||
|
} |
||||||
|
|
||||||
|
$this->sendReportReleaseRemindMessage($info, $report_type, $item_name, $report_time, $report_serial_no, $dept_name, $remark); |
||||||
|
|
||||||
|
return [true, '成功,已加入推送队列。']; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,39 @@ |
|||||||
|
<?php |
||||||
|
declare(strict_types = 1); |
||||||
|
|
||||||
|
namespace App\Http\Middleware; |
||||||
|
|
||||||
|
use Closure; |
||||||
|
use Illuminate\Http\Request; |
||||||
|
|
||||||
|
class IntranetAccess |
||||||
|
{ |
||||||
|
|
||||||
|
/** |
||||||
|
* @param Request $request |
||||||
|
* @param Closure $next |
||||||
|
* @return mixed |
||||||
|
*/ |
||||||
|
public function handle(Request $request, Closure $next): mixed |
||||||
|
{ |
||||||
|
$forwarded = request()->header("x-forwarded-for"); |
||||||
|
if($forwarded){ |
||||||
|
$ip = explode(',',$forwarded)[0]; |
||||||
|
}else{ |
||||||
|
$ip = request()->ip(); |
||||||
|
} |
||||||
|
|
||||||
|
if( |
||||||
|
$ip != '::1' && |
||||||
|
$ip != '127.0.0.1' && |
||||||
|
!str_starts_with($ip, "10.") && |
||||||
|
!str_starts_with($ip, "172.") && |
||||||
|
!str_starts_with($ip, "192.") |
||||||
|
) { |
||||||
|
return response('Not Found.', 404); |
||||||
|
} |
||||||
|
|
||||||
|
return $next($request); |
||||||
|
} |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue