Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵增煜
/
tzt-admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
85c4b10b
authored
Mar 31, 2025
by
赵增煜
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' of
http://git.imohe.com/zhaozengyu/tzt-admin
into develop
parents
4ac546ad
02f5f63c
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
258 additions
and
258 deletions
+258
-258
app/Admin/Controllers/ExternalPrescriptionController.php
+38
-39
app/Admin/Controllers/HomeController.php
+9
-10
app/Admin/Controllers/PharmacyController.php
+2
-2
app/Admin/Controllers/PharmacyExternalPrescriptionController.php
+56
-66
app/Admin/Extensions/ToolBar/Actions/ExternalPrescriptionImportAction.php
+0
-1
app/Admin/Extensions/ToolBar/Forms/ExternalPrescriptionImportForm.php
+34
-40
app/Admin/Metrics/Statistics/NewUsers.php
+4
-4
app/Admin/Metrics/Statistics/Patient.php
+5
-4
app/Admin/Metrics/Statistics/Pharmacist.php
+5
-4
app/Admin/Metrics/Statistics/Pharmacy.php
+4
-4
app/Admin/Metrics/Statistics/PharmacyChart.php
+8
-12
app/Admin/Metrics/Statistics/Prescription.php
+5
-4
app/Admin/Metrics/Statistics/PrescriptionChart.php
+6
-13
app/Api/Controllers/PatientController.php
+2
-2
app/Api/Controllers/PrescriptionController.php
+2
-2
app/Api/Controllers/SiteConfigController.php
+1
-2
app/Api/Controllers/StatisticsController.php
+27
-39
app/Http/Kernel.php
+1
-0
app/Http/Middleware/CustomJwtMiddleware.php
+43
-0
app/Models/ExternalPrescriptionModel.php
+4
-6
app/Models/PharmacyModel.php
+0
-2
database/migrations/2024_12_23_112136_create_external_prescription_table.php
+2
-2
No files found.
app/Admin/Controllers/ExternalPrescriptionController.php
View file @
85c4b10b
...
...
@@ -2,17 +2,16 @@
namespace
App\Admin\Controllers
;
use
App\Admin\Repositories\ExternalPrescription
;
use
Dcat\Admin\Form
;
use
Dcat\Admin\Grid
;
use
Dcat\Admin\Show
;
use
Dcat\Admin\Http\Controllers\AdminController
;
use
App\Models\PharmacyModel
;
use
App\Models\ExternalPrescriptionModel
;
use
App\Admin\Extensions\ToolBar\Actions\ExternalPrescriptionImportAction
;
use
App\Models\ExternalPrescriptionModel
;
use
App\Models\PharmacyModel
;
use
Box\Spout\Common\Entity\Style\Color
;
use
Box\Spout\Writer\Common\Creator\Style\StyleBuilder
;
use
Box\Spout\Writer\Common\Creator\WriterEntityFactory
;
use
Dcat\Admin\Form
;
use
Dcat\Admin\Grid
;
use
Dcat\Admin\Http\Controllers\AdminController
;
use
Dcat\Admin\Show
;
use
Dcat\EasyExcel\Excel
;
use
Illuminate\Http\Request
;
...
...
@@ -49,8 +48,9 @@ protected function grid()
if
(
is_array
(
$drugInfoArray
))
{
// 使用 array_map 来格式化每个药物的信息
$formattedDrugs
=
array_map
(
function
(
$item
)
{
return
$item
[
'drug_name'
]
.
' : '
.
(
$item
[
'drug_spec'
]
??
''
)
.
' : '
.
$item
[
'drug_num'
];
return
$item
[
'drug_name'
]
.
' : '
.
(
$item
[
'drug_spec'
]
??
''
)
.
' : '
.
$item
[
'drug_num'
];
},
$drugInfoArray
);
// 将数组转换为以逗号分隔的字符串(或根据您的需求进行其他格式化)
return
implode
(
', '
,
$formattedDrugs
);
}
else
{
...
...
@@ -70,12 +70,12 @@ protected function grid()
$grid
->
tools
(
function
(
$tools
)
{
$tools
->
append
(
new
ExternalPrescriptionImportAction
());
// 导入药品信息
});
$grid
->
filter
(
function
(
Grid\Filter
$filter
)
{
//$filter->equal('id');
$filter
->
panel
();
// 更改为 panel 布局
$filter
->
expand
();
// 默认展开搜索框
$filter
->
equal
(
'external_prescription_id'
,
'580处方单编号'
)
->
width
(
3
);
$filter
->
equal
(
'external_prescription_id'
,
'580处方单编号'
)
->
width
(
3
);
$filter
->
equal
(
'pharmacy_id'
)
->
select
(
PharmacyModel
::
all
()
->
pluck
(
'name'
,
'id'
))
->
width
(
3
);
// $filter->equal('pharmacy_id','药店编号')->width(3);
});
...
...
@@ -91,39 +91,39 @@ protected function grid()
/**
* Make a show builder.
*
* @param mixed $id
*
* @param mixed $id
* @return Show
*/
protected
function
detail
(
$id
)
{
//$this->title('580处方单详情');
return
Show
::
make
(
$id
,
new
ExternalPrescriptionModel
(),
function
(
Show
$show
)
{
$show
->
field
(
'id'
);
$show
->
field
(
'external_prescription_id'
,
'580处方单编号'
);
$show
->
field
(
'issue_at'
,
'处方开具时间'
);
$show
->
field
(
'status'
,
'状态'
);
$show
->
field
(
'company_name'
,
'企业名称'
);
$show
->
field
(
'pharmacy_name'
,
'药店名称'
);
$show
->
field
(
'external_prescription_id'
,
'580处方单编号'
);
$show
->
field
(
'issue_at'
,
'处方开具时间'
);
$show
->
field
(
'status'
,
'状态'
);
$show
->
field
(
'company_name'
,
'企业名称'
);
$show
->
field
(
'pharmacy_name'
,
'药店名称'
);
//$show->field('pharmacy_id');
$show
->
field
(
'agent'
,
'会员/代理人'
);
$show
->
field
(
'patient_name'
,
'就诊人姓名'
);
$show
->
field
(
'patient_mobile'
,
'就诊人手机号'
);
$show
->
field
(
'patient_gender'
,
'就诊人性别'
)
->
using
(
ExternalPrescriptionModel
::
SEX_MAP
)
->
width
(
3
);
$show
->
field
(
'patient_age'
,
'就诊人年龄'
);
$show
->
field
(
'patient_id_card'
,
'就诊人身份证号'
);
$show
->
field
(
'doctor_name'
,
'接诊医师姓名'
);
$show
->
field
(
'diagnosis'
,
'诊断'
);
$show
->
field
(
'drug_info'
,
'用药信息'
)
->
as
(
function
(
$drugInfoJson
)
{
$show
->
field
(
'agent'
,
'会员/代理人'
);
$show
->
field
(
'patient_name'
,
'就诊人姓名'
);
$show
->
field
(
'patient_mobile'
,
'就诊人手机号'
);
$show
->
field
(
'patient_gender'
,
'就诊人性别'
)
->
using
(
ExternalPrescriptionModel
::
SEX_MAP
)
->
width
(
3
);
$show
->
field
(
'patient_age'
,
'就诊人年龄'
);
$show
->
field
(
'patient_id_card'
,
'就诊人身份证号'
);
$show
->
field
(
'doctor_name'
,
'接诊医师姓名'
);
$show
->
field
(
'diagnosis'
,
'诊断'
);
$show
->
field
(
'drug_info'
,
'用药信息'
)
->
as
(
function
(
$drugInfoJson
)
{
// 尝试将 $drugInfoJson 解码为数组
$drugInfoArray
=
json_decode
(
$drugInfoJson
,
true
);
// 检查解码是否成功且 $drugInfoArray 是一个数组
if
(
is_array
(
$drugInfoArray
))
{
// 使用 array_map 来格式化每个药物的信息
$formattedDrugs
=
array_map
(
function
(
$item
)
{
return
$item
[
'drug_name'
]
.
' : '
.
(
$item
[
'drug_spec'
]
??
''
)
.
' : '
.
$item
[
'drug_num'
];
return
$item
[
'drug_name'
]
.
' : '
.
(
$item
[
'drug_spec'
]
??
''
)
.
' : '
.
$item
[
'drug_num'
];
},
$drugInfoArray
);
// 将数组转换为以逗号分隔的字符串(或根据您的需求进行其他格式化)
return
implode
(
', '
,
$formattedDrugs
);
}
else
{
...
...
@@ -131,12 +131,12 @@ protected function detail($id)
return
$drugInfoJson
;
// 或者返回一个错误消息,如 'Invalid JSON'
}
})
->
label
();
// 设置列的标签
$show
->
field
(
'pharmacist_name'
,
'审核药师'
);
$show
->
field
(
'review_at'
,
'审核时间'
);
$show
->
field
(
'pharmacist_attr'
,
'药师属性'
);
$show
->
field
(
'dispatcher'
,
'调配人'
);
$show
->
field
(
'checker'
,
'核对人'
);
$show
->
field
(
'dispenser'
,
'发药人'
);
$show
->
field
(
'pharmacist_name'
,
'审核药师'
);
$show
->
field
(
'review_at'
,
'审核时间'
);
$show
->
field
(
'pharmacist_attr'
,
'药师属性'
);
$show
->
field
(
'dispatcher'
,
'调配人'
);
$show
->
field
(
'checker'
,
'核对人'
);
$show
->
field
(
'dispenser'
,
'发药人'
);
// $show->field('created_at');
// $show->field('updated_at');
$show
->
panel
()
->
tools
(
function
(
$tools
)
{
...
...
@@ -176,19 +176,18 @@ protected function form()
$form
->
text
(
'dispatcher'
);
$form
->
text
(
'checker'
);
$form
->
text
(
'dispenser'
);
$form
->
display
(
'created_at'
);
$form
->
display
(
'updated_at'
);
});
}
public
function
exportPrescriptionTemplate
(
Request
$request
)
{
$sheet1Head
=
[
'处方编号'
,
'处方开具时间'
,
'处方状态'
,
'企业名称'
,
'门店名称'
,
'会员/代理人'
,
'就诊人姓名'
,
'就诊人电话'
,
'就诊人性别'
,
'就诊人年龄'
,
'就诊人身份证号'
,
'接诊医师姓名'
,
'诊断'
,
'药品名称'
,
'药品规格'
,
'药品数量'
,
'审核药师'
,
'药师审核时间'
,
'药师属性'
,
'调配人'
,
'核对人'
,
'发药人'
];
$sheet1Head
=
[
'处方编号'
,
'处方开具时间'
,
'处方状态'
,
'企业名称'
,
'门店名称'
,
'会员/代理人'
,
'就诊人姓名'
,
'就诊人电话'
,
'就诊人性别'
,
'就诊人年龄'
,
'就诊人身份证号'
,
'接诊医师姓名'
,
'诊断'
,
'药品名称'
,
'药品规格'
,
'药品数量'
,
'审核药师'
,
'药师审核时间'
,
'药师属性'
,
'调配人'
,
'核对人'
,
'发药人'
];
$sheet1Data
=
[
[
'P1734339107979HN0'
,
'2024-12-16 16:51:48'
,
'正常'
,
'国药控股国大药房河南连锁有限公司'
,
'江阴市正鑫医药有限公司'
,
'会员_1085'
,
'赵海英'
,
'13335150001'
,
'女'
,
'34'
,
''
,
'陆海'
,
'维生素D缺乏症,急性上呼吸道感染'
,
'维生素AD滴剂'
,
'10粒*3板'
,
'1'
,
'林俊杰'
,
'2024-12-16 16:51:58'
,
'总部药师'
,
''
,
''
,
''
],
[
'P1734339107979HN0'
,
'2024-12-16 16:51:48'
,
'正常'
,
'国药控股国大药房河南连锁有限公司'
,
'江阴市正鑫医药有限公司'
,
'会员_1085'
,
'赵海英'
,
'13335150001'
,
'女'
,
'34'
,
''
,
'陆海'
,
'维生素D缺乏症,急性上呼吸道感染'
,
'飞扬胃肠炎片'
,
'24片'
,
'1'
,
'林俊杰'
,
'2024-12-16 16:51:58'
,
'总部药师'
,
''
,
''
,
''
],
[
'P1734339107979HN0'
,
'2024-12-16 16:51:48'
,
'正常'
,
'国药控股国大药房河南连锁有限公司'
,
'江阴市正鑫医药有限公司'
,
'会员_1085'
,
'赵海英'
,
'13335150001'
,
'女'
,
'34'
,
''
,
'陆海'
,
'维生素D缺乏症,急性上呼吸道感染'
,
'维生素AD滴剂'
,
'10粒*3板'
,
'1'
,
'林俊杰'
,
'2024-12-16 16:51:58'
,
'总部药师'
,
''
,
''
,
''
],
[
'P1734339107979HN0'
,
'2024-12-16 16:51:48'
,
'正常'
,
'国药控股国大药房河南连锁有限公司'
,
'江阴市正鑫医药有限公司'
,
'会员_1085'
,
'赵海英'
,
'13335150001'
,
'女'
,
'34'
,
''
,
'陆海'
,
'维生素D缺乏症,急性上呼吸道感染'
,
'飞扬胃肠炎片'
,
'24片'
,
'1'
,
'林俊杰'
,
'2024-12-16 16:51:58'
,
'总部药师'
,
''
,
''
,
''
],
];
$sheet1
=
Excel
::
createSheet
(
$sheet1Data
,
'处方明细列表'
,
$sheet1Head
)
->
row
(
function
(
array
$row
)
{
...
...
app/Admin/Controllers/HomeController.php
View file @
85c4b10b
...
...
@@ -2,14 +2,14 @@
namespace
App\Admin\Controllers
;
use
App\Admin\Metrics\Statistics
;
use
App\Admin\Metrics\Examples
;
use
App\Admin\Metrics\Statistics
;
use
App\Http\Controllers\Controller
;
use
Dcat\Admin\Admin
;
use
Dcat\Admin\Http\Controllers\Dashboard
;
use
Dcat\Admin\Layout\Column
;
use
Dcat\Admin\Layout\Content
;
use
Dcat\Admin\Layout\Row
;
use
Dcat\Admin\Admin
;
class
HomeController
extends
Controller
{
...
...
@@ -19,8 +19,8 @@ public function index(Content $content)
->
header
(
'首页'
)
->
body
(
function
(
Row
$row
)
{
// $row->column(6, function (Column $column) {
// $column->row(Dashboard::title());
// $column->row(new Examples\Tickets());
// $column->row(Dashboard::title());
// $column->row(new Examples\Tickets());
// });
if
(
!
Admin
::
user
()
->
isRole
(
'pharmacy'
))
{
$row
->
column
(
12
,
function
(
Column
$column
)
{
...
...
@@ -29,20 +29,19 @@ public function index(Content $content)
$row
->
column
(
3
,
new
Statistics\Pharmacist
());
$row
->
column
(
3
,
new
Statistics\Patient
());
$row
->
column
(
3
,
new
Statistics\Prescription
());
//$row->column(6, new Examples\Sessions());
$row
->
column
(
6
,
new
Statistics\PrescriptionChart
());
$row
->
column
(
6
,
new
Statistics\PharmacyChart
());
$row
->
column
(
6
,
new
Statistics\PrescriptionChart
());
$row
->
column
(
6
,
new
Statistics\PharmacyChart
());
});
//$column->row(new Statistics\PrescriptionChart());
// $row->column(6, new Examples\NewDevices());
//$column->row(new Examples\ProductOrders());
//$column->row(new Examples\Tickets());
});
}
});
}
}
app/Admin/Controllers/PharmacyController.php
View file @
85c4b10b
...
...
@@ -49,7 +49,7 @@ protected function grid()
}
$grid
->
column
(
'is_open'
)
->
using
(
PharmacyModel
::
IS_OPEN_MAP
)
->
help
(
'药店控制'
)
->
dot
(
PharmacyModel
::
IS_OPEN_MAP_COLOR
);
$grid
->
column
(
'is_auto'
)
->
using
(
PharmacyModel
::
IS_AUTO_MAP
)
->
dot
(
PharmacyModel
::
IS_AUTO_MAP_COLOR
);
$grid
->
column
(
'is_yb_open'
,
'医保开方'
)
->
using
(
PharmacyModel
::
IS_YB_OPEN_MAP
)
->
dot
(
PharmacyModel
::
IS_AUTO_MAP_COLOR
);
$grid
->
column
(
'is_yb_open'
,
'医保开方'
)
->
using
(
PharmacyModel
::
IS_YB_OPEN_MAP
)
->
dot
(
PharmacyModel
::
IS_AUTO_MAP_COLOR
);
$grid
->
column
(
'name'
);
$grid
->
column
(
'药师数量'
)
->
display
(
function
()
{
$num
=
PharmacistModel
::
where
(
'pharmacy_id'
,
$this
->
id
)
->
count
();
...
...
@@ -182,7 +182,7 @@ protected function form()
$form
->
switch
(
'status'
);
}
$form
->
switch
(
'is_auto'
);
$form
->
switch
(
'is_yb_open'
,
'医保开方'
);
$form
->
switch
(
'is_yb_open'
,
'医保开方'
);
$form
->
display
(
'created_at'
);
$form
->
display
(
'updated_at'
);
});
...
...
app/Admin/Controllers/PharmacyExternalPrescriptionController.php
View file @
85c4b10b
...
...
@@ -2,11 +2,6 @@
namespace
App\Admin\Controllers
;
use
App\Admin\Extensions\ToolBar\Actions\AddPharmacyDrugAction
;
use
App\Admin\Repositories\PharmacyDrugRepository
;
use
App\Models\DosageModel
;
use
App\Models\DrugModel
;
use
App\Models\DrugUnitModel
;
use
App\Models\ExternalPrescriptionModel
;
use
Dcat\Admin\Admin
;
use
Dcat\Admin\Form
;
...
...
@@ -15,10 +10,8 @@
use
Dcat\Admin\Layout\Content
;
use
Dcat\Admin\Show
;
class
PharmacyExternalPrescriptionController
extends
AdminController
{
public
function
index
(
Content
$content
)
{
return
$content
...
...
@@ -26,6 +19,7 @@ public function index(Content $content)
->
description
(
'列表'
)
// 可选,设置 content-header 的副标题
->
body
(
$this
->
grid
());
// 设置页面主体为 Grid
}
/**
* Make a grid builder.
*
...
...
@@ -37,34 +31,34 @@ protected function grid()
if
(
!
Admin
::
user
()
->
pharmacy_id
)
{
admin_exit
(
Content
::
make
()
->
withError
(
trans
(
'admin.deny'
)));
}
$grid
->
model
()
->
orderBy
(
'id'
,
'DESC'
);
$grid
->
model
()
->
where
(
'pharmacy_id'
,
Admin
::
user
()
->
pharmacy_id
);
$grid
->
column
(
'id'
)
->
sortable
();
$grid
->
column
(
'external_prescription_id'
,
'580处方单编号'
);
$grid
->
column
(
'issue_at'
,
'处方开具时间'
)
->
sortable
();
$grid
->
column
(
'status'
,
'状态'
);
$grid
->
column
(
'company_name'
,
'企业名称'
);
$grid
->
column
(
'pharmacy_name'
,
'药店名称'
);
$grid
->
column
(
'external_prescription_id'
,
'580处方单编号'
);
$grid
->
column
(
'issue_at'
,
'处方开具时间'
)
->
sortable
();
$grid
->
column
(
'status'
,
'状态'
);
$grid
->
column
(
'company_name'
,
'企业名称'
);
$grid
->
column
(
'pharmacy_name'
,
'药店名称'
);
// $grid->column('pharmacy_id');
$grid
->
column
(
'agent'
,
'会员/代理人'
);
$grid
->
column
(
'patient_name'
,
'就诊人姓名'
);
$grid
->
column
(
'patient_mobile'
,
'就诊人手机号'
);
$grid
->
column
(
'patient_gender'
,
'就诊人性别'
)
->
using
(
ExternalPrescriptionModel
::
SEX_MAP
);
$grid
->
column
(
'patient_age'
,
'就诊人年龄'
);
$grid
->
column
(
'patient_id_card'
,
'就诊人身份证号'
);
$grid
->
column
(
'doctor_name'
,
'接诊医师姓名'
);
$grid
->
column
(
'diagnosis'
,
'诊断'
);
$grid
->
column
(
'drug_info'
,
'用药信息'
)
->
display
(
function
(
$drugInfoJson
)
{
$grid
->
column
(
'agent'
,
'会员/代理人'
);
$grid
->
column
(
'patient_name'
,
'就诊人姓名'
);
$grid
->
column
(
'patient_mobile'
,
'就诊人手机号'
);
$grid
->
column
(
'patient_gender'
,
'就诊人性别'
)
->
using
(
ExternalPrescriptionModel
::
SEX_MAP
);
$grid
->
column
(
'patient_age'
,
'就诊人年龄'
);
$grid
->
column
(
'patient_id_card'
,
'就诊人身份证号'
);
$grid
->
column
(
'doctor_name'
,
'接诊医师姓名'
);
$grid
->
column
(
'diagnosis'
,
'诊断'
);
$grid
->
column
(
'drug_info'
,
'用药信息'
)
->
display
(
function
(
$drugInfoJson
)
{
// 尝试将 $drugInfoJson 解码为数组
$drugInfoArray
=
json_decode
(
$drugInfoJson
,
true
);
// 检查解码是否成功且 $drugInfoArray 是一个数组
if
(
is_array
(
$drugInfoArray
))
{
// 使用 array_map 来格式化每个药物的信息
$formattedDrugs
=
array_map
(
function
(
$item
)
{
return
$item
[
'drug_name'
]
.
' : '
.
(
$item
[
'drug_spec'
]
??
''
)
.
' : '
.
$item
[
'drug_num'
];
return
$item
[
'drug_name'
]
.
' : '
.
(
$item
[
'drug_spec'
]
??
''
)
.
' : '
.
$item
[
'drug_num'
];
},
$drugInfoArray
);
// 将数组转换为以逗号分隔的字符串(或根据您的需求进行其他格式化)
return
implode
(
', '
,
$formattedDrugs
);
}
else
{
...
...
@@ -72,30 +66,30 @@ protected function grid()
return
$drugInfoJson
;
// 或者返回一个错误消息,如 'Invalid JSON'
}
})
->
label
();
// 设置列的标签
$grid
->
column
(
'pharmacist_name'
,
'审核药师'
);
$grid
->
column
(
'review_at'
,
'审核时间'
);
$grid
->
column
(
'pharmacist_attr'
,
'药师属性'
);
$grid
->
column
(
'dispatcher'
,
'调配人'
);
$grid
->
column
(
'checker'
,
'核对人'
);
$grid
->
column
(
'dispenser'
,
'发药人'
);
$grid
->
column
(
'pharmacist_name'
,
'审核药师'
);
$grid
->
column
(
'review_at'
,
'审核时间'
);
$grid
->
column
(
'pharmacist_attr'
,
'药师属性'
);
$grid
->
column
(
'dispatcher'
,
'调配人'
);
$grid
->
column
(
'checker'
,
'核对人'
);
$grid
->
column
(
'dispenser'
,
'发药人'
);
// $grid->column('created_at');
// $grid->column('updated_at')->sortable();
// 工具栏普通按钮
// $grid->tools(function ($tools) {
// $tools->append(new ExternalPrescriptionImportAction()); // 导入药品信息
// });
$grid
->
filter
(
function
(
Grid\Filter
$filter
)
{
//$filter->equal('id');
$filter
->
panel
();
// 更改为 panel 布局
$filter
->
expand
();
// 默认展开搜索框
$filter
->
equal
(
'external_prescription_id'
,
'580处方单编号'
)
->
width
(
3
);
$filter
->
equal
(
'external_prescription_id'
,
'580处方单编号'
)
->
width
(
3
);
// $filter->equal('pharmacy_id')->select(PharmacyModel::all()->pluck('name', 'id'))->width(3);
// $filter->equal('pharmacy_id','药店编号')->width(3);
$filter
->
like
(
'patient_name'
,
'就诊人姓名'
)
->
width
(
3
);
$filter
->
like
(
'patient_mobile'
,
'就诊人手机号'
)
->
width
(
3
);
$filter
->
like
(
'doctor_name'
,
'接诊医生'
)
->
width
(
3
);
$filter
->
like
(
'patient_name'
,
'就诊人姓名'
)
->
width
(
3
);
$filter
->
like
(
'patient_mobile'
,
'就诊人手机号'
)
->
width
(
3
);
$filter
->
like
(
'doctor_name'
,
'接诊医生'
)
->
width
(
3
);
});
// 行按钮控制
...
...
@@ -109,8 +103,7 @@ protected function grid()
/**
* Make a show builder.
*
* @param mixed $id
*
* @param mixed $id
* @return Show
*/
protected
function
detail
(
$id
)
...
...
@@ -118,29 +111,30 @@ protected function detail($id)
// return Content::make()->title('详情')->description('详情')->body($this->showDetail($id));
return
Show
::
make
(
$id
,
new
ExternalPrescriptionModel
(),
function
(
Show
$show
)
{
$show
->
field
(
'id'
);
$show
->
field
(
'external_prescription_id'
,
'580处方单编号'
);
$show
->
field
(
'issue_at'
,
'处方开具时间'
);
$show
->
field
(
'status'
,
'状态'
);
$show
->
field
(
'company_name'
,
'企业名称'
);
$show
->
field
(
'pharmacy_name'
,
'药店名称'
);
$show
->
field
(
'external_prescription_id'
,
'580处方单编号'
);
$show
->
field
(
'issue_at'
,
'处方开具时间'
);
$show
->
field
(
'status'
,
'状态'
);
$show
->
field
(
'company_name'
,
'企业名称'
);
$show
->
field
(
'pharmacy_name'
,
'药店名称'
);
//$show->field('pharmacy_id');
$show
->
field
(
'agent'
,
'会员/代理人'
);
$show
->
field
(
'patient_name'
,
'就诊人姓名'
);
$show
->
field
(
'patient_mobile'
,
'就诊人手机号'
);
$show
->
field
(
'patient_gender'
,
'就诊人性别'
)
->
using
(
ExternalPrescriptionModel
::
SEX_MAP
)
->
width
(
3
);
$show
->
field
(
'patient_age'
,
'就诊人年龄'
);
$show
->
field
(
'patient_id_card'
,
'就诊人身份证号'
);
$show
->
field
(
'doctor_name'
,
'接诊医师姓名'
);
$show
->
field
(
'diagnosis'
,
'诊断'
);
$show
->
field
(
'drug_info'
,
'用药信息'
)
->
as
(
function
(
$drugInfoJson
)
{
$show
->
field
(
'agent'
,
'会员/代理人'
);
$show
->
field
(
'patient_name'
,
'就诊人姓名'
);
$show
->
field
(
'patient_mobile'
,
'就诊人手机号'
);
$show
->
field
(
'patient_gender'
,
'就诊人性别'
)
->
using
(
ExternalPrescriptionModel
::
SEX_MAP
)
->
width
(
3
);
$show
->
field
(
'patient_age'
,
'就诊人年龄'
);
$show
->
field
(
'patient_id_card'
,
'就诊人身份证号'
);
$show
->
field
(
'doctor_name'
,
'接诊医师姓名'
);
$show
->
field
(
'diagnosis'
,
'诊断'
);
$show
->
field
(
'drug_info'
,
'用药信息'
)
->
as
(
function
(
$drugInfoJson
)
{
// 尝试将 $drugInfoJson 解码为数组
$drugInfoArray
=
json_decode
(
$drugInfoJson
,
true
);
// 检查解码是否成功且 $drugInfoArray 是一个数组
if
(
is_array
(
$drugInfoArray
))
{
// 使用 array_map 来格式化每个药物的信息
$formattedDrugs
=
array_map
(
function
(
$item
)
{
return
$item
[
'drug_name'
]
.
' : '
.
(
$item
[
'drug_spec'
]
??
''
)
.
' : '
.
$item
[
'drug_num'
];
return
$item
[
'drug_name'
]
.
' : '
.
(
$item
[
'drug_spec'
]
??
''
)
.
' : '
.
$item
[
'drug_num'
];
},
$drugInfoArray
);
// 将数组转换为以逗号分隔的字符串(或根据您的需求进行其他格式化)
return
implode
(
', '
,
$formattedDrugs
);
}
else
{
...
...
@@ -148,12 +142,12 @@ protected function detail($id)
return
$drugInfoJson
;
// 或者返回一个错误消息,如 'Invalid JSON'
}
})
->
label
();
// 设置列的标签
$show
->
field
(
'pharmacist_name'
,
'审核药师'
);
$show
->
field
(
'review_at'
,
'审核时间'
);
$show
->
field
(
'pharmacist_attr'
,
'药师属性'
);
$show
->
field
(
'dispatcher'
,
'调配人'
);
$show
->
field
(
'checker'
,
'核对人'
);
$show
->
field
(
'dispenser'
,
'发药人'
);
$show
->
field
(
'pharmacist_name'
,
'审核药师'
);
$show
->
field
(
'review_at'
,
'审核时间'
);
$show
->
field
(
'pharmacist_attr'
,
'药师属性'
);
$show
->
field
(
'dispatcher'
,
'调配人'
);
$show
->
field
(
'checker'
,
'核对人'
);
$show
->
field
(
'dispenser'
,
'发药人'
);
// $show->field('created_at');
// $show->field('updated_at');
$show
->
panel
()
->
tools
(
function
(
$tools
)
{
...
...
@@ -163,10 +157,7 @@ protected function detail($id)
});
}
protected
function
showDetail
(
$id
){
}
protected
function
showDetail
(
$id
)
{}
/**
* Make a form builder.
...
...
@@ -198,9 +189,9 @@ protected function form()
$form
->
text
(
'dispatcher'
);
$form
->
text
(
'checker'
);
$form
->
text
(
'dispenser'
);
$form
->
display
(
'created_at'
);
$form
->
display
(
'updated_at'
);
});
}
}
\ No newline at end of file
}
app/Admin/Extensions/ToolBar/Actions/ExternalPrescriptionImportAction.php
View file @
85c4b10b
...
...
@@ -2,7 +2,6 @@
namespace
App\Admin\Extensions\ToolBar\Actions
;
use
App\Admin\Extensions\ToolBar\Forms\DrugImportForm
;
use
App\Admin\Extensions\ToolBar\Forms\ExternalPrescriptionImportForm
;
use
Dcat\Admin\Grid\Tools\AbstractTool
;
use
Dcat\Admin\Widgets\Modal
;
...
...
app/Admin/Extensions/ToolBar/Forms/ExternalPrescriptionImportForm.php
View file @
85c4b10b
...
...
@@ -2,24 +2,20 @@
namespace
App\Admin\Extensions\ToolBar\Forms
;
use
App\Models\DosageModel
;
use
App\Models\ExternalPrescriptionModel
;
use
App\Models\PharmacyModel
;
use
Dcat\Admin\Admin
;
use
Dcat\Admin\Http\JsonResponse
;
use
Dcat\Admin\Widgets\Form
;
use
Dcat\EasyExcel\Excel
;
use
Dcat\EasyExcel\Sheet
;
use
Dcat\EasyExcel\Support\SheetCollection
;
use
Illuminate\Support\Facades\Log
;
use
Exception
;
use
Illuminate\Support\Facades\Log
;
set_time_limit
(
1800
);
ini_set
(
'memory_limit'
,
'-1'
);
ini_set
(
'max_execution_time'
,
10800
);
ini_set
(
'max_input_time'
,
10800
);
class
ExternalPrescriptionImportForm
extends
Form
{
/**
...
...
@@ -27,44 +23,44 @@ class ExternalPrescriptionImportForm extends Form
*/
public
function
handle
(
array
$input
)
:
JsonResponse
{
// 表单参数
$file
=
$input
[
'import_file'
];
$filePath
=
storage_path
(
'app/'
.
$file
);
// Log::info("====>".$filePath);
try
{
#
$excel = Excel::import($filePath)->toArray();
// Get the sheet names from the file
#
$sheetNames = $excel[0]->getSheetNames();
#
Log::info("====>".$sheetNames."====>".json_encode($excel));
// 每100行数据为一批数据进行读取
$chunkSize
=
10
;
$successNum
=
0
;
$failNum
=
0
;
$data
=
Excel
::
import
(
$filePath
)
->
sheet
(
'处方明细列表'
)
->
toArray
();
if
(
!
empty
(
$data
)
&&
is_array
(
$data
))
{
// 表单参数
$file
=
$input
[
'import_file'
];
$filePath
=
storage_path
(
'app/'
.
$file
);
// Log::info("====>".$filePath);
try
{
//
$excel = Excel::import($filePath)->toArray();
// Get the sheet names from the file
//
$sheetNames = $excel[0]->getSheetNames();
//
Log::info("====>".$sheetNames."====>".json_encode($excel));
// 每100行数据为一批数据进行读取
$chunkSize
=
10
;
$successNum
=
0
;
$failNum
=
0
;
$data
=
Excel
::
import
(
$filePath
)
->
sheet
(
'处方明细列表'
)
->
toArray
();
if
(
!
empty
(
$data
)
&&
is_array
(
$data
))
{
// 判断处方单编号是会否重复,如果重复需进行合并药品数据
$prescriptions
=
[];
foreach
(
$data
as
$row
)
{
foreach
(
$data
as
$row
)
{
$prescriptionNo
=
$row
[
'处方编号'
];
$drug_info
[
'drug_name'
]
=
$row
[
'药品名称'
]
??
''
;
$drug_info
[
'drug_spec'
]
=
$row
[
'药品规格'
]
??
''
;
$drug_info
[
'drug_num'
]
=
$row
[
'药品数量'
]
??
0
;
if
(
!
isset
(
$prescriptions
[
$prescriptionNo
]))
{
if
(
!
isset
(
$prescriptions
[
$prescriptionNo
]))
{
$prescriptions
[
$prescriptionNo
]
=
$row
;
}
$prescriptions
[
$prescriptionNo
][
'药品明细'
][]
=
$drug_info
;
}
// 循环插入数据
foreach
(
$prescriptions
as
$prescriptionNo
=>
$prescription
)
{
foreach
(
$prescriptions
as
$prescriptionNo
=>
$prescription
)
{
// 校验数据库中是否存在该数据
$externalPrescriptionModel
=
ExternalPrescriptionModel
::
where
(
'external_prescription_id'
,
$prescriptionNo
)
->
first
();
if
(
!
$externalPrescriptionModel
)
{
if
(
!
$externalPrescriptionModel
)
{
$externalPrescriptionModel
=
new
ExternalPrescriptionModel
;
}
// 查找对应的药店ID
$pharmacy
=
PharmacyModel
::
where
(
'name'
,
$prescription
[
'门店名称'
])
->
first
();
$pharmacyId
=
0
;
if
(
$pharmacy
)
{
if
(
$pharmacy
)
{
$pharmacyId
=
$pharmacy
->
id
;
}
$externalPrescriptionModel
->
external_prescription_id
=
$prescriptionNo
;
...
...
@@ -83,27 +79,27 @@ public function handle(array $input): JsonResponse
$externalPrescriptionModel
->
diagnosis
=
$prescription
[
'诊断'
];
$externalPrescriptionModel
->
drug_info
=
json_encode
(
$prescription
[
'药品明细'
]);
$externalPrescriptionModel
->
pharmacist_name
=
$prescription
[
'审核药师'
]
??
''
;
if
(
$prescription
[
'药师审核时间'
])
{
if
(
$prescription
[
'药师审核时间'
])
{
$externalPrescriptionModel
->
review_at
=
$prescription
[
'药师审核时间'
];
}
$externalPrescriptionModel
->
pharmacist_attr
=
$prescription
[
'药师属性'
]
??
''
;
$externalPrescriptionModel
->
dispatcher
=
$prescription
[
'调配人'
]
??
''
;
$externalPrescriptionModel
->
checker
=
$prescription
[
'核对人'
]
??
''
;
$externalPrescriptionModel
->
dispenser
=
$prescription
[
'发药人'
]
??
''
;
if
(
$externalPrescriptionModel
->
save
()
)
{
if
(
$externalPrescriptionModel
->
save
())
{
$successNum
++
;
}
}
// Log::info("prescriptions====>".json_encode($prescriptions));
}
$return
=
$this
->
response
()
->
success
(
"导入成功
{
$successNum
}
条"
)
->
refresh
();
unlink
(
$filePath
);
}
catch
(
Exception
$e
)
{
$return
=
$this
->
response
()
->
error
(
"导入失败
{
$failNum
}
条:"
.
$e
->
getMessage
());
}
}
$return
=
$this
->
response
()
->
success
(
"导入成功
{
$successNum
}
条"
)
->
refresh
();
unlink
(
$filePath
);
}
catch
(
Exception
$e
)
{
$return
=
$this
->
response
()
->
error
(
"导入失败
{
$failNum
}
条:"
.
$e
->
getMessage
());
}
return
$return
;
return
$return
;
}
/**
...
...
@@ -126,8 +122,8 @@ public function form()
$this
->
html
(
"<a target='_blank' href='
{
$downloadUrl
}
'>下载580处方单导入模板</a>"
);
}
private
static
function
getGender
(
$value
)
{
private
static
function
getGender
(
$value
)
{
$value
=
trim
(
$value
);
switch
(
$value
)
{
case
'男'
:
...
...
@@ -138,5 +134,4 @@ private static function getGender($value){
return
0
;
}
}
}
\ No newline at end of file
}
app/Admin/Metrics/Statistics/NewUsers.php
View file @
85c4b10b
...
...
@@ -17,7 +17,7 @@ protected function init()
parent
::
init
();
$this
->
title
(
'药店数量'
);
}
/**
...
...
@@ -55,10 +55,10 @@ public function handle(Request $request)
// break;
// case '7':
// default:
// 卡片内容
// 卡片内容
$this
->
withContent
(
'89.2k'
);
// 图表数据
// $this->withChart([28, 40, 36, 52, 38, 60, 55]);
// 图表数据
// $this->withChart([28, 40, 36, 52, 38, 60, 55]);
//}
}
...
...
app/Admin/Metrics/Statistics/Patient.php
View file @
85c4b10b
...
...
@@ -2,9 +2,10 @@
namespace
App\Admin\Metrics\Statistics
;
use
App\Models\PatientModel
;
use
Dcat\Admin\Widgets\Metrics\Line
;
use
Illuminate\Http\Request
;
use
App\Models\PatientModel
;
class
Patient
extends
Line
{
/**
...
...
@@ -17,7 +18,7 @@ protected function init()
parent
::
init
();
$this
->
title
(
'问诊人数量'
);
}
/**
...
...
@@ -29,10 +30,10 @@ protected function init()
public
function
handle
(
Request
$request
)
{
$query_time
=
date
(
'Y-m-d 23:59:59'
);
$patient_count
=
PatientModel
::
where
(
'created_at'
,
'<='
,
$query_time
)
->
count
();
$patient_count
=
PatientModel
::
where
(
'created_at'
,
'<='
,
$query_time
)
->
count
();
// 卡片内容
$this
->
withContent
(
$patient_count
);
}
/**
...
...
app/Admin/Metrics/Statistics/Pharmacist.php
View file @
85c4b10b
...
...
@@ -2,9 +2,10 @@
namespace
App\Admin\Metrics\Statistics
;
use
App\Models\PharmacistModel
;
use
Dcat\Admin\Widgets\Metrics\Line
;
use
Illuminate\Http\Request
;
use
App\Models\PharmacistModel
;
class
Pharmacist
extends
Line
{
/**
...
...
@@ -17,7 +18,7 @@ protected function init()
parent
::
init
();
$this
->
title
(
'药师数量'
);
}
/**
...
...
@@ -29,10 +30,10 @@ protected function init()
public
function
handle
(
Request
$request
)
{
$query_time
=
date
(
'Y-m-d 23:59:59'
);
$pharmacist_count
=
PharmacistModel
::
where
(
'created_at'
,
'<='
,
$query_time
)
->
count
();
$pharmacist_count
=
PharmacistModel
::
where
(
'created_at'
,
'<='
,
$query_time
)
->
count
();
// 卡片内容
$this
->
withContent
(
$pharmacist_count
);
}
/**
...
...
app/Admin/Metrics/Statistics/Pharmacy.php
View file @
85c4b10b
...
...
@@ -2,9 +2,9 @@
namespace
App\Admin\Metrics\Statistics
;
use
App\Models\PharmacyModel
;
use
Dcat\Admin\Widgets\Metrics\Line
;
use
Illuminate\Http\Request
;
use
App\Models\PharmacyModel
;
class
Pharmacy
extends
Line
{
...
...
@@ -18,7 +18,7 @@ protected function init()
parent
::
init
();
$this
->
title
(
'药店数量'
);
}
/**
...
...
@@ -30,10 +30,10 @@ protected function init()
public
function
handle
(
Request
$request
)
{
$query_time
=
date
(
'Y-m-d 23:59:59'
);
$pharmacy_count
=
PharmacyModel
::
where
(
'created_at'
,
'<='
,
$query_time
)
->
count
();
$pharmacy_count
=
PharmacyModel
::
where
(
'created_at'
,
'<='
,
$query_time
)
->
count
();
// 卡片内容
$this
->
withContent
(
$pharmacy_count
);
}
/**
...
...
app/Admin/Metrics/Statistics/PharmacyChart.php
View file @
85c4b10b
...
...
@@ -2,14 +2,13 @@
namespace
App\Admin\Metrics\Statistics
;
use
Dcat\Admin\Widgets\Metrics\Line
;
use
Illuminate\Http\Request
;
use
App\Models\PrescriptionModel
;
use
Dcat\Admin\Admi
n
;
use
Carbon\Carbo
n
;
use
Dcat\Admin\Widgets\Metrics\Bar
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\DB
;
use
Carbon\Carbon
;
use
Illuminate\Support\Facades\Log
;
class
PharmacyChart
extends
Bar
{
/**
...
...
@@ -20,8 +19,8 @@ class PharmacyChart extends Bar
protected
function
init
()
{
parent
::
init
();
$date
=
date
(
'Y-m-d'
,
strtotime
(
'-1 day'
));
$this
->
title
(
$date
.
'开方药店数量'
);
$date
=
date
(
'Y-m-d'
,
strtotime
(
'-1 day'
));
$this
->
title
(
$date
.
'开方药店数量'
);
}
/**
...
...
@@ -42,7 +41,7 @@ public function handle(Request $request)
$datesRange
=
[];
for
(
$date
=
clone
$eightDaysAgoStart
;
$date
->
lte
(
$yesterdayEnd
);
$date
->
addDay
())
{
$query_date
=
$date
->
format
(
'Y-m-d'
);
$res
=
DB
::
select
(
'SELECT COUNT(DISTINCT pharmacy_id) AS pharmacy_count
FROM prescription
...
...
@@ -50,8 +49,8 @@ public function handle(Request $request)
AND created_at < :next_day
AND status = 2'
,
[
'start_of_day'
=>
$query_date
.
' 00:00:00'
,
'next_day'
=>
$query_date
.
' 23:59:59'
'start_of_day'
=>
$query_date
.
' 00:00:00'
,
'next_day'
=>
$query_date
.
' 23:59:59'
,
]
);
...
...
@@ -71,7 +70,6 @@ public function handle(Request $request)
],
]);
}
/**
...
...
@@ -87,8 +85,6 @@ public function withChart(array $data)
]);
}
/**
* 设置卡片内容.
*
...
...
app/Admin/Metrics/Statistics/Prescription.php
View file @
85c4b10b
...
...
@@ -2,9 +2,10 @@
namespace
App\Admin\Metrics\Statistics
;
use
App\Models\PrescriptionModel
;
use
Dcat\Admin\Widgets\Metrics\Line
;
use
Illuminate\Http\Request
;
use
App\Models\PrescriptionModel
;
class
Prescription
extends
Line
{
/**
...
...
@@ -17,7 +18,7 @@ protected function init()
parent
::
init
();
$this
->
title
(
'处方数量'
);
}
/**
...
...
@@ -29,10 +30,10 @@ protected function init()
public
function
handle
(
Request
$request
)
{
$query_time
=
date
(
'Y-m-d 23:59:59'
);
$prescription_total
=
PrescriptionModel
::
where
(
'created_at'
,
'<='
,
$query_time
)
->
count
();
$prescription_total
=
PrescriptionModel
::
where
(
'created_at'
,
'<='
,
$query_time
)
->
count
();
// 卡片内容
$this
->
withContent
(
$prescription_total
);
}
/**
...
...
app/Admin/Metrics/Statistics/PrescriptionChart.php
View file @
85c4b10b
...
...
@@ -2,14 +2,13 @@
namespace
App\Admin\Metrics\Statistics
;
use
Dcat\Admin\Widgets\Metrics\Line
;
use
Illuminate\Http\Request
;
use
App\Models\PrescriptionModel
;
use
Dcat\Admin\Admi
n
;
use
Carbon\Carbo
n
;
use
Dcat\Admin\Widgets\Metrics\Bar
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\DB
;
use
Carbon\Carbon
;
use
Illuminate\Support\Facades\Log
;
class
PrescriptionChart
extends
Bar
{
/**
...
...
@@ -20,8 +19,8 @@ class PrescriptionChart extends Bar
protected
function
init
()
{
parent
::
init
();
$date
=
date
(
'Y-m-d'
,
strtotime
(
'-1 day'
));
$this
->
title
(
$date
.
'开方数量'
);
$date
=
date
(
'Y-m-d'
,
strtotime
(
'-1 day'
));
$this
->
title
(
$date
.
'开方数量'
);
}
/**
...
...
@@ -40,7 +39,7 @@ public function handle(Request $request)
$eightDaysAgoStart
=
clone
$yesterdayEnd
;
$eightDaysAgoStart
->
subDays
(
7
)
->
startOfDay
();
// 八天前的00:00:00
// 创建包含过去7天日期的完整数组
$datesRange
=
[];
for
(
$date
=
clone
$eightDaysAgoStart
;
$date
->
lte
(
$yesterdayEnd
);
$date
->
addDay
())
{
...
...
@@ -56,9 +55,6 @@ public function handle(Request $request)
->
groupBy
(
'date'
)
// 按日期分组
->
orderBy
(
'date'
)
// 按日期排序
->
get
();
// 执行查询并获取结果
// 将查询结果合并到日期范围数组中
foreach
(
$prescriptionCounts
as
$day
)
{
...
...
@@ -80,7 +76,6 @@ public function handle(Request $request)
],
]);
}
/**
...
...
@@ -96,8 +91,6 @@ public function withChart(array $data)
]);
}
/**
* 设置卡片内容.
*
...
...
app/Api/Controllers/PatientController.php
View file @
85c4b10b
...
...
@@ -68,7 +68,7 @@ public function add(Request $request)
$idValidator
=
new
IdValidator
();
// if (! $idValidator->isValid($data['id_card'])) {
// if( !in_array(strlen($data['id_card']),[15,18])){
if
(
isset
(
$data
[
'id_card'
])
&&
!
validateIDCard
(
$data
[
'id_card'
]))
{
// 身份证非必填项
if
(
isset
(
$data
[
'id_card'
])
&&
!
validateIDCard
(
$data
[
'id_card'
]))
{
// 身份证非必填项
return
$this
->
failed
(
'身份证格式错误'
);
}
...
...
@@ -116,7 +116,7 @@ public function update(Request $request)
// 验证身份证格式
$idValidator
=
new
IdValidator
();
// if (! $idValidator->isValid($id_card)) {
if
(
isset
(
$id_card
)
&&
!
validateIDCard
(
$id_card
))
{
if
(
isset
(
$id_card
)
&&
!
validateIDCard
(
$id_card
))
{
return
$this
->
failed
(
'身份证格式错误'
);
}
...
...
app/Api/Controllers/PrescriptionController.php
View file @
85c4b10b
...
...
@@ -363,7 +363,7 @@ public function create(Request $request)
// $currentTime = $review_at;
// $pharmacistLog->log_info = $pharmacist->name.'在'.$review_at.'为'.$patient->name.'('.$patient->mobile.')审方(处方单编号:'.$prescription_number.')';
// $pharmacistLog->save();
}
elseif
(
$pharmacy
->
is_auto
==
0
)
{
}
elseif
(
$pharmacy
->
is_auto
==
0
)
{
// 手动审方发送药店通知短信 1219发送短信注销
// if (env('SMS_CHANNEL') == 'chengliye') {
// $templateName = 'pharmacist_notification';
...
...
@@ -488,7 +488,7 @@ public function enter(Request $request)
'drug_id'
=>
$pharmacyDrugQueryInfo
->
drug_id
,
'drug_name'
=>
$pharmacyDrugQueryInfo
->
drug
->
name
,
'spec'
=>
$pharmacyDrugQueryInfo
->
drug
->
spec
,
'unit'
=>
$pharmacyDrugQueryInfo
->
drug
->
unit
,
//$pharmacyDrugQueryInfo->unit,
'unit'
=>
$pharmacyDrugQueryInfo
->
drug
->
unit
,
//$pharmacyDrugQueryInfo->unit,
'dosage_id'
=>
$drug
[
'dosage_id'
]
??
0
,
// $pharmacyDrugQueryInfo->dosage_id,
'dosage_desc'
=>
$drug
[
'dosage_desc'
]
??
'等待药师录入'
,
// $pharmacyDrugQueryInfo->dosage->dosage_desc,
'num'
=>
$drug
[
'num'
],
// 中药为药师录入数量
...
...
app/Api/Controllers/SiteConfigController.php
View file @
85c4b10b
...
...
@@ -35,12 +35,11 @@ public function config(Request $request)
return
$this
->
success
(
$data
);
}
public
function
isYBOpen
(
Request
$request
)
{
$is_open_yb
=
0
;
$authInfo
=
auth
(
'api'
)
->
user
();
if
(
$authInfo
->
last_login_type
==
User
::
LOGIN_TYPE_PHARMACY
)
{
if
(
$authInfo
->
last_login_type
==
User
::
LOGIN_TYPE_PHARMACY
)
{
$pharmacy
=
PharmacyModel
::
where
(
'user_id'
,
$authInfo
->
id
)
->
first
();
if
(
$pharmacy
)
{
$is_open_yb
=
$pharmacy
->
is_yb_open
;
...
...
app/Api/Controllers/StatisticsController.php
View file @
85c4b10b
...
...
@@ -3,51 +3,41 @@
namespace
App\Api\Controllers
;
use
App\Http\Controllers\BaseApiController
;
use
App\Models\DiagnosiModel
;
use
App\Models\DoctorModel
;
use
App\Models\InquiryModel
;
use
App\Models\PatientModel
;
use
App\Models\PharmacistModel
;
use
App\Models\PharmacyDrugModel
;
use
App\Models\PharmacyModel
;
use
App\Models\PrescriptionLogModel
;
use
App\Models\PrescriptionModel
;
use
App\Models\User
;
use
App\Services\SmsService
;
use
Carbon\Carbon
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Support\Facades\Log
;
use
Overtrue\EasySms\EasySms
;
class
StatisticsController
extends
BaseApiController
{
public
function
index
(
Request
$request
)
{
$request
=
$request
->
all
();
// var_dump($request);
if
(
!
isset
(
$request
[
'token'
])
||
$request
[
'token'
]
!=
'imohe123@'
){
echo
'错误请求'
;
exit
();
if
(
!
isset
(
$request
[
'token'
])
||
$request
[
'token'
]
!=
'imohe123@'
)
{
echo
'错误请求'
;
exit
();
}
// 搜索前一天的数据 23:59:59
$query_time
=
date
(
'Y-m-d 23:59:59'
,
strtotime
(
"-1 day"
));
$prev_start_time
=
date
(
'Y-m-d 00:00:00'
,
strtotime
(
"-1 day"
));
$prev_end_time
=
date
(
'Y-m-d 23:59:59'
,
strtotime
(
"-1 day"
));
$query_date
=
date
(
'Y-m-d'
,
strtotime
(
"-1 day"
));
if
(
isset
(
$request
[
'date'
])
)
{
$query_time
=
date
(
'Y-m-d 23:59:59'
,
strtotime
(
'-1 day'
));
$prev_start_time
=
date
(
'Y-m-d 00:00:00'
,
strtotime
(
'-1 day'
));
$prev_end_time
=
date
(
'Y-m-d 23:59:59'
,
strtotime
(
'-1 day'
));
$query_date
=
date
(
'Y-m-d'
,
strtotime
(
'-1 day'
));
if
(
isset
(
$request
[
'date'
]))
{
$query_time
=
date
(
'Y-m-d 23:59:59'
,
strtotime
(
$request
[
'date'
]));
$prev_start_time
=
date
(
'Y-m-d 00:00:00'
,
strtotime
(
$request
[
'date'
]));
$prev_end_time
=
date
(
'Y-m-d 23:59:59'
,
strtotime
(
$request
[
'date'
]));
$query_date
=
date
(
'Y-m-d'
,
strtotime
(
$request
[
'date'
]));
}
$pharmacy_count
=
PharmacyModel
::
where
(
'created_at'
,
'<='
,
$query_time
)
->
count
();
$pharmacist_count
=
PharmacistModel
::
where
(
'created_at'
,
'<='
,
$query_time
)
->
count
();
$pharmacy_count
=
PharmacyModel
::
where
(
'created_at'
,
'<='
,
$query_time
)
->
count
();
$pharmacist_count
=
PharmacistModel
::
where
(
'created_at'
,
'<='
,
$query_time
)
->
count
();
$results
=
DB
::
select
(
'SELECT count(pharmacy_id) FROM prescription WHERE created_at <= :query_time GROUP BY pharmacy_id having count(pharmacy_id) >=100'
,
[
'query_time'
=>
$query_time
]);
$prescription_count
=
count
(
$results
);
$prescription_total
=
PrescriptionModel
::
where
(
'created_at'
,
'<='
,
$query_time
)
->
count
();
$prescription_day_total
=
PrescriptionModel
::
where
(
'created_at'
,
'<='
,
$prev_end_time
)
->
where
(
'created_at'
,
'>='
,
$prev_start_time
)
->
count
();
$prescription_total
=
PrescriptionModel
::
where
(
'created_at'
,
'<='
,
$query_time
)
->
count
();
$prescription_day_total
=
PrescriptionModel
::
where
(
'created_at'
,
'<='
,
$prev_end_time
)
->
where
(
'created_at'
,
'>='
,
$prev_start_time
)
->
count
();
$res
=
DB
::
select
(
'SELECT COUNT(DISTINCT pharmacy_id) AS pharmacy_count
FROM prescription
...
...
@@ -55,24 +45,23 @@ public function index(Request $request)
AND created_at < :next_day
AND status = 2'
,
// 只统计审方成功的记录
[
'start_of_day'
=>
$query_date
.
' 00:00:00'
,
'next_day'
=>
$query_date
.
' 23:59:59'
'start_of_day'
=>
$query_date
.
' 00:00:00'
,
'next_day'
=>
$query_date
.
' 23:59:59'
,
]
);
// var_dump($res[0]->pharmacy_count);exit();
$next_day_count
=
$res
[
0
]
->
pharmacy_count
;
$patient_count
=
PatientModel
::
where
(
'created_at'
,
'<='
,
$query_time
)
->
count
();
echo
"统计数据("
.
$query_time
.
"):<br />
药店数量:"
.
$pharmacy_count
.
"<br />
药师数量:"
.
$pharmacist_count
.
"<br />
开方药店(处方数超过100单):"
.
$prescription_count
.
"<br />
处方总量:"
.
$prescription_total
.
"<br />
问诊人数量:"
.
$patient_count
.
"<br />
"
.
$query_date
.
"开方量:"
.
$prescription_day_total
.
"<br />
"
.
$query_date
.
"开方药店量:"
.
$next_day_count
.
"<br />
"
;
exit
();
$patient_count
=
PatientModel
::
where
(
'created_at'
,
'<='
,
$query_time
)
->
count
();
echo
'统计数据('
.
$query_time
.
'):<br />
药店数量:'
.
$pharmacy_count
.
'<br />
药师数量:'
.
$pharmacist_count
.
'<br />
开方药店(处方数超过100单):'
.
$prescription_count
.
'<br />
处方总量:'
.
$prescription_total
.
'<br />
问诊人数量:'
.
$patient_count
.
'<br />
'
.
$query_date
.
'开方量:'
.
$prescription_day_total
.
'<br />
'
.
$query_date
.
'开方药店量:'
.
$next_day_count
.
'<br />
'
;
exit
();
}
}
\ No newline at end of file
}
app/Http/Kernel.php
View file @
85c4b10b
...
...
@@ -67,5 +67,6 @@ class Kernel extends HttpKernel
'verified'
=>
\Illuminate\Auth\Middleware\EnsureEmailIsVerified
::
class
,
'watermark'
=>
\App\Http\Middleware\WatermarkMiddleware
::
class
,
'checkrole'
=>
\App\Http\Middleware\CheckRoleChangeMiddleware
::
class
,
'custom.jwt'
=>
\App\Http\Middleware\CustomJwtMiddleware
::
class
,
];
}
app/Http/Middleware/CustomJwtMiddleware.php
0 → 100644
View file @
85c4b10b
<?php
namespace
App\Http\Middleware
;
use
Closure
;
use
Illuminate\Http\Request
;
use
Tymon\JWTAuth\Exceptions\JWTException
;
use
Tymon\JWTAuth\Exceptions\TokenExpiredException
;
use
Tymon\JWTAuth\Exceptions\TokenInvalidException
;
use
Tymon\JWTAuth\Facades\JWTAuth
;
class
CustomJwtMiddleware
{
public
function
handle
(
Request
$request
,
Closure
$next
)
{
try
{
// 检查 JWT Token 是否存在
$token
=
$request
->
bearerToken
();
if
(
!
$token
)
{
return
response
()
->
json
([
'status'
=>
false
,
'code'
=>
600
,
'message'
=>
'未提供 Token'
,
'data'
=>
[]]);
}
// 尝试解析 Token
$user
=
JWTAuth
::
parseToken
()
->
authenticate
();
if
(
!
$user
)
{
return
response
()
->
json
([
'status'
=>
false
,
'code'
=>
600
,
'message'
=>
'用户未找到'
,
'data'
=>
[]]);
}
// 如果需要,可以在这里添加更多逻辑,例如检查用户状态等
}
catch
(
TokenExpiredException
$e
)
{
// Token 过期
return
response
()
->
json
([
'status'
=>
false
,
'code'
=>
600
,
'message'
=>
'Token 已过期'
,
'data'
=>
[]]);
}
catch
(
TokenInvalidException
$e
)
{
// Token 无效
return
response
()
->
json
([
'status'
=>
false
,
'code'
=>
600
,
'message'
=>
'无效的 Token'
,
'data'
=>
[]]);
}
catch
(
JWTException
$e
)
{
// 其他 JWT 相关错误
return
response
()
->
json
([
'status'
=>
false
,
'code'
=>
600
,
'message'
=>
'未提供 Token 或 Token 无效'
,
'data'
=>
[]]);
}
return
$next
(
$request
);
}
}
app/Models/ExternalPrescriptionModel.php
View file @
85c4b10b
...
...
@@ -3,13 +3,14 @@
namespace
App\Models
;
use
Dcat\Admin\Traits\HasDateTimeFormatter
;
use
Illuminate\Database\Eloquent\SoftDeletes
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Database\Eloquent\SoftDeletes
;
class
ExternalPrescriptionModel
extends
Model
{
use
HasDateTimeFormatter
;
use
HasDateTimeFormatter
;
use
SoftDeletes
;
// 性别[0=未知,1=男,2=女]
const
SEX_UNDEFINED
=
0
;
...
...
@@ -23,9 +24,6 @@ class ExternalPrescriptionModel extends Model
self
::
SEX_MALE
=>
'男'
,
self
::
SEX_FEMALE
=>
'女'
,
];
protected
$table
=
'external_prescription'
;
protected
$table
=
'external_prescription'
;
}
app/Models/PharmacyModel.php
View file @
85c4b10b
...
...
@@ -61,7 +61,6 @@ class PharmacyModel extends Model
self
::
IS_AUTO_TRUE
=>
'success'
,
];
// 开启医保开方[0=否,1=是]
const
IS_YB_OPEN_FALSE
=
0
;
...
...
@@ -73,7 +72,6 @@ class PharmacyModel extends Model
self
::
IS_YB_OPEN_TRUE
=>
'是'
,
];
// 药店所属于的用户,一对一
public
function
user
()
{
...
...
database/migrations/2024_12_23_112136_create_external_prescription_table.php
View file @
85c4b10b
<?php
use
Illuminate\Support\Facades\Schema
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
class
CreateExternalPrescriptionTable
extends
Migration
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment