From 3ce99c0d32333226da80232b433933f81555c3a1 Mon Sep 17 00:00:00 2001 From: panliang <1163816051@qq.com> Date: Thu, 26 Oct 2023 18:00:07 +0800 Subject: [PATCH] patient_records.description --- app/Admin/Controllers/PatientRecordController.php | 8 +++++--- app/Admin/Controllers/TotalIllnessTypeController.php | 4 ++++ app/Admin/Services/TotalIllnessTypeService.php | 8 +++++++- app/Console/Commands/PatientRecordNotify.php | 2 +- app/Console/Kernel.php | 2 +- app/Models/PatientRecord.php | 4 ++-- .../2023_08_30_090313_create_patient_records_table.php | 1 + lang/zh_CN/patient-record.php | 1 + lang/zh_CN/total-illness-type.php | 1 + public/client/index.html | 2 +- public/client/static/js/344.740e9724.js | 3 +++ .../client/static/js/{344.bc29a90f.js => 649.bf08206b.js} | 2 +- public/client/static/js/93.8e102193.js | 1 - public/client/static/js/index.a1eadb07.js | 1 - public/client/static/js/index.e21192b7.js | 1 + public/client/static/js/pages-patient-detail.ab48b8d6.js | 1 - public/client/static/js/pages-patient-detail.be8913bf.js | 1 + public/client/static/js/pages-record-detail.7f5c9b4c.js | 3 --- public/client/static/js/pages-record-detail.cfc0a862.js | 1 + public/client/static/js/pages-record-index.8e7cbbf3.js | 1 - public/client/static/js/pages-record-index.cd3aaa1f.js | 1 + public/h5/index.html | 2 +- public/h5/static/js/{37.1402b8e6.js => 37.9026f80e.js} | 2 +- .../h5/static/js/{index.61f8b50b.js => index.c596893a.js} | 2 +- public/h5/static/js/pages-patient-detail.6ed4231f.js | 1 + public/h5/static/js/pages-patient-detail.94c2e0e3.js | 1 - public/h5/static/js/pages-record-detail.04efc7b4.js | 1 + public/h5/static/js/pages-record-detail.3bb8ca67.js | 1 - public/h5/static/js/pages-record-form.912edc22.js | 1 - public/h5/static/js/pages-record-form.94fa7f32.js | 1 + 30 files changed, 38 insertions(+), 23 deletions(-) create mode 100644 public/client/static/js/344.740e9724.js rename public/client/static/js/{344.bc29a90f.js => 649.bf08206b.js} (99%) delete mode 100644 public/client/static/js/93.8e102193.js delete mode 100644 public/client/static/js/index.a1eadb07.js create mode 100644 public/client/static/js/index.e21192b7.js delete mode 100644 public/client/static/js/pages-patient-detail.ab48b8d6.js create mode 100644 public/client/static/js/pages-patient-detail.be8913bf.js delete mode 100644 public/client/static/js/pages-record-detail.7f5c9b4c.js create mode 100644 public/client/static/js/pages-record-detail.cfc0a862.js delete mode 100644 public/client/static/js/pages-record-index.8e7cbbf3.js create mode 100644 public/client/static/js/pages-record-index.cd3aaa1f.js rename public/h5/static/js/{37.1402b8e6.js => 37.9026f80e.js} (96%) rename public/h5/static/js/{index.61f8b50b.js => index.c596893a.js} (97%) create mode 100644 public/h5/static/js/pages-patient-detail.6ed4231f.js delete mode 100644 public/h5/static/js/pages-patient-detail.94c2e0e3.js create mode 100644 public/h5/static/js/pages-record-detail.04efc7b4.js delete mode 100644 public/h5/static/js/pages-record-detail.3bb8ca67.js delete mode 100644 public/h5/static/js/pages-record-form.912edc22.js create mode 100644 public/h5/static/js/pages-record-form.94fa7f32.js diff --git a/app/Admin/Controllers/PatientRecordController.php b/app/Admin/Controllers/PatientRecordController.php index 6871efc..29d45a9 100644 --- a/app/Admin/Controllers/PatientRecordController.php +++ b/app/Admin/Controllers/PatientRecordController.php @@ -38,7 +38,7 @@ class PatientRecordController extends AdminController ->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()->SelectControl()->options($this->getIllnessOption())->name('illness_type_id')->label(__('patient-record.illness_type_id'))->size('md')->clearable(), + amisMake()->SelectControl()->options($this->getIllnessOption())->name('illness_type_id')->label(__('patient-record.illness_type_id'))->searchable()->size('md')->clearable(), amisMake()->DateRangeControl()->name('treat_range')->label(__('patient-record.treat_at'))->size('md')->clearable(), amisMake()->SelectControl()->options($this->getAdminUserOptions())->searchable()->name('doctor_id')->label(__('patient-record.doctor_id'))->clearable()->size('md'), amisMake()->SelectControl()->options($this->getAdminUserOptions())->searchable()->name('inviter_id')->label(__('patient-record.inviter_id'))->clearable()->size('md'), @@ -139,11 +139,12 @@ class PatientRecordController extends AdminController ->initFetch(false) // ->body(Components::make()->fuEditorControl()->name('content')->label(__('patient-record.content'))), ->body(amisMake()->TextareaControl()->name('content')->label(__('patient-record.content'))), + amisMake()->TextareaControl()->name('description')->label(__('patient-record.description')), amisMake()->ImageControl()->multiple()->receiver(admin_url('upload_image') . '?full-url=1')->name('images')->label(__('patient-record.images')), amisMake()->DateTimeControl()->name('next_treat_at')->label(__('patient-record.next_treat_at')), amisMake()->SwitchControl()->name('is_notified')->label(__('patient-record.is_notified'))->trueValue(0)->falseValue(1), amisMake()->SelectControl()->options($this->getAdminUserOptions())->searchable()->name('notify_user_id')->label(__('patient-record.notify_user_id')), - amisMake()->DateControl()->name('notify_at')->label(__('patient-record.notify_at')), + 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'))->name('creator_id')->value($this->user()->name)->readonly(), ); @@ -176,7 +177,8 @@ class PatientRecordController extends AdminController ['label' => __('patient-record.illness_type_id'), 'content' => '${illness_type.name}', 'span' => 3], - ['label' => __('patient-record.content'), 'content' => amisMake()->Tpl()->tpl('${content | raw}'), 'span' => 3], + ['label' => __('patient-record.content'), 'content' => amisMake()->TextareaControl()->labelWidth('0px')->static()->value('${content}'), 'span' => 3], + ['label' => __('patient-record.description'), 'content' => amisMake()->TextareaControl()->labelWidth('0px')->static()->value('${description}'), 'span' => 3], ['label' => __('patient-record.images'), 'content' => amisMake()->Images()->source('${images}')->defaultImage(null), 'span' => 3], ['label' => __('patient-record.next_treat_at'), 'content' => '${next_treat_at}'], diff --git a/app/Admin/Controllers/TotalIllnessTypeController.php b/app/Admin/Controllers/TotalIllnessTypeController.php index 35b6033..a6f13fe 100644 --- a/app/Admin/Controllers/TotalIllnessTypeController.php +++ b/app/Admin/Controllers/TotalIllnessTypeController.php @@ -34,11 +34,13 @@ class TotalIllnessTypeController extends AdminController ])) ->columns([ amisMake()->Column()->name('name')->label(__('total-illness-type.id')), + amisMake()->Column()->name('patient_count')->label(__('total-illness-type.patient_count')), amisMake()->Column()->name('count')->label(__('total-illness-type.count')), ]) ->affixRowClassName('text-info-dk') ->affixRow([ ['type' => 'text', 'text' => '总计: ${total}'], + ['type' => 'text', 'text' => __('total-illness-type.patient_count'). ': ${patient_count}'], ['type' => 'text', 'text' => __('total-illness-type.count'). ': ${count}'], ]); @@ -100,10 +102,12 @@ class TotalIllnessTypeController extends AdminController AdminExport::make($query) ->setHeadings([ __('total-illness-type.id'), + __('total-illness-type.patient_count'), __('total-illness-type.count'), ]) ->setMap(fn($row) => [ $row->name, + $row->illnessTypeRecords->groupBy('patient_id')->count(), $row->illnessTypeRecords->count() ]) ->store($path); diff --git a/app/Admin/Services/TotalIllnessTypeService.php b/app/Admin/Services/TotalIllnessTypeService.php index 6a796e9..72e81ca 100644 --- a/app/Admin/Services/TotalIllnessTypeService.php +++ b/app/Admin/Services/TotalIllnessTypeService.php @@ -5,6 +5,7 @@ namespace App\Admin\Services; use App\ModelFilters\KeywordFilter; use App\Models\Keyword; use App\Models\PatientRecord; +use Illuminate\Support\Facades\DB; class TotalIllnessTypeService extends BaseService { @@ -38,16 +39,21 @@ class TotalIllnessTypeService extends BaseService $list = (clone $query)->paginate(request()->input('perPage', 20)); $items = collect($list->items())->map(function ($item) { $item['count'] = $item->illnessTypeRecords->count(); + $item['patient_count'] = $item->illnessTypeRecords->groupBy('patient_id')->count(); return $item; }); $count = PatientRecord::filter([ 'illness_type_id' => request('id'), 'treat_range' => request('treat_range'), ])->count(); + $patient_count = PatientRecord::filter([ + 'illness_type_id' => request('id'), + 'treat_range' => request('treat_range'), + ])->select(['patient_id', 'illness_type_id', DB::raw('count(`patient_id`) as count')])->groupBy('patient_id', 'illness_type_id')->get()->count(); // $allList = (clone $query)->get(); // $count = round($allList->sum(fn ($item) => $item->illnessTypeRecords->count()), 2, PHP_ROUND_HALF_DOWN);; $total = $list->total(); - return compact('items', 'total', 'count'); + return compact('items', 'total', 'count', 'patient_count'); } } diff --git a/app/Console/Commands/PatientRecordNotify.php b/app/Console/Commands/PatientRecordNotify.php index 5fb841c..a7b6b59 100644 --- a/app/Console/Commands/PatientRecordNotify.php +++ b/app/Console/Commands/PatientRecordNotify.php @@ -34,7 +34,7 @@ class PatientRecordNotify extends Command ->where('is_notified', 0) ->whereNotNull('notify_user_id') ->whereNotNull('next_treat_at') - ->where('notify_at', '<=', $now->copy()->endOfDay()) + ->where('notify_at', '<=', $now->copy()->endOfMinute()) ->get(); // 微信公众号关联账户 $adminUsers = UserSocialite::where('user_type', (new AdminUser)->getMorphClass()) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 0e771c4..977ed95 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -14,7 +14,7 @@ class Kernel extends ConsoleKernel { // $schedule->command('inspire')->hourly(); // $schedule->call(fn () => logger('schedule running'))->everyMinute(); - $schedule->command('patient-record:notify')->dailyAt('7:00'); + $schedule->command('patient-record:notify')->everyMinute(); $schedule->command('user:birthday-notify')->dailyAt('8:00'); } diff --git a/app/Models/PatientRecord.php b/app/Models/PatientRecord.php index 6198bbd..e12a770 100644 --- a/app/Models/PatientRecord.php +++ b/app/Models/PatientRecord.php @@ -20,7 +20,7 @@ class PatientRecord extends Model protected $fillable = [ 'patient_id', 'user_id', 'type_id', 'illness_type_id', - 'treat_at', 'content', 'images', + 'treat_at', 'content', 'description', 'images', 'doctor_id', 'doctor_ratio', 'doctor_money', 'saler_id', 'saler_ratio', 'saler_money', 'inviter_id', 'inviter_ratio', 'inviter_money', @@ -33,7 +33,7 @@ class PatientRecord extends Model protected $casts = [ 'order_status' => OrderStatus::class, - 'notify_at' => 'date', + 'notify_at' => 'datetime', 'treat_at' => 'datetime', 'next_treat_at' => 'datetime', 'origin_price' => 'float', diff --git a/database/migrations/2023_08_30_090313_create_patient_records_table.php b/database/migrations/2023_08_30_090313_create_patient_records_table.php index 217bc76..a001108 100644 --- a/database/migrations/2023_08_30_090313_create_patient_records_table.php +++ b/database/migrations/2023_08_30_090313_create_patient_records_table.php @@ -18,6 +18,7 @@ return new class extends Migration $table->unsignedBigInteger('illness_type_id')->comment('病种, keywords.id'); $table->timestamp('treat_at')->comment('就诊时间'); $table->text('content')->nullable()->comment('就诊情况'); + $table->text('description')->nullable()->comment('服用方法'); $table->json('images')->nullable()->comment('图片'); $table->decimal('origin_price')->default(0)->comment('划线价'); $table->decimal('sell_price')->default(0)->comment('实收价'); diff --git a/lang/zh_CN/patient-record.php b/lang/zh_CN/patient-record.php index f1d33d9..1fcb996 100644 --- a/lang/zh_CN/patient-record.php +++ b/lang/zh_CN/patient-record.php @@ -29,4 +29,5 @@ return [ 'images' => '图片资料', 'illness_type_id' => '病种', 'total_money' => '总提成', + 'description' => '服用方法', ]; diff --git a/lang/zh_CN/total-illness-type.php b/lang/zh_CN/total-illness-type.php index edbf2ae..6b3aa9b 100644 --- a/lang/zh_CN/total-illness-type.php +++ b/lang/zh_CN/total-illness-type.php @@ -5,4 +5,5 @@ return [ 'name' => '病种', 'count' => '次数', 'treat_at' => '时间段', + 'patient_count' => '人数', ]; diff --git a/public/client/index.html b/public/client/index.html index 02e0327..85e2a53 100644 --- a/public/client/index.html +++ b/public/client/index.html @@ -1,2 +1,2 @@