update
This commit is contained in:
@@ -122,46 +122,23 @@ type SOPEdge struct {
|
||||
Priority int `json:"priority" gorm:"not null"`
|
||||
}
|
||||
|
||||
type KnowledgeItem struct {
|
||||
Base
|
||||
TenantID uint64 `json:"tenant_id" gorm:"not null;index"`
|
||||
ScenarioID uint64 `json:"scenario_id" gorm:"not null;index"`
|
||||
ItemKey string `json:"key" gorm:"size:64;not null"`
|
||||
Name string `json:"name" gorm:"size:128;not null"`
|
||||
Type string `json:"type" gorm:"size:64;not null"`
|
||||
Content datatypes.JSON `json:"content" gorm:"type:json;not null"`
|
||||
Status string `json:"status" gorm:"size:24;not null"`
|
||||
SortOrder int `json:"sort_order" gorm:"not null"`
|
||||
}
|
||||
|
||||
type KnowledgeRelation struct {
|
||||
Base
|
||||
TenantID uint64 `json:"tenant_id" gorm:"not null;index"`
|
||||
ScenarioID uint64 `json:"scenario_id" gorm:"not null;index"`
|
||||
FromKnowledgeID uint64 `json:"from_knowledge_id" gorm:"not null;index"`
|
||||
RelationType string `json:"relation_type" gorm:"size:64;not null"`
|
||||
ToKnowledgeID uint64 `json:"to_knowledge_id" gorm:"not null;index"`
|
||||
Condition datatypes.JSON `json:"condition" gorm:"type:json;not null"`
|
||||
SortOrder int `json:"sort_order" gorm:"not null"`
|
||||
}
|
||||
|
||||
type SOPRun struct {
|
||||
Base
|
||||
TenantID uint64 `json:"tenant_id" gorm:"not null;index"`
|
||||
SOPID uint64 `json:"sop_id" gorm:"not null;index"`
|
||||
OperatorID uint64 `json:"operator_id" gorm:"not null;index"`
|
||||
ExternalRef string `json:"external_ref" gorm:"size:191;not null;index"`
|
||||
CurrentNodeKey string `json:"current_node_key" gorm:"size:64;not null"`
|
||||
Status string `json:"status" gorm:"size:24;not null"`
|
||||
Answers datatypes.JSON `json:"answers" gorm:"type:json;not null"`
|
||||
Input datatypes.JSON `json:"input" gorm:"type:json;not null"`
|
||||
Derived datatypes.JSON `json:"derived" gorm:"type:json;not null"`
|
||||
Outputs datatypes.JSON `json:"outputs" gorm:"type:json;not null"`
|
||||
KnowledgeSnapshot datatypes.JSON `json:"knowledge_snapshot" gorm:"type:json;not null"`
|
||||
Result string `json:"result" gorm:"size:64;not null"`
|
||||
FinalResult datatypes.JSON `json:"final_result" gorm:"type:json"`
|
||||
StartedAt time.Time `json:"started_at"`
|
||||
CompletedAt *time.Time `json:"completed_at"`
|
||||
TenantID uint64 `json:"tenant_id" gorm:"not null;index"`
|
||||
SOPID uint64 `json:"sop_id" gorm:"not null;index"`
|
||||
OperatorID uint64 `json:"operator_id" gorm:"not null;index"`
|
||||
ExternalRef string `json:"external_ref" gorm:"size:191;not null;index"`
|
||||
CurrentNodeKey string `json:"current_node_key" gorm:"size:64;not null"`
|
||||
Status string `json:"status" gorm:"size:24;not null"`
|
||||
Answers datatypes.JSON `json:"answers" gorm:"type:json;not null"`
|
||||
Input datatypes.JSON `json:"input" gorm:"type:json;not null"`
|
||||
Derived datatypes.JSON `json:"derived" gorm:"type:json;not null"`
|
||||
Outputs datatypes.JSON `json:"outputs" gorm:"type:json;not null"`
|
||||
ScriptState datatypes.JSON `json:"script_state" gorm:"type:json;not null"`
|
||||
Result string `json:"result" gorm:"size:64;not null"`
|
||||
FinalResult datatypes.JSON `json:"final_result" gorm:"type:json"`
|
||||
StartedAt time.Time `json:"started_at"`
|
||||
CompletedAt *time.Time `json:"completed_at"`
|
||||
}
|
||||
|
||||
type SOPRunEvent struct {
|
||||
|
||||
148
internal/model/scriptkit.go
Normal file
148
internal/model/scriptkit.go
Normal file
@@ -0,0 +1,148 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/datatypes"
|
||||
)
|
||||
|
||||
// ScriptPackage is the scenario-level script package. It replaces the legacy
|
||||
// knowledge graph for the consultation scenario. A package owns dimensions,
|
||||
// dimension values, stages, scripts, options, linkages and entry adapters.
|
||||
type ScriptPackage struct {
|
||||
Base
|
||||
TenantID uint64 `json:"tenant_id" gorm:"not null;index"`
|
||||
ScenarioID uint64 `json:"scenario_id" gorm:"not null;uniqueIndex"`
|
||||
Name string `json:"name" gorm:"size:128;not null"`
|
||||
Status string `json:"status" gorm:"size:24;not null"`
|
||||
StartStageKey string `json:"start_stage_key" gorm:"size:64;not null"`
|
||||
CreatedBy uint64 `json:"created_by" gorm:"not null"`
|
||||
}
|
||||
|
||||
// PackageDimension is a quantifiable dimension (symptom, disease, plan, ...).
|
||||
type PackageDimension struct {
|
||||
Base
|
||||
TenantID uint64 `json:"tenant_id" gorm:"not null;index"`
|
||||
PackageID uint64 `json:"package_id" gorm:"not null;index"`
|
||||
DimKey string `json:"dim_key" gorm:"size:64;not null"`
|
||||
Name string `json:"name" gorm:"size:128;not null"`
|
||||
SortOrder int `json:"sort_order" gorm:"not null"`
|
||||
}
|
||||
|
||||
// DimensionValue is one value of a dimension and carries a runtime weight.
|
||||
type DimensionValue struct {
|
||||
Base
|
||||
TenantID uint64 `json:"tenant_id" gorm:"not null;index"`
|
||||
PackageID uint64 `json:"package_id" gorm:"not null;index"`
|
||||
DimensionID uint64 `json:"dimension_id" gorm:"not null;index"`
|
||||
ValueKey string `json:"value_key" gorm:"size:64;not null"`
|
||||
Name string `json:"name" gorm:"size:128;not null"`
|
||||
InitialWeight int `json:"initial_weight" gorm:"not null"`
|
||||
SortOrder int `json:"sort_order" gorm:"not null"`
|
||||
}
|
||||
|
||||
// PackageStage is a SOP stage inside a script package. Each stage has a primary
|
||||
// dimension that drives script matching.
|
||||
type PackageStage struct {
|
||||
Base
|
||||
TenantID uint64 `json:"tenant_id" gorm:"not null;index"`
|
||||
PackageID uint64 `json:"package_id" gorm:"not null;index"`
|
||||
StageKey string `json:"stage_key" gorm:"size:64;not null"`
|
||||
Name string `json:"name" gorm:"size:128;not null"`
|
||||
Purpose string `json:"purpose" gorm:"type:text;not null"`
|
||||
PrimaryDimensionID uint64 `json:"primary_dimension_id" gorm:"not null;index"`
|
||||
SortOrder int `json:"sort_order" gorm:"not null"`
|
||||
}
|
||||
|
||||
// StageScript is a script shown inside a stage. ScriptType is one of
|
||||
// confirm / info / choice / template / fallback / message. Products is the
|
||||
// static product list attached to recommendation scripts. Multiple marks a
|
||||
// choice script whose options can be selected together.
|
||||
type StageScript struct {
|
||||
Base
|
||||
TenantID uint64 `json:"tenant_id" gorm:"not null;index"`
|
||||
PackageID uint64 `json:"package_id" gorm:"not null;index"`
|
||||
StageID uint64 `json:"stage_id" gorm:"not null;index"`
|
||||
ScriptKey string `json:"script_key" gorm:"size:64;not null"`
|
||||
Name string `json:"name" gorm:"size:128;not null"`
|
||||
ScriptType string `json:"script_type" gorm:"size:32;not null"`
|
||||
Content string `json:"content" gorm:"type:text;not null"`
|
||||
DimensionValueID *uint64 `json:"dimension_value_id" gorm:"index"`
|
||||
ShowThreshold int `json:"show_threshold" gorm:"not null"`
|
||||
ConfirmThreshold int `json:"confirm_threshold" gorm:"not null"`
|
||||
CollectFieldKey string `json:"collect_field_key" gorm:"size:64;not null"`
|
||||
Required bool `json:"required" gorm:"not null"`
|
||||
Multiple bool `json:"multiple" gorm:"not null"`
|
||||
Products datatypes.JSON `json:"products" gorm:"type:json;not null"`
|
||||
SortOrder int `json:"sort_order" gorm:"not null"`
|
||||
}
|
||||
|
||||
// ScriptOption is one answer option of a script. Effect is set/add/subtract/zero
|
||||
// and targets a dimension value.
|
||||
type ScriptOption struct {
|
||||
Base
|
||||
TenantID uint64 `json:"tenant_id" gorm:"not null;index"`
|
||||
PackageID uint64 `json:"package_id" gorm:"not null;index"`
|
||||
ScriptID uint64 `json:"script_id" gorm:"not null;index"`
|
||||
OptionKey string `json:"option_key" gorm:"size:64;not null"`
|
||||
Label string `json:"label" gorm:"size:128;not null"`
|
||||
TargetDimensionValueID *uint64 `json:"target_dimension_value_id" gorm:"index"`
|
||||
Effect string `json:"effect" gorm:"size:16;not null"`
|
||||
EffectValue int `json:"effect_value" gorm:"not null"`
|
||||
SortOrder int `json:"sort_order" gorm:"not null"`
|
||||
}
|
||||
|
||||
// DimensionLinkage propagates a confirmed source dimension value weight into
|
||||
// a target dimension value (for example symptom -> disease). A source counts
|
||||
// as confirmed only when its weight reaches ActivationThreshold (engine
|
||||
// default 5 when the value is zero).
|
||||
type DimensionLinkage struct {
|
||||
Base
|
||||
TenantID uint64 `json:"tenant_id" gorm:"not null;index"`
|
||||
PackageID uint64 `json:"package_id" gorm:"not null;index"`
|
||||
FromDimensionValueID uint64 `json:"from_dimension_value_id" gorm:"not null;index"`
|
||||
ToDimensionValueID uint64 `json:"to_dimension_value_id" gorm:"not null;index"`
|
||||
RelationType string `json:"relation_type" gorm:"size:64;not null"`
|
||||
Contribution int `json:"contribution" gorm:"not null"`
|
||||
ActivationThreshold int `json:"activation_threshold" gorm:"not null"`
|
||||
Condition datatypes.JSON `json:"condition" gorm:"type:json;not null"`
|
||||
SortOrder int `json:"sort_order" gorm:"not null"`
|
||||
}
|
||||
|
||||
// PackageAdapter initializes a dimension value weight from an incoming or
|
||||
// derived field value (for example an order product id or symptom tag).
|
||||
type PackageAdapter struct {
|
||||
Base
|
||||
TenantID uint64 `json:"tenant_id" gorm:"not null;index"`
|
||||
PackageID uint64 `json:"package_id" gorm:"not null;index"`
|
||||
SourceField string `json:"source_field" gorm:"size:128;not null"`
|
||||
MatchValue string `json:"match_value" gorm:"size:191;not null"`
|
||||
TargetDimensionValueID uint64 `json:"target_dimension_value_id" gorm:"not null;index"`
|
||||
Weight int `json:"weight" gorm:"not null"`
|
||||
SortOrder int `json:"sort_order" gorm:"not null"`
|
||||
}
|
||||
|
||||
// RunDimension is the materialized current weight of one dimension value in a
|
||||
// run. It is recomputed deterministically after every mutation.
|
||||
type RunDimension struct {
|
||||
Base
|
||||
TenantID uint64 `json:"tenant_id" gorm:"not null;index"`
|
||||
RunID uint64 `json:"run_id" gorm:"not null;index"`
|
||||
PackageID uint64 `json:"package_id" gorm:"not null;index"`
|
||||
DimensionID uint64 `json:"dimension_id" gorm:"not null;index"`
|
||||
ValueKey string `json:"value_key" gorm:"size:64;not null"`
|
||||
Weight int `json:"weight" gorm:"not null"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// ScriptFeedback records like/report/unreasonable feedback on a script.
|
||||
type ScriptFeedback struct {
|
||||
Base
|
||||
TenantID uint64 `json:"tenant_id" gorm:"not null;index"`
|
||||
RunID uint64 `json:"run_id" gorm:"not null;index"`
|
||||
StageID uint64 `json:"stage_id" gorm:"not null;index"`
|
||||
ScriptID uint64 `json:"script_id" gorm:"not null;index"`
|
||||
FeedbackType string `json:"feedback_type" gorm:"size:32;not null"`
|
||||
OperatorID uint64 `json:"operator_id" gorm:"not null;index"`
|
||||
Note string `json:"note" gorm:"type:text;not null"`
|
||||
}
|
||||
Reference in New Issue
Block a user