diff --git a/internal/infra/models/medication.go b/internal/infra/models/medication.go new file mode 100644 index 0000000..05dcbce --- /dev/null +++ b/internal/infra/models/medication.go @@ -0,0 +1,68 @@ +package models + +import ( + "time" + + "gorm.io/datatypes" + "gorm.io/gorm" +) + +/* + 所有与药品、疫苗和用药记录相关的模型 +*/ + +// MedicationType 定义了兽药的类型 +type MedicationType string + +const ( + Powder MedicationType = "粉剂" + Injection MedicationType = "针剂" + Vaccine MedicationType = "疫苗" +) + +// MedicationCategory 定义了兽药的种类 +type MedicationCategory string + +const ( + Tetracycline MedicationCategory = "四环素类" + Sulfonamide MedicationCategory = "磺胺类" + Penicillin MedicationCategory = "青霉素类" + Macrolide MedicationCategory = "大环内酯类" + Quinolone MedicationCategory = "喹诺酮类" + Anthelmintic MedicationCategory = "驱虫药" + Disinfectant MedicationCategory = "消毒药" + BiologicalProduct MedicationCategory = "生物制品" +) + +// MixType 定义了粉剂药物该如何混合 +type MixType string + +const ( + MixFeed = "饲料加药" + MixWater = "水中加药" +) + +// PowderInstructions 定义了粉剂使用说明. +// 在程序中, 可以将 Medication.Instructions 字段反序列化为此结构进行操作. +type PowderInstructions struct { + // 出栏前停药期 + WithdrawalPeriod time.Duration `json:"withdrawal_period"` + // 拌料使用计量, 每千克体重用多少克药, 单位: g/kg + BodyWeightDosageUsed float64 `json:"body_weight_dosage_used"` + // 拌料使用剂量, 每升水加多少克药或每千克饲料干重加多少克药, 单位: g/kg(L) + MixDosageUsed float64 `json:"mix_dosage_used"` + // 拌料使用方式, 兑水/拌料 + MixType MixType `json:"mix_type"` +} + +// Medication 定义了兽药/疫苗的基本信息模型 +type Medication struct { + gorm.Model + Name string `gorm:"size:100;not null;comment:药品名称" json:"name"` + Type MedicationType `gorm:"size:20;not null;comment:兽药类型 (粉剂, 针剂, 疫苗)" json:"type"` + Category MedicationCategory `gorm:"size:30;not null;comment:兽药种类 (四环素类, 磺胺类等)" json:"category"` + DosagePerUnit float64 `gorm:"size:50;comment:一份药物的计量 (针剂计量单位为毫升, 粉剂为克)" json:"dosage_per_unit"` + ActiveIngredientConcentration float64 `gorm:"size:50;comment:有效成分含量百分比" json:"active_ingredient_concentration"` + Manufacturer string `gorm:"size:100;comment:生产厂家" json:"manufacturer"` + Instructions datatypes.JSON `gorm:"type:jsonb;comment:使用说明" json:"instructions"` +}