新增自动完成订单,处理处方数据,修改获取问诊评价返回内容
This commit is contained in:
parent
67429ae31b
commit
3008c1f9bc
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@ function dump(...$vars)
|
||||
* @param string $message 返回提示信息
|
||||
* @return array
|
||||
*/
|
||||
function success(array|string $data = [], int $code = HttpEnumCode::HTTP_SUCCESS, string $message = ""): array
|
||||
function success(array|string|null $data = [], int $code = HttpEnumCode::HTTP_SUCCESS, string $message = ""): array
|
||||
{
|
||||
if (empty($message)) {
|
||||
$message = HttpEnumCode::getMessage($code);
|
||||
|
||||
@ -19,7 +19,7 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
||||
* @property int $patient_id 患者id
|
||||
* @property int $family_id 家庭成员id(就诊用户)
|
||||
* @property int $pharmacist_id 药师id
|
||||
* @property int $prescription_status 处方状态(1:待审核 3:待使用 4:已失效 5:已使用)
|
||||
* @property int $prescription_status 处方状态(1:待审核 2:待使用 3:已失效 4:已使用 5:已作废)
|
||||
* @property int $pharmacist_audit_status 药师审核状态(0:审核中 1:审核成功 2:审核驳回)
|
||||
* @property string $pharmacist_verify_time 药师审核时间
|
||||
* @property string $pharmacist_fail_reason 药师审核驳回原因
|
||||
@ -27,12 +27,15 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
||||
* @property string $platform_fail_time 平台审核失败时间
|
||||
* @property string $platform_fail_reason 处方平台驳回原因
|
||||
* @property string $doctor_created_time 医生开具处方时间
|
||||
* @property string $expired_time 处方过期时间
|
||||
* @property string $void_time 处方做废时间
|
||||
* @property int $is_delete 是否删除(0:否 1:是)
|
||||
* @property string $prescription_code 处方编号
|
||||
* @property string $doctor_name 医生名称
|
||||
* @property string $patient_name 患者姓名-就诊人
|
||||
* @property int $patient_sex 患者性别-就诊人(1:男 2:女)
|
||||
* @property int $patient_age 患者年龄-就诊人
|
||||
* @property string $prescription_pdf 处方pdf
|
||||
* @property string $prescription_img 处方图片
|
||||
* @property string $doctor_advice 医嘱
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
@ -53,7 +56,7 @@ class OrderPrescription extends Model
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['order_prescription_id', 'order_inquiry_id', 'doctor_id', 'patient_id', 'family_id', 'pharmacist_id', 'prescription_status', 'pharmacist_audit_status', 'pharmacist_verify_time', 'pharmacist_fail_reason', 'platform_audit_status', 'platform_fail_time', 'platform_fail_reason', 'doctor_created_time', 'is_delete', 'prescription_code', 'doctor_name', 'patient_name', 'patient_sex', 'patient_age', 'prescription_img', 'doctor_advice', 'created_at', 'updated_at'];
|
||||
protected array $fillable = ['order_prescription_id', 'order_inquiry_id', 'doctor_id', 'patient_id', 'family_id', 'pharmacist_id', 'prescription_status', 'pharmacist_audit_status', 'pharmacist_verify_time', 'pharmacist_fail_reason', 'platform_audit_status', 'platform_fail_time', 'platform_fail_reason', 'doctor_created_time', 'expired_time', 'void_time', 'is_delete', 'prescription_code', 'doctor_name', 'patient_name', 'patient_sex', 'patient_age', 'prescription_pdf', 'prescription_img', 'doctor_advice', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "order_prescription_id";
|
||||
|
||||
|
||||
@ -538,7 +538,7 @@ class InquiryService extends BaseService
|
||||
$params['patient_id'] = $user_info['client_user_id'];
|
||||
$order_inquiry = OrderInquiry::getOne($params);
|
||||
if (empty($order_inquiry)) {
|
||||
return success();
|
||||
return success(null);
|
||||
}
|
||||
|
||||
// 检测是否评价过
|
||||
@ -548,7 +548,7 @@ class InquiryService extends BaseService
|
||||
$params['order_inquiry_id'] = $order_inquiry_id;;
|
||||
$order_evaluation = OrderEvaluation::getOne($params);
|
||||
if (empty($order_evaluation)) {
|
||||
return success();
|
||||
return success(null);
|
||||
}
|
||||
|
||||
$order_evaluation = $order_evaluation->toArray();
|
||||
|
||||
@ -564,7 +564,7 @@ class OrderPrescriptionService extends BaseService
|
||||
}
|
||||
|
||||
// 上报处方平台
|
||||
public function reportPrescription(array $order_inquiry, array $order_prescription, array $order_prescription_product, array $order_product)
|
||||
public function reportPrescription(array $order_inquiry, array $order_prescription, array $order_prescription_product, array $order_product): array
|
||||
{
|
||||
$wg = new WaitGroup();
|
||||
$wg->add(8);
|
||||
@ -810,4 +810,5 @@ class OrderPrescriptionService extends BaseService
|
||||
|
||||
return $arg;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1023,6 +1023,22 @@ class UserDoctorService extends BaseService
|
||||
return fail(HttpEnumCode::SERVER_ERROR,"问诊订单数据为空");
|
||||
}
|
||||
|
||||
if ($order_inquiry['inquiry_status'] == 5){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"问诊已完成,无法重开处方");
|
||||
}
|
||||
|
||||
if ($order_inquiry['inquiry_status'] == 6){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"问诊已结束,无法重开处方");
|
||||
}
|
||||
|
||||
if ($order_inquiry['inquiry_status'] == 7){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"问诊已取消,无法重开处方");
|
||||
}
|
||||
|
||||
if ($order_inquiry['inquiry_status'] != 4){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"问诊状态错误,无法重开处方");
|
||||
}
|
||||
|
||||
Db::beginTransaction();
|
||||
|
||||
try {
|
||||
@ -1670,7 +1686,7 @@ class UserDoctorService extends BaseService
|
||||
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
$order_prescription = OrderPrescription::getOne($params);
|
||||
if (!empty($order_prescription)){
|
||||
if ($order_prescription['prescription_status'] == 1){
|
||||
if ($order_prescription['prescription_status'] == 1 && $order_prescription['pharmacist_audit_status'] == 0){
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "处方正在开具中,请您耐心等待,稍后取消");
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,9 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Amqp\Consumer\PrescriptionExpiredDelayDirectConsumer;
|
||||
use App\Amqp\Producer\AutoFinishInquiryDelayDirectProducer;
|
||||
use App\Amqp\Producer\PrescriptionExpiredDelayDirectProducer;
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Model\OrderInquiry;
|
||||
use App\Model\OrderPrescription;
|
||||
@ -11,7 +14,10 @@ use App\Model\UserDoctor;
|
||||
use App\Model\UserDoctorInfo;
|
||||
use App\Model\UserPharmacist;
|
||||
use App\Model\UserPharmacistInfo;
|
||||
use Hyperf\Amqp\Producer;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* 药师
|
||||
@ -123,6 +129,8 @@ class UserPharmacistService extends BaseService
|
||||
/**
|
||||
* 审核处方
|
||||
* @return array
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function putPrescriptionVerify(): array
|
||||
{
|
||||
@ -181,6 +189,7 @@ class UserPharmacistService extends BaseService
|
||||
}
|
||||
|
||||
// 获取处方商品数据
|
||||
$product_name = "";
|
||||
$params = array();
|
||||
$params['order_prescription_id'] = $order_prescription['order_prescription_id'];
|
||||
$order_prescription_product = OrderPrescriptionProduct::getList($params);
|
||||
@ -241,6 +250,19 @@ class UserPharmacistService extends BaseService
|
||||
// 发送目标不同,重新实例化
|
||||
$MessagePush = new MessagePush($user_doctor['user_id'],$order_inquiry['order_inquiry_id']);
|
||||
$MessagePush->prescriptionVerifySuccess();
|
||||
|
||||
// 添加处方过期队列
|
||||
$data = array();
|
||||
$data['order_prescription_id'] = (string)$order_prescription['order_prescription_id'];
|
||||
|
||||
$message = new PrescriptionExpiredDelayDirectProducer($data);
|
||||
$message->setDelayMs(1000 * 60 * 60 * 24 * 3);
|
||||
$producer = $this->container->get(Producer::class);
|
||||
$res = $producer->produce($message);
|
||||
if (!$res) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::SERVER_ERROR, "订单创建失败");
|
||||
}
|
||||
}else{
|
||||
// 站内、订阅失败发送短信-医生开具的处方审核未通过
|
||||
$MessagePush = new MessagePush($user_doctor['user_id'],$order_inquiry['order_inquiry_id']);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user