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
0e6c7d7d
authored
Nov 30, 2024
by
赵增煜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
脚本自动更新处方单状态
parent
889240a2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
78 additions
and
24 deletions
+78
-24
app/Api/Controllers/PrescriptionController.php
+18
-18
app/Console/Commands/PrescriptionCommand.php
+59
-5
app/Console/Kernel.php
+1
-1
No files found.
app/Api/Controllers/PrescriptionController.php
View file @
0e6c7d7d
...
...
@@ -297,15 +297,15 @@ public function create(Request $request)
// 判断是否为医师自动开方
// $prescription_auto = $site_config['prescription_auto'];
if
(
$randomDoctor
->
is_auto
==
1
)
{
$prescription
->
status
=
PrescriptionModel
::
PRESCRIPTION_STATUS_REVIEWING
;
$prescription
->
save
();
// 生成医师开方日志
$doctorLog
=
new
PrescriptionLogModel
;
$doctorLog
->
pharmacy_id
=
$pharmacy_id
;
$doctorLog
->
pharmacy_name
=
$pharmacy
->
name
;
$currentTime
=
$prescription_at
;
$doctorLog
->
log_info
=
$randomDoctor
->
name
.
'在'
.
$prescription_at
.
'为'
.
$patient
->
name
.
'('
.
$patient
->
mobile
.
')开具处方单(处方单编号:'
.
$prescription_number
.
')'
;
$doctorLog
->
save
();
//
$prescription->status = PrescriptionModel::PRESCRIPTION_STATUS_REVIEWING;
//
$prescription->save();
//
//
生成医师开方日志
//
$doctorLog = new PrescriptionLogModel;
//
$doctorLog->pharmacy_id = $pharmacy_id;
//
$doctorLog->pharmacy_name = $pharmacy->name;
//
$currentTime = $prescription_at;
//
$doctorLog->log_info = $randomDoctor->name.'在'.$prescription_at.'为'.$patient->name.'('.$patient->mobile.')开具处方单(处方单编号:'.$prescription_number.')';
//
$doctorLog->save();
}
elseif
(
$randomDoctor
->
is_auto
==
0
)
{
// 手动开方发送医师通知短信
if
(
env
(
'SMS_CHANNEL'
)
==
'chengliye'
)
{
...
...
@@ -327,15 +327,15 @@ public function create(Request $request)
// 药店自动审方(必须处方单待审方)
if
(
$pharmacy
->
is_auto
==
1
&&
$prescription
->
status
==
PrescriptionModel
::
PRESCRIPTION_STATUS_REVIEWING
)
{
$prescription
->
status
=
PrescriptionModel
::
PRESCRIPTION_STATUS_SUCCESS
;
$prescription
->
save
();
// 生成药师审方日志
$pharmacistLog
=
new
PrescriptionLogModel
;
$pharmacistLog
->
pharmacy_id
=
$pharmacy_id
;
$pharmacistLog
->
pharmacy_name
=
$pharmacy
->
name
;
$currentTime
=
$review_at
;
$pharmacistLog
->
log_info
=
$pharmacist
->
name
.
'在'
.
$review_at
.
'为'
.
$patient
->
name
.
'('
.
$patient
->
mobile
.
')审方(处方单编号:'
.
$prescription_number
.
')'
;
$pharmacistLog
->
save
();
//
$prescription->status = PrescriptionModel::PRESCRIPTION_STATUS_SUCCESS;
//
$prescription->save();
//
//
生成药师审方日志
//
$pharmacistLog = new PrescriptionLogModel;
//
$pharmacistLog->pharmacy_id = $pharmacy_id;
//
$pharmacistLog->pharmacy_name = $pharmacy->name;
//
$currentTime = $review_at;
//
$pharmacistLog->log_info = $pharmacist->name.'在'.$review_at.'为'.$patient->name.'('.$patient->mobile.')审方(处方单编号:'.$prescription_number.')';
//
$pharmacistLog->save();
}
elseif
(
$pharmacy
->
is_auto
==
0
)
{
// 手动审方发送药店通知短信
if
(
env
(
'SMS_CHANNEL'
)
==
'chengliye'
)
{
...
...
app/Console/Commands/PrescriptionCommand.php
View file @
0e6c7d7d
...
...
@@ -32,11 +32,65 @@ class PrescriptionCommand extends Command
*/
public
function
handle
()
{
$this
->
info
(
'开始自动审开方...'
);
while
(
true
)
{
// 执行自动开方
$this
->
autoPrescriptionGen
();
// 执行自动审方
$this
->
autoPrescriptionReview
();
$this
->
info
(
'等待5秒...'
);
sleep
(
5
);
}
}
// 自动开方
public
function
autoPrescriptionGen
()
{
$this
->
info
(
'开始自动开方...'
);
// 如果处方单是审方状态,同时对应的药店开启自动审方
$prescriptions
=
PrescriptionModel
::
where
(
'status'
,
PrescriptionModel
::
PRESCRIPTION_STATUS_PENDING
)
->
get
();
Log
::
info
(
'自动开方:'
.
json_encode
(
$prescriptions
));
if
(
$prescriptions
->
count
()
<=
0
)
{
$this
->
info
(
'没有需要开方的处方单'
);
return
;
}
foreach
(
$prescriptions
as
$prescription
)
{
// 查询对应的医师是手动并且药师为自动
// $pharmacist = PharmacyModel::where('id', $prescription->pharmacy_id)->first();
$doctor
=
DoctorModel
::
where
(
'id'
,
$prescription
->
doctor_id
)
->
first
();
// if ($doctor->is_auto == 0 && $pharmacist->is_auto == 1) {
if
(
$doctor
->
is_auto
==
1
)
{
// 更新处方单状态
$prescriptionInfo
=
PrescriptionModel
::
find
(
$prescription
->
id
);
if
(
$prescriptionInfo
)
{
$prescriptionInfo
->
status
=
PrescriptionModel
::
PRESCRIPTION_STATUS_REVIEWING
;
$prescriptionInfo
->
save
();
// 获取患者信息
$patient
=
PatientModel
::
where
(
'id'
,
$prescriptionInfo
->
patient_id
)
->
first
();
// 生成审方日志
$dateTime
=
new
DateTime
(
$prescription
->
created_at
);
$dateTime
->
modify
(
'+3 minutes'
);
$pharmacistLog
=
new
PrescriptionLogModel
;
$pharmacistLog
->
pharmacy_id
=
$prescription
->
pharmacy_id
;
$pharmacistLog
->
pharmacy_name
=
$prescription
->
pharmacy_name
;
$currentTime
=
$dateTime
->
format
(
'Y-m-d H:i:s'
);
$pharmacistLog
->
log_info
=
$prescription
->
doctor_name
.
'在'
.
$currentTime
.
'为'
.
$prescription
->
patient_name
.
'('
.
$patient
->
mobile
.
')开方(处方单编号:'
.
$prescription
->
id
.
')'
;
$pharmacistLog
->
save
();
$this
->
info
(
$prescription
->
id
.
'开方成功'
);
}
}
}
}
// 自动审方
public
function
autoPrescriptionReview
()
{
$this
->
info
(
'开始自动审方...'
);
// 如果处方单是审方状态,同时对应的药店开启自动审方
$prescriptions
=
PrescriptionModel
::
where
(
'status'
,
PrescriptionModel
::
PRESCRIPTION_STATUS_REVIEWING
)
->
get
();
Log
::
info
(
'自动审
开
方:'
.
json_encode
(
$prescriptions
));
Log
::
info
(
'自动审方:'
.
json_encode
(
$prescriptions
));
if
(
$prescriptions
->
count
()
<=
0
)
{
$this
->
info
(
'没有需要审方的处方单'
);
...
...
@@ -45,8 +99,9 @@ public function handle()
foreach
(
$prescriptions
as
$prescription
)
{
// 查询对应的医师是手动并且药师为自动
$pharmacist
=
PharmacyModel
::
where
(
'id'
,
$prescription
->
pharmacy_id
)
->
first
();
$doctor
=
DoctorModel
::
where
(
'id'
,
$prescription
->
doctor_id
)
->
first
();
if
(
$doctor
->
is_auto
==
0
&&
$pharmacist
->
is_auto
==
1
)
{
// $doctor = DoctorModel::where('id', $prescription->doctor_id)->first();
// if ($doctor->is_auto == 0 && $pharmacist->is_auto == 1) {
if
(
$pharmacist
->
is_auto
==
1
)
{
// 更新处方单状态
$prescriptionInfo
=
PrescriptionModel
::
find
(
$prescription
->
id
);
if
(
$prescriptionInfo
)
{
...
...
@@ -67,6 +122,5 @@ public function handle()
}
}
}
}
}
app/Console/Kernel.php
View file @
0e6c7d7d
...
...
@@ -13,7 +13,7 @@ class Kernel extends ConsoleKernel
protected
function
schedule
(
Schedule
$schedule
)
:
void
{
// $schedule->command('inspire')->hourly();
$schedule
->
command
(
'mohe:prescription'
)
->
everyMinute
();
#
$schedule->command('mohe:prescription')->everyMinute();
}
/**
...
...
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