99 lines
4.1 KiB
PHP
99 lines
4.1 KiB
PHP
<?php
|
||
|
||
namespace App\Services;
|
||
|
||
use App\Model\OrderPrescription;
|
||
use App\Model\OrderPrescriptionProduct;
|
||
use App\Model\OrderProductItem;
|
||
use Hyperf\Contract\LengthAwarePaginatorInterface;
|
||
|
||
class OrderPrescriptionService extends BaseService
|
||
{
|
||
/**
|
||
* 获取医生是否存在被驳回处方
|
||
* @param string $doctor_id 医生id
|
||
* @return bool
|
||
*/
|
||
public function getDoctorExistsAuditFail(string $doctor_id): bool
|
||
{
|
||
$params = array();
|
||
$params['doctor_id'] = $doctor_id;
|
||
$params['pharmacist_audit_status'] = 2;// 处方审核状态(0:审核中 1:审核成功 2:审核驳回)
|
||
$params['platform_audit_status'] = 1;// 处方平台审核状态(0:审核中 1:审核成功 2:审核驳回)
|
||
$params['is_delete'] = 0;// 是否删除(0:否 1:是)
|
||
return OrderPrescription::getExists($params);
|
||
}
|
||
|
||
/**
|
||
* 获取药师待审核处方-分页-存在问题,需修改
|
||
* @param string $pharmacist_id 药师id
|
||
* @param int $pharmacist_audit_status 药师审核状态(0:审核中 1:审核成功 2:审核驳回)
|
||
* @param int $platform_audit_status
|
||
* @param string|int $page
|
||
* @param string|int $per_page
|
||
* @return array
|
||
*/
|
||
public function getPharmacistWaitAuditPage(string $pharmacist_id,int $pharmacist_audit_status,int $platform_audit_status,string|int $page = 1,string|int $per_page = 10): array
|
||
{
|
||
$params = array();
|
||
$params['pharmacist_id'] = $pharmacist_id;
|
||
$params['prescription_status'] = 1; // 处方状态(1:待审核 2:待使用 3:已失效 4:已使用)
|
||
$params['pharmacist_audit_status'] = $pharmacist_audit_status; // 药师审核状态(0:审核中 1:审核成功 2:审核驳回)
|
||
$params['platform_audit_status'] = $platform_audit_status; // 处方平台审核状态(0:审核中 1:审核成功 2:审核驳回)
|
||
|
||
return OrderPrescription::getPage($params, ['*'], $page, $per_page);
|
||
}
|
||
|
||
/**
|
||
* 获取处方中开方药品
|
||
* @param string|int $order_inquiry_id
|
||
* @param string|int $order_prescription_id
|
||
* @return array
|
||
*/
|
||
public function getproductList(string|int $order_inquiry_id, string|int $order_prescription_id): array
|
||
{
|
||
$params = array();
|
||
$params['order_inquiry_id'] = $order_inquiry_id;
|
||
$params['order_prescription_id'] = $order_prescription_id;
|
||
$order_prescription_products = OrderPrescriptionProduct::getLimit($params);
|
||
if (empty($order_prescription_products)) {
|
||
return [];
|
||
}
|
||
|
||
$result = [];
|
||
|
||
foreach ($order_prescription_products as $order_prescription_product) {
|
||
$data = array();
|
||
$data['prescription_product_id'] = $order_prescription_product['prescription_product_id'];
|
||
$data['product_id'] = $order_prescription_product['product_id'];
|
||
$data['prescription_product_num'] = $order_prescription_product['prescription_product_num'];
|
||
$data['product_name'] = $order_prescription_product['product_name'] ?? "";
|
||
$data['product_spec'] = $order_prescription_product['product_spec'] ?? "";
|
||
$data['single_unit'] = $order_prescription_product['single_unit'] ?? "";
|
||
$data['single_use'] = $order_prescription_product['single_use'] ?? "";
|
||
$data['packaging_unit'] = $order_prescription_product['packaging_unit'] ?? "";
|
||
$data['frequency_use'] = $order_prescription_product['frequency_use'] ?? "";
|
||
|
||
$result[] = $data;
|
||
}
|
||
|
||
unset($order_product_items);
|
||
|
||
return $result;
|
||
}
|
||
|
||
/**
|
||
* 获取患者某一状态下的处方数量
|
||
* @param string $patient_id 患者id
|
||
* @param int $prescription_status 处方状态(1:待审核 2:待使用 3:已失效 4:已使用)
|
||
* @return int
|
||
*/
|
||
public function getPatientPrescriptionWithStatus(string $patient_id, int $prescription_status): int
|
||
{
|
||
$params = array();
|
||
$params['patient_id'] = $patient_id;
|
||
$params['prescription_status'] = $prescription_status;
|
||
$params['pharmacist_audit_status'] = 1;
|
||
return OrderPrescription::getCount($params);
|
||
}
|
||
} |