Files
genome2025/backend/src/mpt/entities/mpt.entity.ts

264 lines
4.3 KiB
TypeScript

import { BaseModel } from 'src/common/entities/base.entity';
import { CowModel } from 'src/cow/entities/cow.entity';
import {
Column,
Entity,
Index,
JoinColumn,
ManyToOne,
PrimaryGeneratedColumn,
} from 'typeorm';
/**
* 혈액화학검사 결과 (1개체 N검사)
*/
@Entity({ name: 'tb_mpt' })
export class MptModel extends BaseModel {
@PrimaryGeneratedColumn({
name: 'pk_mpt_no',
type: 'int',
comment: 'MPT 번호 (PK)',
})
pkMptNo: number;
@Index('idx_mpt_cow_id')
@Column({
name: 'cow_id',
type: 'varchar',
length: 15,
nullable: true,
comment: '개체식별번호 (KOR...)',
})
cowId: string;
@Column({
name: 'cow_short_no',
type: 'varchar',
length: 4,
nullable: true,
comment: '개체 요약번호 (뒤 4자리)',
})
cowShortNo: string;
@Index('idx_mpt_fk_farm_no')
@Column({
name: 'fk_farm_no',
type: 'int',
nullable: true,
comment: '농장번호 FK',
})
fkFarmNo: number;
@Column({
name: 'test_dt',
type: 'date',
nullable: true,
comment: '검사일자',
})
testDt: Date;
@Column({
name: 'month_age',
type: 'int',
nullable: true,
comment: '월령',
})
monthAge: number;
@Column({
name: 'milk_yield',
type: 'decimal',
precision: 10,
scale: 2,
nullable: true,
comment: '유량',
})
milkYield: number;
@Column({
name: 'parity',
type: 'int',
nullable: true,
comment: '산차',
})
parity: number;
@Column({
name: 'glucose',
type: 'decimal',
precision: 10,
scale: 2,
nullable: true,
comment: '혈당',
})
glucose: number;
@Column({
name: 'cholesterol',
type: 'decimal',
precision: 10,
scale: 2,
nullable: true,
comment: '콜레스테롤',
})
cholesterol: number;
@Column({
name: 'nefa',
type: 'decimal',
precision: 10,
scale: 2,
nullable: true,
comment: '유리지방산(NEFA)',
})
nefa: number;
@Column({
name: 'bcs',
type: 'decimal',
precision: 5,
scale: 2,
nullable: true,
comment: 'BCS',
})
bcs: number;
@Column({
name: 'total_protein',
type: 'decimal',
precision: 10,
scale: 2,
nullable: true,
comment: '총단백질',
})
totalProtein: number;
@Column({
name: 'albumin',
type: 'decimal',
precision: 10,
scale: 2,
nullable: true,
comment: '알부민',
})
albumin: number;
@Column({
name: 'globulin',
type: 'decimal',
precision: 10,
scale: 2,
nullable: true,
comment: '총글로불린',
})
globulin: number;
@Column({
name: 'ag_ratio',
type: 'decimal',
precision: 5,
scale: 2,
nullable: true,
comment: 'A/G 비율',
})
agRatio: number;
@Column({
name: 'bun',
type: 'decimal',
precision: 10,
scale: 2,
nullable: true,
comment: '요소태질소(BUN)',
})
bun: number;
@Column({
name: 'ast',
type: 'decimal',
precision: 10,
scale: 2,
nullable: true,
comment: 'AST',
})
ast: number;
@Column({
name: 'ggt',
type: 'decimal',
precision: 10,
scale: 2,
nullable: true,
comment: 'GGT',
})
ggt: number;
@Column({
name: 'fatty_liver_idx',
type: 'decimal',
precision: 10,
scale: 2,
nullable: true,
comment: '지방간지수',
})
fattyLiverIdx: number;
@Column({
name: 'calcium',
type: 'decimal',
precision: 10,
scale: 2,
nullable: true,
comment: '칼슘',
})
calcium: number;
@Column({
name: 'phosphorus',
type: 'decimal',
precision: 10,
scale: 2,
nullable: true,
comment: '인',
})
phosphorus: number;
@Column({
name: 'ca_p_ratio',
type: 'decimal',
precision: 5,
scale: 2,
nullable: true,
comment: '칼슘/인 비율',
})
caPRatio: number;
@Column({
name: 'magnesium',
type: 'decimal',
precision: 10,
scale: 2,
nullable: true,
comment: '마그네슘',
})
magnesium: number;
@Column({
name: 'creatine',
type: 'decimal',
precision: 10,
scale: 2,
nullable: true,
comment: '크레아틴',
})
creatine: number;
// Relations
@ManyToOne(() => CowModel, {
onDelete: 'CASCADE',
createForeignKeyConstraints: false
})
@JoinColumn({ name: 'cow_id', referencedColumnName: 'cowId' })
cow: CowModel;
}