137 lines
7.3 KiB
PHP
137 lines
7.3 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Controllers;
|
|
|
|
use App\Enums\OrderStatus;
|
|
use App\Admin\Components;
|
|
use App\Models\{Keyword, Patient};
|
|
use Slowlyo\OwlAdmin\Models\AdminUser;
|
|
use App\Admin\Services\PatientRecordService;
|
|
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
|
use Slowlyo\OwlAdmin\Renderers\Form;
|
|
use Slowlyo\OwlAdmin\Renderers\Page;
|
|
|
|
/**
|
|
* 病历管理
|
|
*/
|
|
class PatientRecordController extends AdminController
|
|
{
|
|
protected string $serviceName = PatientRecordService::class;
|
|
|
|
protected $typeOptions;
|
|
|
|
protected $patientOptions;
|
|
|
|
protected $adminUserOptions;
|
|
|
|
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()->SelectControl()->options($this->getPatientOptions())->searchable()->name('patient_id')->label(__('patient_record.patient_id'))->size('md')->clearable(),
|
|
amisMake()->SelectControl()->options($this->getTypeOptions())->name('type_id')->label(__('patient_record.type_id'))->size('md')->clearable(),
|
|
amisMake()->DateRangeControl()->name('treat_range')->label(__('patient_record.treat_at'))->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_record.id')),
|
|
amisMake()->TableColumn()->name('patient.name')->label(__('patient_record.patient_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')),
|
|
$this->rowActions(),
|
|
]);
|
|
|
|
return $this->baseList($crud);
|
|
}
|
|
|
|
public function form($isEdit, $patient_id = null): Form
|
|
{
|
|
$patient_element = amisMake()->SelectControl()->options($this->getPatientOptions())->searchable()->name('patient_id')->label(__('patient_record.patient_id'))->required();
|
|
if ($patient_id) {
|
|
$patient_element->value($patient_id)->static();
|
|
}
|
|
return $this->baseForm()->body([
|
|
$patient_element,
|
|
amisMake()->SelectControl()->options($this->getTypeOptions())->name('type_id')->label(__('patient_record.type_id'))->required()->onEvent([
|
|
'change' => [
|
|
'actions' => [
|
|
['actionType' => 'reload', 'componentId' => 'patient_record_form_content_service', 'args' => ['select_type_id' => '${type_id}']]
|
|
]
|
|
]
|
|
]),
|
|
amisMake()->DateTimeControl()->name('treat_at')->label(__('patient_record.treat_at'))->value(now())->required(),
|
|
amisMake()->SelectControl()->options($this->getAdminUserOptions())->name('doctor_id')->label(__('patient_record.doctor_id'))->required(),
|
|
amisMake()->NumberControl()->name('origin_price')->label(__('patient_record.origin_price'))->required(),
|
|
amisMake()->NumberControl()->name('sell_price')->label(__('patient_record.sell_price'))->required(),
|
|
amisMake()->SelectControl()->options(OrderStatus::options())->name('order_status')->label(__('patient_record.order_status'))->default(OrderStatus::Success->value)->required(),
|
|
amisMake()->Service()
|
|
->className('cxd-Form-item')
|
|
->id('patient_record_form_content_service')
|
|
->api(amisMake()->BaseApi()->method('get')->url(admin_url('api/category/content?id=${select_type_id}')))
|
|
->initFetch(false)
|
|
->body(amisMake()->TextareaControl()->name('content')->label(__('patient_record.content'))),
|
|
amisMake()->DateTimeControl()->name('next_treat_at')->label(__('patient_record.next_treat_at')),
|
|
amisMake()->SelectControl()->options($this->getAdminUserOptions())->name('notify_user_id')->label(__('patient_record.notify_user_id')),
|
|
amisMake()->DateTimeControl()->name('notify_at')->label(__('patient_record.notify_at')),
|
|
amisMake()->TextControl()->name('notify_remarks')->label(__('patient_record.notify_remarks')),
|
|
amisMake()->TextControl()->label(__('patient_record.creator_id'))->value($this->user()->name)->staitc(),
|
|
]);
|
|
}
|
|
|
|
public function detail()
|
|
{
|
|
return $this->baseDetail()->body([
|
|
amisMake()->TextControl()->name('patient_id')->label(__('patient_record.patient_id'))->static(),
|
|
amisMake()->TextControl()->name('type_id')->label(__('patient_record.type_id'))->static(),
|
|
amisMake()->DateTimeControl()->name('treat_at')->label(__('patient_record.treat_at'))->static(),
|
|
amisMake()->SelectControl()->options($this->getAdminUserOptions())->name('doctor_id')->label(__('patient_record.doctor_id'))->static(),
|
|
amisMake()->TextControl()->name('origin_price')->label(__('patient_record.origin_price'))->static(),
|
|
amisMake()->TextControl()->name('sell_price')->label(__('patient_record.sell_price'))->static(),
|
|
amisMake()->SelectControl()->options(OrderStatus::options())->name('order_status')->label(__('patient_record.order_status'))->static(),
|
|
amisMake()->TextareaControl()->name('content')->label(__('patient_record.content'))->static(),
|
|
amisMake()->DateTimeControl()->name('next_treat_at')->label(__('patient_record.next_treat_at'))->static(),
|
|
amisMake()->SelectControl()->options($this->getAdminUserOptions())->name('notify_user_id')->label(__('patient_record.notify_user_id'))->placeholder('')->static(),
|
|
amisMake()->DateTimeControl()->name('notify_at')->label(__('patient_record.notify_at'))->static(),
|
|
amisMake()->TextControl()->name('notify_remarks')->label(__('patient_record.notify_remarks'))->static(),
|
|
amisMake()->SelectControl()->options($this->getAdminUserOptions())->name('creator_id')->label(__('patient_record.creator_id'))->static(),
|
|
amisMake()->DateTimeControl()->name('created_at')->label(__('patient.created_at'))->static(),
|
|
]);
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
public function getPatientOptions()
|
|
{
|
|
if (!$this->patientOptions) {
|
|
$this->patientOptions = Patient::select(['id as value', 'name as label'])->get();
|
|
}
|
|
|
|
return $this->patientOptions;
|
|
}
|
|
|
|
public function getAdminUserOptions()
|
|
{
|
|
if (!$this->adminUserOptions) {
|
|
$this->adminUserOptions = AdminUser::select(['id as value', 'name as label'])->get();
|
|
}
|
|
|
|
return $this->adminUserOptions;
|
|
}
|
|
}
|