新增:获取问诊订单病例缺少字段、医生发送缺少字段至患者、患者填写缺少字段至医生
This commit is contained in:
parent
a69ba2ca2c
commit
6cbbcd586e
@ -61,4 +61,36 @@ class PatientCaseController extends AbstractController
|
||||
$data = $PatientCaseService->getPatientFamilyInquiryCaseUnfilledFields();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 医生发送缺少字段至患者
|
||||
* @return ResponseInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function sendCaseUnfilledFieldsToPatient(): ResponseInterface
|
||||
{
|
||||
$request = $this->container->get(PatientCaseRequest::class);
|
||||
$request->scene('sendCaseUnfilledFieldsToPatient')->validateResolved();
|
||||
|
||||
$PatientCaseService = new PatientCaseService();
|
||||
$data = $PatientCaseService->sendCaseUnfilledFieldsToPatient();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 患者填写缺少字段至医生
|
||||
* @return ResponseInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function sendCaseUnfilledFieldsToDoctor(): ResponseInterface
|
||||
{
|
||||
$request = $this->container->get(PatientCaseRequest::class);
|
||||
$request->scene('sendCaseUnfilledFieldsToDoctor')->validateResolved();
|
||||
|
||||
$PatientCaseService = new PatientCaseService();
|
||||
$data = $PatientCaseService->sendCaseUnfilledFieldsToDoctor();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
}
|
||||
@ -20,6 +20,12 @@ class PatientCaseRequest extends FormRequest
|
||||
'getPatientFamilyInquiryCaseUnfilledFields' => [ // 获取问诊订单病例缺少字段
|
||||
'order_inquiry_id',
|
||||
],
|
||||
'sendCaseUnfilledFieldsToPatient' => [ // 医生发送缺少字段至患者
|
||||
'order_inquiry_id',
|
||||
],
|
||||
'sendCaseUnfilledFieldsToDoctor' => [ // 患者填写缺少字段至医生
|
||||
'order_inquiry_id',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@ -775,4 +775,87 @@ class ImService extends BaseService
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 问诊表-发送患者
|
||||
* @param array|object $order_inquiry 问诊表数据
|
||||
* @param string|int $doctor_user_id 医生用户id
|
||||
* @param string|int $patient_user_id 患者用户id
|
||||
* @param string $case_fields 医生选择需填写的病例字段
|
||||
* @return void
|
||||
*/
|
||||
public function CaseUnfilledFieldsToPatient(array|object $order_inquiry,string|int $doctor_user_id,string|int $patient_user_id,string $case_fields): void
|
||||
{
|
||||
try {
|
||||
// 发送消息
|
||||
$cloud_custom_data = array();
|
||||
$cloud_custom_data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
$cloud_custom_data['is_system'] = 1;
|
||||
$cloud_custom_data['inquiry_type'] = $order_inquiry['inquiry_type'];
|
||||
$cloud_custom_data['message_rounds'] = 0;
|
||||
$cloud_custom_data['patient_family_data']['patient_name'] = $order_inquiry['patient_name'];
|
||||
$cloud_custom_data['patient_family_data']['patient_sex'] = $order_inquiry['patient_sex'];
|
||||
$cloud_custom_data['patient_family_data']['patient_age'] = $order_inquiry['patient_age'];
|
||||
|
||||
// 消息内容
|
||||
$message_content_data = array();
|
||||
$message_content_data['message_type'] = 12;
|
||||
$message_content_data['title'] = "问诊表";
|
||||
$message_content_data['desc'] = "";
|
||||
$message_content_data['data']['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
$message_content_data['data']['order_no'] = $order_inquiry['inquiry_no'];
|
||||
$message_content_data['data']['message_path'] = "/pages/sickForm/sickForm"; // 跳转地址(小程序内页)
|
||||
$message_content_data['data']['case_not_fill_fields'] = $case_fields; // 病例字段,json格式,医生端发送患者端使用(此字段仅针对message_type为12的情况)
|
||||
$message_content = [
|
||||
'Data' => json_encode($message_content_data, JSON_UNESCAPED_UNICODE),
|
||||
];
|
||||
|
||||
$this->sendMessage($doctor_user_id, $patient_user_id, $message_content, "TIMCustomElem", $cloud_custom_data);
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 问诊表-发送医生
|
||||
* @param array|object $order_inquiry 问诊表数据
|
||||
* @param string|int $doctor_user_id 医生用户id
|
||||
* @param string|int $patient_user_id 患者用户id
|
||||
* @param string $case_fields 患者填写的病例字段
|
||||
* @return void
|
||||
*/
|
||||
public function CaseUnfilledFieldsToDoctor(array|object $order_inquiry,string|int $doctor_user_id,string|int $patient_user_id,string $case_fields): void
|
||||
{
|
||||
try {
|
||||
// 发送消息
|
||||
$cloud_custom_data = array();
|
||||
$cloud_custom_data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
$cloud_custom_data['is_system'] = 1;
|
||||
$cloud_custom_data['inquiry_type'] = $order_inquiry['inquiry_type'];
|
||||
$cloud_custom_data['message_rounds'] = 0;
|
||||
$cloud_custom_data['patient_family_data']['patient_name'] = $order_inquiry['patient_name'];
|
||||
$cloud_custom_data['patient_family_data']['patient_sex'] = $order_inquiry['patient_sex'];
|
||||
$cloud_custom_data['patient_family_data']['patient_age'] = $order_inquiry['patient_age'];
|
||||
|
||||
// 消息内容
|
||||
$message_content_data = array();
|
||||
$message_content_data['message_type'] = 12;
|
||||
$message_content_data['title'] = "问诊表-已填写";
|
||||
$message_content_data['desc'] = "";
|
||||
$message_content_data['data']['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
$message_content_data['data']['order_no'] = $order_inquiry['inquiry_no'];
|
||||
$message_content_data['data']['message_path'] = "/Pages/yishi/sick_detail/index"; // 跳转地址(小程序内页)
|
||||
$message_content_data['data']['case_patient_message_path'] = "/pages/sickDetail/sickDetail"; // 跳转地址(小程序内页)
|
||||
$message_content_data['data']['case_filled_fields'] = $case_fields; // 病例字段,json格式,患者端发送医生端使用(此字段仅针对message_type为12的情况)
|
||||
$message_content = [
|
||||
'Data' => json_encode($message_content_data, JSON_UNESCAPED_UNICODE),
|
||||
];
|
||||
|
||||
$this->sendMessage($patient_user_id, $doctor_user_id, $message_content, "TIMCustomElem", $cloud_custom_data);
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Model\DetectionProject;
|
||||
use App\Model\InquiryCaseProduct;
|
||||
use App\Model\OrderDetection;
|
||||
@ -14,6 +15,7 @@ use App\Model\PatientFamily;
|
||||
use App\Model\PatientFamilyHealth;
|
||||
use App\Model\PatientFamilyPersonal;
|
||||
use App\Model\User;
|
||||
use App\Model\UserDoctor;
|
||||
use Hyperf\Redis\Redis;
|
||||
|
||||
/**
|
||||
@ -279,10 +281,14 @@ class PatientCaseService extends BaseService
|
||||
"chemical_compound_describe", // 化合物描述
|
||||
];
|
||||
|
||||
try {
|
||||
// 获取缓存
|
||||
$redis = $this->container->get(Redis::class);
|
||||
$redis_key = "patient_family_inquiry_case_unfilled_fields_" . $order_inquiry_id;
|
||||
$redis_value = $redis->get($redis_key);
|
||||
}catch (\Throwable $e){
|
||||
return fail();
|
||||
}
|
||||
|
||||
// 处理字段
|
||||
$result = null;
|
||||
@ -321,4 +327,236 @@ class PatientCaseService extends BaseService
|
||||
|
||||
return success($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 医生发送缺少字段至患者
|
||||
* @return array
|
||||
*/
|
||||
public function sendCaseUnfilledFieldsToPatient(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
if ($user_info['user_type'] != 2){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"非法请求");
|
||||
}
|
||||
|
||||
$request_params = $this->request->all();
|
||||
|
||||
$order_inquiry_id = $request_params['order_inquiry_id'];
|
||||
|
||||
if (empty($request_params['fields'])){
|
||||
return fail(HttpEnumCode::CLIENT_HTTP_ERROR,"请选择需要发送的信息");
|
||||
}
|
||||
|
||||
// 获取订单数据
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_inquiry_id;
|
||||
$order_inquiry = OrderInquiry::getOne($params);
|
||||
if (empty($order_inquiry)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"订单数据错误");
|
||||
}
|
||||
|
||||
// 获取医生数据
|
||||
$params = array();
|
||||
$params['doctor_id'] = $order_inquiry['doctor_id'];
|
||||
$doctor = UserDoctor::getOne($params);
|
||||
if (empty($doctor)){
|
||||
return fail();
|
||||
}
|
||||
|
||||
// 初始字段定义
|
||||
$fields = [
|
||||
"relation", // 与患者关系(1:本人 2:父母 3:爱人 4:子女 5:亲戚 6:其他 )
|
||||
"name", // 患者名称
|
||||
"sex", // 患者性别(0:未知 1:男 2:女)
|
||||
"age", // 患者年龄
|
||||
"height", // 身高(cm)
|
||||
"weight", // 体重(kg)
|
||||
"marital_status", // 婚姻状况(0:未婚 1:已婚 2:离异)
|
||||
"disease_class_name", // 疾病名称-系统
|
||||
"diagnosis_date", // 确诊日期
|
||||
"disease_desc", // 病情描述(主诉)
|
||||
"is_allergy_history", // 是否存在过敏史(0:否 1:是)
|
||||
"allergy_history", // 过敏史描述
|
||||
"is_family_history", // 是否存在家族病史(0:否 1:是)
|
||||
"family_history", // 家族病史描述
|
||||
"is_pregnant", // 是否备孕、妊娠、哺乳期(0:否 1:是)
|
||||
"pregnant", // 备孕、妊娠、哺乳期描述
|
||||
"is_taboo", // 是否服用过禁忌药物,且无相关禁忌(0:否 1:是)问诊购药时存在
|
||||
"is_take_medicine", // 正在服药(0:否 1:是)
|
||||
"drugs_name", // 正在服药名称
|
||||
"nation_name", // 民族名称
|
||||
"job_name", // 职业名称
|
||||
"diagnosis_hospital", // 确诊医院
|
||||
"is_operation", // 是否存在手术(0:否 1:是)
|
||||
"operation", // 手术描述
|
||||
"drink_wine_status", // 饮酒状态(1:从不 2:偶尔 3:经常 4:每天 5:已戒酒)
|
||||
"smoke_status", // 吸烟状态(1:从不 2:偶尔 3:经常 4:每天 5:已戒烟)
|
||||
"chemical_compound_status", // 化合物状态(1:从不 2:偶尔 3:经常 4:每天)
|
||||
"chemical_compound_describe", // 化合物描述
|
||||
];
|
||||
|
||||
try {
|
||||
$redis = $this->container->get(Redis::class);
|
||||
$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);
|
||||
}
|
||||
|
||||
// 患者病例字段
|
||||
$case_fields = [];
|
||||
foreach ($request_params['fields'] as $value){
|
||||
if (!in_array($value,$fields)){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"数据选择错误");
|
||||
}
|
||||
|
||||
$case_fields[] = $value;
|
||||
|
||||
// 处理缓存
|
||||
if (!empty($redis_value)){
|
||||
if (in_array($value,$redis_value)){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$redis_value[] = $value;
|
||||
}
|
||||
|
||||
if (empty($case_fields)){
|
||||
return fail();
|
||||
}
|
||||
|
||||
$case_fields = json_encode($case_fields,JSON_UNESCAPED_UNICODE);
|
||||
|
||||
// 发送im消息
|
||||
$imService = new ImService();
|
||||
$imService->CaseUnfilledFieldsToPatient($order_inquiry,$doctor['user_id'],$order_inquiry['user_id'],$case_fields);
|
||||
|
||||
// 添加缓存-逗号分割字符串
|
||||
if (!empty($redis_value)){
|
||||
$redis_value = implode(',',$redis_value);
|
||||
$res = $redis->set($redis_key,$redis_value,3 * 24 * 60 * 60);
|
||||
if (!$res){
|
||||
return fail();
|
||||
}
|
||||
}
|
||||
}catch (\Throwable $e){
|
||||
return fail();
|
||||
}
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 患者填写缺少字段至医生
|
||||
* @return array
|
||||
*/
|
||||
public function sendCaseUnfilledFieldsToDoctor(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
if ($user_info['user_type'] != 1){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"非法请求");
|
||||
}
|
||||
|
||||
$request_params = $this->request->all();
|
||||
|
||||
$order_inquiry_id = $request_params['order_inquiry_id'];
|
||||
|
||||
if (empty($request_params['fields'])){
|
||||
return fail(HttpEnumCode::CLIENT_HTTP_ERROR,"请填写后发送");
|
||||
}
|
||||
|
||||
// 获取订单数据
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_inquiry_id;
|
||||
$order_inquiry = OrderInquiry::getOne($params);
|
||||
if (empty($order_inquiry)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"订单数据错误");
|
||||
}
|
||||
|
||||
// 获取医生数据
|
||||
$params = array();
|
||||
$params['doctor_id'] = $order_inquiry['doctor_id'];
|
||||
$doctor = UserDoctor::getOne($params);
|
||||
if (empty($doctor)){
|
||||
return fail();
|
||||
}
|
||||
|
||||
// 初始字段定义
|
||||
$fields = [
|
||||
"relation", // 与患者关系(1:本人 2:父母 3:爱人 4:子女 5:亲戚 6:其他 )
|
||||
"name", // 患者名称
|
||||
"sex", // 患者性别(0:未知 1:男 2:女)
|
||||
"age", // 患者年龄
|
||||
"height", // 身高(cm)
|
||||
"weight", // 体重(kg)
|
||||
"marital_status", // 婚姻状况(0:未婚 1:已婚 2:离异)
|
||||
"disease_class_name", // 疾病名称-系统
|
||||
"diagnosis_date", // 确诊日期
|
||||
"disease_desc", // 病情描述(主诉)
|
||||
"is_allergy_history", // 是否存在过敏史(0:否 1:是)
|
||||
"allergy_history", // 过敏史描述
|
||||
"is_family_history", // 是否存在家族病史(0:否 1:是)
|
||||
"family_history", // 家族病史描述
|
||||
"is_pregnant", // 是否备孕、妊娠、哺乳期(0:否 1:是)
|
||||
"pregnant", // 备孕、妊娠、哺乳期描述
|
||||
"is_taboo", // 是否服用过禁忌药物,且无相关禁忌(0:否 1:是)问诊购药时存在
|
||||
"is_take_medicine", // 正在服药(0:否 1:是)
|
||||
"drugs_name", // 正在服药名称
|
||||
"nation_name", // 民族名称
|
||||
"job_name", // 职业名称
|
||||
"diagnosis_hospital", // 确诊医院
|
||||
"is_operation", // 是否存在手术(0:否 1:是)
|
||||
"operation", // 手术描述
|
||||
"drink_wine_status", // 饮酒状态(1:从不 2:偶尔 3:经常 4:每天 5:已戒酒)
|
||||
"smoke_status", // 吸烟状态(1:从不 2:偶尔 3:经常 4:每天 5:已戒烟)
|
||||
"chemical_compound_status", // 化合物状态(1:从不 2:偶尔 3:经常 4:每天)
|
||||
"chemical_compound_describe", // 化合物描述
|
||||
];
|
||||
|
||||
try {
|
||||
$redis = $this->container->get(Redis::class);
|
||||
$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);
|
||||
}
|
||||
|
||||
// 患者病例字段
|
||||
$case_fields = [];
|
||||
foreach ($request_params['fields'] as $key => $value){
|
||||
if (!in_array($key,$fields)){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"存在非法数据");
|
||||
}
|
||||
|
||||
$case_fields[$key] = $value;
|
||||
}
|
||||
|
||||
$case_fields = json_encode($case_fields,JSON_UNESCAPED_UNICODE);
|
||||
|
||||
// 发送im消息
|
||||
$imService = new ImService();
|
||||
$imService->CaseUnfilledFieldsToDoctor($order_inquiry,$doctor['user_id'],$user_info['user_id'],$case_fields);
|
||||
|
||||
// 处理缓存
|
||||
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();
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$redis->del($redis_key);
|
||||
}
|
||||
}catch (\Throwable $e){
|
||||
return fail();
|
||||
}
|
||||
|
||||
return success();
|
||||
}
|
||||
}
|
||||
@ -734,8 +734,17 @@ Router::addGroup('/case', function () {
|
||||
// 获取问诊订单病例详情
|
||||
Router::get('/inquiry', [PatientCaseController::class, 'getPatientFamilyInquiryCase']);
|
||||
|
||||
// 病例未填字段
|
||||
Router::addGroup('/fields', function () {
|
||||
// 获取问诊订单病例缺少字段
|
||||
Router::get('/fields', [PatientCaseController::class, 'getPatientFamilyInquiryCaseUnfilledFields']);
|
||||
Router::get('/unfilled', [PatientCaseController::class, 'getPatientFamilyInquiryCaseUnfilledFields']);
|
||||
|
||||
// 医生发送缺少字段至患者
|
||||
Router::post('/doctor', [PatientCaseController::class, 'sendCaseUnfilledFieldsToPatient']);
|
||||
|
||||
// 患者填写缺少字段至医生
|
||||
Router::post('/patient', [PatientCaseController::class, 'sendCaseUnfilledFieldsToDoctor']);
|
||||
});
|
||||
});
|
||||
|
||||
// 测试使用
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user