协议样本、生产产出和盘点明细按行更新并保留原 id;补齐存储证明质检预填、离职人员显示名,以及样本采集通知模板字段。 Co-authored-by: Cursor <cursoragent@cursor.com>
198 lines
7.2 KiB
TypeScript
198 lines
7.2 KiB
TypeScript
import {
|
|
SAMPLE_TYPE_PERINATAL_HSC,
|
|
SAMPLE_TYPE_UC_MSC
|
|
} from '@/utils/sample-production-reception-fields'
|
|
|
|
export type StorageCertQcTypeKey = 'perinatal_hsc' | 'uc_msc'
|
|
|
|
export type StorageCertQcControl = 'text' | 'textarea' | 'select_yny' | 'select_result'
|
|
|
|
export interface StorageCertQcField {
|
|
key: string
|
|
label: string
|
|
control?: StorageCertQcControl
|
|
span?: 1 | 2 | 3
|
|
}
|
|
|
|
export interface StorageCertQcGroup {
|
|
title: string
|
|
variant?: 'primary' | 'alt' | 'meta'
|
|
fields: StorageCertQcField[]
|
|
}
|
|
|
|
export function resolveStorageCertQcTypeKey(
|
|
sampleTypeName?: string | null
|
|
): StorageCertQcTypeKey | null {
|
|
const name = String(sampleTypeName || '').trim()
|
|
if (name === SAMPLE_TYPE_PERINATAL_HSC) return 'perinatal_hsc'
|
|
if (name === SAMPLE_TYPE_UC_MSC) return 'uc_msc'
|
|
return null
|
|
}
|
|
|
|
export function supportsStorageCertQc(sampleTypeName?: string | null): boolean {
|
|
return resolveStorageCertQcTypeKey(sampleTypeName) != null
|
|
}
|
|
|
|
const MOTHER_BLOOD: StorageCertQcField[] = [
|
|
{ key: 'mother_hbsag', label: '乙型肝炎病毒表面抗原(HBsAg)', control: 'select_yny' },
|
|
{ key: 'mother_hbv_dna', label: '乙型肝炎病毒核酸(HBV DNA)', control: 'select_yny' },
|
|
{ key: 'mother_anti_hcv', label: '丙型肝炎病毒抗体(抗HCV)', control: 'select_yny' },
|
|
{ key: 'mother_hcv_rna', label: '丙型肝炎病毒核酸(HCV RNA)', control: 'select_yny' },
|
|
{ key: 'mother_anti_tp', label: '梅毒螺旋体特异性抗体(抗TP)', control: 'select_yny' },
|
|
{ key: 'mother_cmv_igm', label: '巨细胞病毒 IgM 抗体 (CMV IgM)', control: 'select_yny' },
|
|
{ key: 'mother_anti_hiv', label: '人类免疫缺陷病毒抗体(抗HIV-1/2)', control: 'select_yny' },
|
|
{
|
|
key: 'mother_hiv1_rna',
|
|
label: '人类免疫缺陷病毒核酸(1型) (HIV-1RNA)',
|
|
control: 'select_yny'
|
|
}
|
|
]
|
|
|
|
export const STORAGE_CERT_QC_GROUPS: Record<StorageCertQcTypeKey, StorageCertQcGroup[]> = {
|
|
perinatal_hsc: [
|
|
{
|
|
title: '采集与运输',
|
|
variant: 'alt',
|
|
fields: [{ key: 'collection_time', label: '造血干细胞采集时间' }]
|
|
},
|
|
{
|
|
title: '造血干细胞检测报告',
|
|
variant: 'primary',
|
|
fields: [
|
|
{ key: 'receive_time', label: '造血干细胞接收时间' },
|
|
{ key: 'cryo_volume_ml', label: '造血干细胞冻存体积/mL' },
|
|
{ key: 'tnc_1e8', label: '有核细胞数 TNC / *10E8' },
|
|
{ key: 'cd34_count_1e6', label: 'CD34+ 细胞计数 / *10E6' },
|
|
{ key: 'cd34_cd45dim_1e5', label: 'CD34+ CD45dim 细胞计数 / *10E5' },
|
|
{ key: 'viability_pct', label: '细胞活性/%' },
|
|
{ key: 'bacteria_test', label: '细菌检测', control: 'select_yny' },
|
|
{ key: 'hbsag', label: '乙型肝炎病毒表面抗原(HBsAg)', control: 'select_yny' },
|
|
{ key: 'anti_hcv', label: '丙型肝炎病毒抗体(抗HCV)', control: 'select_yny' },
|
|
{ key: 'anti_tp', label: '梅毒螺旋体特异性抗体(抗TP)', control: 'select_yny' },
|
|
{
|
|
key: 'anti_hiv',
|
|
label: '人类免疫缺陷病毒抗体(抗HIV-1/2)',
|
|
control: 'select_yny'
|
|
},
|
|
{ key: 'cmv_igm', label: '巨细胞病毒 IgM 抗体 (CMV-IgM)', control: 'select_yny' }
|
|
]
|
|
},
|
|
{ title: '母亲血液检测报告', variant: 'primary', fields: MOTHER_BLOOD },
|
|
{
|
|
title: '储存证收尾信息',
|
|
variant: 'meta',
|
|
fields: [
|
|
{ key: 'hla_typing', label: 'HLA 分型', control: 'textarea', span: 3 },
|
|
{ key: 'storage_date', label: '储存日期' },
|
|
{ key: 'storage_years', label: '储存年限' },
|
|
{ key: 'result_comment', label: '检测结果评论', control: 'select_result' },
|
|
{ key: 'report_issue_date', label: '报告发出日期' }
|
|
]
|
|
}
|
|
],
|
|
uc_msc: [
|
|
{
|
|
title: '采集与运输',
|
|
variant: 'alt',
|
|
fields: [
|
|
{ key: 'collection_time', label: '脐带采集时间' },
|
|
{ key: 'transport_temp_c', label: '运输温度 /℃' }
|
|
]
|
|
},
|
|
{
|
|
title: '脐带间充质干细胞检测报告',
|
|
variant: 'primary',
|
|
fields: [
|
|
{ key: 'receive_time', label: '脐带接收时间' },
|
|
{ key: 'storage_tube_count', label: '储存总量(管)' },
|
|
{ key: 'available_cell_type', label: '可提供细胞类型' },
|
|
{ key: 'available_cell_count_1e7', label: '可提供细胞数量 / *10E7' },
|
|
{ key: 'available_viability_pct', label: '可提供细胞存活率 %' },
|
|
{ key: 'endotoxin_test', label: '内毒素检测', control: 'select_yny' },
|
|
{ key: 'bacteria_test', label: '细菌检测', control: 'select_yny' },
|
|
{ key: 'fungus_test', label: '真菌检测', control: 'select_yny' },
|
|
{ key: 'mycoplasma_test', label: '支原体检测', control: 'select_yny' },
|
|
{ key: 'available_cell_morphology', label: '可提供细胞形态' },
|
|
{
|
|
key: 'available_immunophenotype',
|
|
label: '可提供细胞免疫表型特征',
|
|
span: 2
|
|
}
|
|
]
|
|
},
|
|
{ title: '母亲血液检测报告', variant: 'primary', fields: MOTHER_BLOOD },
|
|
{
|
|
title: '储存证收尾信息',
|
|
variant: 'meta',
|
|
fields: [
|
|
{ key: 'result_judgment', label: '检测结果评判', control: 'select_result' },
|
|
{ key: 'report_issue_date', label: '报告发出日期' },
|
|
{ key: 'storage_date_p2', label: '储存日期 (P2冻存日期)' },
|
|
{ key: 'freeze_method', label: '冷冻方式' },
|
|
{ key: 'storage_temp', label: '储存温度' },
|
|
{ key: 'storage_years', label: '储存年限' }
|
|
]
|
|
}
|
|
]
|
|
}
|
|
|
|
export const YNY_OPTIONS = [
|
|
{ label: '阴', value: '阴' },
|
|
{ label: '阳', value: '阳' }
|
|
]
|
|
|
|
/** 储存证阴阳性:与质检参数值一致,用阴性 / 阳性。 */
|
|
export const NP_OPTIONS = [
|
|
{ label: '阴性', value: '阴性' },
|
|
{ label: '阳性', value: '阳性' }
|
|
]
|
|
|
|
export function isPerinatalQualField(
|
|
typeKey: string | null | undefined,
|
|
control?: StorageCertQcControl
|
|
) {
|
|
return (
|
|
(typeKey === 'perinatal_hsc' || typeKey === 'uc_msc') && control === 'select_yny'
|
|
)
|
|
}
|
|
|
|
export function qualOptionsFor(
|
|
typeKey: string | null | undefined,
|
|
control?: StorageCertQcControl
|
|
) {
|
|
if (control === 'select_result') return RESULT_OPTIONS
|
|
if (isPerinatalQualField(typeKey, control)) return NP_OPTIONS
|
|
return YNY_OPTIONS
|
|
}
|
|
|
|
export function normalizeQualValue(
|
|
typeKey: string | null | undefined,
|
|
control: StorageCertQcControl | undefined,
|
|
raw: string
|
|
) {
|
|
if (!isPerinatalQualField(typeKey, control)) return raw
|
|
const text = raw.trim()
|
|
if (text === '阴' || text === '阴性') return '阴性'
|
|
if (text === '阳' || text === '阳性') return '阳性'
|
|
return raw
|
|
}
|
|
|
|
export const RESULT_OPTIONS = [
|
|
{ label: '合格', value: '合格' },
|
|
{ label: '不合格', value: '不合格' }
|
|
]
|
|
|
|
/** 已存档的非空值优先,只把预填补进空格。 */
|
|
export function mergeStorageCertPrefill(
|
|
payload: Record<string, unknown> | null | undefined,
|
|
prefill: Record<string, unknown> | null | undefined
|
|
): Record<string, unknown> {
|
|
const out: Record<string, unknown> = { ...(payload || {}) }
|
|
for (const [key, value] of Object.entries(prefill || {})) {
|
|
if (value == null || String(value).trim() === '') continue
|
|
const current = out[key]
|
|
if (current == null || String(current).trim() === '') out[key] = value
|
|
}
|
|
return out
|
|
}
|