From 80ce000ef7c2fa259f5b923ef8393c6eb1a9f348 Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Mon, 22 May 2023 13:51:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E6=8A=A5=E7=9B=91=E7=AE=A1=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Command/ReportRegulatoryCommand.php | 262 ++++++------------ .../RegulatoryPlatform/regulatoryPlatform.php | 1 + 2 files changed, 92 insertions(+), 171 deletions(-) diff --git a/app/Command/ReportRegulatoryCommand.php b/app/Command/ReportRegulatoryCommand.php index 20f568b..0cbf353 100644 --- a/app/Command/ReportRegulatoryCommand.php +++ b/app/Command/ReportRegulatoryCommand.php @@ -47,7 +47,7 @@ class ReportRegulatoryCommand extends HyperfCommand $this->line("开始"); // 获取未上传监管平台订单 - $report_regulatorys = $this->getNotReportRegulatory(0,100); + $report_regulatorys = $this->getNotReportRegulatory(); if (empty($report_regulatorys)) { $this->line("结束:无可执行订单"); return; @@ -72,164 +72,29 @@ class ReportRegulatoryCommand extends HyperfCommand continue; } + $order_inquiry = $order_inquiry->toArray(); + $res = $this->checkInquiryOrder($order_inquiry); if (!$res) { // 问诊订单数据不符合条件,不执行 continue; } - $this->line("开始:" . $report_regulatory['report_regulatory_id']); // 上报问诊 if ($report_regulatory['report_inquiry_status'] != 1){ $this->line("信息:上报问诊"); - - try { - $this->line("信息:检测执行次数"); - - $key = $report_regulatory['report_regulatory_id'] . 'report_inquiry'; - $res = $this->checkHandleNumber($key); - - if (!$res){ - $this->line("错误:超出最大执行次数或检测错误"); - $res = $this->modifyReportRegulatoryInquiry($report_regulatory, 2, 1, "超出最大执行次数或检测错误"); - if (!$res) { - $this->line("错误:系统错误"); - continue; - } - } - - $this->line("信息:检测执行次数通过"); - } catch (\Exception $e) { - $this->line("错误:" . $e->getMessage()); - continue; - } - - try { - // 检测患者是否首次问诊 - $is_first = $this->checkPatientFirstInquiry($order_prescription['patient_id'], $order_prescription['order_prescription_id']); - - // 获取上报监管数据-问诊 - $report_inquiry_data = $this->getReportInquiryData($order_inquiry, $order_prescription, $is_first); - - // 上报监管平台-问诊 - $res = $this->reportRegulatoryInquiry($report_inquiry_data, $is_first); - if (empty($res)) { - // 上报成功 - $res = $this->modifyReportRegulatoryInquiry($report_regulatory, 1, $is_first ? 1 : 2); - if (!$res) { - // 记录失败 - $this->line("错误:上报成功,存储记录失败"); - } - } else { - // 上报失败 - $res = $this->modifyReportRegulatoryInquiry($report_regulatory, 2, $is_first ? 1 : 2, $res); - if (!$res) { - // 记录失败 - $this->line("错误:上报失败,存储记录失败"); - } - } - } catch (\Exception $e) { - $this->line("错误:" . $e->getMessage()); - // 上报失败 - $res = $this->modifyReportRegulatoryInquiry($report_regulatory, 2, $is_first ? 1 : 2, $e->getMessage()); - if (!$res) { - // 记录失败 - $this->line("错误:上报失败,存储记录失败"); - } - continue; - } + $this->reportRegulatoryInquiry($report_regulatory,$order_inquiry,$order_prescription); } // 上报处方 if ($report_regulatory['report_prescription_status'] != 1){ $this->line("信息:上报处方"); - - try { - $this->line("信息:检测执行次数"); - - $key = $report_regulatory['report_regulatory_id'] . 'report_prescription'; - $res = $this->checkHandleNumber($key); - if (!$res){ - // 修改为上报失败 - $this->line("错误:超出最大执行次数或检测错误"); - $res = $this->modifyReportRegulatoryPrescription($report_regulatory, 2, "超出最大执行次数或检测错误"); - if (!$res) { - // 记录失败 - $this->line("错误:记录失败"); - } - } - - $this->line("信息:检测执行次数通过"); - } catch (\Exception $e) { - $this->line("错误:" . $e->getMessage()); - continue; - } + $this->reportRegulatoryPrescription($report_regulatory,$order_inquiry,$order_prescription); } - } - - - - - - - - - - - - for ($i = 0; $i < $report_regulatory_count; $i++) { - - - $this->line("信息:检测执行次数通过"); - - - - - - - - $this->line("信息:上报监管平台-处方"); - - try { - // 检测处方是否已经上报监管平台 - $res = $this->checkIsReportRegulatoryPrescription($order_prescription['order_inquiry_id']); - if (!$res) { - // 获取上报监管数据-处方 - $report_prescription_data = $this->getReportPrescriptionData($order_inquiry, $order_prescription); - - // 上报监管平台-处方 - $res = $this->reportRegulatoryPrescription($report_prescription_data); - if (empty($res)) { - // 上报成功 - $res = $this->modifyReportRegulatoryPrescription($order_prescription, 1); - if (!$res) { - // 记录失败 - $this->line("错误:记录失败"); - } - } else { - // 上报失败 - $res = $this->modifyReportRegulatoryPrescription($order_prescription, 2, $e->getMessage()); - if (!$res) { - // 记录失败 - $this->line("错误:记录失败"); - } - } - } - } catch (\Exception $e) { - $this->line("错误:" . $e->getMessage()); - - // 上报失败 - $res = $this->modifyReportRegulatoryPrescription($order_prescription, 2, $res); - if (!$res) { - // 记录失败 - $this->line("错误:记录失败"); - } - } - - $this->line("结束:" . $order_prescription['order_prescription_id']); + $this->line("结束:" . $report_regulatory['report_regulatory_id']); } $this->line("全部结束"); @@ -273,7 +138,7 @@ class ReportRegulatoryCommand extends HyperfCommand } // 执行次数过多 - if ($redis_value > 1) { + if ($redis_value > 5) { // 加入短信队列,通知管理员 return false; @@ -346,7 +211,6 @@ class ReportRegulatoryCommand extends HyperfCommand return true; } - /** * 检测问诊订单数据 * @param array|object $order_inquiry 问诊订单数据 @@ -401,7 +265,6 @@ class ReportRegulatoryCommand extends HyperfCommand return true; } - /** * 获取上报监管数据-问诊 * @param array|object $order_inquiry @@ -477,9 +340,9 @@ class ReportRegulatoryCommand extends HyperfCommand $data['serviceType'] = 1; // 服务类型 1网络咨询 2网络门诊 $data['consultNo'] = $order_inquiry['inquiry_no']; // 网络咨询或网络门诊编号 订单编号 $data['consultType'] = 1; // 咨询类别 1、图文咨询 2语音咨询3、视频咨询 - $data['consultApplyTime'] = $order_inquiry['created_at']; // 咨询申请时间 - $data['consultStartTime'] = $order_inquiry['reception_time']; // 咨询开始时间 - $data['consultEndTime'] = $order_inquiry['complete_time']; // 咨询结束时间 + $data['consultApplyTime'] = date('Y-m-d H:i:s',strtotime($order_inquiry['created_at'])); // 咨询申请时间 + $data['consultStartTime'] = date('Y-m-d H:i:s',strtotime($order_inquiry['reception_time'])); // 咨询开始时间 + $data['consultEndTime'] = date('Y-m-d H:i:s',strtotime($order_inquiry['complete_time'])); // 咨询结束时间 $data['feeType'] = 1; // 费别 1自费 2医保 $data['price'] = $order_inquiry['payment_amount_total']; // 咨询价格 元 $data['isReply'] = 1; //咨询是否回复 0未回复 1已回复 @@ -508,6 +371,8 @@ class ReportRegulatoryCommand extends HyperfCommand return false; } + $first_order_prescription = $first_order_prescription->toArray(); + // 获取患者初诊疾病诊断数据 $params = array(); $params['order_prescription_id'] = $first_order_prescription['order_prescription_id']; @@ -519,12 +384,16 @@ class ReportRegulatoryCommand extends HyperfCommand } $first_icd_name_data = array_column($first_order_prescription_icd->toArray(), 'icd_name'); - if (!empty($first_icd_name_data)) { - if (count($first_icd_name_data) > 1) { - $first_icd_name = implode('|', $first_icd_name_data); - } else { - $first_icd_name = $first_icd_name_data[0]; - } + if (empty($first_icd_name_data)){ + // 复诊,但是未找到关联疾病 + $this->line("错误:无初诊疾病诊断数据"); + return false; + } + + if (count($first_icd_name_data) > 1) { + $first_icd_name = implode('|', $first_icd_name_data); + } else { + $first_icd_name = $first_icd_name_data[0]; } // 获取患者复诊疾病诊断数据 @@ -576,11 +445,11 @@ class ReportRegulatoryCommand extends HyperfCommand $data['medicalHistory'] = $order_inquiry_case['disease_desc']; //患者病史描述 $data['consultDiagnosisType'] = 1; // 首诊诊断类型 $data['consultDiagnosis'] = $first_icd_name; // 首诊诊断 复诊患者在首诊医院的诊断,如有多条,使用“|”进行分隔;当传图片时,需要传图片的base64字符串 - $data['consultTime'] = $first_order_prescription['doctor_created_time']; // 首诊时间 + $data['consultTime'] = date('Y-m-d H:i:s',strtotime($first_order_prescription['doctor_created_time'])); // 首诊时间 $data['consultOrg'] = "成都金牛欣欣相照互联网医院"; // 首诊机构 - $data['furtherConsultApplyTime'] = $order_inquiry['created_at']; // 复诊申请时间 - $data['furtherConsulStartTime'] = $order_inquiry['reception_time']; // 复诊开始时间 - $data['furtherConsulEndTime'] = $order_inquiry['complete_time']; // 复诊结束时间 + $data['furtherConsultApplyTime'] = date('Y-m-d H:i:s',strtotime($order_inquiry['created_at'])); // 复诊申请时间 + $data['furtherConsulStartTime'] = date('Y-m-d H:i:s',strtotime($order_inquiry['reception_time'])); // 复诊开始时间 + $data['furtherConsulEndTime'] = date('Y-m-d H:i:s',strtotime($order_inquiry['complete_time'])); // 复诊结束时间 $data['furtherConsulIsReply'] = 1; // 复诊是否回复 0未回复 1已回复 $data['feeType'] = 1; // 费别 1自费 2医保 $data['furtherConsultDiagnosis'] = $icd_name; // 复诊诊断 复诊患者在实体医院的诊断名称,如有多条,使用“|”进行分隔 @@ -600,16 +469,28 @@ class ReportRegulatoryCommand extends HyperfCommand } /** - * 上报监管平台-问诊 - * @param array $report_inquiry_data 上报数据 - * @param bool $is_first - * @return string + * 上报问诊 + * @param array|object $report_regulatory + * @param array|object $order_inquiry + * @param array|object $order_prescription * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - private function reportRegulatoryInquiry(array $report_inquiry_data, bool $is_first = true): string + private function reportRegulatoryInquiry(array|object $report_regulatory,array|object $order_inquiry,array|object $order_prescription): void { + if($report_regulatory['report_inquiry_int'] >= 5){ + $this->line("错误:超出最大执行次数,本条不执行"); + return ; + } + + // 检测患者是否首次问诊 + $is_first = $this->checkPatientFirstInquiry($order_prescription['patient_id'], $order_prescription['order_prescription_id']); + try { + // 获取上报监管数据-问诊 + $report_inquiry_data = $this->getReportInquiryData($order_inquiry, $order_prescription, $is_first); + + // 上报监管平台-问诊 $regulatoryPlatform = new regulatoryPlatform(); if ($is_first) { $result = $regulatoryPlatform->uploadConsult([$report_inquiry_data]); @@ -617,10 +498,24 @@ class ReportRegulatoryCommand extends HyperfCommand $result = $regulatoryPlatform->uploadFurtherConsult([$report_inquiry_data]); } - return ""; + $this->line("信息:上报成功" . json_encode($result,JSON_UNESCAPED_UNICODE)); + + // 上报成功 + $res = $this->modifyReportRegulatoryInquiry($report_regulatory, 1, $is_first ? 1 : 2); + if (!$res) { + // 记录失败 + $this->line("错误:上报成功,存储记录失败"); + return; + } } catch (\Exception $e) { $this->line("错误:" . $e->getMessage()); - return $e->getMessage(); + // 上报失败 + $res = $this->modifyReportRegulatoryInquiry($report_regulatory, 2, $is_first ? 1 : 2, $e->getMessage()); + if (!$res) { + // 记录失败 + $this->line("错误:上报失败,存储记录失败"); + return; + } } } @@ -765,22 +660,47 @@ class ReportRegulatoryCommand extends HyperfCommand } /** - * 上报监管平台-处方 - * @param array $report_prescription_data - * @return string + * 上报处方 + * @param array|object $report_regulatory + * @param array|object $order_inquiry + * @param array|object $order_prescription + * @return void * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - private function reportRegulatoryPrescription(array $report_prescription_data): string + private function reportRegulatoryPrescription(array|object $report_regulatory,array|object $order_inquiry,array|object $order_prescription): void { + if ($report_regulatory['report_prescription_int'] >= 5){ + // 修改为上报失败 + $this->line("错误:超出最大执行次数,本条不执行"); + return ; + } + try { + // 获取上报监管数据-处方 + $report_prescription_data = $this->getReportPrescriptionData($order_inquiry, $order_prescription); + + // 上报监管平台-处方 $regulatoryPlatform = new regulatoryPlatform(); $result = $regulatoryPlatform->uploadRecipe([$report_prescription_data]); + $this->line("信息:上报成功" . json_encode($result,JSON_UNESCAPED_UNICODE)); - return ""; - } catch (\Exception $e) { + // 上报成功 + $res = $this->modifyReportRegulatoryPrescription($report_regulatory, 1); + if (!$res) { + // 记录失败 + $this->line("错误:上报成功,存储记录失败"); + return ; + } + }catch (\Exception $e){ $this->line("错误:" . $e->getMessage()); - return $e->getMessage(); + // 上报失败 + $res = $this->modifyReportRegulatoryPrescription($report_regulatory, 2, $e->getMessage()); + if (!$res) { + // 记录失败 + $this->line("错误:上报失败,存储记录失败"); + return ; + } } } diff --git a/extend/RegulatoryPlatform/regulatoryPlatform.php b/extend/RegulatoryPlatform/regulatoryPlatform.php index 9897ed2..dc5ab7c 100644 --- a/extend/RegulatoryPlatform/regulatoryPlatform.php +++ b/extend/RegulatoryPlatform/regulatoryPlatform.php @@ -156,6 +156,7 @@ class regulatoryPlatform ]; $response = $this->httpRequest($this->api_url . '/wjw/upload/uploadFurtherConsult', $option); + dump($response); if (isset($response['status'])) { if ($response['status'] != 0) { if (!empty($response['message'])) {