验收要求仅展示知情同意书与孕妇健康调查表,移除第三项「协议附件」分组。 Co-authored-by: Cursor <cursoragent@cursor.com>
74 lines
2.3 KiB
TypeScript
74 lines
2.3 KiB
TypeScript
export type ProtocolSourceAttachmentMeta = {
|
|
label: string
|
|
files: Array<Record<string, unknown>>
|
|
}
|
|
|
|
function normalizeAttachmentFiles(raw: unknown): Array<Record<string, unknown>> {
|
|
if (!Array.isArray(raw)) return []
|
|
return raw.filter((item) => item && typeof item === 'object') as Array<Record<string, unknown>>
|
|
}
|
|
|
|
/** 按来源返回协议级主附件标签与文件列表(细胞存储=孕妇健康调查表,科研捐赠=传染病检测报告) */
|
|
export function getSourceProtocolAttachment(
|
|
row: Record<string, unknown>
|
|
): ProtocolSourceAttachmentMeta {
|
|
const source = String(row.sourceType || 'cell_storage').trim()
|
|
if (source === 'research_donation') {
|
|
return {
|
|
label: '传染病检测报告',
|
|
files: normalizeAttachmentFiles(row.infectiousDiseaseReportAttachmentFiles)
|
|
}
|
|
}
|
|
return {
|
|
label: '孕妇健康调查表',
|
|
files: normalizeAttachmentFiles(row.healthSurveyAttachmentFiles)
|
|
}
|
|
}
|
|
|
|
/** 知情同意书(细胞存储与科研捐赠共用字段) */
|
|
export function getConsentProtocolAttachment(
|
|
row: Record<string, unknown>
|
|
): ProtocolSourceAttachmentMeta {
|
|
return {
|
|
label: '知情同意书',
|
|
files: normalizeAttachmentFiles(row.consentAttachmentFiles)
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 样本接收弹窗:按来源返回质检需查看的协议附件分组。
|
|
* 细胞存储:仅知情同意书 / 孕妇健康调查表(不展示「协议附件」项)
|
|
* 科研捐赠:知情同意书 / 传染病检测报告 / 其他附件
|
|
*/
|
|
export function getSourceProtocolAttachmentGroups(
|
|
row: Record<string, unknown>
|
|
): ProtocolSourceAttachmentMeta[] {
|
|
const source = String(row.sourceType || 'cell_storage').trim()
|
|
if (source === 'research_donation') {
|
|
return [
|
|
{
|
|
label: '知情同意书',
|
|
files: normalizeAttachmentFiles(row.consentAttachmentFiles)
|
|
},
|
|
{
|
|
label: '传染病检测报告',
|
|
files: normalizeAttachmentFiles(row.infectiousDiseaseReportAttachmentFiles)
|
|
},
|
|
{
|
|
label: '其他附件',
|
|
files: normalizeAttachmentFiles(row.attachmentFiles ?? row.otherAttachmentFiles)
|
|
}
|
|
]
|
|
}
|
|
return [
|
|
{
|
|
label: '知情同意书',
|
|
files: normalizeAttachmentFiles(row.consentAttachmentFiles)
|
|
},
|
|
{
|
|
label: '孕妇健康调查表',
|
|
files: normalizeAttachmentFiles(row.healthSurveyAttachmentFiles)
|
|
}
|
|
]
|
|
}
|