新增分配药师队列、新增处方开具、修改接口
This commit is contained in:
parent
e047f4971c
commit
d51d5355a0
@ -27,7 +27,7 @@ class CancelUnpayOrdersDelayDirectConsumer extends ConsumerMessage
|
|||||||
|
|
||||||
protected string $type = Type::DIRECT; //Type::FANOUT;
|
protected string $type = Type::DIRECT; //Type::FANOUT;
|
||||||
|
|
||||||
protected string|array $routingKey = '';
|
protected string|array $routingKey = 'CancelUnpayOrders';
|
||||||
|
|
||||||
public function consumeMessage($data, AMQPMessage $message): string
|
public function consumeMessage($data, AMQPMessage $message): string
|
||||||
{
|
{
|
||||||
|
|||||||
21
app/Amqp/Consumer/PrescriptionDistributePhConsumer.php
Normal file
21
app/Amqp/Consumer/PrescriptionDistributePhConsumer.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Amqp\Consumer;
|
||||||
|
|
||||||
|
use Hyperf\Amqp\Message\Type;
|
||||||
|
use Hyperf\Amqp\Result;
|
||||||
|
use Hyperf\Amqp\Annotation\Consumer;
|
||||||
|
use Hyperf\Amqp\Message\ConsumerMessage;
|
||||||
|
use PhpAmqpLib\Message\AMQPMessage;
|
||||||
|
|
||||||
|
#[Consumer(exchange: 'amqp.direct', routingKey: 'PrescriptionDistribute', queue: 'prescription.distribute.pharmacist.queue', nums: 1)]
|
||||||
|
class PrescriptionDistributePhConsumer extends ConsumerMessage
|
||||||
|
{
|
||||||
|
public function consumeMessage($data, AMQPMessage $message): string
|
||||||
|
{
|
||||||
|
dump($data);
|
||||||
|
return Result::ACK;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -10,11 +10,10 @@ use Hyperf\Amqp\Message\ProducerMessage;
|
|||||||
use Hyperf\Amqp\Message\Type;
|
use Hyperf\Amqp\Message\Type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 延迟队列
|
* 取消未支付订单生产者-延迟队列
|
||||||
* 生产者
|
|
||||||
*/
|
*/
|
||||||
#[Producer]
|
#[Producer]
|
||||||
class AmqpDelayDirectProducer extends ProducerMessage
|
class CancelUnpayOrdersDelayDirectProducer extends ProducerMessage
|
||||||
{
|
{
|
||||||
use ProducerDelayedMessageTrait;
|
use ProducerDelayedMessageTrait;
|
||||||
|
|
||||||
@ -22,7 +21,7 @@ class AmqpDelayDirectProducer extends ProducerMessage
|
|||||||
|
|
||||||
protected string $type = Type::DIRECT;
|
protected string $type = Type::DIRECT;
|
||||||
|
|
||||||
protected string|array $routingKey = '';
|
protected string|array $routingKey = 'CancelUnpayOrders';
|
||||||
|
|
||||||
public function __construct($data)
|
public function __construct($data)
|
||||||
{
|
{
|
||||||
21
app/Amqp/Producer/PrescriptionDistributePhProducer.php
Normal file
21
app/Amqp/Producer/PrescriptionDistributePhProducer.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Amqp\Producer;
|
||||||
|
|
||||||
|
use Hyperf\Amqp\Annotation\Producer;
|
||||||
|
use Hyperf\Amqp\Message\ProducerMessage;
|
||||||
|
use Hyperf\Amqp\Message\Type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 药师处方分配队列
|
||||||
|
*/
|
||||||
|
#[Producer(exchange: 'amqp.direct', routingKey: 'PrescriptionDistribute')]
|
||||||
|
class PrescriptionDistributePhProducer extends ProducerMessage
|
||||||
|
{
|
||||||
|
public function __construct($data)
|
||||||
|
{
|
||||||
|
$this->payload = $data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -21,12 +21,12 @@ class InquiryController extends AbstractController
|
|||||||
*/
|
*/
|
||||||
public function addInquiryOrder(): ResponseInterface
|
public function addInquiryOrder(): ResponseInterface
|
||||||
{
|
{
|
||||||
// $message = new AmqpDelayDirectProducer(10000);
|
// $message = new CancelUnpayOrdersDelayDirectProducer(10000);
|
||||||
// $message->setDelayMs(10000);
|
// $message->setDelayMs(10000);
|
||||||
// $producer = ApplicationContext::getContainer()->get(Producer::class);
|
// $producer = ApplicationContext::getContainer()->get(Producer::class);
|
||||||
// $producer->produce($message);
|
// $producer->produce($message);
|
||||||
//
|
//
|
||||||
// $message = new AmqpDelayDirectProducer(5000);
|
// $message = new CancelUnpayOrdersDelayDirectProducer(5000);
|
||||||
// $message->setDelayMs(5000);
|
// $message->setDelayMs(5000);
|
||||||
// $producer = ApplicationContext::getContainer()->get(Producer::class);
|
// $producer = ApplicationContext::getContainer()->get(Producer::class);
|
||||||
// $producer->produce($message);
|
// $producer->produce($message);
|
||||||
|
|||||||
@ -2,11 +2,16 @@
|
|||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use App\Amqp\Producer\PrescriptionDistributePhProducer;
|
||||||
|
use App\Constants\HttpEnumCode;
|
||||||
use App\Request\DoctorAuthRequest;
|
use App\Request\DoctorAuthRequest;
|
||||||
use App\Request\UserDoctorRequest;
|
use App\Request\UserDoctorRequest;
|
||||||
use App\Services\DoctorAuthService;
|
use App\Services\DoctorAuthService;
|
||||||
use App\Services\DoctorInquiryService;
|
use App\Services\DoctorInquiryService;
|
||||||
use App\Services\UserDoctorService;
|
use App\Services\UserDoctorService;
|
||||||
|
use Hyperf\Amqp\Producer;
|
||||||
|
use Hyperf\DbConnection\Db;
|
||||||
|
use Hyperf\Utils\ApplicationContext;
|
||||||
use Psr\Container\ContainerExceptionInterface;
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
use Psr\Container\NotFoundExceptionInterface;
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
@ -255,4 +260,20 @@ class UserDoctorController extends AbstractController
|
|||||||
$data = $UserDoctorService->putPrescription();
|
$data = $UserDoctorService->putPrescription();
|
||||||
return $this->response->json($data);
|
return $this->response->json($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增处方
|
||||||
|
* @return ResponseInterface
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
|
*/
|
||||||
|
public function addPrescription(): ResponseInterface
|
||||||
|
{
|
||||||
|
$request = $this->container->get(UserDoctorRequest::class);
|
||||||
|
$request->scene('addPrescription')->validateResolved();
|
||||||
|
|
||||||
|
$UserDoctorService = new UserDoctorService();
|
||||||
|
$data = $UserDoctorService->addPrescription();
|
||||||
|
return $this->response->json($data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -93,4 +93,26 @@ class DiseaseClassIcd extends Model
|
|||||||
->where($params)
|
->where($params)
|
||||||
->get($fields);
|
->get($fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取关键字搜索数据
|
||||||
|
* 限制数量
|
||||||
|
* @param array $params
|
||||||
|
* @param string $keyword
|
||||||
|
* @param array $fields
|
||||||
|
* @return Collection|array
|
||||||
|
*/
|
||||||
|
public static function getSearchKeywordLimit(array $params = [],string $keyword = '',array $fields = ['*']): Collection|array
|
||||||
|
{
|
||||||
|
return self::when($keyword, function ($query, $keyword) {
|
||||||
|
$query->where(function ($query) use ($keyword) {
|
||||||
|
$query->orwhere("icd_name", 'like', '%' . $keyword . '%');
|
||||||
|
$query->orwhere("icd_code", 'like', '%' . $keyword . '%');
|
||||||
|
$query->orwhere("icd_spell", 'like', '%' . $keyword . '%');
|
||||||
|
});
|
||||||
|
})
|
||||||
|
->where($params)
|
||||||
|
->limit(10)
|
||||||
|
->get($fields);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -136,4 +136,25 @@ class OrderPrescription extends Model
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改
|
||||||
|
* @param array $params
|
||||||
|
* @param array $data
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public static function edit(array $params = [], array $data = []): int
|
||||||
|
{
|
||||||
|
return self::where($params)->update($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增
|
||||||
|
* @param array $data
|
||||||
|
* @return \Hyperf\Database\Model\Model|OrderPrescription
|
||||||
|
*/
|
||||||
|
public static function addOrderPrescription(array $data): \Hyperf\Database\Model\Model|OrderPrescription
|
||||||
|
{
|
||||||
|
return self::create($data);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -65,4 +65,24 @@ class OrderPrescriptionIcd extends Model
|
|||||||
{
|
{
|
||||||
return self::where($params)->exists();
|
return self::where($params)->exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
* @param array $params
|
||||||
|
* @return int|mixed
|
||||||
|
*/
|
||||||
|
public static function deleteOrderPrescriptionIcd(array $params): mixed
|
||||||
|
{
|
||||||
|
return self::where($params)->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增
|
||||||
|
* @param array $data
|
||||||
|
* @return \Hyperf\Database\Model\Model|OrderPrescriptionIcd
|
||||||
|
*/
|
||||||
|
public static function addOrderPrescriptionIcd(array $data): \Hyperf\Database\Model\Model|OrderPrescriptionIcd
|
||||||
|
{
|
||||||
|
return self::create($data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@ namespace App\Model;
|
|||||||
|
|
||||||
|
|
||||||
use Hyperf\Database\Model\Collection;
|
use Hyperf\Database\Model\Collection;
|
||||||
|
use Hyperf\Database\Model\Model;
|
||||||
use Hyperf\Database\Model\Relations\HasOne;
|
use Hyperf\Database\Model\Relations\HasOne;
|
||||||
use Hyperf\Snowflake\Concern\Snowflake;
|
use Hyperf\Snowflake\Concern\Snowflake;
|
||||||
|
|
||||||
@ -113,4 +114,24 @@ class OrderPrescriptionProduct extends Model
|
|||||||
->limit(10)
|
->limit(10)
|
||||||
->get($fields);
|
->get($fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
* @param array $params
|
||||||
|
* @return int|mixed
|
||||||
|
*/
|
||||||
|
public static function deleteOrderPrescriptionProduct(array $params): mixed
|
||||||
|
{
|
||||||
|
return self::where($params)->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增
|
||||||
|
* @param array $data
|
||||||
|
* @return Model|OrderPrescriptionProduct
|
||||||
|
*/
|
||||||
|
public static function addOrderPrescriptionProduct(array $data): \Hyperf\Database\Model\Model|OrderPrescriptionProduct
|
||||||
|
{
|
||||||
|
return self::create($data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -56,11 +56,18 @@ class UserDoctorRequest extends FormRequest
|
|||||||
],
|
],
|
||||||
'getPrescriptionInfo' => [ // 获取处方详情
|
'getPrescriptionInfo' => [ // 获取处方详情
|
||||||
'order_inquiry_id',
|
'order_inquiry_id',
|
||||||
'order_prescription_id', // 处方id(非必须)
|
|
||||||
],
|
],
|
||||||
'putPrescription' => [ // 修改处方
|
'putPrescription' => [ // 修改处方
|
||||||
'order_prescription_id',
|
'order_prescription_id',
|
||||||
'order_prescription_id',
|
'prescription_icd',// 诊断疾病
|
||||||
|
'doctor_advice', // 医嘱
|
||||||
|
'prescription_product',// 处方药品
|
||||||
|
],
|
||||||
|
'addPrescription' => [ // 新增处方
|
||||||
|
'order_inquiry_id',// 订单-问诊id
|
||||||
|
'prescription_icd',// 诊断疾病[]
|
||||||
|
'doctor_advice', // 医嘱
|
||||||
|
'prescription_product',// 处方药品[]
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -94,6 +101,11 @@ class UserDoctorRequest extends FormRequest
|
|||||||
'doctor_id' => 'required',
|
'doctor_id' => 'required',
|
||||||
'evaluation_type' => 'required|integer|min:1|max:3',
|
'evaluation_type' => 'required|integer|min:1|max:3',
|
||||||
'order_inquiry_id' => 'required',
|
'order_inquiry_id' => 'required',
|
||||||
|
|
||||||
|
'order_prescription_id' => 'required',
|
||||||
|
'prescription_icd' => 'required|array|min:1',
|
||||||
|
'doctor_advice' => 'required',
|
||||||
|
'prescription_product' => 'required|array|min:1',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,6 +156,15 @@ class UserDoctorRequest extends FormRequest
|
|||||||
'evaluation_type.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
'evaluation_type.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
'evaluation_type.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
'evaluation_type.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
'order_inquiry_id.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
'order_inquiry_id.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
|
|
||||||
|
'order_prescription_id.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
|
'prescription_icd.required' => "请填写诊断疾病",
|
||||||
|
'prescription_icd.array' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
|
'prescription_icd.min' => "请填写诊断疾病",
|
||||||
|
'doctor_advice.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
|
'prescription_product.required' => "请开具药品",
|
||||||
|
'prescription_product.array' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
|
'prescription_product.min' => "请开具药品",
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -244,7 +244,7 @@ class BasicDataService extends BaseService
|
|||||||
$params = array();
|
$params = array();
|
||||||
$params['icd_status'] = 1;// 状态(0:删除 1:正常)
|
$params['icd_status'] = 1;// 状态(0:删除 1:正常)
|
||||||
$params['icd_enable'] = 1;// 是否启用(0:否 1:是)
|
$params['icd_enable'] = 1;// 是否启用(0:否 1:是)
|
||||||
$disease_class_icd = DiseaseClassIcd::getSearchKeywordList($params, $icd_keyword, $fields);
|
$disease_class_icd = DiseaseClassIcd::getSearchKeywordLimit($params, $icd_keyword, $fields);
|
||||||
if (empty($disease_class_icd)){
|
if (empty($disease_class_icd)){
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
use App\Amqp\Producer\AmqpDelayDirectProducer;
|
use App\Amqp\Producer\CancelUnpayOrdersDelayDirectProducer;
|
||||||
use App\Constants\HttpEnumCode;
|
use App\Constants\HttpEnumCode;
|
||||||
use App\Model\DiseaseClass;
|
use App\Model\DiseaseClass;
|
||||||
use App\Model\InquiryCaseProduct;
|
use App\Model\InquiryCaseProduct;
|
||||||
@ -234,7 +234,7 @@ class InquiryService extends BaseService
|
|||||||
$data = array();
|
$data = array();
|
||||||
$data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
$data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||||
|
|
||||||
$message = new AmqpDelayDirectProducer($data);
|
$message = new CancelUnpayOrdersDelayDirectProducer($data);
|
||||||
$message->setDelayMs(60 * 30 * 1000);
|
$message->setDelayMs(60 * 30 * 1000);
|
||||||
$producer = $this->container->get(Producer::class) ;
|
$producer = $this->container->get(Producer::class) ;
|
||||||
$res = $producer->produce($message);
|
$res = $producer->produce($message);
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
|
use App\Amqp\Producer\PrescriptionDistributePhProducer;
|
||||||
use App\Constants\HttpEnumCode;
|
use App\Constants\HttpEnumCode;
|
||||||
use App\Exception\BusinessException;
|
use App\Exception\BusinessException;
|
||||||
use App\Model\BasicBank;
|
use App\Model\BasicBank;
|
||||||
@ -19,12 +20,19 @@ use App\Model\OrderInquiry;
|
|||||||
use App\Model\OrderInquiryCase;
|
use App\Model\OrderInquiryCase;
|
||||||
use App\Model\OrderPrescription;
|
use App\Model\OrderPrescription;
|
||||||
use App\Model\OrderPrescriptionIcd;
|
use App\Model\OrderPrescriptionIcd;
|
||||||
|
use App\Model\OrderPrescriptionProduct;
|
||||||
use App\Model\OrderProductItem;
|
use App\Model\OrderProductItem;
|
||||||
|
use App\Model\Product;
|
||||||
use App\Model\User;
|
use App\Model\User;
|
||||||
use App\Model\UserDoctor;
|
use App\Model\UserDoctor;
|
||||||
use App\Model\UserDoctorInfo;
|
use App\Model\UserDoctorInfo;
|
||||||
use App\Utils\Mask;
|
use App\Utils\Mask;
|
||||||
|
use Hyperf\Amqp\Producer;
|
||||||
use Hyperf\DbConnection\Db;
|
use Hyperf\DbConnection\Db;
|
||||||
|
use Hyperf\Snowflake\IdGeneratorInterface;
|
||||||
|
use Hyperf\Utils\ApplicationContext;
|
||||||
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
|
|
||||||
class UserDoctorService extends BaseService
|
class UserDoctorService extends BaseService
|
||||||
{
|
{
|
||||||
@ -875,13 +883,344 @@ class UserDoctorService extends BaseService
|
|||||||
/**
|
/**
|
||||||
* 修改处方
|
* 修改处方
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
public function putPrescription(): array
|
public function putPrescription(): array
|
||||||
{
|
{
|
||||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||||
|
|
||||||
$order_inquiry_id = $this->request->input('order_inquiry_id');
|
|
||||||
$order_prescription_id = $this->request->input('order_prescription_id');
|
$order_prescription_id = $this->request->input('order_prescription_id');
|
||||||
|
$prescription_icd = $this->request->input('prescription_icd');
|
||||||
|
$doctor_advice = $this->request->input('doctor_advice');
|
||||||
|
$prescription_product = $this->request->input('prescription_product');
|
||||||
|
|
||||||
|
// 获取医生信息
|
||||||
|
$params = array();
|
||||||
|
$params['doctor_id'] = $user_info['client_user_id'];
|
||||||
|
|
||||||
|
$fields = [
|
||||||
|
'doctor_id',
|
||||||
|
'iden_auth_status',
|
||||||
|
'idcard_status',
|
||||||
|
'multi_point_status',
|
||||||
|
];
|
||||||
|
$user_doctor = UserDoctor::getOne($params, $fields);
|
||||||
|
if (empty($user_doctor)) {
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR, "非法医生");
|
||||||
|
}
|
||||||
|
|
||||||
|
$res = $this->checkDoctorAuth($user_doctor);
|
||||||
|
if ($res !== true) {
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR, $res);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取处方数据
|
||||||
|
$params = array();
|
||||||
|
$params['order_prescription_id'] = $order_prescription_id;
|
||||||
|
$params['doctor_id'] = $user_info['client_user_id'];
|
||||||
|
$order_prescription = OrderPrescription::getOne($params);
|
||||||
|
if (empty($order_prescription)) {
|
||||||
|
return fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检测处方状态
|
||||||
|
if ($order_prescription['prescription_status'] == 5) {
|
||||||
|
// 已使用
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR, "处方已使用,无法更改");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($order_prescription['is_delete'] == 1) {
|
||||||
|
// 已使用
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR, "处方已删除,无法更改");
|
||||||
|
}
|
||||||
|
|
||||||
|
Db::beginTransaction();
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 修改订单-处方表
|
||||||
|
$params = array();
|
||||||
|
$params['order_prescription_id'] = $order_prescription_id;
|
||||||
|
|
||||||
|
$data = array();
|
||||||
|
$data['prescription_status'] = 1; // 处方状态(1:待审核 3:待使用 4:已失效 5:已使用)
|
||||||
|
$data['pharmacist_fail_reason'] = ""; // 药师审核驳回原因
|
||||||
|
$data['platform_audit_status'] = 0; // 处方平台审核状态(0:审核中 1:审核成功 2:审核驳回)
|
||||||
|
$data['platform_fail_reason'] = ""; // 处方平台驳回原因
|
||||||
|
if ($order_prescription['doctor_advice'] != $doctor_advice) {
|
||||||
|
$data['doctor_advice'] = $doctor_advice; // 医嘱
|
||||||
|
}
|
||||||
|
|
||||||
|
OrderPrescription::edit($params, $data);
|
||||||
|
|
||||||
|
// 删除订单-处方关联疾病表
|
||||||
|
$params = array();
|
||||||
|
$params['order_prescription_id'] = $order_prescription_id;
|
||||||
|
OrderPrescriptionIcd::deleteOrderPrescriptionIcd($params);
|
||||||
|
|
||||||
|
foreach ($prescription_icd as $item) {
|
||||||
|
// 获取疾病信息
|
||||||
|
$params = array();
|
||||||
|
$params['icd_id'] = $item;
|
||||||
|
$disease_class_icd = DiseaseClassIcd::getOne($params);
|
||||||
|
if (empty($disease_class_icd)) {
|
||||||
|
Db::rollBack();
|
||||||
|
return fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增处方疾病
|
||||||
|
$data = array();
|
||||||
|
$data['order_prescription_id'] = $order_prescription_id;
|
||||||
|
$data['icd_id'] = $item;
|
||||||
|
$data['icd_name'] = $disease_class_icd['icd_name'];
|
||||||
|
$data['icd_code'] = $disease_class_icd['icd_code'];
|
||||||
|
$order_prescription_icd = OrderPrescriptionIcd::addOrderPrescriptionIcd($data);
|
||||||
|
if (empty($order_prescription_icd)) {
|
||||||
|
Db::rollBack();
|
||||||
|
return fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($disease_class_icd);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除订单-处方药品表
|
||||||
|
$params = array();
|
||||||
|
$params['order_prescription_id'] = $order_prescription_id;
|
||||||
|
OrderPrescriptionProduct::deleteOrderPrescriptionProduct($params);
|
||||||
|
|
||||||
|
foreach ($prescription_product as $item) {
|
||||||
|
// 获取商品数据
|
||||||
|
$params = array();
|
||||||
|
$params['product_id'] = $item['product_id'];
|
||||||
|
$product = Product::getWithAmountOne($params);
|
||||||
|
if (empty($product)) {
|
||||||
|
Db::rollBack();
|
||||||
|
return fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($product['ProductPlatformAmount'])) {
|
||||||
|
// 无药品库存数据
|
||||||
|
Db::rollBack();
|
||||||
|
return fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检测药品库存数据
|
||||||
|
if ($item['prescription_product_num'] > $product['ProductPlatformAmount']['real_stock']) {
|
||||||
|
// 库存不足
|
||||||
|
Db::rollBack();
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR, "药品" . $product['product_name'] . "库存不足");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增订单-处方药品表
|
||||||
|
$data = array();
|
||||||
|
$data['order_prescription_id'] = $order_prescription_id;
|
||||||
|
$data['product_id'] = $item['product_id'];
|
||||||
|
$data['prescription_product_num'] = $item['prescription_product_num'];
|
||||||
|
$data['product_name'] = $product['product_name'];
|
||||||
|
$data['product_spec'] = $product['product_spec'];
|
||||||
|
$data['license_number'] = $product['license_number'];
|
||||||
|
$data['manufacturer'] = $product['manufacturer'];
|
||||||
|
$data['single_unit'] = $item['single_unit'] ?? $product['single_unit'];
|
||||||
|
$data['single_use'] = $item['single_use'] ?? $product['single_use'];
|
||||||
|
$data['packaging_unit'] = $item['packaging_unit'] ?? $product['packaging_unit'];
|
||||||
|
$data['frequency_use'] = $item['frequency_use'] ?? $product['frequency_use'];
|
||||||
|
$data['available_days'] = $item['available_days'] ?? $product['available_days'];
|
||||||
|
$order_prescription_product = OrderPrescriptionProduct::addOrderPrescriptionProduct($data);
|
||||||
|
if (empty($order_prescription_product)) {
|
||||||
|
Db::rollBack();
|
||||||
|
return fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($product);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加入分配药师队列
|
||||||
|
$data = array();
|
||||||
|
$data['order_prescription_id'] = $order_prescription_id;
|
||||||
|
|
||||||
|
$message = new PrescriptionDistributePhProducer($data);
|
||||||
|
$producer = ApplicationContext::getContainer()->get(Producer::class);
|
||||||
|
$result = $producer->produce($message);
|
||||||
|
if (!$result) {
|
||||||
|
Db::rollBack();
|
||||||
|
return fail(HttpEnumCode::SERVER_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Db::rollBack();
|
||||||
|
return fail(HttpEnumCode::SERVER_ERROR, $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增处方
|
||||||
|
* @return array
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
|
*/
|
||||||
|
public function addPrescription(): array
|
||||||
|
{
|
||||||
|
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||||
|
|
||||||
|
$order_inquiry_id = $this->request->input('order_inquiry_id');
|
||||||
|
$prescription_icd = $this->request->input('prescription_icd');
|
||||||
|
$doctor_advice = $this->request->input('doctor_advice');
|
||||||
|
$prescription_product = $this->request->input('prescription_product');
|
||||||
|
|
||||||
|
// 获取医生信息
|
||||||
|
$params = array();
|
||||||
|
$params['doctor_id'] = $user_info['client_user_id'];
|
||||||
|
|
||||||
|
$fields = [
|
||||||
|
'doctor_id',
|
||||||
|
'iden_auth_status',
|
||||||
|
'idcard_status',
|
||||||
|
'multi_point_status',
|
||||||
|
];
|
||||||
|
$user_doctor = UserDoctor::getOne($params, $fields);
|
||||||
|
if (empty($user_doctor)) {
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR, "非法医生");
|
||||||
|
}
|
||||||
|
|
||||||
|
$res = $this->checkDoctorAuth($user_doctor);
|
||||||
|
if ($res !== true) {
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR, $res);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取问诊订单数据
|
||||||
|
$params['order_inquiry_id'] = $order_inquiry_id;
|
||||||
|
$order_inquiry = OrderInquiry::getOne($params);
|
||||||
|
if (empty($order_inquiry)) {
|
||||||
|
return fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array($order_inquiry['inquiry_status'], [1, 2,3,6,7])){
|
||||||
|
// 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR,"订单无法开具处方");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检测处方是否重复开具
|
||||||
|
$params = array();
|
||||||
|
$params['order_prescription_id'] = $order_inquiry['order_inquiry_id'];
|
||||||
|
$params['doctor_id'] = $user_info['client_user_id'];
|
||||||
|
$order_prescription = OrderPrescription::getOne($params);
|
||||||
|
if (!empty($order_prescription)) {
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR,"订单已开具处方,无法重复开具");
|
||||||
|
}
|
||||||
|
|
||||||
|
Db::beginTransaction();
|
||||||
|
$generator = $this->container->get(IdGeneratorInterface::class);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 新增处方表
|
||||||
|
$data = array();
|
||||||
|
$data['order_inquiry_id'] = $order_inquiry_id;
|
||||||
|
$data['doctor_id'] = $user_info['client_user_id'];
|
||||||
|
$data['prescription_status'] = 1;
|
||||||
|
$data['prescription_code'] = $generator->generate(); // 处方编号
|
||||||
|
$data['doctor_name'] = $user_doctor['user_name']; // 医生名称
|
||||||
|
$data['patient_name'] = $order_inquiry['patient_name'];
|
||||||
|
$data['patient_sex'] = $order_inquiry['patient_sex'];
|
||||||
|
$data['patient_age'] = $order_inquiry['patient_age'];
|
||||||
|
$data['doctor_advice'] = $doctor_advice;
|
||||||
|
$order_prescription = OrderPrescription::addOrderPrescription($data);
|
||||||
|
if (empty($order_prescription)){
|
||||||
|
Db::rollBack();
|
||||||
|
return fail(HttpEnumCode::SERVER_ERROR,"处方开具失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($prescription_icd as $item) {
|
||||||
|
// 获取疾病信息
|
||||||
|
$params = array();
|
||||||
|
$params['icd_id'] = $item;
|
||||||
|
$disease_class_icd = DiseaseClassIcd::getOne($params);
|
||||||
|
if (empty($disease_class_icd)) {
|
||||||
|
Db::rollBack();
|
||||||
|
return fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增处方疾病
|
||||||
|
$data = array();
|
||||||
|
$data['order_prescription_id'] = $order_prescription['order_prescription_id'];
|
||||||
|
$data['icd_id'] = $item;
|
||||||
|
$data['icd_name'] = $disease_class_icd['icd_name'];
|
||||||
|
$data['icd_code'] = $disease_class_icd['icd_code'];
|
||||||
|
$order_prescription_icd = OrderPrescriptionIcd::addOrderPrescriptionIcd($data);
|
||||||
|
if (empty($order_prescription_icd)) {
|
||||||
|
Db::rollBack();
|
||||||
|
return fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($disease_class_icd);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($prescription_product as $item) {
|
||||||
|
// 获取商品数据
|
||||||
|
$params = array();
|
||||||
|
$params['product_id'] = $item['product_id'];
|
||||||
|
$product = Product::getWithAmountOne($params);
|
||||||
|
if (empty($product)) {
|
||||||
|
Db::rollBack();
|
||||||
|
return fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($product['ProductPlatformAmount'])) {
|
||||||
|
// 无药品库存数据
|
||||||
|
Db::rollBack();
|
||||||
|
return fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检测药品库存数据
|
||||||
|
if ($item['prescription_product_num'] > $product['ProductPlatformAmount']['real_stock']) {
|
||||||
|
// 库存不足
|
||||||
|
Db::rollBack();
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR, "药品" . $product['product_name'] . "库存不足");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增订单-处方药品表
|
||||||
|
$data = array();
|
||||||
|
$data['order_prescription_id'] = $order_prescription['order_prescription_id'];
|
||||||
|
$data['product_id'] = $item['product_id'];
|
||||||
|
$data['prescription_product_num'] = $item['prescription_product_num'];
|
||||||
|
$data['product_name'] = $product['product_name'];
|
||||||
|
$data['product_spec'] = $product['product_spec'];
|
||||||
|
$data['license_number'] = $product['license_number'];
|
||||||
|
$data['manufacturer'] = $product['manufacturer'];
|
||||||
|
$data['single_unit'] = $item['single_unit'] ?? $product['single_unit'];
|
||||||
|
$data['single_use'] = $item['single_use'] ?? $product['single_use'];
|
||||||
|
$data['packaging_unit'] = $item['packaging_unit'] ?? $product['packaging_unit'];
|
||||||
|
$data['frequency_use'] = $item['frequency_use'] ?? $product['frequency_use'];
|
||||||
|
$data['available_days'] = $item['available_days'] ?? $product['available_days'];
|
||||||
|
$order_prescription_product = OrderPrescriptionProduct::addOrderPrescriptionProduct($data);
|
||||||
|
if (empty($order_prescription_product)) {
|
||||||
|
Db::rollBack();
|
||||||
|
return fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($product);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加入分配药师队列
|
||||||
|
$data = array();
|
||||||
|
$data['order_prescription_id'] = $order_prescription['order_prescription_id'];
|
||||||
|
|
||||||
|
$message = new PrescriptionDistributePhProducer($data);
|
||||||
|
$producer = ApplicationContext::getContainer()->get(Producer::class);
|
||||||
|
$result = $producer->produce($message);
|
||||||
|
if (!$result) {
|
||||||
|
Db::rollBack();
|
||||||
|
return fail(HttpEnumCode::SERVER_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Db::rollBack();
|
||||||
|
return fail(HttpEnumCode::SERVER_ERROR, $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -137,6 +137,9 @@ Router::addGroup('/doctor', function () {
|
|||||||
|
|
||||||
// 修改处方
|
// 修改处方
|
||||||
Router::put('', [UserDoctorController::class, 'putPrescription']);
|
Router::put('', [UserDoctorController::class, 'putPrescription']);
|
||||||
|
|
||||||
|
// 新增处方
|
||||||
|
Router::post('', [UserDoctorController::class, 'addPrescription']);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 常用语
|
// 常用语
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user