修改问诊表重复请求问题
This commit is contained in:
parent
811acd7880
commit
74a72c1cf6
@ -218,6 +218,10 @@ class PatientCaseService extends BaseService
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
$order_inquiry_id = $this->request->input('order_inquiry_id');
|
||||
|
||||
if ($user_info['user_type'] != 2){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"非法请求");
|
||||
}
|
||||
|
||||
// 获取订单数据
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_inquiry_id;
|
||||
@ -235,6 +239,8 @@ class PatientCaseService extends BaseService
|
||||
return fail();
|
||||
}
|
||||
|
||||
$order_inquiry_case = $order_inquiry_case->toArray();
|
||||
|
||||
// 获取患者家庭成员信息表-基本信息
|
||||
$params = array();
|
||||
$params['family_id'] = $order_inquiry_case['family_id'];
|
||||
@ -274,6 +280,20 @@ class PatientCaseService extends BaseService
|
||||
|
||||
try {
|
||||
// 获取缓存
|
||||
/**
|
||||
* 获取缓存
|
||||
* 缓存格式
|
||||
* {
|
||||
"height":{
|
||||
"value":1,
|
||||
"is_filled":1
|
||||
},
|
||||
"weight":{
|
||||
"value":1,
|
||||
"is_filled":1
|
||||
}
|
||||
* }
|
||||
*/
|
||||
$redis = $this->container->get(Redis::class);
|
||||
$redis_key = "patient_family_inquiry_case_unfilled_fields_" . $order_inquiry_id;
|
||||
$redis_value = $redis->get($redis_key);
|
||||
@ -284,31 +304,41 @@ class PatientCaseService extends BaseService
|
||||
// 处理字段
|
||||
$result = null;
|
||||
foreach ($fields as $field){
|
||||
if ($order_inquiry_case[$field] !== null){
|
||||
continue;
|
||||
if (array_key_exists($field,$order_inquiry_case)){
|
||||
if ($order_inquiry_case[$field] !== null){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!empty($patient_family)){
|
||||
if ($patient_family[$field] !== null){
|
||||
continue;
|
||||
if (array_key_exists($field,$patient_family->toArray())){
|
||||
if ($patient_family[$field] !== null){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($patient_family_health)){
|
||||
if ($patient_family_health[$field] !== null){
|
||||
continue;
|
||||
if (array_key_exists($field,$patient_family_health->toArray())){
|
||||
if ($patient_family_health[$field] !== null){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($patient_family_personal)){
|
||||
if ($patient_family_personal[$field] !== null){
|
||||
continue;
|
||||
if (array_key_exists($field,$patient_family_personal->toArray())){
|
||||
if ($patient_family_personal[$field] !== null){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 缓存
|
||||
if (!empty($redis_value)){
|
||||
if (strstr($redis_value,$field)){
|
||||
$redis_value = json_decode($redis_value,true);
|
||||
if (array_key_exists($field,$redis_value)){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -393,25 +423,29 @@ class PatientCaseService extends BaseService
|
||||
// 获取缓存
|
||||
$redis_value = $redis->get($redis_key);
|
||||
if (!empty($redis_value)){
|
||||
$redis_value = explode(',',$redis_value);
|
||||
$redis_value = json_decode($redis_value,true);
|
||||
}
|
||||
|
||||
// 患者病例字段
|
||||
$case_fields = [];
|
||||
foreach ($request_params['fields'] as $value){
|
||||
if (!in_array($value,$fields)){
|
||||
foreach ($request_params['fields'] as $key){
|
||||
if (!in_array($key,$fields)){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"数据选择错误");
|
||||
}
|
||||
|
||||
$case_fields[] = $value;
|
||||
$case_fields[] = $key;
|
||||
|
||||
// 处理缓存
|
||||
if (!empty($redis_value)){
|
||||
if (in_array($value,$redis_value)){
|
||||
if (array_key_exists($key,$redis_value)){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$redis_value[] = $value;
|
||||
|
||||
$redis_value[$key] = [
|
||||
"value" => "",
|
||||
"is_filled" => 0
|
||||
];
|
||||
}
|
||||
|
||||
if (empty($case_fields)){
|
||||
@ -426,8 +460,8 @@ class PatientCaseService extends BaseService
|
||||
|
||||
// 添加缓存-逗号分割字符串
|
||||
if (!empty($redis_value)){
|
||||
$redis_value = implode(',',$redis_value);
|
||||
$res = $redis->set($redis_key,$redis_value,3 * 24 * 60 * 60);
|
||||
$redis_value = json_encode($redis_value,JSON_UNESCAPED_UNICODE);
|
||||
$res = $redis->set($redis_key,$redis_value,31 * 24 * 60 * 60);
|
||||
if (!$res){
|
||||
return fail();
|
||||
}
|
||||
@ -523,7 +557,7 @@ class PatientCaseService extends BaseService
|
||||
$redis_key = "patient_family_inquiry_case_unfilled_fields_" . $order_inquiry_id;
|
||||
$redis_value = $redis->get($redis_key);
|
||||
if (!empty($redis_value)){
|
||||
$redis_value = explode(',',$redis_value);
|
||||
$redis_value = json_decode($redis_value,true);
|
||||
}
|
||||
|
||||
// 患者病例字段
|
||||
@ -540,10 +574,27 @@ class PatientCaseService extends BaseService
|
||||
}
|
||||
}
|
||||
|
||||
// 跳过关联字段传空,如是否是否过敏史、过敏史描述
|
||||
if ($value === ""){
|
||||
continue;
|
||||
}
|
||||
|
||||
// 判断是否存在于缓存中
|
||||
if (!empty($redis_value)){
|
||||
if (!array_key_exists($key,$redis_value)){
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"存在非法数据");
|
||||
}else{
|
||||
if ($redis_value[$key]['is_filled'] == 1){
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"请勿重复提交");
|
||||
}
|
||||
|
||||
$redis_value[$key]['value'] = $value;
|
||||
$redis_value[$key]['is_filled'] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// 判断修改数据
|
||||
if (array_key_exists($key,$order_inquiry_case)){
|
||||
if ($order_inquiry_case[$key] == null){
|
||||
@ -573,17 +624,11 @@ class PatientCaseService extends BaseService
|
||||
|
||||
// 处理缓存
|
||||
if (!empty($redis_value)){
|
||||
$diff_values = array_diff($redis_value, array_keys($request_params['fields']));
|
||||
if (!empty($diff_values)){
|
||||
// 添加缓存-逗号分割字符串
|
||||
$redis_value = implode(',',$diff_values);
|
||||
$res = $redis->set($redis_key,$redis_value,3 * 24 * 60 * 60);
|
||||
if (!$res){
|
||||
return fail();
|
||||
}
|
||||
$redis_value = json_encode($redis_value,JSON_UNESCAPED_UNICODE);
|
||||
$res = $redis->set($redis_key,$redis_value,31 * 24 * 60 * 60);
|
||||
if (!$res){
|
||||
return fail();
|
||||
}
|
||||
}else{
|
||||
$redis->del($redis_key);
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
|
||||
@ -22,7 +22,6 @@ use App\Controller\LoginController;
|
||||
use App\Controller\CodeController;
|
||||
use App\Controller\MessageNoticeController;
|
||||
use App\Controller\PatientCaseController;
|
||||
use App\Controller\PatientCenterController;
|
||||
use App\Controller\PatientDoctorController;
|
||||
use App\Controller\PatientFamilyController;
|
||||
use App\Controller\PatientOrderController;
|
||||
@ -35,7 +34,6 @@ use App\Controller\UserDoctorController;
|
||||
use App\Controller\UserPatientController;
|
||||
use App\Controller\UserPharmacistController;
|
||||
use App\Middleware\Rule\LockRequestMiddleware;
|
||||
use App\Services\SafeService;
|
||||
use Hyperf\HttpServer\Router\Router;
|
||||
|
||||
|
||||
@ -83,9 +81,6 @@ Router::addGroup('/doctor', function () {
|
||||
// 修改医生问诊配置
|
||||
Router::put('/config', [UserDoctorController::class, 'putInquiryConfig']);
|
||||
|
||||
// // 获取患者问诊病例
|
||||
// Router::get('/case', [InquiryController::class, 'getPatientInquiryCase']);
|
||||
|
||||
// 获取医生问诊消息列表
|
||||
Router::get('/message', [UserDoctorController::class, 'getDoctorMessageList']);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user