You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
111 lines
3.5 KiB
111 lines
3.5 KiB
6 days ago
|
<?php
|
||
|
declare(strict_types = 1);
|
||
|
|
||
|
namespace App\Http\Controllers\Outpatient;
|
||
|
|
||
|
use App\Dictionary\Medical\SettleType;
|
||
|
use App\Exceptions\GeneralException;
|
||
|
use App\Http\Logics\Outpatient\MedicalLogic;
|
||
|
use App\Http\Resources\Outpatient\Medical\PrescriptionPreSettleResource;
|
||
|
use Illuminate\Http\JsonResponse;
|
||
|
use Illuminate\Http\Request;
|
||
|
use Illuminate\Validation\Rules\Enum;
|
||
|
use Symfony\Component\HttpFoundation\Response;
|
||
|
|
||
|
class MedicalController
|
||
|
{
|
||
|
protected MedicalLogic $medical_logic;
|
||
|
|
||
|
/**
|
||
|
* MedicalController Construct.
|
||
|
*/
|
||
|
public function __construct()
|
||
|
{
|
||
|
$this->medical_logic = new MedicalLogic();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 跳转免密授权页面
|
||
|
* @param Request $request
|
||
|
* @return JsonResponse
|
||
|
*/
|
||
|
public function redirectAuth(Request $request): JsonResponse
|
||
|
{
|
||
|
$redirect_url = $this->medical_logic->getMiniProgramAuthRedirectUrl();
|
||
|
|
||
|
return jsonResponse(Response::HTTP_OK, 'success', [
|
||
|
// 固定跳转医保小程序APP ID
|
||
|
'app_id' => config('custom.redirect_app_id'),
|
||
|
'url' => $redirect_url
|
||
|
]);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 查询患者授权信息
|
||
|
* @param Request $request
|
||
|
* @param string $patient_id
|
||
|
* @return JsonResponse
|
||
|
* @throws GeneralException
|
||
|
*/
|
||
|
public function userAuthInfo(Request $request, string $patient_id): JsonResponse
|
||
|
{
|
||
|
$validated = $request->validate([
|
||
|
'auth_code.require' => 'required',
|
||
|
], [
|
||
|
'auth_code.required' => '查询数据参数错误',
|
||
|
]);
|
||
|
|
||
|
$user_info = $this->medical_logic->queryPatientMedicalInsuranceAuthInfo($patient_id, $validated['auth_code']);
|
||
|
|
||
|
return jsonResponse(Response::HTTP_OK, 'success', $user_info);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 处方预结算
|
||
|
* @param Request $request
|
||
|
* @param string $patient_id
|
||
|
* @param string $serial_no
|
||
|
* @return JsonResponse
|
||
|
* @throws GeneralException
|
||
|
*/
|
||
|
public function prescriptionPreSettle(Request $request, string $patient_id, string $serial_no): JsonResponse
|
||
|
{
|
||
|
$validated = $request->validate([
|
||
|
'settle_type' => ['required', new Enum(SettleType::class)],
|
||
|
], [
|
||
|
'settle_type.required' => '请选择结算类型',
|
||
|
'settle_type.Illuminate\Validation\Rules\Enum' => '请选择正确的结算类型',
|
||
|
]);
|
||
|
|
||
|
$settle_type = SettleType::from((int) $validated['settle_type']);
|
||
|
|
||
|
$response = $this->medical_logic->pendingPrescriptionPreSettle($patient_id, $serial_no, $settle_type);
|
||
|
|
||
|
return jsonResponse(Response::HTTP_OK, 'success', PrescriptionPreSettleResource::make($response)->toArray());
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 医保支付
|
||
|
* @param Request $request
|
||
|
* @param string $patient_id
|
||
|
* @param string $serial_no
|
||
|
* @return JsonResponse
|
||
|
* @throws GeneralException
|
||
|
*/
|
||
|
public function payment(Request $request, string $patient_id, string $serial_no): JsonResponse
|
||
|
{
|
||
|
$validated = $request->validate([
|
||
|
'settle_type' => ['required', new Enum(SettleType::class)],
|
||
|
], [
|
||
|
'settle_type.required' => '请选择结算类型',
|
||
|
'settle_type.Illuminate\Validation\Rules\Enum' => '请选择正确的结算类型',
|
||
|
]);
|
||
|
|
||
|
$settle_type = SettleType::from((int) $validated['settle_type']);
|
||
|
|
||
|
$response = $this->medical_logic->medicalPayment($patient_id, $serial_no, $settle_type);
|
||
|
|
||
|
return jsonResponse(Response::HTTP_OK, 'success', $response);
|
||
|
}
|
||
|
}
|