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

117 lines
4.3 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\Database\Model\Relations\HasOne;
use Hyperf\Snowflake\Concern\Snowflake;
/**
* @property int $inquiry_case_id 主键id
* @property int $inquiry_cases_id 主键id
* @property int $user_id 用户id
* @property int $patient_id 患者id
* @property int $order_inquiry_id 订单-问诊id
* @property int $family_id 家庭成员id
* @property int $relation 与患者关系1:本人 2:父母 3:爱人 4:子女 5:亲戚 6:其他
* @property int $status 状态1:正常 2:删除)
* @property string $name 患者名称
* @property int $sex 患者性别0:未知 1:男 2:女)
* @property int $age 患者年龄
* @property string $height 身高cm
* @property string $weight 体重kg
* @property int $disease_class_id 疾病分类id-系统
* @property string $disease_class_name 疾病名称-系统
* @property string $diagnosis_date 确诊日期
* @property string $disease_desc 病情描述(主诉)
* @property string $diagnose_images 复诊凭证(多个使用逗号分隔)
* @property int $is_allergy_history 是否存在过敏史0:否 1:是)
* @property string $allergy_history 过敏史描述
* @property int $is_family_history 是否存在家族病史0:否 1:是)
* @property string $family_history 家族病史描述
* @property int $is_pregnant 是否备孕、妊娠、哺乳期0:否 1:是)
* @property string $pregnant 备孕、妊娠、哺乳期描述
* @property \Carbon\Carbon $created_at 创建时间
* @property \Carbon\Carbon $updated_at 修改时间
* @property-read BasicJob $BasicJob
* @property-read BasicNation $BasicNation
* @property-read OrderInquiry $OrderInquiry
*/
class OrderInquiryCase extends Model
{
use Snowflake;
/**
* The table associated with the model.
*/
protected ?string $table = 'order_inquiry_case';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = ['inquiry_case_id', 'inquiry_cases_id', 'user_id', 'patient_id', 'order_inquiry_id', 'family_id', 'relation', 'status', 'name', 'sex', 'age', 'height', 'weight', 'disease_class_id', 'disease_class_name', 'diagnosis_date', 'disease_desc', 'diagnose_images', 'is_allergy_history', 'allergy_history', 'is_family_history', 'family_history', 'is_pregnant', 'pregnant', 'created_at', 'updated_at'];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['inquiry_case_id' => 'integer', 'inquiry_cases_id' => 'integer', 'user_id' => 'integer', 'patient_id' => 'integer', 'order_inquiry_id' => 'integer', 'family_id' => 'integer', 'relation' => 'integer', 'status' => 'integer', 'sex' => 'integer', 'age' => 'integer', 'disease_class_id' => 'integer', 'is_allergy_history' => 'integer', 'is_family_history' => 'integer', 'is_pregnant' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];
protected string $primaryKey = "inquiry_cases_id";
/**
* 关联问诊订单表
*/
public function OrderInquiry(): HasOne
{
return $this->hasOne(OrderInquiry::class, 'order_inquiry_id', 'order_inquiry_id');
}
/**
* 关联民族表
*/
public function BasicNation(): HasOne
{
return $this->hasOne(BasicNation::class, 'nation_id', 'nation_id');
}
/**
* 关联职位表
*/
public function BasicJob(): HasOne
{
return $this->hasOne(BasicJob::class, 'job_id', 'job_id');
}
/**
* 单条
* @param array $params
* @param array $fields
* @return object|null
*/
public static function getOne(array $params, array $fields = ['*']): object|null
{
return self::where($params)->first($fields);
}
/**
* 获取结束问诊订单病例-单
* @param array $params
* @param array $order_inquiry_params
* @param array $fields
* @return object|null
*/
public static function getEndOrderInquiryCaseOne(array $params, array $order_inquiry_params, array $fields = ['*']): object|null
{
return self::with([
"OrderInquiry",
])
->whereHas('OrderInquiry' , function($query) use ($order_inquiry_params){
$query->where($order_inquiry_params);
})
->where($params)
->first($fields);
}
}