Commit 4e001354 by lujunyi

问诊人

parent 3ef4d510
......@@ -25,7 +25,7 @@ protected function grid()
$grid->column('content');
// 快捷搜索
$grid->quickSearch(['name', 'code', 'factcontentory'])->placeholder('请输入[诊断/诊断显示/简码]')->width(25);
$grid->quickSearch(['name', 'code', 'content'])->placeholder('请输入[诊断/诊断显示/简码]')->width(25);
$grid->filter(function (Grid\Filter $filter) {
$filter->panel(); // 更改为 panel 布局
......
<?php
namespace App\Admin\Controllers;
use App\Admin\Repositories\PatientRepository;
use App\Models\PatientModel;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Http\Controllers\AdminController;
use Dcat\Admin\Show;
class PatientController extends AdminController
{
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Grid::make(new PatientRepository(), function (Grid $grid) {
$grid->model()->orderBy('id', 'DESC');
$grid->column('id')->sortable();
$grid->column('name');
$grid->column('id_card');
$grid->column('gender', '性别')->using(PatientModel::SEX_MAP);
$grid->column('age', '年龄')->display(function ($value) {
return getAgeByIdCard($this->id_card);
});
$grid->column('mobile');
$grid->column('miniapp_openid');
$grid->column('avatar');
$grid->column('nick_name');
// 快捷搜索
$grid->quickSearch(['name', 'id_card', 'mobile'])->placeholder('请输入[姓名/身份证/手机号]')->width(25);
$grid->filter(function (Grid\Filter $filter) {
$filter->panel(); // 更改为 panel 布局
$filter->expand(); // 默认展开搜索框
$filter->like('name')->width(3);
$filter->like('id_card')->width(3);
$filter->like('mobile')->width(3);
});
// 行按钮控制
$grid->disableCreateButton(); // 禁用创建按钮
$grid->disableEditButton(); // 禁用编辑按钮
$grid->disableDeleteButton(); // 禁用删除按钮
// 工具栏按钮控制
$grid->disableBatchDelete(); // 禁用批量删除
});
}
/**
* Make a show builder.
*
* @param mixed $id
* @return Show
*/
protected function detail($id)
{
return Show::make($id, new PatientRepository(), function (Show $show) {
$show->field('id')->width(4);
$show->field('name')->width(4);
$show->field('gender')->width(4);
$show->field('id_card')->width(4);
$show->field('mobile')->width(4);
$show->field('miniapp_openid')->width(4);
$show->field('avatar')->width(4);
$show->field('nick_name')->width(4);
$show->field('created_at')->width(4);
$show->field('updated_at')->width(4);
$show->panel()->tools(function ($tools) {
$tools->disableEdit(); // 禁止编辑
$tools->disableDelete(); // 禁止删除按钮
});
});
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
return Form::make(new PatientRepository(), function (Form $form) {
$form->display('id')->width(4);
$form->text('name')->width(4);
$form->text('gender')->width(4);
$form->text('id_card')->width(4);
$form->text('mobile')->width(4);
$form->text('miniapp_openid')->width(4);
$form->text('avatar')->width(4);
$form->text('nick_name')->width(4);
$form->display('created_at')->width(4);
$form->display('updated_at')->width(4);
// 右上角按钮控制
$form->disableDeleteButton(); // 去掉删除按钮
});
}
}
<?php
namespace App\Admin\Repositories;
use App\Models\PatientModel as Model;
use Dcat\Admin\Repositories\EloquentRepository;
class PatientRepository extends EloquentRepository
{
/**
* Model.
*
* @var string
*/
protected $eloquentClass = Model::class;
}
......@@ -18,6 +18,8 @@
$router->resource('drug', 'DrugController');
// 诊断
$router->resource('diagnosi', 'DiagnosiController');
// 问诊人
$router->resource('patient', 'PatientController');
// 导入日志
$router->resource('/import-log', 'Common\ImportLogController')->names('import-log');
......
<?php
namespace App\Models;
use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class PatientModel extends Model
{
use HasDateTimeFormatter;
use SoftDeletes;
protected $table = 'patient';
// 性别[0=未知,1=男,2=女]
const SEX_UNDEFINED = 0;
const SEX_MALE = 1;
const SEX_FEMALE = 2;
// 性别-文字映射
const SEX_MAP = [
self::SEX_UNDEFINED => '未知',
self::SEX_MALE => '男',
self::SEX_FEMALE => '女',
];
}
......@@ -119,3 +119,53 @@ function is_sequential($array)
return true;
}
}
if (! function_exists('getAgeByIdCard')) {
function getAgeByIdCard($idCard)
{
// 验证身份证号码的长度
if (strlen($idCard) != 18) {
return ''; // 未知
}
// 提取出生日期
$birthDate = substr($idCard, 6, 8); // 身份证的第7到第14位为出生日期
$year = (int) substr($birthDate, 0, 4);
$month = (int) substr($birthDate, 4, 2);
$day = (int) substr($birthDate, 6, 2);
// 获取当前日期
$currentDate = new DateTime();
$birthDateTime = new DateTime("$year-$month-$day");
// 计算年龄
$age = $currentDate->diff($birthDateTime)->y;
return $age;
}
}
if (! function_exists('getSexByIdCard')) {
/**
* 根据身份证获取性别
*
* @param string $idCard 身份正号
* @return int 1=男, 2=女
*/
function getSexByIdCard($idCard)
{
// 验证身份证号码的长度
if (strlen($idCard) != 18) {
return 0; // 未知
}
// 提取性别位(第17位)
$gender = (int) substr($idCard, 16, 1); // 第17位的性别数字
// 判断性别
if ($gender % 2 == 0) {
return 2; // 偶数女
} else {
return 1; // 基数男
}
}
}
......@@ -28,6 +28,7 @@ public function up()
$table->timestamps();
$table->softDeletes();
});
\DB::statement("ALTER TABLE `patient` comment '药品'");
}
/**
......
......@@ -21,6 +21,7 @@ public function up()
$table->timestamps();
$table->softDeletes();
});
\DB::statement("ALTER TABLE `patient` comment '诊断'");
}
/**
......
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('patient', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name', 50)->nullable()->comment('姓名');
$table->tinyInteger('gender')->default(0)->comment('性别。[1=男性,2=女性,0=未知]');
$table->string('id_card', 18)->nullable()->index('idx_idcard')->comment('身份证号');
$table->string('mobile', 11)->nullable()->index('idx_mobile')->comment('手机号');
$table->string('miniapp_openid', 40)->nullable()->index('idx_miniappopenid')->comment('小程序openid');
$table->string('avatar')->nullable()->comment('头像');
$table->string('nick_name', 100)->nullable()->comment('昵称');
$table->timestamps();
$table->softDeletes();
});
\DB::statement("ALTER TABLE `patient` comment '问诊人'");
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('patient');
}
};
......@@ -41,7 +41,9 @@
* @property Grid\Column|Collection avatar
* @property Grid\Column|Collection remember_token
* @property Grid\Column|Collection is_block
* @property Grid\Column|Collection content
* @property Grid\Column|Collection code
* @property Grid\Column|Collection deleted_at
* @property Grid\Column|Collection unit
* @property Grid\Column|Collection spec
* @property Grid\Column|Collection dosage_form
......@@ -50,7 +52,6 @@
* @property Grid\Column|Collection limit_buy_7
* @property Grid\Column|Collection is_rx
* @property Grid\Column|Collection tag
* @property Grid\Column|Collection deleted_at
* @property Grid\Column|Collection uuid
* @property Grid\Column|Collection connection
* @property Grid\Column|Collection queue
......@@ -59,6 +60,11 @@
* @property Grid\Column|Collection failed_at
* @property Grid\Column|Collection email
* @property Grid\Column|Collection token
* @property Grid\Column|Collection gender
* @property Grid\Column|Collection id_card
* @property Grid\Column|Collection mobile
* @property Grid\Column|Collection miniapp_openid
* @property Grid\Column|Collection nick_name
* @property Grid\Column|Collection tokenable_type
* @property Grid\Column|Collection tokenable_id
* @property Grid\Column|Collection abilities
......@@ -96,7 +102,9 @@
* @method Grid\Column|Collection avatar(string $label = null)
* @method Grid\Column|Collection remember_token(string $label = null)
* @method Grid\Column|Collection is_block(string $label = null)
* @method Grid\Column|Collection content(string $label = null)
* @method Grid\Column|Collection code(string $label = null)
* @method Grid\Column|Collection deleted_at(string $label = null)
* @method Grid\Column|Collection unit(string $label = null)
* @method Grid\Column|Collection spec(string $label = null)
* @method Grid\Column|Collection dosage_form(string $label = null)
......@@ -105,7 +113,6 @@
* @method Grid\Column|Collection limit_buy_7(string $label = null)
* @method Grid\Column|Collection is_rx(string $label = null)
* @method Grid\Column|Collection tag(string $label = null)
* @method Grid\Column|Collection deleted_at(string $label = null)
* @method Grid\Column|Collection uuid(string $label = null)
* @method Grid\Column|Collection connection(string $label = null)
* @method Grid\Column|Collection queue(string $label = null)
......@@ -114,6 +121,11 @@
* @method Grid\Column|Collection failed_at(string $label = null)
* @method Grid\Column|Collection email(string $label = null)
* @method Grid\Column|Collection token(string $label = null)
* @method Grid\Column|Collection gender(string $label = null)
* @method Grid\Column|Collection id_card(string $label = null)
* @method Grid\Column|Collection mobile(string $label = null)
* @method Grid\Column|Collection miniapp_openid(string $label = null)
* @method Grid\Column|Collection nick_name(string $label = null)
* @method Grid\Column|Collection tokenable_type(string $label = null)
* @method Grid\Column|Collection tokenable_id(string $label = null)
* @method Grid\Column|Collection abilities(string $label = null)
......@@ -156,7 +168,9 @@ class MiniGrid extends Grid {}
* @property Show\Field|Collection avatar
* @property Show\Field|Collection remember_token
* @property Show\Field|Collection is_block
* @property Show\Field|Collection content
* @property Show\Field|Collection code
* @property Show\Field|Collection deleted_at
* @property Show\Field|Collection unit
* @property Show\Field|Collection spec
* @property Show\Field|Collection dosage_form
......@@ -165,7 +179,6 @@ class MiniGrid extends Grid {}
* @property Show\Field|Collection limit_buy_7
* @property Show\Field|Collection is_rx
* @property Show\Field|Collection tag
* @property Show\Field|Collection deleted_at
* @property Show\Field|Collection uuid
* @property Show\Field|Collection connection
* @property Show\Field|Collection queue
......@@ -174,6 +187,11 @@ class MiniGrid extends Grid {}
* @property Show\Field|Collection failed_at
* @property Show\Field|Collection email
* @property Show\Field|Collection token
* @property Show\Field|Collection gender
* @property Show\Field|Collection id_card
* @property Show\Field|Collection mobile
* @property Show\Field|Collection miniapp_openid
* @property Show\Field|Collection nick_name
* @property Show\Field|Collection tokenable_type
* @property Show\Field|Collection tokenable_id
* @property Show\Field|Collection abilities
......@@ -211,7 +229,9 @@ class MiniGrid extends Grid {}
* @method Show\Field|Collection avatar(string $label = null)
* @method Show\Field|Collection remember_token(string $label = null)
* @method Show\Field|Collection is_block(string $label = null)
* @method Show\Field|Collection content(string $label = null)
* @method Show\Field|Collection code(string $label = null)
* @method Show\Field|Collection deleted_at(string $label = null)
* @method Show\Field|Collection unit(string $label = null)
* @method Show\Field|Collection spec(string $label = null)
* @method Show\Field|Collection dosage_form(string $label = null)
......@@ -220,7 +240,6 @@ class MiniGrid extends Grid {}
* @method Show\Field|Collection limit_buy_7(string $label = null)
* @method Show\Field|Collection is_rx(string $label = null)
* @method Show\Field|Collection tag(string $label = null)
* @method Show\Field|Collection deleted_at(string $label = null)
* @method Show\Field|Collection uuid(string $label = null)
* @method Show\Field|Collection connection(string $label = null)
* @method Show\Field|Collection queue(string $label = null)
......@@ -229,6 +248,11 @@ class MiniGrid extends Grid {}
* @method Show\Field|Collection failed_at(string $label = null)
* @method Show\Field|Collection email(string $label = null)
* @method Show\Field|Collection token(string $label = null)
* @method Show\Field|Collection gender(string $label = null)
* @method Show\Field|Collection id_card(string $label = null)
* @method Show\Field|Collection mobile(string $label = null)
* @method Show\Field|Collection miniapp_openid(string $label = null)
* @method Show\Field|Collection nick_name(string $label = null)
* @method Show\Field|Collection tokenable_type(string $label = null)
* @method Show\Field|Collection tokenable_id(string $label = null)
* @method Show\Field|Collection abilities(string $label = null)
......
<?php
return [
'labels' => [
'Patient' => '问诊人',
'patient' => '问诊人',
],
'fields' => [
'name' => '姓名',
'gender' => '性别',
'id_card' => '身份证号',
'mobile' => '手机号',
'miniapp_openid' => 'openid',
'avatar' => '头像',
'nick_name' => '昵称',
],
'options' => [
],
];
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment