feat: 修复 AI 风险语义并隔离 Mock 数据
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package service
|
||||
|
||||
import "strings"
|
||||
|
||||
// CrossValidate 交叉验证:AI 检测结果 vs LAMP 检测结果(规格书:一致→确认诊断;不一致→升级专家会诊)
|
||||
func CrossValidate(aiClass, lampResult string, lampDiseases []string) (bool, string) {
|
||||
switch {
|
||||
@@ -7,6 +9,8 @@ func CrossValidate(aiClass, lampResult string, lampDiseases []string) (bool, str
|
||||
return false, "LAMP 判读无效,建议复检或专家会诊"
|
||||
case aiClass == "":
|
||||
return false, "未找到关联巡检记录,暂无法交叉验证"
|
||||
case aiClass == "unknown":
|
||||
return false, "AI 结果未知,建议复检或专家会诊"
|
||||
case aiClass == "sick" && lampResult == "positive":
|
||||
return true, "AI 检出异常与 LAMP 阳性一致,确认诊断"
|
||||
case aiClass == "healthy" && lampResult == "negative":
|
||||
@@ -20,15 +24,26 @@ func CrossValidate(aiClass, lampResult string, lampDiseases []string) (bool, str
|
||||
}
|
||||
}
|
||||
|
||||
// AIClassFromDetections 从巡检检测结果归纳 AI 结论(任一非 healthy 视为 sick)
|
||||
// AIClassFromDetections 从巡检检测结果归纳 AI 结论;空检测或 unknown 不当作 healthy。
|
||||
func AIClassFromDetections(detections []AIDetection) string {
|
||||
if len(detections) == 0 {
|
||||
return ""
|
||||
return "unknown"
|
||||
}
|
||||
healthySeen := false
|
||||
unknownSeen := false
|
||||
for _, d := range detections {
|
||||
if d.ClassName != "healthy" {
|
||||
class := strings.ToLower(strings.TrimSpace(d.ClassName))
|
||||
switch class {
|
||||
case "healthy":
|
||||
healthySeen = true
|
||||
case "", "unknown":
|
||||
unknownSeen = true
|
||||
default:
|
||||
return "sick"
|
||||
}
|
||||
}
|
||||
return "healthy"
|
||||
if healthySeen && !unknownSeen {
|
||||
return "healthy"
|
||||
}
|
||||
return "unknown"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user