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
5615fd45
authored
Nov 22, 2024
by
赵增煜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加常驻脚本
parent
e7cf05a2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
0 deletions
+75
-0
app/Console/Commands/PrescriptionCommand.php
+71
-0
app/Console/Kernel.php
+4
-0
No files found.
app/Console/Commands/PrescriptionCommand.php
0 → 100644
View file @
5615fd45
<?php
namespace
App\Console\Commands
;
use
App\Models\DoctorModel
;
use
App\Models\PatientModel
;
use
App\Models\PharmacyModel
;
use
App\Models\PrescriptionLogModel
;
use
App\Models\PrescriptionModel
;
use
DateTime
;
use
Illuminate\Console\Command
;
class
PrescriptionCommand
extends
Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected
$signature
=
'app:prescription-command'
;
/**
* The console command description.
*
* @var string
*/
protected
$description
=
'Command description'
;
/**
* Execute the console command.
*/
public
function
handle
()
{
$this
->
info
(
'start command'
);
// 常驻脚本
while
(
true
)
{
sleep
(
5
);
// 如果处方单是审方状态,同时对应的药店开启自动审方
$prescriptions
=
PrescriptionModel
::
where
(
'status'
,
1
)
->
where
(
'status'
,
PrescriptionModel
::
PRESCRIPTION_STATUS_REVIEWING
)
->
get
();
if
(
$prescriptions
->
count
()
>
0
)
{
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
)
{
var_dump
(
$prescription
);
// 更新处方单状态
PrescriptionModel
::
where
(
'id'
,
$prescription
->
id
)
->
update
([
'status'
=>
PrescriptionModel
::
PRESCRIPTION_STATUS_SUCCESS
]);
// 获取患者信息
$patient
=
PatientModel
::
where
(
'id'
,
$prescription
->
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
();
}
}
}
else
{
$this
->
info
(
'没有需要审方的处方单'
);
}
}
}
}
app/Console/Kernel.php
View file @
5615fd45
...
...
@@ -7,6 +7,10 @@
class
Kernel
extends
ConsoleKernel
{
protected
$commands
=
[
\App\Console\Commands\PrescriptionCommand
::
class
,
];
/**
* Define the application's command schedule.
*/
...
...
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