import { RiesgoPacienteCacu } from './paciente-riesgo.models'; const CS = 'https://isssteleon.org/fhir/CodeSystem'; export const INTERVALO = 'https://isssteleon.org/fhir/StructureDefinition/intervalo-confianza'; /** A FHIR prediction: probability `p` from `inicio` to `fin`, with its interval when given. */ export function prediccion(p: number, inicio: string, fin: string, ic?: [number, number]): any { return { outcome: { coding: [{ system: `${CS}/desenlace`, code: 'cin2_mas', display: 'CIN2+ por biopsia' }] }, probabilityDecimal: p, whenPeriod: { start: inicio, end: fin }, ...(ic ? { extension: [{ url: INTERVALO, valueRange: { low: { value: ic[0] }, high: { value: ic[1] } } }] } : {}), }; } /** TEST ONLY. The external contract example: a `searchset` Bundle with patient 42's current `RiskAssessment`, as * `GET /cacu/fhir/RiskAssessment?subject=Patient/42` answers it; never belongs to the selected patient. */ export function riesgoCacuEjemplo(): any { return { resourceType: 'Bundle', type: 'searchset', total: 1, entry: [{ fullUrl: 'http://localhost/cacu/fhir/RiskAssessment/12-42', resource: { resourceType: 'RiskAssessment', id: '12-42', status: 'final', meta: { tag: [{ system: `${CS}/etiqueta`, code: 'simulado', display: 'Datos simulados' }] }, subject: { reference: 'Patient/42' }, occurrenceDateTime: '2026-10-01T00:00:00Z', method: { coding: [{ system: `${CS}/modelo`, code: 'modelo-cacu', version: '2.1.0' }] }, prediction: [ prediccion(0.08, '2026-06-01', '2027-06-01', [0.05, 0.12]), prediccion(0.21, '2026-06-01', '2029-06-01', [0.15, 0.28]), prediccion(0.34, '2026-06-01', '2031-06-01', [0.26, 0.44]), ], }, search: { mode: 'match' }, }], }; } /** TEST ONLY. What the record shows from `riesgoCacuEjemplo()`. */ export function riesgoCacuVista(): RiesgoPacienteCacu { return { simulado: true, riesgo: { id: '12-42', modelo_nombre: 'modelo-cacu', modelo_version: '2.1.0', fecha_indice: '2026-06-01', evaluado_en: '2026-10-01T00:00:00Z', estado_lote: 'final', desenlace: 'cin2_mas', desenlace_texto: 'CIN2+ por biopsia', horizontes: [ { horizonte_anios: 1, probabilidad: 0.08, ic_bajo: 0.05, ic_alto: 0.12 }, { horizonte_anios: 3, probabilidad: 0.21, ic_bajo: 0.15, ic_alto: 0.28 }, { horizonte_anios: 5, probabilidad: 0.34, ic_bajo: 0.26, ic_alto: 0.44 }, ], }, }; }