新增 获取家庭成员用药记录列表
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,11 +54,6 @@ class PatientFamily extends Model
|
||||
*/
|
||||
protected array $fillable = ['family_id', 'patient_id', 'relation', 'status', 'is_default', 'card_name', 'card_name_mask', 'mobile', 'mobile_mask', 'type', 'id_number', 'id_number_mask', 'sex', 'age', 'province_id', 'province', 'city_id', 'city', 'county_id', 'county', 'height', 'weight', 'marital_status', 'nation_id', 'nation_name', 'job_id', 'job_name', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*/
|
||||
protected array $casts = ['family_id' => 'string', 'patient_id' => 'string', 'relation' => 'integer', 'status' => 'integer', 'is_default' => 'integer', 'type' => 'integer', 'sex' => 'integer', 'age' => 'integer', 'province_id' => 'integer', 'city_id' => 'integer', 'county_id' => 'integer', 'marital_status' => 'integer', 'nation_id' => 'integer', 'job_id' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];
|
||||
|
||||
protected string $primaryKey = "family_id";
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user