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
5c577a59
authored
Nov 30, 2024
by
赵增煜
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev-1130' into develop
parents
66fb75d5
0e6c7d7d
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
163 additions
and
37 deletions
+163
-37
app/Admin/Controllers/PrescriptionLogController.php
+1
-0
app/Admin/Controllers/PrescriptionPrintController.php
+5
-4
app/Api/Controllers/PatientController.php
+8
-4
app/Api/Controllers/PrescriptionController.php
+18
-18
app/Console/Commands/InitPharmacyDrugCommand.php
+66
-0
app/Console/Commands/PrescriptionCommand.php
+59
-5
app/Console/Kernel.php
+1
-1
app/Models/PrescriptionModel.php
+4
-4
database/migrations/2024_11_28_223219_add_prescription_type_to_prescription_table.php
+1
-1
No files found.
app/Admin/Controllers/PrescriptionLogController.php
View file @
5c577a59
...
@@ -33,6 +33,7 @@ protected function grid()
...
@@ -33,6 +33,7 @@ protected function grid()
$filter
->
expand
();
// 默认展开搜索框
$filter
->
expand
();
// 默认展开搜索框
$filter
->
like
(
'pharmacy_name'
)
->
width
(
3
);
$filter
->
like
(
'pharmacy_name'
)
->
width
(
3
);
$filter
->
between
(
'created_at'
,
'创建时间'
)
->
date
()
->
width
(
3
);
});
});
// 行按钮控制
// 行按钮控制
...
...
app/Admin/Controllers/PrescriptionPrintController.php
View file @
5c577a59
...
@@ -52,8 +52,9 @@ public function search()
...
@@ -52,8 +52,9 @@ public function search()
}
}
try
{
try
{
$pharmacy_id
=
Admin
::
user
()
->
pharmacy_id
;
// 获取处方信息
// 获取处方信息
$prescription
=
PrescriptionModel
::
where
(
'id'
,
$prescriptionNo
)
->
where
(
'status'
,
PrescriptionModel
::
PRESCRIPTION_STATUS_SUCCESS
)
->
first
();
$prescription
=
PrescriptionModel
::
where
(
'id'
,
$prescriptionNo
)
->
where
(
'
pharmacy_id'
,
$pharmacy_id
)
->
where
(
'
status'
,
PrescriptionModel
::
PRESCRIPTION_STATUS_SUCCESS
)
->
first
();
if
(
!
$prescription
)
{
if
(
!
$prescription
)
{
return
response
()
->
json
([
'status'
=>
false
,
'message'
=>
'未找到该处方或还未审方成功~'
]);
return
response
()
->
json
([
'status'
=>
false
,
'message'
=>
'未找到该处方或还未审方成功~'
]);
}
}
...
@@ -78,9 +79,9 @@ public function search()
...
@@ -78,9 +79,9 @@ public function search()
// 创建处方图片
// 创建处方图片
// 处方背景图宽1653,高2339
// 处方背景图宽1653,高2339
$backgroudImg
=
public_path
(
'static/images/
zhong
yao.jpg'
);
$backgroudImg
=
public_path
(
'static/images/
xi
yao.jpg'
);
if
(
$prescription
->
prescription_type
==
P
RESCRIPTION_TYPE_W
M
)
{
if
(
$prescription
->
prescription_type
==
P
rescriptionModel
::
PRESCRIPTION_TYPE_TC
M
)
{
$backgroudImg
=
public_path
(
'static/images/
xi
yao.jpg'
);
$backgroudImg
=
public_path
(
'static/images/
zhong
yao.jpg'
);
}
}
$img
=
Image
::
read
(
$backgroudImg
);
$img
=
Image
::
read
(
$backgroudImg
);
...
...
app/Api/Controllers/PatientController.php
View file @
5c577a59
...
@@ -24,15 +24,19 @@ public function patientList(Request $request)
...
@@ -24,15 +24,19 @@ public function patientList(Request $request)
$authInfo
=
auth
(
'api'
)
->
user
();
$authInfo
=
auth
(
'api'
)
->
user
();
$query
=
PatientModel
::
query
();
$query
=
PatientModel
::
query
();
if
(
$authInfo
->
last_login_type
==
User
::
LOGIN_TYPE_USER
)
{
// 用户
if
(
$authInfo
->
last_login_type
==
User
::
LOGIN_TYPE_USER
)
{
// 用户
$query
=
$query
->
where
(
'user_id'
,
$authInfo
->
id
);
$query
->
where
(
'user_id'
,
$authInfo
->
id
);
}
elseif
(
$authInfo
->
last_login_type
==
User
::
LOGIN_TYPE_PHARMACY
)
{
// 药店
}
elseif
(
$authInfo
->
last_login_type
==
User
::
LOGIN_TYPE_PHARMACY
)
{
// 药店
$pharmacy
=
PharmacyModel
::
query
()
->
where
(
'user_id'
,
$authInfo
->
id
)
->
first
();
$pharmacy
=
PharmacyModel
::
query
()
->
where
(
'user_id'
,
$authInfo
->
id
)
->
first
();
$query
=
$query
->
where
(
'pharmacy_id'
,
$pharmacy
->
id
);
$query
->
where
(
'pharmacy_id'
,
$pharmacy
->
id
);
}
}
$search_input
=
$request
->
input
(
'search_input'
);
$search_input
=
$request
->
input
(
'search_input'
);
if
(
$search_input
)
{
if
(
$search_input
)
{
$query
->
where
(
'id_card'
,
'like'
,
"%
{
$search_input
}
%"
)
$query
->
where
(
function
(
$q
)
use
(
$search_input
)
{
->
orWhere
(
'name'
,
'like'
,
"%
{
$search_input
}
%"
);
$q
->
where
(
'id_card'
,
'like'
,
"%
{
$search_input
}
%"
)
->
orWhere
(
'name'
,
'like'
,
"%
{
$search_input
}
%"
);
});
// $query->where('id_card', 'like', "%{$search_input}%");
// $query->orWhere('name', 'like', "%{$search_input}%");
// ->orWhere('mobile', 'like', "%{$search_input}%");
// ->orWhere('mobile', 'like', "%{$search_input}%");
}
}
// 分页
// 分页
...
...
app/Api/Controllers/PrescriptionController.php
View file @
5c577a59
...
@@ -300,15 +300,15 @@ public function create(Request $request)
...
@@ -300,15 +300,15 @@ public function create(Request $request)
// 判断是否为医师自动开方
// 判断是否为医师自动开方
// $prescription_auto = $site_config['prescription_auto'];
// $prescription_auto = $site_config['prescription_auto'];
if
(
$randomDoctor
->
is_auto
==
1
)
{
if
(
$randomDoctor
->
is_auto
==
1
)
{
$prescription
->
status
=
PrescriptionModel
::
PRESCRIPTION_STATUS_REVIEWING
;
//
$prescription->status = PrescriptionModel::PRESCRIPTION_STATUS_REVIEWING;
$prescription
->
save
();
//
$prescription->save();
// 生成医师开方日志
//
//
生成医师开方日志
$doctorLog
=
new
PrescriptionLogModel
;
//
$doctorLog = new PrescriptionLogModel;
$doctorLog
->
pharmacy_id
=
$pharmacy_id
;
//
$doctorLog->pharmacy_id = $pharmacy_id;
$doctorLog
->
pharmacy_name
=
$pharmacy
->
name
;
//
$doctorLog->pharmacy_name = $pharmacy->name;
$currentTime
=
$prescription_at
;
//
$currentTime = $prescription_at;
$doctorLog
->
log_info
=
$randomDoctor
->
name
.
'在'
.
$prescription_at
.
'为'
.
$patient
->
name
.
'('
.
$patient
->
mobile
.
')开具处方单(处方单编号:'
.
$prescription_number
.
')'
;
//
$doctorLog->log_info = $randomDoctor->name.'在'.$prescription_at.'为'.$patient->name.'('.$patient->mobile.')开具处方单(处方单编号:'.$prescription_number.')';
$doctorLog
->
save
();
//
$doctorLog->save();
}
elseif
(
$randomDoctor
->
is_auto
==
0
)
{
}
elseif
(
$randomDoctor
->
is_auto
==
0
)
{
// 手动开方发送医师通知短信
// 手动开方发送医师通知短信
if
(
env
(
'SMS_CHANNEL'
)
==
'chengliye'
)
{
if
(
env
(
'SMS_CHANNEL'
)
==
'chengliye'
)
{
...
@@ -330,15 +330,15 @@ public function create(Request $request)
...
@@ -330,15 +330,15 @@ public function create(Request $request)
// 药店自动审方(必须处方单待审方)
// 药店自动审方(必须处方单待审方)
if
(
$pharmacy
->
is_auto
==
1
&&
$prescription
->
status
==
PrescriptionModel
::
PRESCRIPTION_STATUS_REVIEWING
)
{
if
(
$pharmacy
->
is_auto
==
1
&&
$prescription
->
status
==
PrescriptionModel
::
PRESCRIPTION_STATUS_REVIEWING
)
{
$prescription
->
status
=
PrescriptionModel
::
PRESCRIPTION_STATUS_SUCCESS
;
//
$prescription->status = PrescriptionModel::PRESCRIPTION_STATUS_SUCCESS;
$prescription
->
save
();
//
$prescription->save();
// 生成药师审方日志
//
//
生成药师审方日志
$pharmacistLog
=
new
PrescriptionLogModel
;
//
$pharmacistLog = new PrescriptionLogModel;
$pharmacistLog
->
pharmacy_id
=
$pharmacy_id
;
//
$pharmacistLog->pharmacy_id = $pharmacy_id;
$pharmacistLog
->
pharmacy_name
=
$pharmacy
->
name
;
//
$pharmacistLog->pharmacy_name = $pharmacy->name;
$currentTime
=
$review_at
;
//
$currentTime = $review_at;
$pharmacistLog
->
log_info
=
$pharmacist
->
name
.
'在'
.
$review_at
.
'为'
.
$patient
->
name
.
'('
.
$patient
->
mobile
.
')审方(处方单编号:'
.
$prescription_number
.
')'
;
//
$pharmacistLog->log_info = $pharmacist->name.'在'.$review_at.'为'.$patient->name.'('.$patient->mobile.')审方(处方单编号:'.$prescription_number.')';
$pharmacistLog
->
save
();
//
$pharmacistLog->save();
}
elseif
(
$pharmacy
->
is_auto
==
0
)
{
}
elseif
(
$pharmacy
->
is_auto
==
0
)
{
// 手动审方发送药店通知短信
// 手动审方发送药店通知短信
if
(
env
(
'SMS_CHANNEL'
)
==
'chengliye'
)
{
if
(
env
(
'SMS_CHANNEL'
)
==
'chengliye'
)
{
...
...
app/Console/Commands/InitPharmacyDrugCommand.php
0 → 100644
View file @
5c577a59
<?php
namespace
App\Console\Commands
;
use
App\Models\PharmacyDrugModel
;
use
App\Models\PharmacyModel
;
use
Illuminate\Console\Command
;
class
InitPharmacyDrugCommand
extends
Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected
$signature
=
'init:pharmacy_drug {pharmacy_id}'
;
/**
* The console command description.
*
* @var string
*/
protected
$description
=
'药店药品复制'
;
/**
* Execute the console command.
*/
public
function
handle
()
{
$this
->
info
(
'开始药店药品复制...'
);
// 以药店1的药品为模板复制到其他药店
$pharmacy_id
=
$this
->
argument
(
'pharmacy_id'
)
??
0
;
if
(
intval
(
$pharmacy_id
)
<=
1
)
{
$this
->
info
(
'请输入正确的药店id'
);
return
;
}
// 查找一下传入的药店id是否存在
$pharmacy
=
PharmacyModel
::
where
(
'id'
,
$pharmacy_id
)
->
first
();
if
(
empty
(
$pharmacy
))
{
$this
->
info
(
'药店不存在,请重新输入'
);
return
;
}
$pharmacyDrugList
=
PharmacyDrugModel
::
where
(
'pharmacy_id'
,
1
)
->
get
();
if
(
$pharmacyDrugList
->
count
()
<=
0
)
{
$this
->
info
(
'模板药店药品为空'
);
return
;
}
foreach
(
$pharmacyDrugList
as
$pharmacyDrug
)
{
// 查找该药品在该药店是否存在,如果存在则跳过,如果不存在则复制
$is_exists
=
PharmacyDrugModel
::
where
(
'pharmacy_id'
,
$pharmacy_id
)
->
where
(
'drug_id'
,
$pharmacyDrug
->
drug_id
)
->
first
();
if
(
!
empty
(
$is_exists
))
{
continue
;
}
$newPharmacyDrug
=
new
PharmacyDrugModel
();
$newPharmacyDrug
->
pharmacy_id
=
$pharmacy_id
;
$newPharmacyDrug
->
drug_id
=
$pharmacyDrug
->
drug_id
;
$newPharmacyDrug
->
unit
=
$pharmacyDrug
->
unit
;
$newPharmacyDrug
->
save
();
}
}
}
app/Console/Commands/PrescriptionCommand.php
View file @
5c577a59
...
@@ -32,11 +32,65 @@ class PrescriptionCommand extends Command
...
@@ -32,11 +32,65 @@ class PrescriptionCommand extends Command
*/
*/
public
function
handle
()
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
)
$prescriptions
=
PrescriptionModel
::
where
(
'status'
,
PrescriptionModel
::
PRESCRIPTION_STATUS_REVIEWING
)
->
get
();
->
get
();
Log
::
info
(
'自动审
开
方:'
.
json_encode
(
$prescriptions
));
Log
::
info
(
'自动审方:'
.
json_encode
(
$prescriptions
));
if
(
$prescriptions
->
count
()
<=
0
)
{
if
(
$prescriptions
->
count
()
<=
0
)
{
$this
->
info
(
'没有需要审方的处方单'
);
$this
->
info
(
'没有需要审方的处方单'
);
...
@@ -45,8 +99,9 @@ public function handle()
...
@@ -45,8 +99,9 @@ public function handle()
foreach
(
$prescriptions
as
$prescription
)
{
foreach
(
$prescriptions
as
$prescription
)
{
// 查询对应的医师是手动并且药师为自动
// 查询对应的医师是手动并且药师为自动
$pharmacist
=
PharmacyModel
::
where
(
'id'
,
$prescription
->
pharmacy_id
)
->
first
();
$pharmacist
=
PharmacyModel
::
where
(
'id'
,
$prescription
->
pharmacy_id
)
->
first
();
$doctor
=
DoctorModel
::
where
(
'id'
,
$prescription
->
doctor_id
)
->
first
();
// $doctor = DoctorModel::where('id', $prescription->doctor_id)->first();
if
(
$doctor
->
is_auto
==
0
&&
$pharmacist
->
is_auto
==
1
)
{
// if ($doctor->is_auto == 0 && $pharmacist->is_auto == 1) {
if
(
$pharmacist
->
is_auto
==
1
)
{
// 更新处方单状态
// 更新处方单状态
$prescriptionInfo
=
PrescriptionModel
::
find
(
$prescription
->
id
);
$prescriptionInfo
=
PrescriptionModel
::
find
(
$prescription
->
id
);
if
(
$prescriptionInfo
)
{
if
(
$prescriptionInfo
)
{
...
@@ -67,6 +122,5 @@ public function handle()
...
@@ -67,6 +122,5 @@ public function handle()
}
}
}
}
}
}
}
}
}
}
app/Console/Kernel.php
View file @
5c577a59
...
@@ -13,7 +13,7 @@ class Kernel extends ConsoleKernel
...
@@ -13,7 +13,7 @@ class Kernel extends ConsoleKernel
protected
function
schedule
(
Schedule
$schedule
)
:
void
protected
function
schedule
(
Schedule
$schedule
)
:
void
{
{
// $schedule->command('inspire')->hourly();
// $schedule->command('inspire')->hourly();
$schedule
->
command
(
'mohe:prescription'
)
->
everyMinute
();
#
$schedule->command('mohe:prescription')->everyMinute();
}
}
/**
/**
...
...
app/Models/PrescriptionModel.php
View file @
5c577a59
...
@@ -87,15 +87,15 @@ class PrescriptionModel extends Model
...
@@ -87,15 +87,15 @@ class PrescriptionModel extends Model
self
::
IS_VOIDED_TRUE
=>
'danger'
,
self
::
IS_VOIDED_TRUE
=>
'danger'
,
];
];
// 处方类型[0=
中药,1=西
药]
// 处方类型[0=
西药,1=中
药]
const
PRESCRIPTION_TYPE_
TC
M
=
0
;
const
PRESCRIPTION_TYPE_
W
M
=
0
;
const
PRESCRIPTION_TYPE_
W
M
=
1
;
const
PRESCRIPTION_TYPE_
TC
M
=
1
;
// 处方类型-文字映射
// 处方类型-文字映射
const
PRESCRIPTION_TYPE_MAP
=
[
const
PRESCRIPTION_TYPE_MAP
=
[
self
::
PRESCRIPTION_TYPE_TCM
=>
'中药'
,
self
::
PRESCRIPTION_TYPE_WM
=>
'西药'
,
self
::
PRESCRIPTION_TYPE_WM
=>
'西药'
,
self
::
PRESCRIPTION_TYPE_TCM
=>
'中药'
,
];
];
public
function
getDoctorSignedPicAttribute
(
$value
)
public
function
getDoctorSignedPicAttribute
(
$value
)
...
...
database/migrations/2024_11_28_223219_add_prescription_type_to_prescription_table.php
View file @
5c577a59
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
public
function
up
()
:
void
public
function
up
()
:
void
{
{
Schema
::
table
(
'prescription'
,
function
(
Blueprint
$table
)
{
Schema
::
table
(
'prescription'
,
function
(
Blueprint
$table
)
{
$table
->
tinyInteger
(
'prescription_type'
)
->
default
(
0
)
->
comment
(
'处方类型[0=
中药,1=西
药]'
);
$table
->
tinyInteger
(
'prescription_type'
)
->
default
(
0
)
->
comment
(
'处方类型[0=
西药,1=中
药]'
);
});
});
}
}
...
...
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