修改获取处方列表多个病例问题
This commit is contained in:
@@ -7,6 +7,8 @@ namespace App\Model;
|
||||
|
||||
|
||||
use Hyperf\Contract\LengthAwarePaginatorInterface;
|
||||
use Hyperf\Database\Model\Relations\HasMany;
|
||||
use Hyperf\Database\Model\Relations\HasOne;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
@@ -14,8 +16,6 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
||||
* @property int $order_inquiry_id 订单-问诊id
|
||||
* @property int $doctor_id 医生id
|
||||
* @property int $pharmacist_id 药师id
|
||||
* @property int $icd_id 疾病id(icd)
|
||||
* @property string $icd_name 疾病名称(icd)
|
||||
* @property int $prescription_status 处方状态(1:待审核 3:待使用 4:已失效 5:已使用)
|
||||
* @property int $pharmacist_audit_status 药师审核状态(0:审核中 1:审核成功 2:审核驳回)
|
||||
* @property string $pharmacist_fail_reason 药师审核驳回原因
|
||||
@@ -27,8 +27,6 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
||||
* @property string $patient_name 患者姓名-就诊人
|
||||
* @property int $patient_sex 患者性别-就诊人(1:男 2:女)
|
||||
* @property int $patient_age 患者年龄-就诊人
|
||||
* @property string $drugs_info 药品数据
|
||||
* @property string $disease_desc 病情描述(主诉)
|
||||
* @property string $prescription_img 处方图片
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
* @property \Carbon\Carbon $updated_at 修改时间
|
||||
@@ -45,15 +43,18 @@ class OrderPrescription extends Model
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['order_prescription_id', 'order_inquiry_id', 'doctor_id', 'pharmacist_id', 'icd_id', 'icd_name', 'prescription_status', 'pharmacist_audit_status', 'pharmacist_fail_reason', 'platform_audit_status', 'platform_fail_reason', 'is_delete', 'prescription_code', 'doctor_name', 'patient_name', 'patient_sex', 'patient_age', 'drugs_info', 'disease_desc', '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', 'pharmacist_audit_status' => 'integer', 'platform_audit_status' => 'integer', 'is_delete' => 'integer', 'patient_sex' => 'integer', 'patient_age' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];
|
||||
protected array $fillable = ['order_prescription_id', 'order_inquiry_id', 'doctor_id', 'pharmacist_id', 'prescription_status', 'pharmacist_audit_status', 'pharmacist_fail_reason', 'platform_audit_status', 'platform_fail_reason', 'is_delete', 'prescription_code', 'doctor_name', 'patient_name', 'patient_sex', 'patient_age', 'prescription_img', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "order_prescription_id";
|
||||
|
||||
/**
|
||||
* 关联处方病例表
|
||||
*/
|
||||
public function OrderPrescriptionIcd(): HasMany
|
||||
{
|
||||
return $this->HasMany(OrderPrescriptionIcd::class, 'order_prescription_id','order_prescription_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取是否存在
|
||||
* @param array $params
|
||||
@@ -65,7 +66,7 @@ class OrderPrescription extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取待审核处方列表-分页
|
||||
* 获取处方列表-分页
|
||||
* @param array $params 条件
|
||||
* @param array $fields 字段
|
||||
* @param int|null $page 页码
|
||||
@@ -85,5 +86,29 @@ class OrderPrescription extends Model
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取处方列表-分页
|
||||
* @param array $params 条件
|
||||
* @param array $fields 字段
|
||||
* @param int|null $page 页码
|
||||
* @param int|null $per_page 每页个数
|
||||
* @return array
|
||||
*/
|
||||
public static function getWithIcdPage(array $params, array $fields = ["*"], int $page = null, ?int $per_page = 10): array
|
||||
{
|
||||
$raw = self::with([
|
||||
'OrderPrescriptionIcd'
|
||||
])
|
||||
->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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $prescription_icd_id 主键id
|
||||
* @property int $order_prescription_id 订单-处方id
|
||||
* @property int $icd_id 疾病id(icd)
|
||||
* @property string $icd_name 疾病名称(icd)
|
||||
* @property string $icd_code icd编码
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
* @property \Carbon\Carbon $updated_at 修改时间
|
||||
*/
|
||||
class OrderPrescriptionIcd extends Model
|
||||
{
|
||||
use Snowflake;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'order_prescription_icd';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['prescription_icd_id', 'order_prescription_id', 'icd_id', 'icd_name', 'icd_code', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*/
|
||||
protected array $casts = ['prescription_icd_id' => 'integer', 'order_prescription_id' => 'integer', 'icd_id' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];
|
||||
|
||||
protected string $primaryKey = "prescription_icd_id";
|
||||
}
|
||||
Reference in New Issue
Block a user