删除自动开方时增加上报处方数据。增加自动结束时上报处方数据,修改上报处方脚本
This commit is contained in:
parent
f697ce77b1
commit
2ce4aafb01
@ -4,6 +4,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Amqp\Consumer;
|
namespace App\Amqp\Consumer;
|
||||||
|
|
||||||
|
use App\Amqp\Producer\AutoFinishInquiryDelayDirectProducer;
|
||||||
|
use App\Constants\HttpEnumCode;
|
||||||
use App\Model\DoctorAccount;
|
use App\Model\DoctorAccount;
|
||||||
use App\Model\DoctorAccountDay;
|
use App\Model\DoctorAccountDay;
|
||||||
use App\Model\OrderEvaluation;
|
use App\Model\OrderEvaluation;
|
||||||
@ -17,11 +19,13 @@ use App\Model\UserDoctor;
|
|||||||
use App\Model\UserPatient;
|
use App\Model\UserPatient;
|
||||||
use App\Services\ImService;
|
use App\Services\ImService;
|
||||||
use App\Services\MessagePush;
|
use App\Services\MessagePush;
|
||||||
|
use App\Services\ReportRegulatoryService;
|
||||||
use App\Utils\Log;
|
use App\Utils\Log;
|
||||||
use App\Utils\Mask;
|
use App\Utils\Mask;
|
||||||
use Hyperf\Amqp\Message\ConsumerDelayedMessageTrait;
|
use Hyperf\Amqp\Message\ConsumerDelayedMessageTrait;
|
||||||
use Hyperf\Amqp\Message\ProducerDelayedMessageTrait;
|
use Hyperf\Amqp\Message\ProducerDelayedMessageTrait;
|
||||||
use Hyperf\Amqp\Message\Type;
|
use Hyperf\Amqp\Message\Type;
|
||||||
|
use Hyperf\Amqp\Producer;
|
||||||
use Hyperf\Amqp\Result;
|
use Hyperf\Amqp\Result;
|
||||||
use Hyperf\Amqp\Annotation\Consumer;
|
use Hyperf\Amqp\Annotation\Consumer;
|
||||||
use Hyperf\Amqp\Message\ConsumerMessage;
|
use Hyperf\Amqp\Message\ConsumerMessage;
|
||||||
@ -54,45 +58,55 @@ class AutoFinishInquiryDelayDirectConsumer extends ConsumerMessage
|
|||||||
{
|
{
|
||||||
Log::getInstance("queue-AutoFinishInquiry")->info("开始:" . json_encode($data, JSON_UNESCAPED_UNICODE));
|
Log::getInstance("queue-AutoFinishInquiry")->info("开始:" . json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||||
|
|
||||||
|
// 检测入参参数
|
||||||
|
if (empty($data['order_inquiry_id'])) {
|
||||||
|
Log::getInstance("queue-AutoFinishInquiry")->error("错误:入参错误");
|
||||||
|
return Result::DROP;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取问诊订单数据
|
||||||
|
$params = array();
|
||||||
|
$params['order_inquiry_id'] = $data['order_inquiry_id'];
|
||||||
|
$order_inquiry = OrderInquiry::getOne($params);
|
||||||
|
if (empty($order_inquiry)) {
|
||||||
|
Log::getInstance("queue-AutoFinishInquiry")->error("问诊订单数据为空");
|
||||||
|
return Result::DROP;
|
||||||
|
}
|
||||||
|
|
||||||
|
$order_inquiry = $order_inquiry->toArray();
|
||||||
|
|
||||||
|
// 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||||
|
if ($order_inquiry['inquiry_status'] != 5) {
|
||||||
|
Log::getInstance("queue-AutoFinishInquiry")->error("问诊订单未完成,无法结束");
|
||||||
|
return Result::DROP;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)
|
||||||
|
if (!in_array($order_inquiry['inquiry_refund_status'], [0, 4, 5])) {
|
||||||
|
Log::getInstance("queue-AutoFinishInquiry")->error("问诊订单正在申请退款");
|
||||||
|
return Result::DROP;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($order_inquiry['doctor_id'])) {
|
||||||
|
Log::getInstance("queue-AutoFinishInquiry")->error("医生id为空");
|
||||||
|
return Result::DROP;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Db::beginTransaction();
|
Db::beginTransaction();
|
||||||
try {
|
try {
|
||||||
// 检测入参参数
|
// 检测执行次数
|
||||||
if (empty($data['order_inquiry_id'])) {
|
$result = $this->checkExecutionCount($data['order_inquiry_id']);
|
||||||
|
if (empty($result)) {
|
||||||
Db::rollBack();
|
Db::rollBack();
|
||||||
Log::getInstance("queue-AutoFinishInquiry")->error("错误:入参错误");
|
Log::getInstance("queue-AutoFinishInquiry")->error("检测订单执行次数错误");
|
||||||
return Result::DROP;
|
return Result::ACK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取问诊订单数据
|
// 超出执行次数
|
||||||
$params = array();
|
if ($result['code'] == 2){
|
||||||
$params['order_inquiry_id'] = $data['order_inquiry_id'];
|
|
||||||
$order_inquiry = OrderInquiry::getOne($params);
|
|
||||||
if (empty($order_inquiry)) {
|
|
||||||
Db::rollBack();
|
Db::rollBack();
|
||||||
Log::getInstance("queue-AutoFinishInquiry")->error("错误:问诊订单数据为空");
|
return Result::ACK;
|
||||||
return Result::DROP;
|
|
||||||
}
|
|
||||||
|
|
||||||
$order_inquiry = $order_inquiry->toArray();
|
|
||||||
|
|
||||||
// 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
|
||||||
if ($order_inquiry['inquiry_status'] != 5) {
|
|
||||||
Db::rollBack();
|
|
||||||
Log::getInstance("queue-AutoFinishInquiry")->error("错误:问诊订单未完成,无法结束");
|
|
||||||
return Result::DROP;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)
|
|
||||||
if (!in_array($order_inquiry['inquiry_refund_status'], [0, 4, 5])) {
|
|
||||||
Db::rollBack();
|
|
||||||
Log::getInstance("queue-AutoFinishInquiry")->error("错误:问诊订单正在申请退款");
|
|
||||||
return Result::DROP;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($order_inquiry['doctor_id'])) {
|
|
||||||
Db::rollBack();
|
|
||||||
Log::getInstance("queue-AutoFinishInquiry")->error("错误:医生id为空");
|
|
||||||
return Result::DROP;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理统计问题
|
// 处理统计问题
|
||||||
@ -101,16 +115,16 @@ class AutoFinishInquiryDelayDirectConsumer extends ConsumerMessage
|
|||||||
$res = $this->handleDoctorAccount($order_inquiry);
|
$res = $this->handleDoctorAccount($order_inquiry);
|
||||||
if (!$res) {
|
if (!$res) {
|
||||||
Db::rollBack();
|
Db::rollBack();
|
||||||
Log::getInstance("queue-AutoFinishInquiry")->error("错误:处理医生账户总表失败");
|
Log::getInstance("queue-AutoFinishInquiry")->error("处理医生账户总表失败");
|
||||||
return Result::DROP;
|
return Result::REQUEUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理医生账户表-日
|
// 处理医生账户表-日
|
||||||
$res = $this->handleDoctorAccountDay($order_inquiry);
|
$res = $this->handleDoctorAccountDay($order_inquiry);
|
||||||
if (!$res) {
|
if (!$res) {
|
||||||
Db::rollBack();
|
Db::rollBack();
|
||||||
Log::getInstance("queue-AutoFinishInquiry")->error("错误:处理医生账户表-日失败");
|
Log::getInstance("queue-AutoFinishInquiry")->error("处理医生账户表-日失败");
|
||||||
return Result::DROP;
|
return Result::REQUEUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,12 +149,22 @@ class AutoFinishInquiryDelayDirectConsumer extends ConsumerMessage
|
|||||||
// 计算医生平均响应时间
|
// 计算医生平均响应时间
|
||||||
$this->computeDoctorAvgPesponseTime($order_inquiry['doctor_id']);
|
$this->computeDoctorAvgPesponseTime($order_inquiry['doctor_id']);
|
||||||
|
|
||||||
|
// 新增上报监管平台数据
|
||||||
|
$reportRegulatoryService = new ReportRegulatoryService();
|
||||||
|
$res = $reportRegulatoryService->addReportRegulatory($order_inquiry['order_inquiry_id']);
|
||||||
|
if (!$res){
|
||||||
|
// 新增上报失败
|
||||||
|
Db::rollBack();
|
||||||
|
Log::getInstance("queue-AutoFinishInquiry")->error("新增上报监管平台数据失败");
|
||||||
|
return Result::REQUEUE;
|
||||||
|
}
|
||||||
|
|
||||||
Db::commit();
|
Db::commit();
|
||||||
Log::getInstance("queue-AutoFinishInquiry")->info("成功");
|
Log::getInstance("queue-AutoFinishInquiry")->info("成功");
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Db::rollBack();
|
Db::rollBack();
|
||||||
Log::getInstance("queue-AutoFinishInquiry")->error("错误:" . $e->getMessage());
|
Log::getInstance("queue-AutoFinishInquiry")->error("错误:" . $e->getMessage());
|
||||||
return Result::ACK; // 重回队列
|
return Result::REQUEUE; // 重回队列
|
||||||
}
|
}
|
||||||
|
|
||||||
// 推送消息
|
// 推送消息
|
||||||
@ -259,11 +283,6 @@ class AutoFinishInquiryDelayDirectConsumer extends ConsumerMessage
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取用户数据
|
|
||||||
$params = array();
|
|
||||||
$params['patient_id'] = $order_inquiry['patient_id'];
|
|
||||||
$user_patient = UserPatient::getOne($params);
|
|
||||||
|
|
||||||
// 未评价
|
// 未评价
|
||||||
$data = array();
|
$data = array();
|
||||||
$data['doctor_id'] = $order_inquiry['doctor_id'];
|
$data['doctor_id'] = $order_inquiry['doctor_id'];
|
||||||
@ -600,4 +619,53 @@ class AutoFinishInquiryDelayDirectConsumer extends ConsumerMessage
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检测执行次数
|
||||||
|
* @param string $redis_key
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function checkExecutionCount(string $redis_key): array
|
||||||
|
{
|
||||||
|
// code:0:异常 1:正常 2:超出最大执行次数
|
||||||
|
$result = array();
|
||||||
|
$result['code'] = 0;
|
||||||
|
$result['message'] = "";
|
||||||
|
|
||||||
|
try {
|
||||||
|
$redis = $this->container->get(Redis::class);
|
||||||
|
}catch (\Throwable $e) {
|
||||||
|
Log::getInstance("queue-AutoFinishInquiry")->error($e->getMessage());
|
||||||
|
$result['message'] = $e->getMessage();
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$redis_value = $redis->get($redis_key);
|
||||||
|
if (empty($redis_value)) {
|
||||||
|
$redis->set($redis_key, 1, 60 * 60 * 24 * 1);
|
||||||
|
|
||||||
|
$result['code'] = 1;
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 执行次数超出4次
|
||||||
|
if ($redis_value > 4) {
|
||||||
|
Log::getInstance("queue-AutoFinishInquiry")->info("超出最大执行次数");
|
||||||
|
// 加入短信队列,通知管理员
|
||||||
|
|
||||||
|
$result['code'] = 2;
|
||||||
|
$result['message'] = "超出最大执行次数";
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
$redis->incr($redis_key);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Log::getInstance("queue-AutoFinishInquiry")->error($e->getMessage());
|
||||||
|
$result['message'] = $e->getMessage();
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -257,14 +257,6 @@ class AutoPharmacistCaVerifyDelayDirectConsumer extends ConsumerMessage
|
|||||||
// 修改处方表为通过
|
// 修改处方表为通过
|
||||||
$this->modifyOrderPrescription($data['order_prescription_id'],1);
|
$this->modifyOrderPrescription($data['order_prescription_id'],1);
|
||||||
|
|
||||||
// 增加上报监管平台表
|
|
||||||
$res = $this->addReportRegulatory($order_inquiry['order_inquiry_id'],$order_prescription['order_prescription_id']);
|
|
||||||
if (!$res){
|
|
||||||
Db::rollBack();
|
|
||||||
Log::getInstance("queue-AutoPharmacistCaVerify")->error("错误:增加监管平台上报表失败");
|
|
||||||
return Result::REQUEUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
Db::commit();
|
Db::commit();
|
||||||
Log::getInstance("queue-AutoPharmacistCaVerify")->info("成功");
|
Log::getInstance("queue-AutoPharmacistCaVerify")->info("成功");
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
@ -479,31 +471,4 @@ class AutoPharmacistCaVerifyDelayDirectConsumer extends ConsumerMessage
|
|||||||
|
|
||||||
OrderPrescription::edit($params,$data);
|
OrderPrescription::edit($params,$data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 增加上报监管平台表
|
|
||||||
* @param string $order_inquiry_id
|
|
||||||
* @param string $order_prescription_id
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
protected function addReportRegulatory(string $order_inquiry_id,string $order_prescription_id): bool
|
|
||||||
{
|
|
||||||
// 检测是否已添加
|
|
||||||
$params = array();
|
|
||||||
$params['order_inquiry_id'] = $order_inquiry_id;
|
|
||||||
$report_regulatory = ReportRegulatory::getOne($params);
|
|
||||||
if (!empty($report_regulatory)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = array();
|
|
||||||
$data['order_inquiry_id'] = $order_inquiry_id;
|
|
||||||
$data['order_prescription_id'] = $order_prescription_id;
|
|
||||||
$report_regulatory = ReportRegulatory::addReportRegulatory($data);
|
|
||||||
if (empty($report_regulatory)){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -54,44 +54,142 @@ class ReportRegulatoryCommand extends HyperfCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($report_regulatorys as $report_regulatory){
|
foreach ($report_regulatorys as $report_regulatory){
|
||||||
// 获取处方数据
|
|
||||||
$params = array();
|
|
||||||
$params['order_prescription_id'] = $report_regulatory['order_prescription_id'];
|
|
||||||
$order_prescription = OrderPrescription::getOne($params);
|
|
||||||
if (empty($order_prescription)){
|
|
||||||
// 无处方数据,不处理
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取问诊订单数据
|
|
||||||
$params = array();
|
|
||||||
$params['order_inquiry_id'] = $order_prescription['order_inquiry_id'];
|
|
||||||
$order_inquiry = OrderInquiry::getOne($params);
|
|
||||||
if (empty($order_inquiry)) {
|
|
||||||
// 无处方数据,不处理
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$order_inquiry = $order_inquiry->toArray();
|
|
||||||
|
|
||||||
$res = $this->checkInquiryOrder($order_inquiry);
|
|
||||||
if (!$res) {
|
|
||||||
// 问诊订单数据不符合条件,不执行
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->line("开始:" . $report_regulatory['report_regulatory_id']);
|
$this->line("开始:" . $report_regulatory['report_regulatory_id']);
|
||||||
|
|
||||||
// 上报问诊
|
try {
|
||||||
if ($report_regulatory['report_inquiry_status'] != 1){
|
// 获取问诊订单数据
|
||||||
$this->line("信息:上报问诊");
|
$params = array();
|
||||||
$this->reportRegulatoryInquiry($report_regulatory,$order_inquiry,$order_prescription);
|
$params['order_inquiry_id'] = $report_regulatory['order_inquiry_id'];
|
||||||
|
$order_inquiry = OrderInquiry::getOne($params);
|
||||||
|
if (empty($order_inquiry)) {
|
||||||
|
// 问诊订单数据错误
|
||||||
|
$this->line("问诊订单数据错误");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$order_inquiry = $order_inquiry->toArray();
|
||||||
|
|
||||||
|
// 检测问诊订单
|
||||||
|
$res = $this->checkInquiryOrder($order_inquiry);
|
||||||
|
if (!$res) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}catch (\Throwable $e){
|
||||||
|
$this->line($e->getMessage());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 上报网络咨询
|
||||||
|
try {
|
||||||
|
if ($report_regulatory['report_consult_status'] != 1 && $report_regulatory['report_consult_int'] < 5){
|
||||||
|
$this->line("上报网络咨询");
|
||||||
|
|
||||||
|
// 获取上报数据-网络咨询
|
||||||
|
$consult_data = $this->getConsultData($order_inquiry);
|
||||||
|
|
||||||
|
// 上报网络咨询
|
||||||
|
$regulatoryPlatform = new regulatoryPlatform();
|
||||||
|
$result = $regulatoryPlatform->uploadConsult([$consult_data]);
|
||||||
|
|
||||||
|
$this->line("上报网络咨询成功" . json_encode($result,JSON_UNESCAPED_UNICODE));
|
||||||
|
|
||||||
|
// 修改上报状态-网络咨询
|
||||||
|
$res = $this->modifyReportConsultStatus($report_regulatory, 1);
|
||||||
|
if (!$res) {
|
||||||
|
// 记录失败
|
||||||
|
$this->line("上报成功,存储记录失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch (\Throwable $e){
|
||||||
|
$this->line("上报网络咨询失败" . $e->getMessage());
|
||||||
|
|
||||||
|
// 上报失败
|
||||||
|
$res = $this->modifyReportConsultStatus($report_regulatory, 2, $e->getMessage());
|
||||||
|
if (!$res) {
|
||||||
|
// 记录失败
|
||||||
|
$this->line("上报网络咨询失败,存储记录失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 上报复诊
|
||||||
|
try {
|
||||||
|
if ($report_regulatory['is_further_consult'] == 1){
|
||||||
|
if ($report_regulatory['report_further_consult_status'] != 1 && $report_regulatory['report_further_consult_int'] < 5) {
|
||||||
|
$this->line("上报复诊");
|
||||||
|
|
||||||
|
// 获取处方数据
|
||||||
|
$params = array();
|
||||||
|
$params['order_prescription_id'] = $report_regulatory['order_prescription_id'];
|
||||||
|
$order_prescription = OrderPrescription::getOne($params);
|
||||||
|
if (empty($order_prescription)){
|
||||||
|
$this->line("需上报复诊,但无处方数据");
|
||||||
|
}else{
|
||||||
|
// 获取上报数据-复诊
|
||||||
|
$further_consult_data = $this->getFurtherConsultData($order_inquiry,$order_prescription);
|
||||||
|
|
||||||
|
// 上报复诊
|
||||||
|
$regulatoryPlatform = new regulatoryPlatform();
|
||||||
|
$result = $regulatoryPlatform->uploadFurtherConsult([$further_consult_data]);
|
||||||
|
$this->line("上报复诊成功" . json_encode($result,JSON_UNESCAPED_UNICODE));
|
||||||
|
|
||||||
|
// 修改上报状态-复诊
|
||||||
|
$res = $this->modifyReportFurtherConsultStatus($report_regulatory, 1);
|
||||||
|
if (!$res) {
|
||||||
|
// 记录失败
|
||||||
|
$this->line("上报成功,存储记录失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch (\Throwable $e){
|
||||||
|
$this->line("上报复诊失败" . $e->getMessage());
|
||||||
|
|
||||||
|
// 上报失败
|
||||||
|
$res = $this->modifyReportFurtherConsultStatus($report_regulatory, 2, $e->getMessage());
|
||||||
|
if (!$res) {
|
||||||
|
// 记录失败
|
||||||
|
$this->line("上报复诊失败,存储记录失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 上报处方
|
// 上报处方
|
||||||
if ($report_regulatory['report_prescription_status'] != 1){
|
try {
|
||||||
$this->line("信息:上报处方");
|
$this->line("上报处方");
|
||||||
$this->reportRegulatoryPrescription($report_regulatory,$order_inquiry,$order_prescription);
|
|
||||||
|
// 获取处方数据
|
||||||
|
$params = array();
|
||||||
|
$params['order_prescription_id'] = $report_regulatory['order_prescription_id'];
|
||||||
|
$order_prescription = OrderPrescription::getOne($params);
|
||||||
|
if (empty($order_prescription)){
|
||||||
|
$this->line("需上报复诊,但无处方数据");
|
||||||
|
}else{
|
||||||
|
// 获取上报数据-处方
|
||||||
|
$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));
|
||||||
|
|
||||||
|
// 上报成功
|
||||||
|
$res = $this->modifyReportRegulatoryPrescription($report_regulatory, 1);
|
||||||
|
if (!$res) {
|
||||||
|
// 记录失败
|
||||||
|
$this->line("上报处方失败,存储记录失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch (\Throwable $e){
|
||||||
|
$this->line("上报处方失败" . $e->getMessage());
|
||||||
|
|
||||||
|
// 上报失败
|
||||||
|
$res = $this->modifyReportRegulatoryPrescription($report_regulatory, 2, $e->getMessage());
|
||||||
|
if (!$res) {
|
||||||
|
// 记录失败
|
||||||
|
$this->line("上报复诊失败,存储记录失败");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->line("结束:" . $report_regulatory['report_regulatory_id']);
|
$this->line("结束:" . $report_regulatory['report_regulatory_id']);
|
||||||
@ -106,11 +204,7 @@ class ReportRegulatoryCommand extends HyperfCommand
|
|||||||
*/
|
*/
|
||||||
private function getNotReportRegulatory(): array
|
private function getNotReportRegulatory(): array
|
||||||
{
|
{
|
||||||
$params = array();
|
$report_regulatory = ReportRegulatory::getNotReportList();
|
||||||
$params[] = ['report_inquiry_int','<',5];
|
|
||||||
$params[] = ['report_prescription_int','<',5];
|
|
||||||
|
|
||||||
$report_regulatory = ReportRegulatory::getNotReportList($params,['*']);
|
|
||||||
if (empty($report_regulatory)){
|
if (empty($report_regulatory)){
|
||||||
return [];
|
return [];
|
||||||
}else{
|
}else{
|
||||||
@ -119,48 +213,13 @@ class ReportRegulatoryCommand extends HyperfCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检测执行次数
|
* 修改上报状态-网络咨询
|
||||||
* @param string $key
|
|
||||||
* @return bool
|
|
||||||
* @throws ContainerExceptionInterface
|
|
||||||
* @throws NotFoundExceptionInterface
|
|
||||||
*/
|
|
||||||
protected function checkHandleNumber(string $key): bool
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$redis = $this->container->get(Redis::class);
|
|
||||||
|
|
||||||
$redis_key = "ReportRegulatoryInquiry" . $key;
|
|
||||||
$redis_value = $redis->get($redis_key);
|
|
||||||
if (empty($redis_value)) {
|
|
||||||
$redis->set($redis_key, 1, 60 * 60 * 24 * 10);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 执行次数过多
|
|
||||||
if ($redis_value > 5) {
|
|
||||||
// 加入短信队列,通知管理员
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$redis->incr($redis_key);
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改上报问诊数据
|
|
||||||
* @param array|object $report_regulatory
|
* @param array|object $report_regulatory
|
||||||
* @param int $report_inquiry_status 问诊上报状态(0:未上报 1:已上报 2:上报失败)
|
* @param int $report_consult_status 上报网络咨询状态(0:未上报 1:已上报 2:上报失败)
|
||||||
* @param int $report_inquiry_type 问诊上报类型(1:网络初诊 2:网络复诊)
|
* @param string $report_consult_fail_reason 网络咨询上报失败原因
|
||||||
* @param string $report_inquiry_fail_reason 问诊上报失败原因
|
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function modifyReportRegulatoryInquiry(array|object $report_regulatory, int $report_inquiry_status, int $report_inquiry_type, string $report_inquiry_fail_reason = ""): bool
|
private function modifyReportConsultStatus(array|object $report_regulatory, int $report_consult_status,string $report_consult_fail_reason = ""): bool
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
// 修改
|
// 修改
|
||||||
@ -168,14 +227,41 @@ class ReportRegulatoryCommand extends HyperfCommand
|
|||||||
$params['report_regulatory_id'] = $report_regulatory['report_regulatory_id'];
|
$params['report_regulatory_id'] = $report_regulatory['report_regulatory_id'];
|
||||||
|
|
||||||
$data = array();
|
$data = array();
|
||||||
$data['report_inquiry_status'] = $report_inquiry_status;
|
$data['report_consult_status'] = $report_consult_status;
|
||||||
$data['report_inquiry_int'] = $report_regulatory['report_inquiry_int'] + 1;
|
$data['report_consult_int'] = $report_regulatory['report_consult_int'] + 1;
|
||||||
$data['report_inquiry_type'] = $report_inquiry_type;
|
$data['report_consult_time'] = date('Y-m-d H:i:s', time());
|
||||||
$data['report_inquiry_time'] = date('Y-m-d H:i:s', time());
|
$data['report_consult_fail_reason'] = $report_consult_fail_reason;
|
||||||
$data['report_inquiry_fail_reason'] = $report_inquiry_fail_reason;
|
|
||||||
ReportRegulatory::edit($params, $data);
|
ReportRegulatory::edit($params, $data);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->line("失败:" . $e->getMessage());
|
$this->line($e->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改上报状态-复诊
|
||||||
|
* @param array|object $report_regulatory
|
||||||
|
* @param int $report_further_consult_status 上报网络复诊状态(0:未上报 1:已上报 2:上报失败)
|
||||||
|
* @param string $report_further_consult_fail_reason 网络复诊上报失败原因
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private function modifyReportFurtherConsultStatus(array|object $report_regulatory, int $report_further_consult_status,string $report_further_consult_fail_reason = ""): bool
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// 修改
|
||||||
|
$params = array();
|
||||||
|
$params['report_regulatory_id'] = $report_regulatory['report_regulatory_id'];
|
||||||
|
|
||||||
|
$data = array();
|
||||||
|
$data['report_further_consult_status'] = $report_further_consult_status;
|
||||||
|
$data['report_further_consult_int'] = $report_regulatory['report_further_consult_int'] + 1;
|
||||||
|
$data['report_further_consult_time'] = date('Y-m-d H:i:s', time());
|
||||||
|
$data['report_further_consult_fail_reason'] = $report_further_consult_fail_reason;
|
||||||
|
ReportRegulatory::edit($params, $data);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$this->line($e->getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,7 +314,7 @@ class ReportRegulatoryCommand extends HyperfCommand
|
|||||||
|
|
||||||
// 已取消状态,查看是否完成后取消的
|
// 已取消状态,查看是否完成后取消的
|
||||||
if ($order_inquiry['inquiry_status'] == 7 && $order_inquiry['cancel_reason'] != 4 && empty($order_inquiry['complete_time'])) {
|
if ($order_inquiry['inquiry_status'] == 7 && $order_inquiry['cancel_reason'] != 4 && empty($order_inquiry['complete_time'])) {
|
||||||
$this->line("信息:订单为取消的未完成订单,不执行");
|
$this->line("信息:订单未取消的未完成订单,不执行");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,291 +322,7 @@ class ReportRegulatoryCommand extends HyperfCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检测患者是否首次问诊-是否开具过处方
|
* 获取上报数据-处方
|
||||||
* @param string $patient_id
|
|
||||||
* @param string $order_prescription_id
|
|
||||||
* @return bool true:首次 false:复诊
|
|
||||||
*/
|
|
||||||
private function checkPatientFirstInquiry(string $patient_id, string $order_prescription_id): bool
|
|
||||||
{
|
|
||||||
$params = array();
|
|
||||||
$params['patient_id'] = $patient_id;
|
|
||||||
$params['pharmacist_audit_status'] = 1;
|
|
||||||
|
|
||||||
$prescription_status_params = [2, 3, 4];
|
|
||||||
$order_prescriptions = OrderPrescription::getStatusList($params, $prescription_status_params);
|
|
||||||
if (empty($order_prescriptions)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($order_prescriptions as $item) {
|
|
||||||
if ($item['order_prescription_id'] == $order_prescription_id) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 开具过处方
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取上报监管数据-问诊
|
|
||||||
* @param array|object $order_inquiry
|
|
||||||
* @param array|object $order_prescription
|
|
||||||
* @param bool $is_first 是否首次问诊 true:是 1:否
|
|
||||||
* @return bool|array
|
|
||||||
*/
|
|
||||||
private function getReportInquiryData(array|object $order_inquiry, array|object $order_prescription, bool $is_first = true): bool|array
|
|
||||||
{
|
|
||||||
// 获取医生数据
|
|
||||||
$params = array();
|
|
||||||
$params['doctor_id'] = $order_inquiry['doctor_id'];
|
|
||||||
$user_doctor = UserDoctor::getOne($params);
|
|
||||||
if (empty($user_doctor)) {
|
|
||||||
$this->line("错误:医生数据错误");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$params = array();
|
|
||||||
$params['doctor_id'] = $order_inquiry['doctor_id'];
|
|
||||||
$user_doctor_info = UserDoctorInfo::getOne($params);
|
|
||||||
if (empty($user_doctor_info)) {
|
|
||||||
$this->line("错误:医生详情数据错误");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取医生自定义科室数据
|
|
||||||
$params = array();
|
|
||||||
$params['department_custom_id'] = $user_doctor['department_custom_id'];
|
|
||||||
$hospital_department_custom = HospitalDepartmentCustom::getOne($params);
|
|
||||||
if (empty($hospital_department_custom)) {
|
|
||||||
$this->line("错误:医生自定义数据错误");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取问诊患者数据
|
|
||||||
$params = array();
|
|
||||||
$params['family_id'] = $order_inquiry['family_id'];
|
|
||||||
$patient_family = PatientFamily::getOne($params);
|
|
||||||
if (empty($patient_family)) {
|
|
||||||
$this->line("错误:问诊患者数据错误");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取患者问诊病例
|
|
||||||
$params = array();
|
|
||||||
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
|
||||||
$params['status'] = 1;
|
|
||||||
$order_inquiry_case = OrderInquiryCase::getOne($params);
|
|
||||||
if (empty($order_inquiry_case)) {
|
|
||||||
$this->line("错误:患者问诊病例错误");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($is_first) {
|
|
||||||
$this->line("信息:患者首次问诊");
|
|
||||||
// 初诊
|
|
||||||
// 网络咨询(网络门诊)服务
|
|
||||||
$data = array();
|
|
||||||
$data['thirdUniqueid'] = $order_inquiry['order_inquiry_id']; // 唯一标识
|
|
||||||
$data['orgName'] = "成都金牛欣欣相照互联网医院"; // 机构名称
|
|
||||||
$data['orgCode'] = "MA6CGUDA251010619D2112"; // 机构编码
|
|
||||||
$data['channelName'] = "成都金牛欣欣相照互联网医院";//平台名称
|
|
||||||
$data['section'] = $hospital_department_custom['department_name'];//科室名称
|
|
||||||
$data['sectionCode'] = $hospital_department_custom['department_code'];//科室编码
|
|
||||||
$data['docName'] = $user_doctor['user_name'];// 姓名(医师、护师、技师)
|
|
||||||
$data['certificateNum'] = $user_doctor_info['qualification_cert_num']; // 执业资格证号
|
|
||||||
$data['patientName'] = $order_inquiry['patient_name']; // 患者姓名
|
|
||||||
$data['patientAge'] = (int)$order_inquiry['patient_age']; // 患者年龄
|
|
||||||
$data['patientSex'] = $order_inquiry['patient_sex'] == 0 ?: 1; // 患者性别
|
|
||||||
$data['patientIdcardType'] = 1; // 证件类型
|
|
||||||
$data['patientIdcardNum'] = $patient_family['id_number']; // 患者证件号码
|
|
||||||
$data['serviceType'] = 1; // 服务类型 1网络咨询 2网络门诊
|
|
||||||
$data['consultNo'] = $order_inquiry['inquiry_no']; // 网络咨询或网络门诊编号 订单编号
|
|
||||||
$data['consultType'] = 1; // 咨询类别 1、图文咨询 2语音咨询3、视频咨询
|
|
||||||
$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已回复
|
|
||||||
$data['patientEvaluate'] = 1; //患者满意度 1-5 1代表非常满意 5代表非常不满意
|
|
||||||
$data['complainInfo'] = "无"; //投诉举报信息
|
|
||||||
$data['disposeResult'] = "无"; //处理结果信息
|
|
||||||
$data['isRiskWarn'] = 1; //是否进行诊前风险提示 0否 1是
|
|
||||||
$data['isPatientSign'] = 1; //是否确认患者为签约对象 0否 1是
|
|
||||||
$data['uploadTime'] = date('Y-m-d H:i:s', time()); //上传时间
|
|
||||||
$data['medicalHistory'] = $order_inquiry_case['disease_desc']; //患者病史描述
|
|
||||||
$data['docAdvice'] = $order_prescription['doctor_advice'] ?? "无"; // 医生建议描述 医嘱
|
|
||||||
$data['cityId'] = "510100"; // 城市ID(参考地区字段)
|
|
||||||
$data['isMark'] = 1;//是否留痕 1:代表留痕;0代表未留痕
|
|
||||||
} else {
|
|
||||||
$this->line("信息:患者复诊");
|
|
||||||
// 获取患者首次问诊病例数据
|
|
||||||
$params = array();
|
|
||||||
$params['patient_id'] = $order_inquiry['patient_id'];
|
|
||||||
$params['pharmacist_audit_status'] = 1;
|
|
||||||
|
|
||||||
$prescription_status_params = [2, 3, 4];
|
|
||||||
$first_order_prescription = OrderPrescription::getStatusOne($params, $prescription_status_params);
|
|
||||||
if (empty($first_order_prescription)) {
|
|
||||||
// 复诊,但是未找到复诊处方单
|
|
||||||
$this->line("错误:无初诊处方单");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$first_order_prescription = $first_order_prescription->toArray();
|
|
||||||
|
|
||||||
// 获取患者初诊疾病诊断数据
|
|
||||||
$params = array();
|
|
||||||
$params['order_prescription_id'] = $first_order_prescription['order_prescription_id'];
|
|
||||||
$first_order_prescription_icd = OrderPrescriptionIcd::getList($params);
|
|
||||||
if (empty($first_order_prescription_icd)) {
|
|
||||||
// 复诊,但是未找到关联疾病
|
|
||||||
$this->line("错误:无初诊疾病诊断数据");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$first_icd_name_data = array_column($first_order_prescription_icd->toArray(), 'icd_name');
|
|
||||||
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];
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取患者复诊疾病诊断数据
|
|
||||||
$params = array();
|
|
||||||
$params['order_prescription_id'] = $order_prescription['order_prescription_id'];
|
|
||||||
$order_prescription_icd = OrderPrescriptionIcd::getList($params);
|
|
||||||
if (empty($order_prescription_icd)) {
|
|
||||||
// 复诊,但是未找到关联疾病
|
|
||||||
$this->line("错误:无复诊疾病诊断数据");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$icd_name_data = array_column($order_prescription_icd->toArray(), 'icd_name');
|
|
||||||
if (!empty($icd_name_data)) {
|
|
||||||
if (count($icd_name_data) > 1) {
|
|
||||||
$icd_name = implode('|', $icd_name_data);
|
|
||||||
} else {
|
|
||||||
$icd_name = $icd_name_data[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// icd编码
|
|
||||||
$icd_code_data = array_column($order_prescription_icd->toArray(), 'icd_code');
|
|
||||||
if (!empty($icd_code_data)) {
|
|
||||||
if (count($icd_code_data) > 1) {
|
|
||||||
$icd_code = implode('|', $icd_code_data);
|
|
||||||
} else {
|
|
||||||
$icd_code = $icd_code_data[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 网络复诊服务
|
|
||||||
$data = array();
|
|
||||||
$data['thirdUniqueid'] = $order_inquiry['order_inquiry_id']; // 唯一标识
|
|
||||||
$data['orgName'] = "成都金牛欣欣相照互联网医院"; // 机构名称
|
|
||||||
$data['orgCode'] = "MA6CGUDA251010619D2112"; // 机构编码
|
|
||||||
$data['channelName'] = "成都金牛欣欣相照互联网医院";//平台名称
|
|
||||||
$data['section'] = $hospital_department_custom['department_name'];//科室名称
|
|
||||||
$data['sectionCode'] = $hospital_department_custom['department_code'];//科室编码
|
|
||||||
$data['docName'] = $user_doctor['user_name'];// 复诊医师姓名
|
|
||||||
$data['certificateNum'] = $user_doctor_info['qualification_cert_num']; // 执业资格证号
|
|
||||||
$data['patientName'] = $order_inquiry['patient_name']; // 患者姓名
|
|
||||||
$data['patientAge'] = (int)$order_inquiry['patient_age']; // 患者年龄
|
|
||||||
$data['patientSex'] = $order_inquiry['patient_sex'] == 0 ?: 1; // 患者性别
|
|
||||||
$data['patientIdcardType'] = 1; // 证件类型
|
|
||||||
$data['patientIdcardNum'] = $patient_family['id_number']; // 患者证件号码
|
|
||||||
$data['furtherConsultNo'] = $order_inquiry['order_inquiry_id']; // 网络复诊编号
|
|
||||||
$data['furtherConsulType'] = "1"; // 复诊类别 1、图文诊疗 2、语音诊疗 3、视频诊疗
|
|
||||||
$data['medicalHistory'] = $order_inquiry_case['disease_desc']; //患者病史描述
|
|
||||||
$data['consultDiagnosisType'] = 1; // 首诊诊断类型
|
|
||||||
$data['consultDiagnosis'] = $first_icd_name; // 首诊诊断 复诊患者在首诊医院的诊断,如有多条,使用“|”进行分隔;当传图片时,需要传图片的base64字符串
|
|
||||||
$data['consultTime'] = date('Y-m-d H:i:s',strtotime($first_order_prescription['doctor_created_time'])); // 首诊时间
|
|
||||||
$data['consultOrg'] = "成都金牛欣欣相照互联网医院"; // 首诊机构
|
|
||||||
$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; // 复诊诊断 复诊患者在实体医院的诊断名称,如有多条,使用“|”进行分隔
|
|
||||||
$data['furtherConsultDiagnosisNo'] = $icd_code; // 复诊icd诊断编码
|
|
||||||
$data['furtherConsultPrice'] = $order_inquiry['payment_amount_total']; // 复诊价格
|
|
||||||
$data['patientEvaluate'] = 1; // 患者满意度 1-5 1代表非常满意 5代表非常不满意
|
|
||||||
$data['complainInfo'] = "无"; // 投诉举报信息
|
|
||||||
$data['disposeResult'] = "无"; // 处理结果信息
|
|
||||||
$data['isRiskWarn'] = 1; // 是否进行诊前风险提示 0否 1是
|
|
||||||
$data['isPatientSign'] = 1; // 是否确认患者为签约对象 0否 1是
|
|
||||||
$data['isPrescription'] = 1; // 是否开具处方 0否 1是
|
|
||||||
$data['uploadTime'] = date('Y-m-d H:i:s', time()); // 上传时间
|
|
||||||
$data['cityId'] = "510100"; // 城市ID(参考地区字段)
|
|
||||||
$data['isMark'] = 1;//是否留痕 1:代表留痕;0代表未留痕
|
|
||||||
}
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 上报问诊
|
|
||||||
* @param array|object $report_regulatory
|
|
||||||
* @param array|object $order_inquiry
|
|
||||||
* @param array|object $order_prescription
|
|
||||||
* @throws ContainerExceptionInterface
|
|
||||||
* @throws NotFoundExceptionInterface
|
|
||||||
*/
|
|
||||||
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]);
|
|
||||||
} else {
|
|
||||||
$result = $regulatoryPlatform->uploadFurtherConsult([$report_inquiry_data]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$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());
|
|
||||||
// 上报失败
|
|
||||||
$res = $this->modifyReportRegulatoryInquiry($report_regulatory, 2, $is_first ? 1 : 2, $e->getMessage());
|
|
||||||
if (!$res) {
|
|
||||||
// 记录失败
|
|
||||||
$this->line("错误:上报失败,存储记录失败");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取上报监管数据-处方
|
|
||||||
* @param array|object $order_inquiry
|
* @param array|object $order_inquiry
|
||||||
* @param array|object $order_prescription
|
* @param array|object $order_prescription
|
||||||
* @return bool|array
|
* @return bool|array
|
||||||
@ -659,51 +461,6 @@ class ReportRegulatoryCommand extends HyperfCommand
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 上报处方
|
|
||||||
* @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|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));
|
|
||||||
|
|
||||||
// 上报成功
|
|
||||||
$res = $this->modifyReportRegulatoryPrescription($report_regulatory, 1);
|
|
||||||
if (!$res) {
|
|
||||||
// 记录失败
|
|
||||||
$this->line("错误:上报成功,存储记录失败");
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
}catch (\Exception $e){
|
|
||||||
$this->line("错误:" . $e->getMessage());
|
|
||||||
// 上报失败
|
|
||||||
$res = $this->modifyReportRegulatoryPrescription($report_regulatory, 2, $e->getMessage());
|
|
||||||
if (!$res) {
|
|
||||||
// 记录失败
|
|
||||||
$this->line("错误:上报失败,存储记录失败");
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取处方商品数据
|
* 获取处方商品数据
|
||||||
* @param string $order_prescription_id
|
* @param string $order_prescription_id
|
||||||
@ -778,4 +535,214 @@ class ReportRegulatoryCommand extends HyperfCommand
|
|||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取上报数据-网络咨询
|
||||||
|
* @param array|object $order_inquiry
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function getConsultData(array|object $order_inquiry): array
|
||||||
|
{
|
||||||
|
// 获取医生数据
|
||||||
|
$params = array();
|
||||||
|
$params['doctor_id'] = $order_inquiry['doctor_id'];
|
||||||
|
$user_doctor = UserDoctor::getOne($params);
|
||||||
|
if (empty($user_doctor)) {
|
||||||
|
$this->line("错误:医生数据错误");
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$params = array();
|
||||||
|
$params['doctor_id'] = $order_inquiry['doctor_id'];
|
||||||
|
$user_doctor_info = UserDoctorInfo::getOne($params);
|
||||||
|
if (empty($user_doctor_info)) {
|
||||||
|
$this->line("错误:医生详情数据错误");
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取医生自定义科室数据
|
||||||
|
$params = array();
|
||||||
|
$params['department_custom_id'] = $user_doctor['department_custom_id'];
|
||||||
|
$hospital_department_custom = HospitalDepartmentCustom::getOne($params);
|
||||||
|
if (empty($hospital_department_custom)) {
|
||||||
|
$this->line("错误:医生自定义数据错误");
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取问诊患者数据
|
||||||
|
$params = array();
|
||||||
|
$params['family_id'] = $order_inquiry['family_id'];
|
||||||
|
$patient_family = PatientFamily::getOne($params);
|
||||||
|
if (empty($patient_family)) {
|
||||||
|
$this->line("错误:问诊患者数据错误");
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取患者问诊病例
|
||||||
|
$params = array();
|
||||||
|
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||||
|
$params['status'] = 1;
|
||||||
|
$order_inquiry_case = OrderInquiryCase::getOne($params);
|
||||||
|
if (empty($order_inquiry_case)) {
|
||||||
|
$this->line("错误:患者问诊病例错误");
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 网络咨询(网络门诊)服务
|
||||||
|
$data = array();
|
||||||
|
$data['thirdUniqueid'] = $order_inquiry['order_inquiry_id']; // 唯一标识
|
||||||
|
$data['orgName'] = "成都金牛欣欣相照互联网医院"; // 机构名称
|
||||||
|
$data['orgCode'] = "MA6CGUDA251010619D2112"; // 机构编码
|
||||||
|
$data['channelName'] = "成都金牛欣欣相照互联网医院";//平台名称
|
||||||
|
$data['section'] = $hospital_department_custom['department_name'];//科室名称
|
||||||
|
$data['sectionCode'] = $hospital_department_custom['department_code'];//科室编码
|
||||||
|
$data['docName'] = $user_doctor['user_name'];// 姓名(医师、护师、技师)
|
||||||
|
$data['certificateNum'] = $user_doctor_info['qualification_cert_num']; // 执业资格证号
|
||||||
|
$data['patientName'] = $order_inquiry['patient_name']; // 患者姓名
|
||||||
|
$data['patientAge'] = (int)$order_inquiry['patient_age']; // 患者年龄
|
||||||
|
$data['patientSex'] = $order_inquiry['patient_sex'] == 0 ?: 1; // 患者性别
|
||||||
|
$data['patientIdcardType'] = 1; // 证件类型
|
||||||
|
$data['patientIdcardNum'] = $patient_family['id_number']; // 患者证件号码
|
||||||
|
$data['serviceType'] = 1; // 服务类型 1网络咨询 2网络门诊
|
||||||
|
$data['consultNo'] = $order_inquiry['inquiry_no']; // 网络咨询或网络门诊编号 订单编号
|
||||||
|
$data['consultType'] = 1; // 咨询类别 1、图文咨询 2语音咨询3、视频咨询
|
||||||
|
$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已回复
|
||||||
|
$data['patientEvaluate'] = 1; //患者满意度 1-5 1代表非常满意 5代表非常不满意
|
||||||
|
$data['complainInfo'] = "无"; //投诉举报信息
|
||||||
|
$data['disposeResult'] = "无"; //处理结果信息
|
||||||
|
$data['isRiskWarn'] = 1; //是否进行诊前风险提示 0否 1是
|
||||||
|
$data['isPatientSign'] = 1; //是否确认患者为签约对象 0否 1是
|
||||||
|
$data['uploadTime'] = date('Y-m-d H:i:s', time()); //上传时间
|
||||||
|
$data['medicalHistory'] = $order_inquiry_case['disease_desc']; //患者病史描述
|
||||||
|
$data['docAdvice'] = $order_prescription['doctor_advice'] ?? "无"; // 医生建议描述 医嘱
|
||||||
|
$data['cityId'] = "510100"; // 城市ID(参考地区字段)
|
||||||
|
$data['isMark'] = 1;//是否留痕 1:代表留痕;0代表未留痕
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取上报数据-复诊
|
||||||
|
* @param array|object $order_inquiry
|
||||||
|
* @param array|object $order_prescription
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function getFurtherConsultData(array|object $order_inquiry,array|object $order_prescription): array
|
||||||
|
{
|
||||||
|
// 获取医生数据
|
||||||
|
$params = array();
|
||||||
|
$params['doctor_id'] = $order_inquiry['doctor_id'];
|
||||||
|
$user_doctor = UserDoctor::getOne($params);
|
||||||
|
if (empty($user_doctor)) {
|
||||||
|
$this->line("医生数据错误");
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$params = array();
|
||||||
|
$params['doctor_id'] = $order_inquiry['doctor_id'];
|
||||||
|
$user_doctor_info = UserDoctorInfo::getOne($params);
|
||||||
|
if (empty($user_doctor_info)) {
|
||||||
|
$this->line("医生详情数据错误");
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取医生自定义科室数据
|
||||||
|
$params = array();
|
||||||
|
$params['department_custom_id'] = $user_doctor['department_custom_id'];
|
||||||
|
$hospital_department_custom = HospitalDepartmentCustom::getOne($params);
|
||||||
|
if (empty($hospital_department_custom)) {
|
||||||
|
$this->line("医生自定义数据错误");
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取问诊患者数据
|
||||||
|
$params = array();
|
||||||
|
$params['family_id'] = $order_inquiry['family_id'];
|
||||||
|
$patient_family = PatientFamily::getOne($params);
|
||||||
|
if (empty($patient_family)) {
|
||||||
|
$this->line("问诊患者数据错误");
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取患者问诊病例
|
||||||
|
$params = array();
|
||||||
|
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||||
|
$params['status'] = 1;
|
||||||
|
$order_inquiry_case = OrderInquiryCase::getOne($params);
|
||||||
|
if (empty($order_inquiry_case)) {
|
||||||
|
$this->line("患者问诊病例错误");
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取患者复诊疾病诊断数据
|
||||||
|
$params = array();
|
||||||
|
$params['order_prescription_id'] = $order_prescription['order_prescription_id'];
|
||||||
|
$order_prescription_icd = OrderPrescriptionIcd::getList($params);
|
||||||
|
if (empty($order_prescription_icd)) {
|
||||||
|
// 复诊,但是未找到关联疾病
|
||||||
|
$this->line("无复诊疾病诊断数据");
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$icd_name_data = array_column($order_prescription_icd->toArray(), 'icd_name');
|
||||||
|
if (count($icd_name_data) > 1) {
|
||||||
|
$icd_name = implode('|', $icd_name_data);
|
||||||
|
} else {
|
||||||
|
$icd_name = $icd_name_data[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
$icd_code_data = array_column($order_prescription_icd->toArray(), 'icd_code');
|
||||||
|
if (count($icd_code_data) > 1) {
|
||||||
|
$icd_code = implode('|', $icd_code_data);
|
||||||
|
} else {
|
||||||
|
$icd_code = $icd_code_data[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 网络复诊服务
|
||||||
|
$data = array();
|
||||||
|
$data['thirdUniqueid'] = $order_inquiry['order_inquiry_id']; // 唯一标识
|
||||||
|
$data['orgName'] = "成都金牛欣欣相照互联网医院"; // 机构名称
|
||||||
|
$data['orgCode'] = "MA6CGUDA251010619D2112"; // 机构编码
|
||||||
|
$data['channelName'] = "成都金牛欣欣相照互联网医院";//平台名称
|
||||||
|
$data['section'] = $hospital_department_custom['department_name'];//科室名称
|
||||||
|
$data['sectionCode'] = $hospital_department_custom['department_code'];//科室编码
|
||||||
|
$data['docName'] = $user_doctor['user_name'];// 复诊医师姓名
|
||||||
|
$data['certificateNum'] = $user_doctor_info['qualification_cert_num']; // 执业资格证号
|
||||||
|
$data['patientName'] = $order_inquiry['patient_name']; // 患者姓名
|
||||||
|
$data['patientAge'] = (int)$order_inquiry['patient_age']; // 患者年龄
|
||||||
|
$data['patientSex'] = $order_inquiry['patient_sex'] == 0 ?: 1; // 患者性别
|
||||||
|
$data['patientIdcardType'] = 1; // 证件类型
|
||||||
|
$data['patientIdcardNum'] = $patient_family['id_number']; // 患者证件号码
|
||||||
|
$data['furtherConsultNo'] = $order_inquiry['order_inquiry_id']; // 网络复诊编号
|
||||||
|
$data['furtherConsulType'] = "1"; // 复诊类别 1、图文诊疗 2、语音诊疗 3、视频诊疗
|
||||||
|
$data['medicalHistory'] = $order_inquiry_case['disease_desc']; //患者病史描述
|
||||||
|
$data['consultDiagnosisType'] = 1; // 首诊诊断类型
|
||||||
|
$data['consultDiagnosis'] = $order_inquiry_case['disease_class_name']; // 首诊诊断 复诊患者在首诊医院的诊断,如有多条,使用“|”进行分隔;当传图片时,需要传图片的base64字符串
|
||||||
|
$data['consultTime'] = date('Y-m-d H:i:s',strtotime($order_inquiry_case['diagnosis_date'])); // 首诊时间(使用确诊时间)
|
||||||
|
$data['consultOrg'] = "成都金牛欣欣相照互联网医院"; // 首诊机构
|
||||||
|
$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; // 复诊诊断 复诊患者在实体医院的诊断名称,如有多条,使用“|”进行分隔
|
||||||
|
$data['furtherConsultDiagnosisNo'] = $icd_code; // 复诊icd诊断编码
|
||||||
|
$data['furtherConsultPrice'] = $order_inquiry['payment_amount_total']; // 复诊价格
|
||||||
|
$data['patientEvaluate'] = 1; // 患者满意度 1-5 1:代表非常满意 5:代表非常不满意
|
||||||
|
$data['complainInfo'] = "无"; // 投诉举报信息
|
||||||
|
$data['disposeResult'] = "无"; // 处理结果信息
|
||||||
|
$data['isRiskWarn'] = 1; // 是否进行诊前风险提示 0否 1是
|
||||||
|
$data['isPatientSign'] = 1; // 是否确认患者为签约对象 0否 1是
|
||||||
|
$data['isPrescription'] = 1; // 是否开具处方 0否 1是
|
||||||
|
$data['uploadTime'] = date('Y-m-d H:i:s', time()); // 上传时间
|
||||||
|
$data['cityId'] = "510100"; // 城市ID(参考地区字段)
|
||||||
|
$data['isMark'] = 1;//是否留痕 1:代表留痕;0:代表未留痕
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,11 +15,16 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
|||||||
* @property int $order_inquiry_id 订单-问诊id
|
* @property int $order_inquiry_id 订单-问诊id
|
||||||
* @property int $order_prescription_id 订单-处方表id(无需上报处方时为null)
|
* @property int $order_prescription_id 订单-处方表id(无需上报处方时为null)
|
||||||
* @property int $order_product_id 订单-商品表id(无需上报处方时为null)
|
* @property int $order_product_id 订单-商品表id(无需上报处方时为null)
|
||||||
* @property int $report_inquiry_status 问诊上报状态(0:未上报 1:已上报 2:上报失败)
|
* @property int $report_consult_status 上报网络咨询状态(0:未上报 1:已上报 2:上报失败)
|
||||||
* @property int $report_inquiry_int 问诊上报次数
|
* @property int $report_consult_int 网络咨询上报次数
|
||||||
* @property int $report_inquiry_type 问诊上报类型(1:网络初诊 2:网络复诊)
|
* @property string $report_consult_time 网络咨询上报时间
|
||||||
* @property string $report_inquiry_time 问诊上报时间
|
* @property string $report_consult_fail_reason 网络咨询上报失败原因
|
||||||
* @property string $report_inquiry_fail_reason 问诊上报失败原因
|
* @property int $is_further_consult 是否需要上报网络复诊(0:否 1:是)
|
||||||
|
* @property int $report_further_consult_status 上报网络复诊状态(0:未上报 1:已上报 2:上报失败)
|
||||||
|
* @property int $report_further_consult_int 网络复诊上报次数
|
||||||
|
* @property string $report_further_consult_time 网络复诊上报时间
|
||||||
|
* @property string $report_further_consult_fail_reason 网络复诊上报失败原因
|
||||||
|
* @property int $is_prescription 是否需要上报处方(0:否 1:是)
|
||||||
* @property int $report_prescription_status 处方上报状态(0:未上报 1:已上报 2:上报失败)
|
* @property int $report_prescription_status 处方上报状态(0:未上报 1:已上报 2:上报失败)
|
||||||
* @property int $report_prescription_int 处方上报次数
|
* @property int $report_prescription_int 处方上报次数
|
||||||
* @property string $report_prescription_time 处方上报时间
|
* @property string $report_prescription_time 处方上报时间
|
||||||
@ -39,11 +44,10 @@ class ReportRegulatory extends Model
|
|||||||
/**
|
/**
|
||||||
* The attributes that are mass assignable.
|
* The attributes that are mass assignable.
|
||||||
*/
|
*/
|
||||||
protected array $fillable = ['report_regulatory_id', 'order_inquiry_id', 'order_prescription_id', 'order_product_id', 'report_inquiry_status', 'report_inquiry_int', 'report_inquiry_type', 'report_inquiry_time', 'report_inquiry_fail_reason', 'report_prescription_status', 'report_prescription_int', 'report_prescription_time', 'report_prescription_fail_reason', 'created_at', 'updated_at'];
|
protected array $fillable = ['report_regulatory_id', 'order_inquiry_id', 'order_prescription_id', 'order_product_id', 'report_consult_status', 'report_consult_int', 'report_consult_time', 'report_consult_fail_reason', 'is_further_consult', 'report_further_consult_status', 'report_further_consult_int', 'report_further_consult_time', 'report_further_consult_fail_reason', 'is_prescription', 'report_prescription_status', 'report_prescription_int', 'report_prescription_time', 'report_prescription_fail_reason', 'created_at', 'updated_at'];
|
||||||
|
|
||||||
protected string $primaryKey = "report_regulatory_id";
|
protected string $primaryKey = "report_regulatory_id";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取信息-单条
|
* 获取信息-单条
|
||||||
* @param array $params
|
* @param array $params
|
||||||
@ -116,23 +120,6 @@ class ReportRegulatory extends Model
|
|||||||
->get($fields);
|
->get($fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 列表
|
|
||||||
* @param array $params
|
|
||||||
* @param array $or_params
|
|
||||||
* @param array $fields
|
|
||||||
* @return Collection|array
|
|
||||||
*/
|
|
||||||
public static function getNotReportList(array $params = [],array $fields = ["*"]): Collection|array
|
|
||||||
{
|
|
||||||
return self::where($params)
|
|
||||||
->Where(function ($query) {
|
|
||||||
$query->orWhere('report_inquiry_status','!=',1);
|
|
||||||
$query->orWhere('report_prescription_status','!=',1);
|
|
||||||
})
|
|
||||||
->get($fields);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检测是否存在
|
* 检测是否存在
|
||||||
* @param array $params
|
* @param array $params
|
||||||
@ -142,4 +129,29 @@ class ReportRegulatory extends Model
|
|||||||
{
|
{
|
||||||
return self::where($params)->exists();
|
return self::where($params)->exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取未上报监管平台列表
|
||||||
|
* @param array $fields
|
||||||
|
* @return Collection|array
|
||||||
|
*/
|
||||||
|
public static function getNotReportList(array $fields = ["*"]): Collection|array
|
||||||
|
{
|
||||||
|
return self::orWhere(function ($query) {
|
||||||
|
$query->Where('is_further_consult','=',1);
|
||||||
|
$query->Where('report_further_consult_status','!=',1);
|
||||||
|
$query->Where('report_further_consult_int','<',5);
|
||||||
|
})
|
||||||
|
->orWhere(function ($query) {
|
||||||
|
$query->Where('is_prescription','=',1);
|
||||||
|
$query->Where('report_prescription_status','!=',1);
|
||||||
|
$query->Where('report_prescription_int','<',5);
|
||||||
|
})
|
||||||
|
->orWhere(function ($query) {
|
||||||
|
$query->Where('report_consult_status','!=',1);
|
||||||
|
$query->Where('report_consult_int','<',5);
|
||||||
|
})
|
||||||
|
->get($fields);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
|
use App\Model\OrderPrescription;
|
||||||
use App\Model\ReportRegulatory;
|
use App\Model\ReportRegulatory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -15,22 +16,34 @@ class ReportRegulatoryService extends BaseService
|
|||||||
* @param string $order_prescription_id
|
* @param string $order_prescription_id
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function addReportRegulatory(string $order_inquiry_id,string $order_prescription_id): bool
|
public function addReportRegulatory(string $order_inquiry_id): bool
|
||||||
{
|
{
|
||||||
// 检测是否已添加
|
// 检测是否已添加数据
|
||||||
$params = array();
|
$params = array();
|
||||||
$params['order_inquiry_id'] = $order_inquiry_id;
|
$params['order_inquiry_id'] = $order_inquiry_id;
|
||||||
$res = ReportRegulatory::getExists($params);
|
$report_regulatory = ReportRegulatory::getOne($params);
|
||||||
if ($res) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = array();
|
|
||||||
$data['order_inquiry_id'] = $order_inquiry_id;
|
|
||||||
$data['order_prescription_id'] = $order_prescription_id;
|
|
||||||
$report_regulatory = ReportRegulatory::addReportRegulatory($data);
|
|
||||||
if (empty($report_regulatory)){
|
if (empty($report_regulatory)){
|
||||||
return false;
|
// 检测是否存在处方
|
||||||
|
$params = array();
|
||||||
|
$params['order_inquiry_id'] = $order_inquiry_id;
|
||||||
|
$params['pharmacist_audit_status'] = 1;
|
||||||
|
$params['platform_audit_status'] = 1;
|
||||||
|
$order_prescription = OrderPrescription::getOne($params);
|
||||||
|
|
||||||
|
// 添加数据
|
||||||
|
$data = array();
|
||||||
|
$data['order_inquiry_id'] = $order_inquiry_id;
|
||||||
|
if (!empty($order_prescription)){
|
||||||
|
$data['order_prescription_id'] = $order_prescription['order_prescription_id'];
|
||||||
|
$data['is_further_consult'] = 1;
|
||||||
|
$data['is_prescription'] = 1;
|
||||||
|
}
|
||||||
|
$report_regulatory = ReportRegulatory::addReportRegulatory($data);
|
||||||
|
if (empty($report_regulatory)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -9,7 +9,7 @@ use GuzzleHttp\Client;
|
|||||||
use GuzzleHttp\Exception\GuzzleException;
|
use GuzzleHttp\Exception\GuzzleException;
|
||||||
use Hyperf\Di\Annotation\Inject;
|
use Hyperf\Di\Annotation\Inject;
|
||||||
use Hyperf\Redis\Redis;
|
use Hyperf\Redis\Redis;
|
||||||
use Hyperf\Utils\ApplicationContext;
|
use Hyperf\Context\ApplicationContext;
|
||||||
use Psr\Container\ContainerExceptionInterface;
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
use Psr\Container\ContainerInterface;
|
use Psr\Container\ContainerInterface;
|
||||||
use Psr\Container\NotFoundExceptionInterface;
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
@ -35,9 +35,9 @@ class regulatoryPlatform
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
// 请求地址
|
// 请求地址
|
||||||
$this->api_url = config('regulatory_platform.api_url');
|
$this->api_url = \Hyperf\Config\config('regulatory_platform.api_url');
|
||||||
$this->client_id = config('regulatory_platform.client_id');
|
$this->client_id = \Hyperf\Config\config('regulatory_platform.client_id');
|
||||||
$this->client_secret = config('regulatory_platform.client_secret');
|
$this->client_secret = \Hyperf\Config\config('regulatory_platform.client_secret');
|
||||||
$this->container = ApplicationContext::getContainer();
|
$this->container = ApplicationContext::getContainer();
|
||||||
$this->client = $this->container->get(Client::class);
|
$this->client = $this->container->get(Client::class);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user