149 lines
7.0 KiB
PHP
149 lines
7.0 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Controllers;
|
|
|
|
use App\Enums\Gender;
|
|
use App\Admin\Components;
|
|
use App\Admin\Services\PatientService;
|
|
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
|
use Slowlyo\OwlAdmin\Renderers\Form;
|
|
use Slowlyo\OwlAdmin\Renderers\Page;
|
|
use App\Models\Keyword;
|
|
|
|
/**
|
|
* 病人管理
|
|
*/
|
|
class PatientController extends AdminController
|
|
{
|
|
protected string $serviceName = PatientService::class;
|
|
|
|
protected $typeOptions;
|
|
|
|
public function list(): Page
|
|
{
|
|
$crud = $this->baseCRUD()
|
|
->filterTogglable(false)
|
|
->columnsTogglable(false)
|
|
->headerToolbar([
|
|
$this->createButton(true, 'lg'),
|
|
amis('reload')->align('right'),
|
|
])
|
|
->filter($this->baseFilter()->actions()->body([
|
|
amisMake()->TextControl()->name('keyword')->label(__('patient.keyword'))->placeholder(__('patient.name') . '/' . __('patient.phone'))->size('md')->clearable(),
|
|
// amisMake()->Button()->label(__('admin.reset'))->actionType('clear-and-submit'),
|
|
amisMake()->Component()->setType('submit')->label(__('admin.search'))->level('primary'),
|
|
]))
|
|
->columns([
|
|
amisMake()->TableColumn()->name('id')->label(__('patient.id')),
|
|
amisMake()->TableColumn()->name('name')->label(__('patient.name')),
|
|
amisMake()->TableColumn()->name('sex_text')->label(__('patient.sex')),
|
|
amisMake()->TableColumn()->name('phone')->label(__('patient.phone')),
|
|
amisMake()->TableColumn()->name('age')->label(__('patient.age')),
|
|
amisMake()->TableColumn()->name('treat_format')->label(__('patient.treat_at')),
|
|
$this->rowActions(),
|
|
]);
|
|
|
|
return $this->baseList($crud);
|
|
}
|
|
|
|
public function form(): Form
|
|
{
|
|
return $this->baseForm()->body([
|
|
amisMake()->TextControl()->name('name')->label(__('patient.name'))->required(true),
|
|
amisMake()->SelectControl()->options(Gender::options())->name('sex')->label(__('patient.sex')),
|
|
amisMake()->TextControl()->name('phone')->label(__('patient.phone')),
|
|
amisMake()->TextControl()->name('address')->label(__('patient.address')),
|
|
amisMake()->DateControl()->name('birthday')->label(__('patient.birthday')),
|
|
amisMake()->DateControl()->name('treat_at')->label(__('patient.treat_at')),
|
|
Components::make()->adminUserSelectControl()->name('doctor_id')->label(__('patient.doctor_id')),
|
|
amisMake()->TextareaControl()->name('illness')->label(__('patient.illness')),
|
|
]);
|
|
}
|
|
|
|
public function show($id)
|
|
{
|
|
if ($this->actionOfGetData()) {
|
|
return $this->response()->success($this->service->getDetail($id));
|
|
}
|
|
|
|
$record = new PatientRecordController();
|
|
$detail = amisMake()
|
|
->Card()
|
|
->className('base-form')
|
|
->header(['title' => __('admin.detail')])
|
|
->body($this->detail($id))
|
|
->toolbar([
|
|
amisMake()->Button()->label('修改基础信息')
|
|
->level('primary')
|
|
->className('mr-1')
|
|
->actionType('dialog')
|
|
->dialog(amisMake()->Dialog()->size('lg')->title('修改基础信息')->body(
|
|
$this->form(true)->api($this->getUpdatePath())->initApi($this->getEditGetDataPath())->onEvent([
|
|
'submitSucc' => [
|
|
'actions' => [
|
|
['actionType' => 'custom', 'script' => 'window.$owl.refreshAmisPage()',]
|
|
]
|
|
]
|
|
])
|
|
)),
|
|
amisMake()->Button()->label('添加病历记录')
|
|
->level('warning')
|
|
->className('mr-1')
|
|
->actionType('dialog')
|
|
->dialog(amisMake()->Dialog()->size('lg')->title('修改基础信息')->body(
|
|
$record->form(false, $id)->api('post:' . admin_url('/record'))->onEvent([
|
|
'submitSucc' => [
|
|
'actions' => [
|
|
['actionType' => 'custom', 'script' => 'window.$owl.refreshAmisPage()',]
|
|
]
|
|
]
|
|
])
|
|
)),
|
|
$this->backButton()
|
|
]);
|
|
|
|
$page = $this->basePage()->body($detail);
|
|
|
|
return $this->response()->success($page);
|
|
}
|
|
|
|
public function detail($id)
|
|
{
|
|
return $this->baseDetail()->body(amisMake()->Tabs()->tabs([
|
|
amisMake()->Tab()->title('基础信息')->body([
|
|
amisMake()->TextControl()->name('name')->label(__('patient.name'))->static(),
|
|
amisMake()->SelectControl()->options(Gender::options())->name('sex')->label(__('patient.sex'))->static(),
|
|
amisMake()->TextControl()->name('phone')->label(__('patient.phone'))->static(),
|
|
amisMake()->TextControl()->name('address')->label(__('patient.address'))->static(),
|
|
amisMake()->DateControl()->name('birthday')->label(__('patient.birthday'))->static(),
|
|
amisMake()->DateControl()->name('treat_format')->label(__('patient.treat_at'))->static(),
|
|
amisMake()->TextControl()->name('doctor.name')->label(__('patient.doctor_id'))->static(),
|
|
amisMake()->TextareaControl()->name('illness')->label(__('patient.illness'))->static(),
|
|
amisMake()->TextControl()->name('created_at')->label(__('patient.created_at'))->static(),
|
|
]),
|
|
amisMake()->Tab()->title('病历记录')->body(amisMake()->Service()
|
|
->api(admin_url('/record?_action=getData&page=1&patient_id='.$id.'&perPage=20'))
|
|
->body(amisMake()->Table()->columns([
|
|
amisMake()->TableColumn()->name('id')->label(__('patient_record.id')),
|
|
amisMake()->Mapping()->map($this->getTypeOptions()->pluck('label', 'value'))->name('type_id')->label(__('patient_record.type_id')),
|
|
amisMake()->TableColumn()->name('treat_at')->label(__('patient_record.treat_at')),
|
|
amisMake()->TableColumn()->name('next_treat_at')->label(__('patient_record.next_treat_at')),
|
|
amisMake()->TableColumn()->name('doctor.name')->label(__('patient_record.doctor_id')),
|
|
])->affixRow([
|
|
amisMake()->Button()->level('link')->label('查看更多')->colSpan(5)->actionType('link')->link(admin_url('/record?patient_id=' . $id)),
|
|
])
|
|
)
|
|
)
|
|
]));
|
|
}
|
|
|
|
public function getTypeOptions()
|
|
{
|
|
if (!$this->typeOptions) {
|
|
$this->typeOptions = Keyword::where('type_key', 'treat_type')->select(['id as value', 'name as label'])->get();
|
|
}
|
|
|
|
return $this->typeOptions;
|
|
}
|
|
}
|