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.
63 lines
1.9 KiB
63 lines
1.9 KiB
<?php
|
|
declare(strict_types = 1);
|
|
|
|
namespace App\Http\Controllers\Outpatient;
|
|
|
|
use App\Exceptions\GeneralException;
|
|
use App\Http\Logics\Outpatient\RecordLogic;
|
|
use App\Http\Resources\Outpatient\Record\RecordDetailsResource;
|
|
use App\Http\Resources\Outpatient\Record\RecordListsResource;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
class RecordController
|
|
{
|
|
protected RecordLogic $record_logic;
|
|
|
|
/**
|
|
* RecordController Construct.
|
|
*/
|
|
public function __construct()
|
|
{
|
|
$this->record_logic = new RecordLogic();
|
|
}
|
|
|
|
/**
|
|
* 获取缴费记录列表
|
|
* @param Request $request
|
|
* @param string $patient_id
|
|
* @return JsonResponse
|
|
* @throws GeneralException
|
|
*/
|
|
public function lists(Request $request, string $patient_id): JsonResponse
|
|
{
|
|
$validated = $request->validate([
|
|
'start_date' => 'date_format:Y-m-d',
|
|
'end_date' => 'date_format:Y-m-d|after:start_date',
|
|
], [
|
|
'start_date.date_format' => '日期格式错误',
|
|
'end_date.date_format' => '日期格式错误',
|
|
'end_date.after' => '查询日期错误',
|
|
]);
|
|
|
|
$response = $this->record_logic->getRecordLists($patient_id, $validated['start_date'] ?? '', $validated['end_date'] ?? '');
|
|
|
|
return jsonResponse(Response::HTTP_OK, 'success', RecordListsResource::make($response)->toArray());
|
|
}
|
|
|
|
/**
|
|
* 获取缴费记录详情
|
|
* @param Request $request
|
|
* @param string $patient_id
|
|
* @param string $serial_no
|
|
* @return JsonResponse
|
|
* @throws GeneralException
|
|
*/
|
|
public function details(Request $request, string $patient_id, string $serial_no): JsonResponse
|
|
{
|
|
$response = $this->record_logic->getRecordDetails($patient_id, $serial_no);
|
|
|
|
return jsonResponse(Response::HTTP_OK, 'success.', RecordDetailsResource::make($response)->toArray());
|
|
}
|
|
}
|
|
|