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
37c2b5ce
authored
Dec 05, 2024
by
赵增煜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
扫码新增问诊人接口
parent
f766061f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
0 deletions
+49
-0
app/Api/Controllers/PatientController.php
+47
-0
routes/api.php
+2
-0
No files found.
app/Api/Controllers/PatientController.php
View file @
37c2b5ce
...
@@ -213,6 +213,53 @@ public function getDefault(Request $request)
...
@@ -213,6 +213,53 @@ public function getDefault(Request $request)
return
$this
->
failed
(
'暂无默认问诊人'
);
return
$this
->
failed
(
'暂无默认问诊人'
);
}
}
}
}
public
function
duplicate
(
Request
$request
)
{
$data
=
$request
->
all
();
$authInfo
=
auth
(
'api'
)
->
user
();
// 确保传递了 ID 参数
if
(
!
isset
(
$data
[
'id'
])
||
empty
(
$data
[
'id'
]))
{
return
$this
->
failed
(
'ID 参数缺失'
);
}
// 根据传递的 ID 查找对应患者数据
$existingPatient
=
PatientModel
::
find
(
$data
[
'id'
]);
if
(
!
$existingPatient
)
{
return
$this
->
failed
(
'未找到对应的患者记录'
);
}
// 创建新患者数据
$newPatient
=
new
PatientModel
();
// 根据登录类型设置用户或药店 ID
if
(
$authInfo
->
last_login_type
==
User
::
LOGIN_TYPE_USER
)
{
// 用户
$newPatient
->
user_id
=
$authInfo
->
id
;
}
elseif
(
$authInfo
->
last_login_type
==
User
::
LOGIN_TYPE_PHARMACY
)
{
// 药店
$pharmacy
=
PharmacyModel
::
query
()
->
where
(
'user_id'
,
$authInfo
->
id
)
->
first
();
if
(
$pharmacy
)
{
$newPatient
->
pharmacy_id
=
$pharmacy
->
id
;
}
else
{
return
$this
->
failed
(
'未找到对应的药店信息'
);
}
}
// 复制数据到新记录(可根据实际需求过滤字段)
$newPatient
->
name
=
$existingPatient
->
name
;
$newPatient
->
id_card
=
$existingPatient
->
id_card
;
$newPatient
->
mobile
=
$existingPatient
->
mobile
;
$newPatient
->
gender
=
$existingPatient
->
gender
;
$newPatient
->
age
=
$existingPatient
->
age
;
$newPatient
->
is_default
=
0
;
// 新记录默认值
// 保存新数据
$res
=
$newPatient
->
save
();
if
(
$res
)
{
return
$this
->
success
(
$newPatient
);
}
else
{
return
$this
->
failed
(
'数据复制失败'
);
}
}
// 获取二维码
// 获取二维码
public
function
getQrCode
(
Request
$request
)
public
function
getQrCode
(
Request
$request
)
...
...
routes/api.php
View file @
37c2b5ce
...
@@ -59,6 +59,8 @@
...
@@ -59,6 +59,8 @@
Route
::
post
(
'/pharmacy-logout'
,
'App\Api\Controllers\PharmacyController@logout'
);
Route
::
post
(
'/pharmacy-logout'
,
'App\Api\Controllers\PharmacyController@logout'
);
# 获取药店用法用量
# 获取药店用法用量
Route
::
post
(
'/pharmacy-dosages'
,
'App\Api\Controllers\DosageController@dosageList'
);
Route
::
post
(
'/pharmacy-dosages'
,
'App\Api\Controllers\DosageController@dosageList'
);
# 扫码新增问诊人接口
Route
::
post
(
'/pharmacy-patients-scan'
,
'App\Api\Controllers\PatientController@duplicate'
);
# 获取单位列表
# 获取单位列表
Route
::
post
(
'/units'
,
'App\Api\Controllers\UnitController@unitList'
);
Route
::
post
(
'/units'
,
'App\Api\Controllers\UnitController@unitList'
);
# 处方录入
# 处方录入
...
...
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