104 lines
2.5 KiB
PHP
Executable File
104 lines
2.5 KiB
PHP
Executable File
<?php
|
|
|
|
namespace app\common\model\doctor;
|
|
|
|
use app\common\model\BaseModel;
|
|
|
|
/**
|
|
* 医生预约模型
|
|
* Class Appointment
|
|
* @package app\common\model\doctor
|
|
*/
|
|
class Appointment extends BaseModel
|
|
{
|
|
protected $name = 'doctor_appointment';
|
|
|
|
// 自动时间戳类型设置为整型
|
|
protected $autoWriteTimestamp = true;
|
|
protected $createTime = 'create_time';
|
|
protected $updateTime = 'update_time';
|
|
protected $deleteTime = false;
|
|
|
|
// 时间字段取出后的默认时间格式(设置为false表示保持整型)
|
|
protected $dateFormat = false;
|
|
|
|
/**
|
|
* @notes 状态描述
|
|
* @param $value
|
|
* @param $data
|
|
* @return string
|
|
*/
|
|
public function getStatusDescAttr($value, $data)
|
|
{
|
|
$statusMap = [
|
|
1 => '已预约',
|
|
2 => '已取消',
|
|
3 => '已完成',
|
|
4 => '已过号',
|
|
];
|
|
return $statusMap[$data['status']] ?? '未知';
|
|
}
|
|
|
|
/**
|
|
* @notes 时段描述
|
|
* @param $value
|
|
* @param $data
|
|
* @return string
|
|
*/
|
|
public function getPeriodDescAttr($value, $data)
|
|
{
|
|
return $data['period'] == 'morning' ? '上午' : '下午';
|
|
}
|
|
|
|
/**
|
|
* @notes 预约类型描述
|
|
* @param $value
|
|
* @param $data
|
|
* @return string
|
|
*/
|
|
public function getAppointmentTypeDescAttr($value, $data)
|
|
{
|
|
$typeMap = [
|
|
'video' => '视频问诊',
|
|
'text' => '图文问诊',
|
|
'phone' => '电话问诊',
|
|
];
|
|
return $typeMap[$data['appointment_type']] ?? '未知';
|
|
}
|
|
|
|
/**
|
|
* @notes 预约日期格式化
|
|
* @param $value
|
|
* @param $data
|
|
* @return string
|
|
*/
|
|
public function getAppointmentDateTextAttr($value, $data)
|
|
{
|
|
return $data['appointment_date'] ?? '';
|
|
}
|
|
|
|
/**
|
|
* @notes 关联患者
|
|
* @return \think\model\relation\HasOne
|
|
*/
|
|
public function patient()
|
|
{
|
|
return $this->hasOne('app\common\model\user\User', 'id', 'patient_id')
|
|
->bind(['patient_name' => 'nickname', 'patient_phone' => 'mobile']);
|
|
}
|
|
|
|
/**
|
|
* @notes 关联医生
|
|
* @return \think\model\relation\HasOne
|
|
*/
|
|
public function doctor()
|
|
{
|
|
return $this->hasOne('app\adminapi\logic\auth\AdminLogic', 'id', 'doctor_id')
|
|
->bind(['doctor_name' => 'name']);
|
|
}
|
|
public function diagnosis(){
|
|
|
|
return $this->belongsTo('app\common\model\tcm\Diagnosis', 'patient_id', 'id');
|
|
}
|
|
}
|