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
fe39e064
authored
Nov 13, 2024
by
赵增煜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
本地修改
parent
736361db
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
140 additions
and
56 deletions
+140
-56
app/Api/Controllers/DrugController.php
+17
-2
app/Api/Controllers/InquiryController.php
+11
-12
app/Api/Controllers/PatientController.php
+16
-13
app/Api/Controllers/PrescriptionController.php
+94
-28
app/Models/PharmacyModel.php
+2
-0
database/migrations/2024_11_04_135741_create_patient_table.php
+0
-1
No files found.
app/Api/Controllers/DrugController.php
View file @
fe39e064
...
@@ -18,8 +18,8 @@ public function test()
...
@@ -18,8 +18,8 @@ public function test()
public
function
drugList
(
Request
$request
)
public
function
drugList
(
Request
$request
)
{
{
// $code = $request->input('code');
// $code = $request->input('code');
#
TODO 通过药店编号筛选药品列表
//
TODO 通过药店编号筛选药品列表
#
pharmacy_id = $request->input('code');
//
pharmacy_id = $request->input('code');
$data
=
DrugModel
::
query
()
->
paginate
(
10
);
$data
=
DrugModel
::
query
()
->
paginate
(
10
);
// $total = DrugModel::query()->count();
// $total = DrugModel::query()->count();
...
@@ -29,4 +29,19 @@ public function drugList(Request $request)
...
@@ -29,4 +29,19 @@ public function drugList(Request $request)
// ];
// ];
return
$this
->
success
(
$data
);
return
$this
->
success
(
$data
);
}
}
# 药品7日内限购
public
function
drugLimit
(
Request
$request
)
{
$drug_id
=
$request
->
input
(
'drug_id'
);
# 判断当前药品有没有设置7日内限购
$drug
=
DrugModel
::
query
()
->
find
(
$drug_id
);
# 当前药品未设置则使用全局的7日内限购
$limit_num
=
0
;
if
(
$drug
->
limit_num
==
0
){
}
return
$this
->
success
(
$limit_num
);
}
}
}
app/Api/Controllers/InquiryController.php
View file @
fe39e064
...
@@ -2,11 +2,10 @@
...
@@ -2,11 +2,10 @@
namespace
App\Api\Controllers
;
namespace
App\Api\Controllers
;
use
App\Common\Util
;
use
App\Http\Controllers\BaseApiController
;
use
App\Http\Controllers\BaseApiController
;
use
App\Models\InquiryModel
;
use
App\Models\DrugRelatedTagModel
;
use
App\Models\DrugRelatedTagModel
;
use
App\Models\DrugTagRelatedInquiryModel
;
use
App\Models\DrugTagRelatedInquiryModel
;
use
App\Models\InquiryModel
;
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
// 问诊问题控制器
// 问诊问题控制器
...
@@ -15,24 +14,25 @@ class InquiryController extends BaseApiController
...
@@ -15,24 +14,25 @@ class InquiryController extends BaseApiController
public
function
InquirytList
(
Request
$request
)
public
function
InquirytList
(
Request
$request
)
{
{
$inquiry_list
=
[];
$inquiry_list
=
[];
#
获取通用问题
//
获取通用问题
$inquiry_list_1
=
InquiryModel
::
query
()
->
get
()
->
toArray
();
$inquiry_list_1
=
InquiryModel
::
query
()
->
get
()
->
toArray
();
#
通过药品id获取标签
//
通过药品id获取标签
$inquiry_list_2
=
[];
$inquiry_list_2
=
[];
$drug_ids
=
$request
->
input
(
'drug_ids'
);
$drug_ids
=
$request
->
input
(
'drug_ids'
);
if
(
$drug_ids
)
{
if
(
$drug_ids
)
{
$tag_ids
=
DrugRelatedTagModel
::
whereIn
(
'drug_id'
,
explode
(
','
,
$drug_ids
))
->
pluck
(
'tag_id'
)
->
toArray
();
$tag_ids
=
DrugRelatedTagModel
::
whereIn
(
'drug_id'
,
explode
(
','
,
$drug_ids
))
->
pluck
(
'tag_id'
)
->
toArray
();
#
获取标签关联的问题
//
获取标签关联的问题
if
(
$tag_ids
)
{
if
(
$tag_ids
)
{
$inquiry_ids
=
DrugTagRelatedInquiryModel
::
whereIn
(
'tag_id'
,
$tag_ids
)
->
pluck
(
'inquiry_id'
)
->
toArray
();
$inquiry_ids
=
DrugTagRelatedInquiryModel
::
whereIn
(
'tag_id'
,
$tag_ids
)
->
pluck
(
'inquiry_id'
)
->
toArray
();
#
获取非通用问题
//
获取非通用问题
if
(
$inquiry_ids
)
{
if
(
$inquiry_ids
)
{
$inquiry_list_2
=
InquiryModel
::
whereIn
(
'id'
,
array_column
(
$inquiry_ids
,
'inquiry_id'
))
->
get
()
->
toArray
();
$inquiry_list_2
=
InquiryModel
::
whereIn
(
'id'
,
array_column
(
$inquiry_ids
,
'inquiry_id'
))
->
get
()
->
toArray
();
}
}
}
}
}
}
#
合并问题列表
//
合并问题列表
$inquiry_list
=
array_merge
(
$inquiry_list_1
,
$inquiry_list_2
);
$inquiry_list
=
array_merge
(
$inquiry_list_1
,
$inquiry_list_2
);
return
$this
->
success
(
$inquiry_list
);
return
$this
->
success
(
$inquiry_list
);
}
}
}
}
\ No newline at end of file
app/Api/Controllers/PatientController.php
View file @
fe39e064
...
@@ -21,9 +21,9 @@ public function patientList(Request $request)
...
@@ -21,9 +21,9 @@ public function patientList(Request $request)
$login_type
=
$request
->
input
(
'login_type'
);
$login_type
=
$request
->
input
(
'login_type'
);
$id
=
$request
->
input
(
'id'
);
$id
=
$request
->
input
(
'id'
);
$query
=
PatientModel
::
query
();
$query
=
PatientModel
::
query
();
if
(
$login_type
==
0
){
#
用户
if
(
$login_type
==
0
)
{
//
用户
$query
=
$query
->
where
(
'user_id'
,
$id
);
$query
=
$query
->
where
(
'user_id'
,
$id
);
}
else
if
(
$login_type
==
2
){
#
药店
}
elseif
(
$login_type
==
2
)
{
//
药店
$query
=
$query
->
where
(
'pharmacy_id'
,
$id
);
$query
=
$query
->
where
(
'pharmacy_id'
,
$id
);
}
}
$search_input
=
$request
->
input
(
'search_input'
);
$search_input
=
$request
->
input
(
'search_input'
);
...
@@ -46,7 +46,7 @@ public function add(Request $request)
...
@@ -46,7 +46,7 @@ public function add(Request $request)
$idCardInfo
=
Util
::
getIdCardInfo
(
$data
[
'id_card'
]);
$idCardInfo
=
Util
::
getIdCardInfo
(
$data
[
'id_card'
]);
$data
[
'gender'
]
=
$idCardInfo
[
'gender'
];
$data
[
'gender'
]
=
$idCardInfo
[
'gender'
];
$data
[
'age'
]
=
$idCardInfo
[
'age'
];
#
$data['age'] = $idCardInfo['age'];
$res
=
PatientModel
::
create
(
$data
);
$res
=
PatientModel
::
create
(
$data
);
if
(
$res
)
{
if
(
$res
)
{
return
$this
->
success
(
$res
);
return
$this
->
success
(
$res
);
...
@@ -59,15 +59,17 @@ public function add(Request $request)
...
@@ -59,15 +59,17 @@ public function add(Request $request)
public
function
update
(
Request
$request
)
public
function
update
(
Request
$request
)
{
{
$id
=
$request
->
input
(
'id'
);
$id
=
$request
->
input
(
'id'
);
// TODO 验证身份证号码是否正确
$id_card
=
$request
->
input
(
'id_card'
);
// TODO 提取身份信息
// TODO 提取身份信息
$idCardInfo
=
Util
::
getIdCardInfo
(
$id_card
);
$data
=
PatientModel
::
find
(
$id
);
$data
=
PatientModel
::
find
(
$id
);
if
(
!
$data
)
{
if
(
!
$data
)
{
return
$this
->
error
(
401
,
'该问诊人不存在'
);
return
$this
->
error
(
401
,
'该问诊人不存在'
);
}
}
$data
->
name
=
$request
->
input
(
'name'
);
$data
->
name
=
$request
->
input
(
'name'
);
$data
->
id_card
=
$request
->
input
(
'id_card'
);
$data
->
id_card
=
$id_card
;
$data
->
gender
=
$idCardInfo
[
'gender'
];
$data
->
mobile
=
$request
->
input
(
'mobile'
);
$data
->
mobile
=
$request
->
input
(
'mobile'
);
$data
->
save
();
$data
->
save
();
}
}
...
@@ -81,6 +83,7 @@ public function delete(Request $request)
...
@@ -81,6 +83,7 @@ public function delete(Request $request)
return
$this
->
error
(
401
,
'该问诊人不存在'
);
return
$this
->
error
(
401
,
'该问诊人不存在'
);
}
}
$data
->
delete
();
$data
->
delete
();
return
$this
->
success
(
$data
);
return
$this
->
success
(
$data
);
}
}
...
@@ -91,19 +94,19 @@ public function setDefault(Request $request)
...
@@ -91,19 +94,19 @@ public function setDefault(Request $request)
// TODO 验证条件待调整
// TODO 验证条件待调整
$login_type
=
$request
->
input
(
'login_type'
);
$login_type
=
$request
->
input
(
'login_type'
);
$uid
=
$request
->
input
(
'uid'
);
$uid
=
$request
->
input
(
'uid'
);
#
把该账号下的默认问诊人状态改为0
//
把该账号下的默认问诊人状态改为0
$query
=
PatientModel
::
where
(
'id'
,
$uid
)
->
where
(
'is_default'
,
1
);
$query
=
PatientModel
::
where
(
'id'
,
$uid
)
->
where
(
'is_default'
,
1
);
if
(
$login_type
==
0
)
{
if
(
$login_type
==
0
)
{
$query
=
$query
->
where
(
'user_id'
,
$uid
);
$query
=
$query
->
where
(
'user_id'
,
$uid
);
}
else
if
(
$login_type
==
2
)
{
}
elseif
(
$login_type
==
2
)
{
$query
=
$query
->
where
(
'pharmacy_id'
,
$uid
);
$query
=
$query
->
where
(
'pharmacy_id'
,
$uid
);
}
}
$data
=
$query
->
first
();
$data
=
$query
->
first
();
if
(
$data
)
{
if
(
$data
)
{
$data
->
is_default
=
0
;
$data
->
is_default
=
0
;
$data
->
save
();
$data
->
save
();
}
}
#
把当前问诊人设为默认
//
把当前问诊人设为默认
$id
=
$request
->
input
(
'id'
);
$id
=
$request
->
input
(
'id'
);
$data
=
PatientModel
::
find
(
$id
);
$data
=
PatientModel
::
find
(
$id
);
if
(
!
$data
)
{
if
(
!
$data
)
{
...
@@ -111,6 +114,7 @@ public function setDefault(Request $request)
...
@@ -111,6 +114,7 @@ public function setDefault(Request $request)
}
}
$data
->
is_default
=
1
;
$data
->
is_default
=
1
;
$data
->
save
();
$data
->
save
();
return
$this
->
success
(
$data
);
return
$this
->
success
(
$data
);
}
}
...
@@ -120,9 +124,9 @@ public function getDefault(Request $request)
...
@@ -120,9 +124,9 @@ public function getDefault(Request $request)
$login_type
=
$request
->
input
(
'login_type'
);
$login_type
=
$request
->
input
(
'login_type'
);
$id
=
$request
->
input
(
'id'
);
$id
=
$request
->
input
(
'id'
);
$query
=
PatientModel
::
where
(
'is_default'
,
1
);
$query
=
PatientModel
::
where
(
'is_default'
,
1
);
if
(
$login_type
==
0
)
{
if
(
$login_type
==
0
)
{
$query
=
$query
->
where
(
'user_id'
,
$id
);
$query
=
$query
->
where
(
'user_id'
,
$id
);
}
else
if
(
$login_type
==
2
)
{
}
elseif
(
$login_type
==
2
)
{
$query
=
$query
->
where
(
'pharmacy_id'
,
$id
);
$query
=
$query
->
where
(
'pharmacy_id'
,
$id
);
}
}
$data
=
$query
->
first
();
$data
=
$query
->
first
();
...
@@ -132,5 +136,4 @@ public function getDefault(Request $request)
...
@@ -132,5 +136,4 @@ public function getDefault(Request $request)
return
$this
->
error
(
401
,
'暂无默认问诊人'
);
return
$this
->
error
(
401
,
'暂无默认问诊人'
);
}
}
}
}
}
}
app/Api/Controllers/PrescriptionController.php
View file @
fe39e064
...
@@ -2,52 +2,119 @@
...
@@ -2,52 +2,119 @@
namespace
App\Api\Controllers
;
namespace
App\Api\Controllers
;
use
App\Common\Util
;
use
App\Http\Controllers\BaseApiController
;
use
App\Http\Controllers\BaseApiController
;
use
App\Models\
Prescription
Model
;
use
App\Models\
Doctor
Model
;
use
App\Models\PatientModel
;
use
App\Models\PatientModel
;
use
App\Models\PharmacyModel
;
use
App\Models\PharmacistModel
;
use
App\Models\PharmacyDrugModel
;
use
App\Models\PrescriptionModel
;
use
App\Models\PrescriptionLogModel
;
use
App\Models\User
;
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\DB
;
use
Carbon\Carbon
;
// 问诊人控制器
// 问诊人控制器
class
PrescriptionController
extends
BaseApiController
class
PrescriptionController
extends
BaseApiController
{
{
public
function
test
(){
// 分派医师 医师当日开方未达到上限以及是否在时间段的搜索出来
// $site_config = DB::table('admin_settings')->where('slug', 'site_config')->value('value');
// $site_config = json_decode($site_config, true);
// $pharmacy = PharmacyDrugModel::where('pharmacy_id',1)->get();
$doctors
=
DoctorModel
::
query
()
->
where
(
'status'
,
1
)
->
get
();
$randomDoctor
=
$doctors
->
random
();
return
$this
->
success
(
$randomDoctor
);
}
# 处方列表
public
function
prescriptionList
(
Request
$request
)
{
$authInfo
=
auth
(
'api'
)
->
user
();
$userInfo
=
User
::
with
([
'doctor'
,
'pharmacist'
])
->
find
(
$authInfo
->
id
);
$query
=
PrescriptionModel
::
query
();
# TODO 判断当前登录的用户角色
$prescription
=
$query
->
get
();
return
$this
->
success
(
$prescription
);
}
# 处方详情
public
function
prescriptionDetail
(
Request
$request
)
{
$prescription_id
=
$request
->
input
(
'prescription_id'
);
$prescription
=
PrescriptionModel
::
query
()
->
where
(
'id'
,
$prescription_id
)
->
first
();
return
$this
->
success
(
$prescription
);
}
# 开方
# 开方
public
function
create
(
Request
$request
)
public
function
create
(
Request
$request
)
{
{
#
$userId = auth('api')->user()->id;
//
$userId = auth('api')->user()->id;
#
生成处方单号
//
生成处方单号
$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
=
""
;
$data
=
[];
$data
=
[];
$data
[
'prescription_umber'
]
=
""
;
# TODO 处方单编号生成逻辑待定
$data
[
'prescription_umber'
]
=
''
;
// TODO 处方单编号生成逻辑待定
$data
[
'status'
]
=
0
;
# TODO Model中增加枚举
$data
[
'status'
]
=
0
;
// TODO Model中增加枚举
$data
[
'user_id'
]
=
""
;
# TODO 获取当前用户ID
$data
[
'user_id'
]
=
''
;
// TODO 获取当前用户ID
$data
[
'patient_id'
]
=
$patient_id
;
# 问诊人编号
// 问诊人信息
$data
[
'patient_name'
]
=
$patient
->
name
;
# 问诊人姓名
$data
[
'patient_id'
]
=
$patient_id
;
// 问诊人编号
$data
[
'patient_age'
]
=
$patient
->
age
;
# 问诊人年龄
$data
[
'patient_name'
]
=
$patient
->
name
;
// 问诊人姓名
$data
[
'patient_gender'
]
=
$patient
->
gender
;
# 问诊人性别
$data
[
'patient_age'
]
=
$patient
->
age
;
// 问诊人年龄
$data
[
'patient_gender'
]
=
$patient
->
gender
;
// 问诊人性别
// 诊断信息
$data
[
'diagnosis_id'
]
=
$request
->
input
(
'diagnosis_id'
);
$data
[
'diagnosis_name'
]
=
$request
->
input
(
'diagnosis_name'
);
// 问诊问题
$data
[
'inquiry_info'
]
=
''
;
// TODO 问诊问题
// 用药信息
$data
[
'drug_info'
]
=
''
;
// TODO 用药信息
// 分派医师 医师当日开方未达到上限以及是否在时间段的搜索出来
$site_config
=
DB
::
table
(
'admin_settings'
)
->
where
(
'slug'
,
'site_config'
)
->
value
(
'value'
);
$site_config
=
json_decode
(
$site_config
,
true
);
$prescription_limit
=
$site_config
[
'prescription_limit'
];
# 分派医师 医师当日开方未达到上限以及是否在时间段的搜索出来
// 判断是否开启时间段
$doctors
=
DoctorModel
::
query
()
->
where
(
'status'
,
1
)
->
get
();
# 给医师发送短信
$randomDoctor
=
$doctors
->
random
();
// foreach ($doctors as $key => $doctor) {
# 判断是否为医师自动开方
# 生成医师开方日志
// }
// 判断是否为医师自动开方
# 分派药师
$pharmacy_id
=
$request
->
input
(
'pharmacy_id'
);
$pharmacy
=
PharmacyModel
::
query
()
->
where
(
'id'
,
$pharmacy_id
)
->
first
();
# 判断是否药师自动审方
// 生成医师开方日志
$dockor_log
=
[];
$dockor_log
[
'pharmacy_id'
]
=
$pharmacy_id
;
$dockor_log
[
'pharmacy_name'
]
=
$pharmacy
->
name
;
$currentTime
=
Carbon
::
now
()
->
toDateTimeString
();
$dockor_log
[
'log_info'
]
=
$randomDoctor
->
mame
.
"在"
.
$currentTime
.
"为"
.
$patient
->
name
.
"("
.
$patient
->
mobile
.
")开具处方单(处方单编号:"
.
$prescription_umber
.
")"
;
PrescriptionLogModel
::
create
(
$dockor_log
);
# 分派药师,先搜索是否存在默认药师,如果不存在则随机抽取一个
$pharmacist
=
PharmacistModel
::
query
()
->
where
(
'status'
,
1
)
->
where
(
'is_default'
,
1
)
->
where
(
'pharmacy_id'
,
$pharmacy_id
)
->
first
();
if
(
!
$pharmacist
)
{
$pharmacists
=
PharmacistModel
::
query
()
->
where
(
'status'
,
1
)
->
where
(
'pharmacy_id'
,
$pharmacy_id
)
->
get
();
$pharmacist
=
$pharmacists
->
random
();
}
# 判断是否药师自动审方
# 生成药师审方日志
# 生成药师审方日志
$pharamcy_log
=
[];
$pharamcy_log
[
'pharmacy_id'
]
=
$pharmacy_id
;
$pharamcy_log
[
'pharmacy_name'
]
=
$pharmacy
->
name
;
$currentTime
=
Carbon
::
now
()
->
toDateTimeString
();
$pharamcy_log
[
'log_info'
]
=
$pharmacist
->
name
.
"在"
.
$currentTime
.
"为"
.
$patient
->
name
.
"("
.
$patient
->
mobile
.
")审方"
;
# 给医师发送短信
# 给药师发送短信
# 给药师发送短信
# 生成处方单信息
# 生成处方单信息
return
$this
->
success
(
$data
);
}
}
}
}
\ No newline at end of file
app/Models/PharmacyModel.php
View file @
fe39e064
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
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
{
{
...
@@ -12,4 +13,5 @@ class PharmacyModel extends Model
...
@@ -12,4 +13,5 @@ class PharmacyModel extends Model
use
SoftDeletes
;
use
SoftDeletes
;
protected
$table
=
'pharmacy'
;
protected
$table
=
'pharmacy'
;
}
}
database/migrations/2024_11_04_135741_create_patient_table.php
View file @
fe39e064
...
@@ -16,7 +16,6 @@ public function up(): void
...
@@ -16,7 +16,6 @@ public function up(): void
$table
->
bigIncrements
(
'id'
);
$table
->
bigIncrements
(
'id'
);
$table
->
string
(
'name'
,
50
)
->
comment
(
'姓名'
);
$table
->
string
(
'name'
,
50
)
->
comment
(
'姓名'
);
$table
->
tinyInteger
(
'gender'
)
->
default
(
0
)
->
comment
(
'性别。[1=男性,2=女性,0=未知]'
);
$table
->
tinyInteger
(
'gender'
)
->
default
(
0
)
->
comment
(
'性别。[1=男性,2=女性,0=未知]'
);
$table
->
integer
(
'age'
)
->
default
(
0
)
->
comment
(
'年龄'
);
$table
->
string
(
'id_card'
,
18
)
->
index
(
'idx_idcard'
)
->
comment
(
'身份证号'
);
$table
->
string
(
'id_card'
,
18
)
->
index
(
'idx_idcard'
)
->
comment
(
'身份证号'
);
$table
->
string
(
'mobile'
,
11
)
->
index
(
'idx_mobile'
)
->
comment
(
'手机号'
);
$table
->
string
(
'mobile'
,
11
)
->
index
(
'idx_mobile'
)
->
comment
(
'手机号'
);
$table
->
bigInteger
(
'user_id'
)
->
default
(
0
)
->
index
(
'idx_userid'
)
->
comment
(
'用户表ID。用户添加问诊人才有值'
);
$table
->
bigInteger
(
'user_id'
)
->
default
(
0
)
->
index
(
'idx_userid'
)
->
comment
(
'用户表ID。用户添加问诊人才有值'
);
...
...
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