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
02f5f63c
authored
Feb 06, 2025
by
lujunyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
格式化代码
parent
60473acf
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
204 additions
and
201 deletions
+204
-201
app/Admin/Controllers/ExternalPrescriptionController.php
+34
-35
app/Admin/Controllers/HomeController.php
+4
-5
app/Admin/Controllers/PharmacyController.php
+2
-2
app/Admin/Controllers/PharmacyExternalPrescriptionController.php
+50
-59
app/Admin/Extensions/ToolBar/Actions/ExternalPrescriptionImportAction.php
+0
-1
app/Admin/Extensions/ToolBar/Forms/ExternalPrescriptionImportForm.php
+14
-19
app/Admin/Metrics/Statistics/NewUsers.php
+0
-0
app/Admin/Metrics/Statistics/Patient.php
+3
-2
app/Admin/Metrics/Statistics/Pharmacist.php
+3
-2
app/Admin/Metrics/Statistics/Pharmacy.php
+2
-2
app/Admin/Metrics/Statistics/PharmacyChart.php
+7
-11
app/Admin/Metrics/Statistics/Prescription.php
+3
-2
app/Admin/Metrics/Statistics/PrescriptionChart.php
+5
-12
app/Api/Controllers/PatientController.php
+2
-2
app/Api/Controllers/PrescriptionController.php
+1
-1
app/Api/Controllers/SiteConfigController.php
+1
-2
app/Api/Controllers/StatisticsController.php
+25
-36
app/Http/Kernel.php
+1
-0
app/Http/Middleware/CustomJwtMiddleware.php
+43
-0
app/Models/ExternalPrescriptionModel.php
+2
-4
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 @
02f5f63c
...
...
@@ -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
{
...
...
@@ -75,7 +75,7 @@ protected function grid()
//$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);
});
...
...
@@ -92,7 +92,6 @@ protected function grid()
* Make a show builder.
*
* @param mixed $id
*
* @return Show
*/
protected
function
detail
(
$id
)
...
...
@@ -101,29 +100,30 @@ protected function detail($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
{
...
...
@@ -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
)
{
...
...
@@ -182,13 +182,12 @@ protected function form()
});
}
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 @
02f5f63c
...
...
@@ -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
{
...
...
@@ -30,10 +30,9 @@ public function index(Content $content)
$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());
...
...
app/Admin/Controllers/PharmacyController.php
View file @
02f5f63c
...
...
@@ -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 @
02f5f63c
This diff is collapsed.
Click to expand it.
app/Admin/Extensions/ToolBar/Actions/ExternalPrescriptionImportAction.php
View file @
02f5f63c
...
...
@@ -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 @
02f5f63c
...
...
@@ -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
{
/**
...
...
@@ -32,39 +28,39 @@ public function handle(array $input): JsonResponse
$filePath
=
storage_path
(
'app/'
.
$file
);
// Log::info("====>".$filePath);
try
{
#
$excel = Excel::import($filePath)->toArray();
//
$excel = Excel::import($filePath)->toArray();
// Get the sheet names from the file
#
$sheetNames = $excel[0]->getSheetNames();
#
Log::info("====>".$sheetNames."====>".json_encode($excel));
//
$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
))
{
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,14 +79,14 @@ 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
++
;
}
}
...
...
@@ -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
;
}
}
}
app/Admin/Metrics/Statistics/NewUsers.php
View file @
02f5f63c
app/Admin/Metrics/Statistics/Patient.php
View file @
02f5f63c
...
...
@@ -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
{
/**
...
...
@@ -29,7 +30,7 @@ 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 @
02f5f63c
...
...
@@ -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
{
/**
...
...
@@ -29,7 +30,7 @@ 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 @
02f5f63c
...
...
@@ -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
{
...
...
@@ -30,7 +30,7 @@ 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 @
02f5f63c
...
...
@@ -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
.
'开方药店数量'
);
}
/**
...
...
@@ -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 @
02f5f63c
...
...
@@ -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
{
/**
...
...
@@ -29,7 +30,7 @@ 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 @
02f5f63c
...
...
@@ -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
.
'开方数量'
);
}
/**
...
...
@@ -57,9 +56,6 @@ public function handle(Request $request)
->
orderBy
(
'date'
)
// 按日期排序
->
get
();
// 执行查询并获取结果
// 将查询结果合并到日期范围数组中
foreach
(
$prescriptionCounts
as
$day
)
{
if
(
isset
(
$datesRange
[
$day
->
date
]))
{
...
...
@@ -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 @
02f5f63c
...
...
@@ -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 @
02f5f63c
...
...
@@ -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 @
02f5f63c
...
...
@@ -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 @
02f5f63c
...
...
@@ -3,50 +3,40 @@
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
...
...
@@ -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
();
}
}
app/Http/Kernel.php
View file @
02f5f63c
...
...
@@ -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 @
02f5f63c
<?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 @
02f5f63c
...
...
@@ -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
SoftDeletes
;
// 性别[0=未知,1=男,2=女]
const
SEX_UNDEFINED
=
0
;
...
...
@@ -25,7 +26,4 @@ class ExternalPrescriptionModel extends Model
];
protected
$table
=
'external_prescription'
;
}
app/Models/PharmacyModel.php
View file @
02f5f63c
...
...
@@ -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 @
02f5f63c
<?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