新增 获取家庭成员用药记录列表

This commit is contained in:
2023-03-23 16:14:38 +08:00
parent 1772d4c20f
commit e2486d8047
5 changed files with 78 additions and 14 deletions
+53
View File
@@ -74,6 +74,30 @@ class OrderProduct extends Model
return $this->HasMany(OrderProductItem::class, 'order_product_id','order_product_id');
}
/**
* 关联订单-处方表
*/
public function OrderPrescription(): HasOne
{
return $this->hasOne(OrderPrescription::class, 'order_prescription_id','order_prescription_id');
}
/**
* 关联患者家庭成员信息表-基本信息
*/
public function PatientFamily(): HasOne
{
return $this->hasOne(PatientFamily::class, 'family_id','family_id');
}
/**
* 关联处方关联疾病表
*/
public function OrderPrescriptionIcd(): HasMany
{
return $this->HasMany(OrderPrescriptionIcd::class, 'order_prescription_id','order_prescription_id');
}
/**
* 获取信息-单条
* @param array $params
@@ -162,4 +186,33 @@ class OrderProduct extends Model
{
return self::create($data);
}
/**
* 患者用药记录查询
* @param array $params
* @param array $fields
* @param int|null $page
* @param int|null $per_page
* @return array
*/
public static function getProductRecordPage(array $params,array $fields = ["*"], int $page = null, ?int $per_page = 10): array
{
$result = self::with([
"OrderProductItem:product_item_id,order_product_id,product_id,product_name,amount,manufacturer,product_cover_img,product_spec",
"OrderPrescriptionIcd:prescription_icd_id,order_prescription_id,icd_id,icd_name",
"PatientFamily:family_id,card_name_mask,sex,age",
])
->where($params)
->paginate($per_page, $fields, "page", $page);
$data = array();
$data['current_page'] = $result->currentPage();// 当前页码
$data['total'] = $result->total();// 数据总数
$data['data'] = $result->items();// 数据
$data['per_page'] = $result->perPage();// 每页个数
$data['last_page'] = $result->lastPage();// 最后一页
return $data;
}
}