// PT 临床数据缓存：用于统一 SUV 口径（优先接口，缺失则回退 DICOM 元数据）
const instanceIdToClinicalData = new Map()

function normalizeId(id) {
  if (id === undefined || id === null) return null
  const s = String(id).trim()
  return s ? s : null
}
 
export function setPTClinicalDataForInstance(instanceId, clinicalData) {
  const key = normalizeId(instanceId)
  if (!key) return
  if (!clinicalData || typeof clinicalData !== 'object') return
  instanceIdToClinicalData.set(key, { ...clinicalData })
}

export function getPTClinicalDataForInstance(instanceId) {
  const key = normalizeId(instanceId)
  if (!key) return null
  return instanceIdToClinicalData.get(key) || null
}

export function deletePTClinicalDataForInstance(instanceId) {
  const key = normalizeId(instanceId)
  if (!key) return
  instanceIdToClinicalData.delete(key)
}

export function clearPTClinicalDataCache() {
  instanceIdToClinicalData.clear()
}
