166 lines
5.5 KiB
PHP
166 lines
5.5 KiB
PHP
<?php
|
|
|
|
namespace App\Models\YiiModels;
|
|
|
|
use App\Models\DrugStoreBase;
|
|
use App\Models\DrugStoreRelation;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
|
|
|
/**
|
|
* App\Models\YiiModels\Drug
|
|
*
|
|
* @property int $id
|
|
* @property string $drug_name 药名
|
|
* @property string $pinyin_simple 拼音首拼
|
|
* @property string|null $source 货源(厂家)
|
|
* @property string $type 类型 1中药2西药3颗粒配方
|
|
* @property int $is_otc 是否处方药
|
|
* @property int $category_first 一级分类
|
|
* @property int $category_second 二级分类
|
|
* @property string|null $small_info 简介
|
|
* @property string|null $info 基础信息
|
|
* @property string|null $content 详情信息
|
|
* @property string|null $usage 用法
|
|
* @property string|null $function 功能主治
|
|
* @property string $specification 规格
|
|
* @property string|null $image 药品图片
|
|
* @property int $time_id 使用时间id
|
|
* @property int $type_id 使用方法id
|
|
* @property int $frequency_id 频率id
|
|
* @property int|null $unit_id 单位id
|
|
* @property int $number 数量
|
|
* @property int $status 状态 1草稿 2下架 3上架
|
|
* @property string|null $drug_number 药品编号
|
|
* @property string|null $bar_code 条形码
|
|
* @property string|null $guozi_no 国字准号
|
|
* @property string|null $drug_alias 药品别名
|
|
* @property string|null $place 产地
|
|
* @property string|null $decotion 煎法
|
|
* @property string|null $instruction 说明书图片
|
|
* @property \Illuminate\Support\Carbon $updated_at
|
|
* @property \Illuminate\Support\Carbon $created_at
|
|
* @property-read \App\Models\DrugStoreRelation|null $drugStoreRelation 门店售卖药品关系表[单]
|
|
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\DrugStoreRelation[] $drugStoreRelations 门店售卖药品关系表[多]
|
|
* @property-read int|null $drug_store_relations_count
|
|
* @property-read \App\Models\YiiModels\DrugstoreDrug|null $drugstoreDrug 门店药品关系(库存)[单关联]
|
|
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\YiiModels\DrugstoreDrug[] $drugstoreDrugs 门店药品关系(库存)[多关联]
|
|
* @property-read int|null $drugstore_drugs_count
|
|
* @property-read string $created_at_format 创建时间的格式化
|
|
* @property-read string $status_string 状态名称
|
|
* @property-read string $updated_at_format 更新时间的格式化
|
|
* @property-read \App\Models\YiiModels\WestUnit|null $unit 单位
|
|
* @property-read \App\Models\YiiModels\DrugUseTime|null $useTime 使用时间
|
|
* @property-read \App\Models\YiiModels\DrugUseFrequency|null $userFrequency 频率
|
|
* @property-read \App\Models\YiiModels\DrugUseType|null $userType 使用方法
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\YiiModels\Drug newModelQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\YiiModels\Drug newQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\YiiModels\Drug query()
|
|
* @mixin \Eloquent
|
|
*/
|
|
class Drug extends YiiBaseModel
|
|
{
|
|
// 药品类型
|
|
public const TYPE_CHINESE_DRUG = 1;
|
|
public const TYPE_WEST_DRUG = 2;
|
|
public const TYPE_PELLET_DRUG = 3;
|
|
public const TYPE_PELLET_PATENT = 4;
|
|
public const TYPE = [
|
|
self::TYPE_CHINESE_DRUG => '中药',
|
|
self::TYPE_WEST_DRUG => '西药',
|
|
self::TYPE_PELLET_DRUG => '颗粒配方',
|
|
self::TYPE_PELLET_PATENT => '中成药',
|
|
];
|
|
|
|
// 处方类型
|
|
public const IS_OTC_FALSE = 0;
|
|
public const IS_OTC_TRUE = 1;
|
|
public const IS_OTC = [
|
|
self::IS_OTC_FALSE => '非处方药',
|
|
self::IS_OTC_TRUE => '处方药',
|
|
];
|
|
|
|
// 状态
|
|
public const STATUS_DRAFT = 0;
|
|
public const STATUS_OFF = 1;
|
|
public const STATUS_ON = 2;
|
|
public const STATUS = [
|
|
self::STATUS_DRAFT => '草稿',
|
|
self::STATUS_OFF => '下架',
|
|
self::STATUS_ON => '上架',
|
|
];
|
|
|
|
/**
|
|
* @comment 门店药品关系(库存)[单关联]
|
|
* @return HasOne
|
|
*/
|
|
public function drugstoreDrug(): HasOne
|
|
{
|
|
return $this->hasOne(DrugstoreDrug::class, 'drug_id');
|
|
}
|
|
|
|
/**
|
|
* @comment 门店药品关系(库存)[多关联]
|
|
* @return HasMany
|
|
*/
|
|
public function drugstoreDrugs(): HasMany
|
|
{
|
|
return $this->hasMany(DrugstoreDrug::class, 'drug_id');
|
|
}
|
|
|
|
/**
|
|
* @comment 门店售卖药品关系表[单]
|
|
* @return HasOne
|
|
*/
|
|
public function drugStoreRelation(): HasOne
|
|
{
|
|
return $this->hasOne(DrugStoreRelation::class, 'drug_id');
|
|
}
|
|
|
|
/**
|
|
* @comment 门店售卖药品关系表[多]
|
|
* @return HasMany
|
|
*/
|
|
public function drugStoreRelations(): HasMany
|
|
{
|
|
return $this->hasMany(DrugStoreRelation::class, 'drug_id');
|
|
}
|
|
|
|
/**
|
|
* @comment 使用时间
|
|
* @return BelongsTo
|
|
*/
|
|
public function useTime(): BelongsTo
|
|
{
|
|
return $this->belongsTo(DrugUseTime::class, 'time_id');
|
|
}
|
|
|
|
/**
|
|
* @comment 使用方法
|
|
* @return BelongsTo
|
|
*/
|
|
public function userType(): BelongsTo
|
|
{
|
|
return $this->belongsTo(DrugUseType::class, 'type_id');
|
|
}
|
|
|
|
/**
|
|
* @comment 频率
|
|
* @return BelongsTo
|
|
*/
|
|
public function userFrequency(): BelongsTo
|
|
{
|
|
return $this->belongsTo(DrugUseFrequency::class, 'frequency_id');
|
|
}
|
|
|
|
/**
|
|
* @comment 单位
|
|
* @return BelongsTo
|
|
*/
|
|
public function unit(): BelongsTo
|
|
{
|
|
return $this->belongsTo(WestUnit::class, 'unit_id');
|
|
}
|
|
}
|