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
f4ad1080
authored
Nov 13, 2024
by
赵增煜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
本地修改
parent
fe39e064
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
28 deletions
+30
-28
app/Api/Controllers/PrescriptionController.php
+30
-26
app/Models/PharmacyModel.php
+0
-2
No files found.
app/Api/Controllers/PrescriptionController.php
View file @
f4ad1080
...
@@ -5,51 +5,55 @@
...
@@ -5,51 +5,55 @@
use
App\Http\Controllers\BaseApiController
;
use
App\Http\Controllers\BaseApiController
;
use
App\Models\DoctorModel
;
use
App\Models\DoctorModel
;
use
App\Models\PatientModel
;
use
App\Models\PatientModel
;
use
App\Models\PharmacyModel
;
use
App\Models\PharmacistModel
;
use
App\Models\PharmacistModel
;
use
App\Models\PharmacyDrugModel
;
use
App\Models\PharmacyDrugModel
;
use
App\Models\P
rescription
Model
;
use
App\Models\P
harmacy
Model
;
use
App\Models\PrescriptionLogModel
;
use
App\Models\PrescriptionLogModel
;
use
App\Models\PrescriptionModel
;
use
App\Models\User
;
use
App\Models\User
;
use
Carbon\Carbon
;
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Support\Facades\DB
;
use
Carbon\Carbon
;
// 问诊人控制器
// 问诊人控制器
class
PrescriptionController
extends
BaseApiController
class
PrescriptionController
extends
BaseApiController
{
{
public
function
test
()
public
function
test
()
{
{
// 分派医师 医师当日开方未达到上限以及是否在时间段的搜索出来
// 分派医师 医师当日开方未达到上限以及是否在时间段的搜索出来
// $site_config = DB::table('admin_settings')->where('slug', 'site_config')->value('value');
// $site_config = DB::table('admin_settings')->where('slug', 'site_config')->value('value');
// $site_config = json_decode($site_config, true);
// $site_config = json_decode($site_config, true);
// $pharmacy = PharmacyDrugModel::where('pharmacy_id',1)->get();
// $pharmacy = PharmacyDrugModel::where('pharmacy_id',1)->get();
$doctors
=
DoctorModel
::
query
()
->
where
(
'status'
,
1
)
->
get
();
$doctors
=
DoctorModel
::
query
()
->
where
(
'status'
,
1
)
->
get
();
$randomDoctor
=
$doctors
->
random
();
$randomDoctor
=
$doctors
->
random
();
return
$this
->
success
(
$randomDoctor
);
return
$this
->
success
(
$randomDoctor
);
}
}
# 处方列表
// 处方列表
public
function
prescriptionList
(
Request
$request
)
public
function
prescriptionList
(
Request
$request
)
{
{
$authInfo
=
auth
(
'api'
)
->
user
();
$authInfo
=
auth
(
'api'
)
->
user
();
$userInfo
=
User
::
with
([
'doctor'
,
'pharmacist'
])
->
find
(
$authInfo
->
id
);
$userInfo
=
User
::
with
([
'doctor'
,
'pharmacist'
])
->
find
(
$authInfo
->
id
);
$query
=
PrescriptionModel
::
query
();
$query
=
PrescriptionModel
::
query
();
# TODO 判断当前登录的用户角色
// TODO 判断当前登录的用户角色
$prescription
=
$query
->
get
();
$prescription
=
$query
->
get
();
return
$this
->
success
(
$prescription
);
return
$this
->
success
(
$prescription
);
}
}
#
处方详情
//
处方详情
public
function
prescriptionDetail
(
Request
$request
)
public
function
prescriptionDetail
(
Request
$request
)
{
{
$prescription_id
=
$request
->
input
(
'prescription_id'
);
$prescription_id
=
$request
->
input
(
'prescription_id'
);
$prescription
=
PrescriptionModel
::
query
()
->
where
(
'id'
,
$prescription_id
)
->
first
();
$prescription
=
PrescriptionModel
::
query
()
->
where
(
'id'
,
$prescription_id
)
->
first
();
return
$this
->
success
(
$prescription
);
return
$this
->
success
(
$prescription
);
}
}
#
开方
//
开方
public
function
create
(
Request
$request
)
public
function
create
(
Request
$request
)
{
{
// $userId = auth('api')->user()->id;
// $userId = auth('api')->user()->id;
...
@@ -57,7 +61,7 @@ public function create(Request $request)
...
@@ -57,7 +61,7 @@ public function create(Request $request)
$patient_id
=
$request
->
input
(
'patient_id'
);
$patient_id
=
$request
->
input
(
'patient_id'
);
// 获取问诊人信息
// 获取问诊人信息
$patient
=
PatientModel
::
query
()
->
where
(
'id'
,
$patient_id
)
->
first
();
$patient
=
PatientModel
::
query
()
->
where
(
'id'
,
$patient_id
)
->
first
();
$prescription_umber
=
""
;
$prescription_umber
=
''
;
$data
=
[];
$data
=
[];
$data
[
'prescription_umber'
]
=
''
;
// TODO 处方单编号生成逻辑待定
$data
[
'prescription_umber'
]
=
''
;
// TODO 处方单编号生成逻辑待定
$data
[
'status'
]
=
0
;
// TODO Model中增加枚举
$data
[
'status'
]
=
0
;
// TODO Model中增加枚举
...
@@ -78,12 +82,12 @@ public function create(Request $request)
...
@@ -78,12 +82,12 @@ public function create(Request $request)
$site_config
=
DB
::
table
(
'admin_settings'
)
->
where
(
'slug'
,
'site_config'
)
->
value
(
'value'
);
$site_config
=
DB
::
table
(
'admin_settings'
)
->
where
(
'slug'
,
'site_config'
)
->
value
(
'value'
);
$site_config
=
json_decode
(
$site_config
,
true
);
$site_config
=
json_decode
(
$site_config
,
true
);
$prescription_limit
=
$site_config
[
'prescription_limit'
];
$prescription_limit
=
$site_config
[
'prescription_limit'
];
// 判断是否开启时间段
// 判断是否开启时间段
$doctors
=
DoctorModel
::
query
()
->
where
(
'status'
,
1
)
->
get
();
$doctors
=
DoctorModel
::
query
()
->
where
(
'status'
,
1
)
->
get
();
$randomDoctor
=
$doctors
->
random
();
$randomDoctor
=
$doctors
->
random
();
// foreach ($doctors as $key => $doctor) {
// foreach ($doctors as $key => $doctor) {
// }
// }
// 判断是否为医师自动开方
// 判断是否为医师自动开方
...
@@ -94,26 +98,26 @@ public function create(Request $request)
...
@@ -94,26 +98,26 @@ public function create(Request $request)
$dockor_log
[
'pharmacy_id'
]
=
$pharmacy_id
;
$dockor_log
[
'pharmacy_id'
]
=
$pharmacy_id
;
$dockor_log
[
'pharmacy_name'
]
=
$pharmacy
->
name
;
$dockor_log
[
'pharmacy_name'
]
=
$pharmacy
->
name
;
$currentTime
=
Carbon
::
now
()
->
toDateTimeString
();
$currentTime
=
Carbon
::
now
()
->
toDateTimeString
();
$dockor_log
[
'log_info'
]
=
$randomDoctor
->
mame
.
"在"
.
$currentTime
.
"为"
.
$patient
->
name
.
"("
.
$patient
->
mobile
.
")开具处方单(处方单编号:"
.
$prescription_umber
.
")"
;
$dockor_log
[
'log_info'
]
=
$randomDoctor
->
mame
.
'在'
.
$currentTime
.
'为'
.
$patient
->
name
.
'('
.
$patient
->
mobile
.
')开具处方单(处方单编号:'
.
$prescription_umber
.
')'
;
PrescriptionLogModel
::
create
(
$dockor_log
);
PrescriptionLogModel
::
create
(
$dockor_log
);
#
分派药师,先搜索是否存在默认药师,如果不存在则随机抽取一个
//
分派药师,先搜索是否存在默认药师,如果不存在则随机抽取一个
$pharmacist
=
PharmacistModel
::
query
()
->
where
(
'status'
,
1
)
->
where
(
'is_default'
,
1
)
->
where
(
'pharmacy_id'
,
$pharmacy_id
)
->
first
();
$pharmacist
=
PharmacistModel
::
query
()
->
where
(
'status'
,
1
)
->
where
(
'is_default'
,
1
)
->
where
(
'pharmacy_id'
,
$pharmacy_id
)
->
first
();
if
(
!
$pharmacist
)
{
if
(
!
$pharmacist
)
{
$pharmacists
=
PharmacistModel
::
query
()
->
where
(
'status'
,
1
)
->
where
(
'pharmacy_id'
,
$pharmacy_id
)
->
get
();
$pharmacists
=
PharmacistModel
::
query
()
->
where
(
'status'
,
1
)
->
where
(
'pharmacy_id'
,
$pharmacy_id
)
->
get
();
$pharmacist
=
$pharmacists
->
random
();
$pharmacist
=
$pharmacists
->
random
();
}
}
#
判断是否药师自动审方
//
判断是否药师自动审方
#
生成药师审方日志
//
生成药师审方日志
$pharamcy_log
=
[];
$pharamcy_log
=
[];
$pharamcy_log
[
'pharmacy_id'
]
=
$pharmacy_id
;
$pharamcy_log
[
'pharmacy_id'
]
=
$pharmacy_id
;
$pharamcy_log
[
'pharmacy_name'
]
=
$pharmacy
->
name
;
$pharamcy_log
[
'pharmacy_name'
]
=
$pharmacy
->
name
;
$currentTime
=
Carbon
::
now
()
->
toDateTimeString
();
$currentTime
=
Carbon
::
now
()
->
toDateTimeString
();
$pharamcy_log
[
'log_info'
]
=
$pharmacist
->
name
.
"在"
.
$currentTime
.
"为"
.
$patient
->
name
.
"("
.
$patient
->
mobile
.
")审方"
;
$pharamcy_log
[
'log_info'
]
=
$pharmacist
->
name
.
'在'
.
$currentTime
.
'为'
.
$patient
->
name
.
'('
.
$patient
->
mobile
.
')审方'
;
#
给医师发送短信
//
给医师发送短信
#
给药师发送短信
//
给药师发送短信
#
生成处方单信息
//
生成处方单信息
return
$this
->
success
(
$data
);
return
$this
->
success
(
$data
);
}
}
...
...
app/Models/PharmacyModel.php
View file @
f4ad1080
...
@@ -5,7 +5,6 @@
...
@@ -5,7 +5,6 @@
use
Dcat\Admin\Traits\HasDateTimeFormatter
;
use
Dcat\Admin\Traits\HasDateTimeFormatter
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Database\Eloquent\SoftDeletes
;
use
Illuminate\Database\Eloquent\SoftDeletes
;
use
Illuminate\Database\Eloquent\Relations\HasMany
;
class
PharmacyModel
extends
Model
class
PharmacyModel
extends
Model
{
{
...
@@ -13,5 +12,4 @@ class PharmacyModel extends Model
...
@@ -13,5 +12,4 @@ class PharmacyModel extends Model
use
SoftDeletes
;
use
SoftDeletes
;
protected
$table
=
'pharmacy'
;
protected
$table
=
'pharmacy'
;
}
}
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