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
f241f0de
authored
Nov 23, 2024
by
lujunyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
命令 自动任务
parent
e201d581
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
42 deletions
+34
-42
app/Console/Commands/PrescriptionCommand.php
+33
-38
app/Console/Kernel.php
+1
-4
No files found.
app/Console/Commands/PrescriptionCommand.php
View file @
f241f0de
...
@@ -17,59 +17,54 @@ class PrescriptionCommand extends Command
...
@@ -17,59 +17,54 @@ class PrescriptionCommand extends Command
*
*
* @var string
* @var string
*/
*/
protected
$signature
=
'
app:prescription-command
'
;
protected
$signature
=
'
mohe:prescription
'
;
/**
/**
* The console command description.
* The console command description.
*
*
* @var string
* @var string
*/
*/
protected
$description
=
'
Command description
'
;
protected
$description
=
'
自动审开方
'
;
/**
/**
* Execute the console command.
* Execute the console command.
*/
*/
public
function
handle
()
public
function
handle
()
{
{
$this
->
info
(
'start command'
);
$this
->
info
(
'开始自动审开方...'
);
// 常驻脚本
// 如果处方单是审方状态,同时对应的药店开启自动审方
while
(
true
)
{
$prescriptions
=
PrescriptionModel
::
where
(
'status'
,
1
)
sleep
(
5
);
->
where
(
'status'
,
PrescriptionModel
::
PRESCRIPTION_STATUS_REVIEWING
)
// 如果处方单是审方状态,同时对应的药店开启自动审方
->
get
();
$prescriptions
=
PrescriptionModel
::
where
(
'status'
,
1
)
->
where
(
'status'
,
PrescriptionModel
::
PRESCRIPTION_STATUS_REVIEWING
)
->
get
();
if
(
$prescriptions
->
count
()
>
0
)
{
if
(
$prescriptions
->
count
()
>
0
)
{
foreach
(
$prescriptions
as
$prescription
)
{
$this
->
info
(
'没有需要审方的处方单'
);
// 查询对应的医师是手动并且药师为自动
$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
)
{
// var_dump($prescription);
// 更新处方单状态
$prescriptionInfo
=
PrescriptionModel
::
find
(
$prescription
->
id
);
if
(
$prescriptionInfo
)
{
$prescriptionInfo
->
status
=
PrescriptionModel
::
PRESCRIPTION_STATUS_SUCCESS
;
$prescriptionInfo
->
save
();
// 获取患者信息
$patient
=
PatientModel
::
where
(
'id'
,
$prescriptionInfo
->
patient_id
)
->
first
();
// 生成审方日志
$dateTime
=
new
DateTime
(
$prescription
->
created_at
);
$dateTime
->
modify
(
'+5 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
->
pharmacist_name
.
'在'
.
$currentTime
.
'为'
.
$prescription
->
patient_name
.
'('
.
$patient
->
mobile
.
')审方(处方单编号:'
.
$prescription
->
id
.
')'
;
$pharmacistLog
->
save
();
$this
->
info
(
$prescription
->
id
.
'审方成功'
);
}
}
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
)
{
// 更新处方单状态
$prescriptionInfo
=
PrescriptionModel
::
find
(
$prescription
->
id
);
if
(
$prescriptionInfo
)
{
$prescriptionInfo
->
status
=
PrescriptionModel
::
PRESCRIPTION_STATUS_SUCCESS
;
$prescriptionInfo
->
save
();
// 获取患者信息
$patient
=
PatientModel
::
where
(
'id'
,
$prescriptionInfo
->
patient_id
)
->
first
();
// 生成审方日志
$dateTime
=
new
DateTime
(
$prescription
->
created_at
);
$dateTime
->
modify
(
'+5 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
->
pharmacist_name
.
'在'
.
$currentTime
.
'为'
.
$prescription
->
patient_name
.
'('
.
$patient
->
mobile
.
')审方(处方单编号:'
.
$prescription
->
id
.
')'
;
$pharmacistLog
->
save
();
$this
->
info
(
$prescription
->
id
.
'审方成功'
);
}
}
}
else
{
$this
->
info
(
'没有需要审方的处方单'
);
}
}
}
}
...
...
app/Console/Kernel.php
View file @
f241f0de
...
@@ -7,16 +7,13 @@
...
@@ -7,16 +7,13 @@
class
Kernel
extends
ConsoleKernel
class
Kernel
extends
ConsoleKernel
{
{
protected
$commands
=
[
\App\Console\Commands\PrescriptionCommand
::
class
,
];
/**
/**
* Define the application's command schedule.
* Define the application's command schedule.
*/
*/
protected
function
schedule
(
Schedule
$schedule
)
:
void
protected
function
schedule
(
Schedule
$schedule
)
:
void
{
{
// $schedule->command('inspire')->hourly();
// $schedule->command('inspire')->hourly();
$schedule
->
command
(
'mohe:prescription'
)
->
everyFiveMinutes
();
}
}
/**
/**
...
...
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