feat: 联调登录+对话
This commit is contained in:
+38
-9
@@ -1,3 +1,5 @@
|
||||
import { createTrainingSession, type PatientConfigPayload, type TrainingMode } from './session'
|
||||
|
||||
export type ScenarioRecommendation = {
|
||||
id: string
|
||||
title: string
|
||||
@@ -28,6 +30,7 @@ export type ScenarioOptions = {
|
||||
export type ScenarioConfigPayload = ScenarioForm & {
|
||||
caseId: string
|
||||
caseNo: string
|
||||
mode: TrainingMode
|
||||
recommendationId?: string
|
||||
}
|
||||
|
||||
@@ -41,7 +44,7 @@ export function fetchScenarioOptions() {
|
||||
tags: ['中年', '配合'],
|
||||
defaults: {
|
||||
environment: 'outpatient',
|
||||
ageGroup: 'middle',
|
||||
ageGroup: 'middle_aged',
|
||||
education: 'higher',
|
||||
personality: 'calm'
|
||||
}
|
||||
@@ -55,7 +58,7 @@ export function fetchScenarioOptions() {
|
||||
environment: 'emergency',
|
||||
ageGroup: 'elderly',
|
||||
education: 'secondary',
|
||||
personality: 'irritable'
|
||||
personality: 'impatient'
|
||||
}
|
||||
}
|
||||
] as ScenarioRecommendation[],
|
||||
@@ -67,19 +70,19 @@ export function fetchScenarioOptions() {
|
||||
],
|
||||
ageGroups: [
|
||||
{ value: 'child', label: '儿童' },
|
||||
{ value: 'young', label: '青年' },
|
||||
{ value: 'middle', label: '中年' },
|
||||
{ value: 'youth', label: '青年' },
|
||||
{ value: 'middle_aged', label: '中年' },
|
||||
{ value: 'elderly', label: '老年' }
|
||||
],
|
||||
educations: [
|
||||
{ value: 'primary', label: '小学及以下' },
|
||||
{ value: 'primary_or_below', label: '小学及以下' },
|
||||
{ value: 'secondary', label: '中等教育' },
|
||||
{ value: 'higher', label: '高等教育' }
|
||||
],
|
||||
personalities: [
|
||||
{ value: 'calm', label: '平和' },
|
||||
{ value: 'anxious', label: '焦虑' },
|
||||
{ value: 'irritable', label: '急躁' },
|
||||
{ value: 'impatient', label: '急躁' },
|
||||
{ value: 'cooperative', label: '配合' },
|
||||
{ value: 'suspicious', label: '多疑' }
|
||||
]
|
||||
@@ -88,9 +91,35 @@ export function fetchScenarioOptions() {
|
||||
}
|
||||
|
||||
export function createScenarioConfig(payload: ScenarioConfigPayload) {
|
||||
return Promise.resolve({
|
||||
id: `mock-scenario-${Date.now()}`,
|
||||
return createTrainingSession({
|
||||
case_id: 1,
|
||||
training_type: 'diagnosis_treatment',
|
||||
mode: payload.mode,
|
||||
score_type: 'percentage',
|
||||
patient_config: {
|
||||
visit_environment: payload.environment as PatientConfigPayload['visit_environment'],
|
||||
age_group: payload.ageGroup as PatientConfigPayload['age_group'],
|
||||
education_level: payload.education as PatientConfigPayload['education_level'],
|
||||
personality: payload.personality as PatientConfigPayload['personality']
|
||||
}
|
||||
}).then(session => ({
|
||||
id: session.session_code,
|
||||
...payload,
|
||||
session,
|
||||
createdAt: new Date().toISOString()
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
function resolveCaseId(payload: ScenarioConfigPayload) {
|
||||
const explicitId = Number(payload.caseId)
|
||||
if (Number.isInteger(explicitId) && explicitId > 0) return explicitId
|
||||
|
||||
const caseNo = Number(payload.caseNo)
|
||||
if (Number.isInteger(caseNo) && caseNo > 0) return caseNo
|
||||
|
||||
const matched = payload.caseId.match(/\d+/)
|
||||
const fallbackId = matched ? Number(matched[0]) : 0
|
||||
if (Number.isInteger(fallbackId) && fallbackId > 0) return fallbackId
|
||||
|
||||
throw new Error('病例 ID 无效,无法新建会话')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user