新增分配药师队列、新增处方开具、修改接口
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|array $routingKey = '';
|
||||
protected string|array $routingKey = 'CancelUnpayOrders';
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 延迟队列
|
||||
* 生产者
|
||||
* 取消未支付订单生产者-延迟队列
|
||||
*/
|
||||
#[Producer]
|
||||
class AmqpDelayDirectProducer extends ProducerMessage
|
||||
class CancelUnpayOrdersDelayDirectProducer extends ProducerMessage
|
||||
{
|
||||
use ProducerDelayedMessageTrait;
|
||||
|
||||
@ -22,7 +21,7 @@ class AmqpDelayDirectProducer extends ProducerMessage
|
||||
|
||||
protected string $type = Type::DIRECT;
|
||||
|
||||
protected string|array $routingKey = '';
|
||||
protected string|array $routingKey = 'CancelUnpayOrders';
|
||||
|
||||
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
|
||||
{
|
||||
// $message = new AmqpDelayDirectProducer(10000);
|
||||
// $message = new CancelUnpayOrdersDelayDirectProducer(10000);
|
||||
// $message->setDelayMs(10000);
|
||||
// $producer = ApplicationContext::getContainer()->get(Producer::class);
|
||||
// $producer->produce($message);
|
||||
//
|
||||
// $message = new AmqpDelayDirectProducer(5000);
|
||||
// $message = new CancelUnpayOrdersDelayDirectProducer(5000);
|
||||
// $message->setDelayMs(5000);
|
||||
// $producer = ApplicationContext::getContainer()->get(Producer::class);
|
||||
// $producer->produce($message);
|
||||
|
||||
@ -2,11 +2,16 @@
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Amqp\Producer\PrescriptionDistributePhProducer;
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Request\DoctorAuthRequest;
|
||||
use App\Request\UserDoctorRequest;
|
||||
use App\Services\DoctorAuthService;
|
||||
use App\Services\DoctorInquiryService;
|
||||
use App\Services\UserDoctorService;
|
||||
use Hyperf\Amqp\Producer;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
@ -255,4 +260,20 @@ class UserDoctorController extends AbstractController
|
||||
$data = $UserDoctorService->putPrescription();
|
||||
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)
|
||||
->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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
* @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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @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\Model;
|
||||
use Hyperf\Database\Model\Relations\HasOne;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
@ -113,4 +114,24 @@ class OrderPrescriptionProduct extends Model
|
||||
->limit(10)
|
||||
->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' => [ // 获取处方详情
|
||||
'order_inquiry_id',
|
||||
'order_prescription_id', // 处方id(非必须)
|
||||
],
|
||||
'putPrescription' => [ // 修改处方
|
||||
'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',
|
||||
'evaluation_type' => 'required|integer|min:1|max:3',
|
||||
'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.max' => 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['icd_status'] = 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)){
|
||||
return success();
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Amqp\Producer\AmqpDelayDirectProducer;
|
||||
use App\Amqp\Producer\CancelUnpayOrdersDelayDirectProducer;
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Model\DiseaseClass;
|
||||
use App\Model\InquiryCaseProduct;
|
||||
@ -234,7 +234,7 @@ class InquiryService extends BaseService
|
||||
$data = array();
|
||||
$data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
|
||||
$message = new AmqpDelayDirectProducer($data);
|
||||
$message = new CancelUnpayOrdersDelayDirectProducer($data);
|
||||
$message->setDelayMs(60 * 30 * 1000);
|
||||
$producer = $this->container->get(Producer::class) ;
|
||||
$res = $producer->produce($message);
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Amqp\Producer\PrescriptionDistributePhProducer;
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Exception\BusinessException;
|
||||
use App\Model\BasicBank;
|
||||
@ -19,12 +20,19 @@ use App\Model\OrderInquiry;
|
||||
use App\Model\OrderInquiryCase;
|
||||
use App\Model\OrderPrescription;
|
||||
use App\Model\OrderPrescriptionIcd;
|
||||
use App\Model\OrderPrescriptionProduct;
|
||||
use App\Model\OrderProductItem;
|
||||
use App\Model\Product;
|
||||
use App\Model\User;
|
||||
use App\Model\UserDoctor;
|
||||
use App\Model\UserDoctorInfo;
|
||||
use App\Utils\Mask;
|
||||
use Hyperf\Amqp\Producer;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use Hyperf\Snowflake\IdGeneratorInterface;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
class UserDoctorService extends BaseService
|
||||
{
|
||||
@ -423,10 +431,10 @@ class UserDoctorService extends BaseService
|
||||
$data['disease_desc'] = $order_inquiry_case['disease_desc'];
|
||||
|
||||
// 患病时长
|
||||
if (empty($order_inquiry_case['diagnosis_date'])){
|
||||
if (empty($order_inquiry_case['diagnosis_date'])) {
|
||||
$data['diagnosis_date'] = "未知";
|
||||
}else{
|
||||
$data['diagnosis_date'] = date('Y-m-d',strtotime($order_inquiry_case['diagnosis_date']));
|
||||
} else {
|
||||
$data['diagnosis_date'] = date('Y-m-d', strtotime($order_inquiry_case['diagnosis_date']));
|
||||
}
|
||||
|
||||
// 疾病信息
|
||||
@ -483,14 +491,14 @@ class UserDoctorService extends BaseService
|
||||
// 获取医生账户余额-未提现金额
|
||||
$DoctorAccountService = new DoctorAccountService();
|
||||
$balance_account = $DoctorAccountService->getDoctorBalanceAccount($user_info['client_user_id']);
|
||||
if ($balance_account > 0){
|
||||
if ($balance_account > 0) {
|
||||
$balance_account = $balance_account * 0.75;
|
||||
}
|
||||
|
||||
// 获取医生当日接诊的订单金额
|
||||
$InquiryService = new InquiryService();
|
||||
$estimate_income = $InquiryService->getDoctorDayAmountTotal($user_info['client_user_id'],date('Y-m-d',time()));
|
||||
if (!empty($estimate_income)){
|
||||
$estimate_income = $InquiryService->getDoctorDayAmountTotal($user_info['client_user_id'], date('Y-m-d', time()));
|
||||
if (!empty($estimate_income)) {
|
||||
$estimate_income = $estimate_income * 0.75;
|
||||
}
|
||||
|
||||
@ -517,8 +525,8 @@ class UserDoctorService extends BaseService
|
||||
$params['basics_words_type'] = $words_type;
|
||||
$params['basics_words_status'] = 1;
|
||||
$basic_words = BasicWord::getList($params);
|
||||
if (!empty($basic_words)){
|
||||
foreach ($basic_words as $item){
|
||||
if (!empty($basic_words)) {
|
||||
foreach ($basic_words as $item) {
|
||||
$data = array();
|
||||
$data['words'] = $item['basics_words'];
|
||||
|
||||
@ -532,8 +540,8 @@ class UserDoctorService extends BaseService
|
||||
$params['words_type'] = $words_type;
|
||||
$params['words_status'] = 1;
|
||||
$doctor_words = DoctorWord::getList($params);
|
||||
if (!empty($doctor_words)){
|
||||
foreach ($doctor_words as $item){
|
||||
if (!empty($doctor_words)) {
|
||||
foreach ($doctor_words as $item) {
|
||||
$data = array();
|
||||
$data['words'] = $item['words'];
|
||||
|
||||
@ -561,11 +569,11 @@ class UserDoctorService extends BaseService
|
||||
$params['words_type'] = $words_type;
|
||||
$params['words'] = $words;
|
||||
$doctor_words = DoctorWord::getOne($params);
|
||||
if (!empty($doctor_words)){
|
||||
if ($doctor_words['words_status'] == 0){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"此常用语已被禁用");
|
||||
}else{
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"请勿重复添加");
|
||||
if (!empty($doctor_words)) {
|
||||
if ($doctor_words['words_status'] == 0) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "此常用语已被禁用");
|
||||
} else {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "请勿重复添加");
|
||||
}
|
||||
}
|
||||
|
||||
@ -577,7 +585,7 @@ class UserDoctorService extends BaseService
|
||||
$data['words'] = $words;
|
||||
|
||||
$doctor_words = DoctorWord::addDoctorWord($data);
|
||||
if (empty($doctor_words)){
|
||||
if (empty($doctor_words)) {
|
||||
return fail(HttpEnumCode::SERVER_ERROR);
|
||||
}
|
||||
|
||||
@ -593,11 +601,11 @@ class UserDoctorService extends BaseService
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
$doctor_id = $this->request->input('doctor_id');
|
||||
$evaluation_type = $this->request->input('evaluation_type',1);
|
||||
$page = $this->request->input('page',1);
|
||||
$per_page = $this->request->input('per_page',10);
|
||||
$evaluation_type = $this->request->input('evaluation_type', 1);
|
||||
$page = $this->request->input('page', 1);
|
||||
$per_page = $this->request->input('per_page', 10);
|
||||
|
||||
if (empty($user_info)){
|
||||
if (empty($user_info)) {
|
||||
return fail();
|
||||
}
|
||||
|
||||
@ -605,57 +613,57 @@ class UserDoctorService extends BaseService
|
||||
$params['doctor_id'] = $doctor_id;
|
||||
|
||||
// 4-5分为好评、3分为中评、2-1分为差评
|
||||
if ($evaluation_type == 1){
|
||||
if ($evaluation_type == 1) {
|
||||
// 全部
|
||||
$avg_score_params = [0,100];
|
||||
}elseif ($evaluation_type == 2){
|
||||
$avg_score_params = [0, 100];
|
||||
} elseif ($evaluation_type == 2) {
|
||||
// 好评
|
||||
$avg_score_params = [80,100];
|
||||
}elseif ($evaluation_type == 3){
|
||||
$avg_score_params = [80, 100];
|
||||
} elseif ($evaluation_type == 3) {
|
||||
// 中/差评
|
||||
$avg_score_params = [0,80];
|
||||
}else{
|
||||
$avg_score_params = [0, 80];
|
||||
} else {
|
||||
return fail();
|
||||
}
|
||||
|
||||
$order_evaluation = OrderEvaluation::getScorePage($params,$avg_score_params);
|
||||
if (!empty($order_evaluation['data'])){
|
||||
foreach ($order_evaluation['data'] as &$item){
|
||||
$order_evaluation = OrderEvaluation::getScorePage($params, $avg_score_params);
|
||||
if (!empty($order_evaluation['data'])) {
|
||||
foreach ($order_evaluation['data'] as &$item) {
|
||||
$item['avg_score'] = floor($item['avg_score'] * 0.05);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// 获取其他类型评论总数
|
||||
if ($evaluation_type != 1){
|
||||
if ($evaluation_type != 1) {
|
||||
// 好评
|
||||
$avg_score_params = [80,100];
|
||||
$good_quantity = OrderEvaluation::getScoreCount($params,$avg_score_params);
|
||||
$avg_score_params = [80, 100];
|
||||
$good_quantity = OrderEvaluation::getScoreCount($params, $avg_score_params);
|
||||
|
||||
// 中/差评
|
||||
$avg_score_params = [0,80];
|
||||
$bad_quantity = OrderEvaluation::getScoreCount($params,$avg_score_params);
|
||||
$avg_score_params = [0, 80];
|
||||
$bad_quantity = OrderEvaluation::getScoreCount($params, $avg_score_params);
|
||||
}
|
||||
|
||||
if ($evaluation_type != 2){
|
||||
if ($evaluation_type != 2) {
|
||||
// 全部+
|
||||
$avg_score_params = [0,100];
|
||||
$total_quantity = OrderEvaluation::getScoreCount($params,$avg_score_params);
|
||||
$avg_score_params = [0, 100];
|
||||
$total_quantity = OrderEvaluation::getScoreCount($params, $avg_score_params);
|
||||
|
||||
// 中/差评
|
||||
$avg_score_params = [0,80];
|
||||
$bad_quantity = OrderEvaluation::getScoreCount($params,$avg_score_params);
|
||||
$avg_score_params = [0, 80];
|
||||
$bad_quantity = OrderEvaluation::getScoreCount($params, $avg_score_params);
|
||||
|
||||
}
|
||||
|
||||
if ($evaluation_type != 3){
|
||||
if ($evaluation_type != 3) {
|
||||
// 全部+
|
||||
$avg_score_params = [0,100];
|
||||
$total_quantity = OrderEvaluation::getScoreCount($params,$avg_score_params);
|
||||
$avg_score_params = [0, 100];
|
||||
$total_quantity = OrderEvaluation::getScoreCount($params, $avg_score_params);
|
||||
|
||||
// 好评
|
||||
$avg_score_params = [80,100];
|
||||
$good_quantity = OrderEvaluation::getScoreCount($params,$avg_score_params);
|
||||
$avg_score_params = [80, 100];
|
||||
$good_quantity = OrderEvaluation::getScoreCount($params, $avg_score_params);
|
||||
}
|
||||
|
||||
$order_evaluation['total_quantity'] = $total_quantity ?? $order_evaluation['total'];
|
||||
@ -704,11 +712,11 @@ class UserDoctorService extends BaseService
|
||||
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$user_doctor_info = UserDoctorInfo::getOne($params,$fields);
|
||||
$user_doctor_info = UserDoctorInfo::getOne($params, $fields);
|
||||
if (empty($user_doctor_info)) {
|
||||
$user_doctor['card_name'] = "";
|
||||
$user_doctor['card_num_mask'] = "";
|
||||
}else{
|
||||
} else {
|
||||
$user_doctor['card_name'] = $user_doctor_info['card_name'];
|
||||
$user_doctor['card_num_mask'] = $user_doctor_info['card_num_mask'];
|
||||
}
|
||||
@ -750,7 +758,7 @@ class UserDoctorService extends BaseService
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$user_doctor_info = UserDoctorInfo::getOne($params);
|
||||
if (empty($user_doctor_info)){
|
||||
if (empty($user_doctor_info)) {
|
||||
return success();
|
||||
}
|
||||
|
||||
@ -829,27 +837,27 @@ class UserDoctorService extends BaseService
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_inquiry_id;
|
||||
$params['status'] = 1;
|
||||
$order_inquiry_case = OrderInquiryCase::getOne($params,$fields);
|
||||
if (empty($order_inquiry_case)){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"患者病例信息错误");
|
||||
$order_inquiry_case = OrderInquiryCase::getOne($params, $fields);
|
||||
if (empty($order_inquiry_case)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "患者病例信息错误");
|
||||
}
|
||||
|
||||
// 获取用药意向
|
||||
$CaseService = new CaseService();
|
||||
$inquiry_case_product = $CaseService->getCaseProductlist($order_inquiry_case['inquiry_case_id']);
|
||||
|
||||
if (!empty($order_prescription_id)){
|
||||
if (!empty($order_prescription_id)) {
|
||||
// 获取处方数据
|
||||
$params = array();
|
||||
$params['order_prescription_id'] = $order_prescription_id;
|
||||
$order_prescription = OrderPrescription::getOne($params);
|
||||
if (empty($order_prescription)){
|
||||
if (empty($order_prescription)) {
|
||||
return fail();
|
||||
}
|
||||
|
||||
// 订单-商品订单列表
|
||||
$OrderPrescriptionService = new OrderPrescriptionService();
|
||||
$order_prescription_product = $OrderPrescriptionService->getproductList($order_inquiry_id,$order_prescription_id);
|
||||
$order_prescription_product = $OrderPrescriptionService->getproductList($order_inquiry_id, $order_prescription_id);
|
||||
|
||||
// 获取处方关联疾病表
|
||||
$fields = [
|
||||
@ -859,7 +867,7 @@ class UserDoctorService extends BaseService
|
||||
];
|
||||
$params = array();
|
||||
$params['order_prescription_id'] = $order_prescription_id;
|
||||
$order_prescription_icd = OrderPrescriptionIcd::getList($params,$fields);
|
||||
$order_prescription_icd = OrderPrescriptionIcd::getList($params, $fields);
|
||||
}
|
||||
|
||||
$result = array();
|
||||
@ -869,19 +877,350 @@ class UserDoctorService extends BaseService
|
||||
$result['prescription_icd'] = $order_prescription_icd ?? [];// 处方诊断疾病
|
||||
$result['prescription']['doctor_advice'] = $order_prescription['doctor_advice'] ?? "";// 医嘱
|
||||
|
||||
return success($result);
|
||||
return success($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改处方
|
||||
* @return array
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function putPrescription(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
$order_inquiry_id = $this->request->input('order_inquiry_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();
|
||||
}
|
||||
|
||||
@ -893,25 +1232,25 @@ class UserDoctorService extends BaseService
|
||||
* @param bool $is_multi_point 是否检测多点执业认证
|
||||
* @return bool|string string:错误信息 bool:通过
|
||||
*/
|
||||
public function checkDoctorAuth(object|array $user_doctor,bool $is_iden_auth = true,bool $is_idcard = true,bool $is_multi_point = true): bool|string
|
||||
public function checkDoctorAuth(object|array $user_doctor, bool $is_iden_auth = true, bool $is_idcard = true, bool $is_multi_point = true): bool|string
|
||||
{
|
||||
if (empty($user_doctor)){
|
||||
if (empty($user_doctor)) {
|
||||
throw new BusinessException();
|
||||
}
|
||||
|
||||
if (isset($user_doctor['iden_auth_status'])){
|
||||
if (isset($user_doctor['iden_auth_status'])) {
|
||||
if ($user_doctor['iden_auth_status'] != 1) {
|
||||
return "请先完成身份认证";
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($user_doctor['idcard_status'])){
|
||||
if (isset($user_doctor['idcard_status'])) {
|
||||
if ($user_doctor['idcard_status'] != 1) {
|
||||
return "请先完成实名认证";
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($user_doctor['multi_point_status'])){
|
||||
if (isset($user_doctor['multi_point_status'])) {
|
||||
if ($user_doctor['multi_point_status'] != 1) {
|
||||
return "请先完成多点执业认证";
|
||||
}
|
||||
@ -932,7 +1271,7 @@ class UserDoctorService extends BaseService
|
||||
$params['idcard_status'] = 1; // 实名认证状态
|
||||
$params['iden_auth_status'] = 1;// 身份认证状态
|
||||
|
||||
if ($inquiry_type == 4){
|
||||
if ($inquiry_type == 4) {
|
||||
// 问诊购药
|
||||
$params['multi_point_status'] = 1;// 医生多点执业认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败)
|
||||
}
|
||||
@ -967,20 +1306,20 @@ class UserDoctorService extends BaseService
|
||||
* @param int|string $inquiry_type 订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药)
|
||||
* @return array
|
||||
*/
|
||||
public function getBeforeCurrentTimeDoctor(string|int $minute,int|string $inquiry_type): array
|
||||
public function getBeforeCurrentTimeDoctor(string|int $minute, int|string $inquiry_type): array
|
||||
{
|
||||
// 获取当前时间n分钟前时间
|
||||
$date = date('Y-m-d H:i:s',time() - $minute * 60);
|
||||
$date = date('Y-m-d H:i:s', time() - $minute * 60);
|
||||
|
||||
$params = array();
|
||||
$params[] = ['inquiry_type','=',$inquiry_type]; // 订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药)
|
||||
$params[] = ['inquiry_mode','=',1];
|
||||
$params[] = ['reception_time','>',$date];
|
||||
$params[] = ['inquiry_type', '=', $inquiry_type]; // 订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药)
|
||||
$params[] = ['inquiry_mode', '=', 1];
|
||||
$params[] = ['reception_time', '>', $date];
|
||||
|
||||
$inquiry_status_params = array();
|
||||
$inquiry_status_params = [4,5];
|
||||
$order_inquiry = OrderInquiry::getInquiryStatusList($params,$inquiry_status_params);
|
||||
if (empty($order_inquiry)){
|
||||
$inquiry_status_params = [4, 5];
|
||||
$order_inquiry = OrderInquiry::getInquiryStatusList($params, $inquiry_status_params);
|
||||
if (empty($order_inquiry)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
@ -137,6 +137,9 @@ Router::addGroup('/doctor', function () {
|
||||
|
||||
// 修改处方
|
||||
Router::put('', [UserDoctorController::class, 'putPrescription']);
|
||||
|
||||
// 新增处方
|
||||
Router::post('', [UserDoctorController::class, 'addPrescription']);
|
||||
});
|
||||
|
||||
// 常用语
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user