114 lines
4.2 KiB
PHP
114 lines
4.2 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
|
||
* @return array
|
||
*/
|
||
public function getPharmacistWaitAuditPage(string $pharmacist_id): array
|
||
{
|
||
$params = array();
|
||
$params['pharmacist_id'] = $pharmacist_id;
|
||
$params['pharmacist_audit_status'] = 0; //处方审核状态(0:审核中 1:审核成功 2:审核驳回)
|
||
|
||
// $fields = [
|
||
// "order_prescription_id",
|
||
// "order_inquiry_id",
|
||
// "doctor_id",
|
||
// "pharmacist_id",
|
||
// "prescription_status",
|
||
// "pharmacist_audit_status",
|
||
// "is_delete",
|
||
// "is_pass",
|
||
// "prescription_code",
|
||
// "not_pass_reason",
|
||
// "audit_fail_reason",
|
||
// "doctor_name",
|
||
// "patient_name",
|
||
// "patient_sex",
|
||
// "patient_age",
|
||
// "created_at",
|
||
// ];
|
||
$fields = [];
|
||
$page = $this->request->input('page', 1);
|
||
$per_page = $this->request->input('per_page', 10);
|
||
return OrderPrescription::getPage($params, $fields);
|
||
}
|
||
|
||
/**
|
||
* 获取处方中开方药品
|
||
* @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:待审核 3:待使用 4:已失效 5:已使用)
|
||
* @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);
|
||
}
|
||
} |