hospital-applets-api/app/Model/OrderPrescription.php
2023-02-17 17:10:16 +08:00

87 lines
3.4 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
declare(strict_types=1);
namespace App\Model;
use Hyperf\Contract\LengthAwarePaginatorInterface;
use Hyperf\Snowflake\Concern\Snowflake;
/**
* @property int $order_prescription_id 主键id
* @property int $order_inquiry_id 订单-问诊id
* @property int $doctor_id 医生id
* @property int $pharmacist_id 药师id
* @property int $icd_id 疾病id
* @property int $prescription_status 处方状态1:待审核 3:待使用 4:已失效 5:已使用)
* @property int $prescription_audit_status 处方审核状态0:审核中 1:审核成功 2:审核驳回)
* @property int $is_delete 是否删除0:否 1:是)
* @property int $is_pass 处方平台是否审核通过0:否 1:是)
* @property string $prescription 处方编号
* @property string $not_pass_reason 处方平台审核不通过原因
* @property string $audit_fail_reason 审核驳回原因
* @property string $doctor_name 医生名称
* @property string $patient_name 患者姓名-就诊人
* @property int $patient_sex 患者性别-就诊人1:男 2:女)
* @property int $patient_age 患者年龄-就诊人
* @property string $drugs_info 药品数据
* @property string $prescription_img 处方图片
* @property \Carbon\Carbon $created_at 创建时间
* @property \Carbon\Carbon $updated_at 修改时间
*/
class OrderPrescription extends Model
{
use Snowflake;
/**
* The table associated with the model.
*/
protected ?string $table = 'order_prescription';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = ['order_prescription_id', 'order_inquiry_id', 'doctor_id', 'pharmacist_id', 'icd_id', 'prescription_status', 'prescription_audit_status', 'is_delete', 'is_pass', 'prescription', 'not_pass_reason', 'audit_fail_reason', 'doctor_name', 'patient_name', 'patient_sex', 'patient_age', 'drugs_info', 'prescription_img', 'created_at', 'updated_at'];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['order_prescription_id' => 'integer', 'order_inquiry_id' => 'integer', 'doctor_id' => 'integer', 'pharmacist_id' => 'integer', 'icd_id' => 'integer', 'prescription_status' => 'integer', 'prescription_audit_status' => 'integer', 'is_delete' => 'integer', 'is_pass' => 'integer', 'patient_sex' => 'integer', 'patient_age' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];
protected string $primaryKey = "order_prescription_id";
/**
* 获取是否存在
* @param array $params
* @return bool
*/
public static function getExists(array $params): bool
{
return self::where($params)->exists();
}
/**
* 获取待审核处方列表-分页
* @param array $params 条件
* @param array $fields 字段
* @param int|null $page 页码
* @param int|null $per_page 每页个数
* @return array
*/
public static function getPage(array $params, array $fields = ["*"], int $page = null, ?int $per_page = 10): array
{
$raw = self::where($params)->paginate($per_page, $fields, "page", $page);
$data = array();
$data['current_page'] = $raw->currentPage();// 当前页码
$data['total'] = $raw->total();//数据总数
$data['data'] = $raw->items();//数据
$data['per_page'] = $raw->perPage();//每页个数
$data['last_page'] = $raw->lastPage();//最后一页
return $data;
}
}