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
2d2b5e61
authored
Dec 01, 2024
by
赵增煜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
1aa8b4c3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
39 deletions
+27
-39
app/Api/Controllers/PrescriptionController.php
+27
-39
No files found.
app/Api/Controllers/PrescriptionController.php
View file @
2d2b5e61
...
@@ -50,9 +50,6 @@ public function prescriptionList(Request $request)
...
@@ -50,9 +50,6 @@ public function prescriptionList(Request $request)
$query
=
$query
->
where
(
'doctor_id'
,
$doctor
->
id
);
$query
=
$query
->
where
(
'doctor_id'
,
$doctor
->
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
();
if
(
!
$pharmacy
)
{
return
$this
->
failed
(
'请重新登录!'
);
}
$query
=
$query
->
where
(
'pharmacy_id'
,
$pharmacy
->
id
);
$query
=
$query
->
where
(
'pharmacy_id'
,
$pharmacy
->
id
);
}
}
...
@@ -122,7 +119,7 @@ public function create(Request $request)
...
@@ -122,7 +119,7 @@ public function create(Request $request)
return
$this
->
failed
(
'用户端暂时无法开处方'
);
return
$this
->
failed
(
'用户端暂时无法开处方'
);
$pharmacy
=
PharmacyModel
::
find
(
$pharmacy_id
);
$pharmacy
=
PharmacyModel
::
find
(
$pharmacy_id
);
if
(
!
$pharmacy
)
{
if
(
!
$pharmacy
)
{
return
$this
->
failed
(
'
你查询的药店信息不存在!
'
);
return
$this
->
failed
(
'
药店信息不存在
'
);
}
}
}
else
{
}
else
{
return
$this
->
failed
(
'pharmacy_id不能为空'
);
return
$this
->
failed
(
'pharmacy_id不能为空'
);
...
@@ -262,26 +259,17 @@ public function create(Request $request)
...
@@ -262,26 +259,17 @@ public function create(Request $request)
$prescription
->
pharmacy_id
=
$pharmacy
->
id
;
$prescription
->
pharmacy_id
=
$pharmacy
->
id
;
$prescription
->
pharmacy_name
=
$pharmacy
->
name
;
$prescription
->
pharmacy_name
=
$pharmacy
->
name
;
// 分派药师,先搜索是否存在默认药师,如果不存在则随机抽取一个
// 分派药师,先搜索是否存在默认药师,如果不存在则随机抽取一个
$pharmacist
=
PharmacistModel
::
where
(
'status'
,
PharmacistModel
::
IS_STATUS_TRUE
)
$pharmacist
=
PharmacistModel
::
where
(
'status'
,
1
)
->
where
(
'is_default'
,
PharmacistModel
::
IS_DEFAULT_TRUE
)
->
where
(
'pharmacy_id'
,
$pharmacy_id
)
->
where
(
function
(
$query
)
{
$query
->
where
(
'is_default'
,
1
)
->
orWhere
(
'is_default'
,
0
);
})
->
inRandomOrder
()
->
first
();
->
first
();
if
(
!
$pharmacist
)
{
$pharmacist
=
PharmacistModel
::
where
(
'status'
,
PharmacistModel
::
IS_STATUS_TRUE
)
->
inRandomOrder
()
->
first
();
}
// $pharmacist = PharmacistModel::where('status', 1)
// ->where('pharmacy_id', $pharmacy_id)
// ->where(function ($query) {
// $query->where('is_default', 1)
// ->orWhere('is_default', 0);
// })
// ->inRandomOrder()
// ->first();
if
(
!
$pharmacist
)
{
if
(
!
$pharmacist
)
{
return
$this
->
failed
(
'
该药店暂无可审方药师,请联系管理员!
'
);
return
$this
->
failed
(
'
药师信息不存在
'
);
}
}
Log
::
info
(
'药师:'
.
json_encode
(
$pharmacist
));
Log
::
info
(
'药师:'
.
json_encode
(
$pharmacist
));
$prescription
->
pharmacist_id
=
$pharmacist
->
id
;
$prescription
->
pharmacist_id
=
$pharmacist
->
id
;
...
@@ -309,15 +297,15 @@ public function create(Request $request)
...
@@ -309,15 +297,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'
)
{
...
@@ -339,15 +327,15 @@ public function create(Request $request)
...
@@ -339,15 +327,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'
)
{
...
...
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