Commit 37c2b5ce by 赵增煜

扫码新增问诊人接口

parent f766061f
...@@ -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)
......
...@@ -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');
# 处方录入 # 处方录入
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment