<?php

namespace console\models;

use common\components\PathologyActiveRecord;
use Yii;

/**
 * This is the model class for table "patient_case_approve".
 *
 * @property string $id_case
 * @property string|null $title
 * @property string|null $name
 * @property int|null $gender
 * @property string|null $birthdate
 * @property float|null $age
 * @property string|null $age_unit
 * @property int $hospital_id
 * @property string $hospital
 * @property string|null $collect_at
 * @property string|null $register_at
 * @property string|null $cut_at
 * @property int $status_id
 * @property string $status
 * @property int|null $pathologist_id
 * @property string|null $pathologist
 * @property string|null $report_at
 * @property string|null $diagnosis
 * @property int|null $approve_status
 * @property int|null $approve_by
 * @property string|null $approve_at
 * @property string|null $remark
 * @property int|null $approve_id
 * @property int|null $is_send_request
 * @property int|null $is_critical_diagnosis
 * @property string|null $send_request_at
 * @property int|null $is_critical_diagnosis
 */
class PatientCaseApprove extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'patient_case_approve';
    }

    public static function getDb()
    {
        return Yii::$app->get('patho');
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['gender', 'hospital_id', 'status_id', 'pathologist_id', 'approve_status', 'approve_by', 'approve_id', 'is_send_request', 'is_critical_diagnosis'], 'integer'],
            [['birthdate', 'collect_at', 'register_at', 'cut_at', 'report_at', 'approve_at', 'send_request_at'], 'safe'],
            [['age'], 'number'],
            [['diagnosis'], 'string'],
            [['id_case'], 'string', 'max' => 12],
            [['title'], 'string', 'max' => 100],
            [['name'], 'string', 'max' => 1000],
            [['age_unit'], 'string', 'max' => 15],
            [['hospital'], 'string', 'max' => 400],
            [['status'], 'string', 'max' => 500],
            [['pathologist'], 'string', 'max' => 600],
            [['remark'], 'string', 'max' => 300],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id_case' => 'Id Case',
            'title' => 'Title',
            'name' => 'Name',
            'gender' => 'Gender',
            'birthdate' => 'Birthdate',
            'age' => 'Age',
            'age_unit' => 'Age Unit',
            'hospital_id' => 'Hospital ID',
            'hospital' => 'Hospital',
            'collect_at' => 'Collect At',
            'register_at' => 'Register At',
            'cut_at' => 'Cut At',
            'status_id' => 'Status ID',
            'status' => 'Status',
            'pathologist_id' => 'Pathologist ID',
            'pathologist' => 'Pathologist',
            'report_at' => 'Report At',
            'diagnosis' => 'Diagnosis',
            'approve_status' => 'Approve Status',
            'approve_by' => 'Approve By',
            'approve_at' => 'Approve At',
            'remark' => 'Remark',
            'approve_id' => 'Approve ID',
            'is_send_request' => 'Is Send Request',
            'is_critical_diagnosis' => 'Is Critical Diagnosis',
            'send_request_at' => 'Send Request At',
        ];
    }

    public function getApproveBy()
    {
        return $this->hasOne(User::class, ['id' => 'approve_by']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getApproveAt()
    {
        return $this->hasOne(User::class, ['id' => 'approve_at']);
    }
}
