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
b73d1225
authored
Nov 13, 2024
by
lujunyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
关联关系修改
parent
736361db
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
66 additions
and
61 deletions
+66
-61
app/Api/Controllers/DrugController.php
+2
-2
app/Api/Controllers/InquiryController.php
+11
-12
app/Api/Controllers/PatientController.php
+11
-10
app/Api/Controllers/PrescriptionController.php
+22
-30
app/Models/PharmacistModel.php
+3
-3
app/Models/PharmacyModel.php
+12
-0
app/Models/User.php
+3
-3
database/migrations/2024_11_04_223543_create_pharmacy_table.php
+1
-0
database/migrations/2024_11_04_224709_create_pharmacist_table.php
+1
-1
No files found.
app/Api/Controllers/DrugController.php
View file @
b73d1225
...
@@ -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();
...
...
app/Api/Controllers/InquiryController.php
View file @
b73d1225
...
@@ -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 @
b73d1225
...
@@ -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'
);
...
@@ -81,6 +81,7 @@ public function delete(Request $request)
...
@@ -81,6 +81,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 +92,19 @@ public function setDefault(Request $request)
...
@@ -91,19 +92,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 +112,7 @@ public function setDefault(Request $request)
...
@@ -111,6 +112,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 +122,9 @@ public function getDefault(Request $request)
...
@@ -120,9 +122,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 +134,4 @@ public function getDefault(Request $request)
...
@@ -132,5 +134,4 @@ public function getDefault(Request $request)
return
$this
->
error
(
401
,
'暂无默认问诊人'
);
return
$this
->
error
(
401
,
'暂无默认问诊人'
);
}
}
}
}
}
}
app/Api/Controllers/PrescriptionController.php
View file @
b73d1225
...
@@ -2,52 +2,45 @@
...
@@ -2,52 +2,45 @@
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\PrescriptionModel
;
use
App\Models\PatientModel
;
use
App\Models\PatientModel
;
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
// 问诊人控制器
// 问诊人控制器
class
PrescriptionController
extends
BaseApiController
class
PrescriptionController
extends
BaseApiController
{
{
// 开方
# 开方
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
();
$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_id'
]
=
$patient_id
;
// 问诊人编号
$data
[
'patient_name'
]
=
$patient
->
name
;
# 问诊人姓名
$data
[
'patient_name'
]
=
$patient
->
name
;
// 问诊人姓名
$data
[
'patient_age'
]
=
$patient
->
age
;
# 问诊人年龄
$data
[
'patient_age'
]
=
$patient
->
age
;
// 问诊人年龄
$data
[
'patient_gender'
]
=
$patient
->
gender
;
# 问诊人性别
$data
[
'patient_gender'
]
=
$patient
->
gender
;
// 问诊人性别
# 分派医师 医师当日开方未达到上限以及是否在时间段的搜索出来
# 给医师发送短信
// 分派医师 医师当日开方未达到上限以及是否在时间段的搜索出来
# 判断是否为医师自动开方
// 给医师发送短信
# 生成医师开方日志
# 分派药师
// 判断是否为医师自动开方
// 生成医师开方日志
# 判断是否药师自动审方
// 分派药师
# 生成药师审方日志
# 给药师发送短信
// 判断是否药师自动审方
// 生成药师审方日志
# 生成处方单信息
// 给药师发送短信
// 生成处方单信息
}
}
}
}
\ No newline at end of file
app/Models/PharmacistModel.php
View file @
b73d1225
...
@@ -13,9 +13,9 @@ class PharmacistModel extends Model
...
@@ -13,9 +13,9 @@ class PharmacistModel extends Model
protected
$table
=
'pharmacist'
;
protected
$table
=
'pharmacist'
;
// 药师
所属于的用户,一
对一
// 药师
关联的药店,多
对一
public
function
user
()
public
function
pharmacy
()
{
{
return
$this
->
belongsTo
(
User
::
class
,
'user
_id'
,
'id'
);
return
$this
->
belongsTo
(
PharmacyModel
::
class
,
'pharmacy
_id'
,
'id'
);
}
}
}
}
app/Models/PharmacyModel.php
View file @
b73d1225
...
@@ -12,4 +12,16 @@ class PharmacyModel extends Model
...
@@ -12,4 +12,16 @@ class PharmacyModel extends Model
use
SoftDeletes
;
use
SoftDeletes
;
protected
$table
=
'pharmacy'
;
protected
$table
=
'pharmacy'
;
// 药店所属于的用户,一对一
public
function
user
()
{
return
$this
->
belongsTo
(
User
::
class
,
'user_id'
,
'id'
);
}
// 药店关联的药师,一对多
public
function
pharmacy
()
{
return
$this
->
hasMany
(
User
::
class
,
'pharmacy_id'
,
'id'
);
}
}
}
app/Models/User.php
View file @
b73d1225
...
@@ -68,10 +68,10 @@ public function doctor()
...
@@ -68,10 +68,10 @@ public function doctor()
return
$this
->
hasOne
(
DoctorModel
::
class
,
'user_id'
,
'id'
);
return
$this
->
hasOne
(
DoctorModel
::
class
,
'user_id'
,
'id'
);
}
}
// 用户关联的药
师
,一对一
// 用户关联的药
店
,一对一
public
function
pharmac
ist
()
public
function
pharmac
y
()
{
{
return
$this
->
hasOne
(
Pharmac
ist
Model
::
class
,
'user_id'
,
'id'
);
return
$this
->
hasOne
(
Pharmac
y
Model
::
class
,
'user_id'
,
'id'
);
}
}
// 用户关联的问诊人,一对多
// 用户关联的问诊人,一对多
...
...
database/migrations/2024_11_04_223543_create_pharmacy_table.php
View file @
b73d1225
...
@@ -30,6 +30,7 @@ public function up()
...
@@ -30,6 +30,7 @@ public function up()
$table
->
string
(
'lng'
,
12
)
->
comment
(
'经度'
);
$table
->
string
(
'lng'
,
12
)
->
comment
(
'经度'
);
$table
->
string
(
'lat'
,
12
)
->
comment
(
'纬度'
);
$table
->
string
(
'lat'
,
12
)
->
comment
(
'纬度'
);
$table
->
boolean
(
'status'
)
->
default
(
0
)
->
comment
(
'启用[0=未启用,1=启用]'
);
$table
->
boolean
(
'status'
)
->
default
(
0
)
->
comment
(
'启用[0=未启用,1=启用]'
);
$table
->
bigInteger
(
'user_id'
)
->
nullable
()
->
unique
(
'uk_userid'
)
->
comment
(
'用户表ID'
);
$table
->
timestamps
();
$table
->
timestamps
();
$table
->
softDeletes
();
$table
->
softDeletes
();
});
});
...
...
database/migrations/2024_11_04_224709_create_pharmacist_table.php
View file @
b73d1225
...
@@ -25,7 +25,7 @@ public function up()
...
@@ -25,7 +25,7 @@ public function up()
$table
->
string
(
'physician_license'
)
->
comment
(
'执业资格证书'
);
$table
->
string
(
'physician_license'
)
->
comment
(
'执业资格证书'
);
$table
->
string
(
'signed_pic'
)
->
comment
(
'签名照'
);
$table
->
string
(
'signed_pic'
)
->
comment
(
'签名照'
);
$table
->
boolean
(
'status'
)
->
default
(
0
)
->
comment
(
'启用[0=未启用,1=启用]'
);
$table
->
boolean
(
'status'
)
->
default
(
0
)
->
comment
(
'启用[0=未启用,1=启用]'
);
$table
->
bigInteger
(
'
user_id'
)
->
nullable
()
->
unique
(
'uk_userid'
)
->
comment
(
'用户表
ID'
);
$table
->
bigInteger
(
'
pharmacy_id'
)
->
index
(
'idx_pharmacyid'
)
->
comment
(
'药店
ID'
);
$table
->
timestamps
();
$table
->
timestamps
();
$table
->
softDeletes
();
$table
->
softDeletes
();
});
});
...
...
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