fix: 解决查看病历字段缺失问题
This commit is contained in:
+84
-25
@@ -550,7 +550,7 @@
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<div v-if="showPublishedScoringRules" class="case-form-section">
|
||||
<div v-if="visibleScoringRules.length" class="case-form-section">
|
||||
<div class="case-section-title">
|
||||
<h3>评分规则</h3>
|
||||
</div>
|
||||
@@ -799,11 +799,8 @@ const searchPlaceholder = computed(() => (isContentAdmin.value ? '搜索病例'
|
||||
const detailDrawerTitle = computed(() => (detailCase.value ? `病例详情:${detailCase.value.title}` : '病例详情'))
|
||||
const detailDisplay = computed(() => createDetailDisplay(detailCase.value, caseDetail.value))
|
||||
const canEditDetailCase = computed(() => detailCase.value?.publishStatus === 0)
|
||||
const showPublishedScoringRules = computed(() => detailCase.value?.publishStatus === 2)
|
||||
const visibleScoringRules = computed(() =>
|
||||
showPublishedScoringRules.value
|
||||
? detailForm.scoring_rules.filter(rule => rule.dimension.trim() || rule.scoring_standard.trim())
|
||||
: []
|
||||
detailForm.scoring_rules.filter(rule => rule.dimension.trim() || rule.scoring_standard.trim())
|
||||
)
|
||||
const relationsCurrentTitle = computed(() => {
|
||||
if (!relationsCase.value) {
|
||||
@@ -1503,8 +1500,8 @@ function fillCaseFormFromImportedPdf(result: ImportCasePdfResult) {
|
||||
const caseType = normalizeImportCaseType(getImportString(record, ['case_type', 'caseType']), result.caseType)
|
||||
const traditional = getImportRecord(getImportFirst(record, ['traditional']))
|
||||
const teaching = getImportRecord(getImportFirst(record, ['teaching']))
|
||||
const scoringRules = getImportScoringRules(record)
|
||||
const examItems = getImportExamItems(record)
|
||||
const scoringRules = getImportScoringRules(result.raw, result.data, record)
|
||||
const examItems = getImportExamItems(result.raw, result.data, record)
|
||||
|
||||
caseForm.case_type = caseType
|
||||
caseForm.title = getImportString(record, ['title', 'name', 'case_title', 'caseTitle'])
|
||||
@@ -1539,8 +1536,8 @@ function fillDetailForm(row: CaseListItem, fullData: unknown) {
|
||||
const record = getDetailRecord(fullData)
|
||||
const traditional = getImportRecord(getImportFirst(record, ['traditional']))
|
||||
const teaching = getImportRecord(getImportFirst(record, ['teaching']))
|
||||
const scoringRules = getImportScoringRules(record)
|
||||
const examItems = getImportExamItems(record)
|
||||
const scoringRules = getImportScoringRules(fullData, record)
|
||||
const examItems = getImportExamItems(fullData, record)
|
||||
|
||||
detailForm.title = getImportString(record, ['title', 'name', 'case_title', 'caseTitle'], row.title)
|
||||
detailForm.case_type = normalizeImportCaseType(getImportString(record, ['case_type', 'caseType'], row.caseType), normalizeImportCaseType(row.caseType, 'traditional'))
|
||||
@@ -1646,8 +1643,8 @@ function getImportStringList(record: Record<string, unknown>, keys: string[]): s
|
||||
return []
|
||||
}
|
||||
|
||||
function getImportScoringRules(record: Record<string, unknown>): ScoringRuleForm[] {
|
||||
const raw = getImportFirst(record, ['scoring_rules', 'scoringRules'])
|
||||
function getImportScoringRules(...sources: unknown[]): ScoringRuleForm[] {
|
||||
const raw = findImportArray(['scoring_rules', 'scoringRules', 'score_rules', 'scoreRules', 'rules'], sources)
|
||||
if (!Array.isArray(raw)) {
|
||||
return []
|
||||
}
|
||||
@@ -1661,14 +1658,14 @@ function getImportScoringRules(record: Record<string, unknown>): ScoringRuleForm
|
||||
dimension: getImportString(itemRecord, ['dimension', 'name']),
|
||||
score_weight: scoreWeight ?? 1,
|
||||
ai_auto_score: rawAutoScore === undefined ? true : getImportBoolean(itemRecord, ['ai_auto_score', 'aiAutoScore']),
|
||||
scoring_standard: getImportString(itemRecord, ['scoring_standard', 'scoringStandard', 'description'])
|
||||
scoring_standard: getImportString(itemRecord, ['scoring_standard', 'scoringStandard', 'standard', 'description', 'content'])
|
||||
}
|
||||
})
|
||||
.filter(item => item.dimension || item.scoring_standard)
|
||||
}
|
||||
|
||||
function getImportExamItems(record: Record<string, unknown>): ExamItemForm[] {
|
||||
const raw = getImportFirst(record, ['exam_items', 'examItems'])
|
||||
function getImportExamItems(...sources: unknown[]): ExamItemForm[] {
|
||||
const raw = findImportArray(['exam_items', 'examItems', 'exams', 'exam_list', 'examList', 'items'], sources)
|
||||
if (!Array.isArray(raw)) {
|
||||
return []
|
||||
}
|
||||
@@ -1680,12 +1677,70 @@ function getImportExamItems(record: Record<string, unknown>): ExamItemForm[] {
|
||||
item_code: getImportString(itemRecord, ['item_code', 'itemCode', 'code']),
|
||||
item_name: getImportString(itemRecord, ['item_name', 'itemName', 'name']),
|
||||
item_type: getImportString(itemRecord, ['item_type', 'itemType', 'type']),
|
||||
result_text: getImportString(itemRecord, ['result_text', 'resultText'])
|
||||
result_text: getImportString(itemRecord, ['result_text', 'resultText', 'result', 'value', 'content'])
|
||||
}
|
||||
})
|
||||
.filter(item => item.item_code || item.item_name || item.item_type || item.result_text)
|
||||
}
|
||||
|
||||
function findImportArray(keys: string[], sources: unknown[]) {
|
||||
for (const source of sources) {
|
||||
const found = findImportArrayInSource(source, keys)
|
||||
if (found) {
|
||||
return found
|
||||
}
|
||||
}
|
||||
|
||||
return undefined
|
||||
}
|
||||
|
||||
function findImportArrayInSource(value: unknown, keys: string[], depth = 0): unknown[] | undefined {
|
||||
if (!value || typeof value !== 'object' || depth > 5) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
const record = value as Record<string, unknown>
|
||||
for (const key of keys) {
|
||||
const nested = record[key]
|
||||
if (Array.isArray(nested)) {
|
||||
return nested
|
||||
}
|
||||
}
|
||||
|
||||
const preferredKeys = [
|
||||
'data',
|
||||
'case',
|
||||
'case_detail',
|
||||
'caseDetail',
|
||||
'case_info',
|
||||
'caseInfo',
|
||||
'detail',
|
||||
'full',
|
||||
'result',
|
||||
'record',
|
||||
'item'
|
||||
]
|
||||
for (const key of preferredKeys) {
|
||||
const found = findImportArrayInSource(record[key], keys, depth + 1)
|
||||
if (found) {
|
||||
return found
|
||||
}
|
||||
}
|
||||
|
||||
for (const child of Object.values(record)) {
|
||||
const found = findImportArrayInSource(child, keys, depth + 1)
|
||||
if (found) {
|
||||
return found
|
||||
}
|
||||
}
|
||||
|
||||
return undefined
|
||||
}
|
||||
|
||||
function normalizeImportCaseType(value: string, fallback: DraftCaseType): DraftCaseType {
|
||||
return value === 'teaching' ? 'teaching' : fallback
|
||||
}
|
||||
@@ -1740,12 +1795,7 @@ function findDetailRecord(value: unknown, depth = 0): Record<string, unknown> |
|
||||
}
|
||||
|
||||
const record = value as Record<string, unknown>
|
||||
if (hasCaseDetailFields(record)) {
|
||||
return record
|
||||
}
|
||||
|
||||
const preferredKeys = [
|
||||
'data',
|
||||
'case',
|
||||
'case_detail',
|
||||
'caseDetail',
|
||||
@@ -1753,9 +1803,10 @@ function findDetailRecord(value: unknown, depth = 0): Record<string, unknown> |
|
||||
'caseInfo',
|
||||
'detail',
|
||||
'full',
|
||||
'result',
|
||||
'record',
|
||||
'item'
|
||||
'item',
|
||||
'data',
|
||||
'result'
|
||||
]
|
||||
for (const key of preferredKeys) {
|
||||
const found = findDetailRecord(record[key], depth + 1)
|
||||
@@ -1764,6 +1815,10 @@ function findDetailRecord(value: unknown, depth = 0): Record<string, unknown> |
|
||||
}
|
||||
}
|
||||
|
||||
if (hasCaseDetailFields(record)) {
|
||||
return record
|
||||
}
|
||||
|
||||
for (const child of Object.values(record)) {
|
||||
const found = findDetailRecord(child, depth + 1)
|
||||
if (found) {
|
||||
@@ -1783,12 +1838,16 @@ function hasCaseDetailFields(record: Record<string, unknown>) {
|
||||
'caseType',
|
||||
'chief_complaint',
|
||||
'chiefComplaint',
|
||||
'description',
|
||||
'summary',
|
||||
'content',
|
||||
'difficulty',
|
||||
'estimated_minutes',
|
||||
'estimatedMinutes',
|
||||
'patient_age',
|
||||
'patientAge',
|
||||
'patient_gender',
|
||||
'patientGender',
|
||||
'publish_status',
|
||||
'publishStatus'
|
||||
'patientGender'
|
||||
].some(key => record[key] !== undefined && record[key] !== null)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user