73 lines
3.6 KiB
Go
73 lines
3.6 KiB
Go
package model
|
|
|
|
import (
|
|
"encoding/json"
|
|
"time"
|
|
)
|
|
|
|
// LampTest LAMP 检测任务单
|
|
type LampTest struct {
|
|
ID string `gorm:"type:uuid;primaryKey;default:gen_random_uuid()" json:"id"`
|
|
Method string `gorm:"size:32;default:lamp" json:"method"` // lamp/qpcr/sers/hyperspectral
|
|
DetectionTaskID *string `gorm:"column:detection_task_id;type:uuid;index" json:"detectionTaskId,omitempty"`
|
|
RoomID *string `gorm:"column:room_id;type:uuid;index" json:"roomId,omitempty"`
|
|
BatchID *string `gorm:"column:batch_id;type:uuid;index" json:"batchId,omitempty"`
|
|
Diseases json.RawMessage `gorm:"type:jsonb" json:"diseases,omitempty"`
|
|
Status string `gorm:"size:16;default:pending" json:"status"` // pending/testing/resulted
|
|
SampleInfo *string `gorm:"column:sample_info;size:255" json:"sampleInfo,omitempty"`
|
|
Result *string `gorm:"size:16" json:"result,omitempty"` // positive/negative/invalid
|
|
ResultImageURL *string `gorm:"column:result_image_url;size:512" json:"resultImageUrl,omitempty"`
|
|
OperatorID *string `gorm:"column:operator_id;type:uuid" json:"operatorId,omitempty"`
|
|
ResultedAt *time.Time `gorm:"column:resulted_at;type:timestamptz" json:"resultedAt,omitempty"`
|
|
CrossStatus string `gorm:"column:cross_status;size:16;default:pending" json:"crossStatus"` // pending/consistent/inconsistent
|
|
CrossReason *string `gorm:"column:cross_reason;type:text" json:"crossReason,omitempty"`
|
|
ExtraData json.RawMessage `gorm:"column:extra_data;type:jsonb" json:"extraData,omitempty"`
|
|
Note *string `gorm:"type:text" json:"note,omitempty"`
|
|
CreatedAt time.Time `gorm:"type:timestamptz" json:"createdAt"`
|
|
UpdatedAt time.Time `gorm:"type:timestamptz" json:"updatedAt"`
|
|
}
|
|
|
|
func (LampTest) TableName() string { return "lamp_tests" }
|
|
|
|
// LampTestStep LAMP 检测步骤
|
|
type LampTestStep struct {
|
|
ID string `gorm:"type:uuid;primaryKey;default:gen_random_uuid()" json:"id"`
|
|
LampTestID string `gorm:"column:lamp_test_id;type:uuid;index" json:"lampTestId"`
|
|
StepNo int `gorm:"column:step_no;type:int" json:"stepNo"`
|
|
Name string `gorm:"size:64" json:"name"`
|
|
Done bool `gorm:"default:false" json:"done"`
|
|
DoneAt *time.Time `gorm:"column:done_at;type:timestamptz" json:"doneAt,omitempty"`
|
|
Note *string `gorm:"type:text" json:"note,omitempty"`
|
|
CreatedAt time.Time `gorm:"type:timestamptz" json:"createdAt"`
|
|
UpdatedAt time.Time `gorm:"type:timestamptz" json:"updatedAt"`
|
|
}
|
|
|
|
func (LampTestStep) TableName() string { return "lamp_test_steps" }
|
|
|
|
// SpectrumEntry 光谱库条目
|
|
type SpectrumEntry struct {
|
|
ID string `gorm:"type:uuid;primaryKey;default:gen_random_uuid()" json:"id"`
|
|
Disease string `gorm:"size:64" json:"disease"`
|
|
Source *string `gorm:"size:128" json:"source,omitempty"`
|
|
DataURL *string `gorm:"column:data_url;size:512" json:"dataUrl,omitempty"`
|
|
Note *string `gorm:"type:text" json:"note,omitempty"`
|
|
CreatedAt time.Time `gorm:"type:timestamptz" json:"createdAt"`
|
|
}
|
|
|
|
func (SpectrumEntry) TableName() string { return "spectrum_entries" }
|
|
|
|
// DefaultLampSteps LAMP 标准 5 步流程(规格书 3.3.2.1)
|
|
func DefaultLampSteps() []string {
|
|
return []string{"采样", "DNA提取", "反应体系配制", "恒温反应", "结果判读"}
|
|
}
|
|
|
|
// ValidLampResult 校验 LAMP 结果枚举
|
|
func ValidLampResult(result string) bool {
|
|
switch result {
|
|
case "positive", "negative", "invalid":
|
|
return true
|
|
default:
|
|
return false
|
|
}
|
|
}
|