Files
silk/server-go/internal/model/lamp.go
T

56 lines
2.5 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"`
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"`
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" }
// 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
}
}