新增自动完成订单,处理处方数据,修改获取问诊评价返回内容
This commit is contained in:
@@ -9,8 +9,11 @@ use App\Model\DoctorAccountDay;
|
||||
use App\Model\OrderEvaluation;
|
||||
use App\Model\OrderInquiry;
|
||||
use App\Model\OrderInquiryCase;
|
||||
use App\Model\OrderPrescription;
|
||||
use App\Model\PatientFamilyHealth;
|
||||
use App\Model\PatientFamilyPersonal;
|
||||
use App\Model\UserDoctor;
|
||||
use App\Services\MessagePush;
|
||||
use App\Utils\Log;
|
||||
use Hyperf\Amqp\Message\ConsumerDelayedMessageTrait;
|
||||
use Hyperf\Amqp\Message\ProducerDelayedMessageTrait;
|
||||
@@ -20,6 +23,8 @@ use Hyperf\Amqp\Annotation\Consumer;
|
||||
use Hyperf\Amqp\Message\ConsumerMessage;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use PhpAmqpLib\Message\AMQPMessage;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* 自动完成问诊订单
|
||||
@@ -112,6 +117,8 @@ class AutoFinishInquiryDelayDirectConsumer extends ConsumerMessage
|
||||
// 处理回写患者病例-回写失败不做处理
|
||||
$this->handleOrderInquiryCase($order_inquiry);
|
||||
|
||||
// 处理处方数据
|
||||
$this->handlePrescription($order_inquiry);
|
||||
Db::commit();
|
||||
Log::getInstance()->info("自动完成问诊订单队列执行成功");
|
||||
return Result::ACK;
|
||||
@@ -376,4 +383,47 @@ class AutoFinishInquiryDelayDirectConsumer extends ConsumerMessage
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理处方数据
|
||||
* @param array|object $order_inquiry
|
||||
* @return void
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
protected function handlePrescription(array|object $order_inquiry): void
|
||||
{
|
||||
try {
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
$order_prescription = OrderPrescription::getList($params);
|
||||
if (!empty($order_prescription)){
|
||||
foreach ($order_prescription as $item){
|
||||
if ($item['prescription_status'] == 1 && $item['pharmacist_audit_status'] == 0){
|
||||
$params = array();
|
||||
$params['order_prescription_id'] = $item['order_prescription_id'];
|
||||
|
||||
$data = array();
|
||||
$data['pharmacist_audit_status'] = 2;
|
||||
$data['pharmacist_verify_time'] = date('Y-m-d H:i:s',time());
|
||||
$data['pharmacist_fail_reason'] = "药师过期未审核";
|
||||
|
||||
OrderPrescription::edit($params,$data);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取医生数据
|
||||
$params = array();
|
||||
$params['doctor_id'] = $order_inquiry['doctor_id'];
|
||||
$user_doctor = UserDoctor::getOne($params);
|
||||
if (!empty($user_doctor)){
|
||||
// 站内、订阅失败发送短信-医生开具的处方审核未通过
|
||||
$MessagePush = new MessagePush($user_doctor['user_id'],$order_inquiry['order_inquiry_id']);
|
||||
$MessagePush->prescriptionVerifyFail();
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::getInstance()->error("自动完成问诊订单队列执行失败:处理处方数据失败" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,14 +34,14 @@ class PrescriptionExpiredDelayDirectConsumer extends ConsumerMessage
|
||||
|
||||
public function consumeMessage($data, AMQPMessage $message): string
|
||||
{
|
||||
Log::getInstance()->error("开始执行 自动取消未使用处方 队列:" . json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
Log::getInstance()->error("开始执行 处方过期 队列:" . json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
|
||||
Db::beginTransaction();
|
||||
try {
|
||||
// 验证参数
|
||||
if (!isset($data['order_prescription_id'])){
|
||||
Db::rollBack();
|
||||
Log::getInstance()->error("自动取消未使用处方队列执行失败:入参错误");
|
||||
Log::getInstance()->error("处方过期队列执行失败:入参错误");
|
||||
return Result::DROP;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ class PrescriptionExpiredDelayDirectConsumer extends ConsumerMessage
|
||||
$order_prescription = OrderPrescription::getOne($params);
|
||||
if (empty($order_prescription)){
|
||||
Db::rollBack();
|
||||
Log::getInstance()->error("自动取消未使用处方队列执行失败:获取处方数据为空");
|
||||
Log::getInstance()->error("处方过期处方队列执行失败:获取处方数据为空");
|
||||
return Result::DROP;
|
||||
}
|
||||
|
||||
@@ -63,15 +63,14 @@ class PrescriptionExpiredDelayDirectConsumer extends ConsumerMessage
|
||||
}
|
||||
|
||||
// 处理处方过期状态
|
||||
|
||||
|
||||
$this->handlePrescription($order_prescription);
|
||||
|
||||
Db::commit();
|
||||
Log::getInstance()->info("自动取消未使用处方 队列执行成功");
|
||||
Log::getInstance()->info("处方过期 队列执行成功");
|
||||
return Result::ACK;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollBack();
|
||||
Log::getInstance()->error("自动取消未使用处方 执行失败:" . $e->getMessage());
|
||||
Log::getInstance()->error("处方过期 执行失败:" . $e->getMessage());
|
||||
return Result::ACK; // 重回队列
|
||||
}
|
||||
}
|
||||
@@ -85,25 +84,31 @@ class PrescriptionExpiredDelayDirectConsumer extends ConsumerMessage
|
||||
{
|
||||
if ($order_prescription['prescription_status'] == 3){
|
||||
Db::rollBack();
|
||||
Log::getInstance()->info("自动取消未使用处方队列执行失败:处方已失效,无需处理");
|
||||
Log::getInstance()->info("处方过期 队列执行失败:处方已失效,无需处理");
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($order_prescription['prescription_status'] == 4){
|
||||
Db::rollBack();
|
||||
Log::getInstance()->info("自动取消未使用处方队列执行失败:处方已使用,无需处理");
|
||||
Log::getInstance()->info("处方过期 队列执行失败:处方已使用,无需处理");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// 处理处方
|
||||
protected function handlePrescription(array|object $order_prescription){
|
||||
$pamras = array();
|
||||
$pamras['order_prescription_id'] = $order_prescription['order_prescription_id'];
|
||||
/**
|
||||
* 处理处方过期状态
|
||||
* @param array|object $order_prescription
|
||||
* @return void
|
||||
*/
|
||||
protected function handlePrescription(array|object $order_prescription): void
|
||||
{
|
||||
$params = array();
|
||||
$params['order_prescription_id'] = $order_prescription['order_prescription_id'];
|
||||
|
||||
$data = array();
|
||||
$data['prescription_status'] = 3;
|
||||
|
||||
$data['expired_time'] = date('Y-m-d H:i:s',time());
|
||||
OrderPrescription::edit($params,$data);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user