From c5b0d1c4805bc425b3558d6c5a090f99931c86ba Mon Sep 17 00:00:00 2001 From: Alejandro Gomez Auad Date: Wed, 15 Jul 2026 16:52:08 +0000 Subject: [PATCH] Corregido el parametro type de ITI-67 para que sea un token FHIR real Se saca el mapeo de etiquetas propias (IPS/MeOW/IT) a codigo LOINC: 'type' ahora se pasa tal cual al Bus como token FHIR (system|code), consistente con la semantica estandar de busqueda por token en FHIR, en vez de una convencion propia que solo este gateway entendia. Co-Authored-By: Claude Sonnet 5 --- bus-gateway/README.md | 2 +- bus-gateway/controllers/iti67.js | 25 ++++++------------------- bus-gateway/docs/iti67.mmd | 4 ++-- 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/bus-gateway/README.md b/bus-gateway/README.md index f96c0a5..278bb5e 100644 --- a/bus-gateway/README.md +++ b/bus-gateway/README.md @@ -20,7 +20,7 @@ El componente actúa exclusivamente como gateway: no contiene lógica de negocio | ITI-65 | `POST` | `/fhir/MeOWDocument` | Provide Document Bundle (MeOW - Medication Overview): variante document. | | ITI-65 | `POST` | `/fhir/ITTransaction` | Provide Document Bundle (IT - Consultation Note / respuesta de interconsulta): variante transacción. | | ITI-65 | `POST` | `/fhir/ITDocument` | Provide Document Bundle (IT - Consultation Note): variante document. | -| ITI-67 | `GET` | `/fhir/DocumentReference` | Find Document References: busca el paciente por ID local en el MPI para obtener su ID nacional y consulta los DocumentReferences en el Document Registry. Admite filtrar por tipo de documento con el parámetro opcional `type` (`IPS`, `MeOW`, `IT`, o un token FHIR `system\|code`). | +| ITI-67 | `GET` | `/fhir/DocumentReference` | Find Document References: busca el paciente por ID local en el MPI para obtener su ID nacional y consulta los DocumentReferences en el Document Registry. Admite filtrar por tipo de documento con el parámetro opcional `type`, un token FHIR `system\|code` (ej. `http://loinc.org\|60591-5` para IPS, `http://loinc.org\|56445-0` para MeOW, `http://loinc.org\|57133-1` para IT). | | ITI-78 | `GET` | `/fhir/Patient` | Patient Demographics Query: búsqueda de pacientes en el MPI. | | ITI-78 | `GET` | `/fhir/Patient/:id` | Patient Demographics Query: obtención de un paciente por ID en el MPI. | | ITI-104 | `POST` | `/fhir/Patient` | Patient Identity Feed: alta de paciente en el MPI. | diff --git a/bus-gateway/controllers/iti67.js b/bus-gateway/controllers/iti67.js index d51504e..bb079b6 100644 --- a/bus-gateway/controllers/iti67.js +++ b/bus-gateway/controllers/iti67.js @@ -3,7 +3,6 @@ const config = require('../config'); const { getBusToken } = require('../utils/busAuth'); const { findPatient } = require('../services/patient'); const { findDocumentReferenceByPatient } = require('../services/documentReference'); -const { DOCUMENT_TYPES } = require('../constants/documentTypes'); const NATIONAL_ID_SYSTEM = 'https://federador.msal.gob.ar/patient-id'; @@ -15,20 +14,6 @@ function extractNationalIdentifier(patient) { return identifiers.find(id => id.system === NATIONAL_ID_SYSTEM) || null; } -/** - * Resuelve el parámetro de búsqueda `type` a un token FHIR (`system|code`). - * Acepta tanto las etiquetas conocidas (IPS, MeOW, IT — case-insensitive) - * como un token FHIR ya armado (`system|code` o `code`), que se pasa tal cual - * para no acoplar la búsqueda a los tipos de documento ya conocidos. - */ -function resolveDocumentType(rawType) { - if (!rawType) return undefined; - const knownType = Object.values(DOCUMENT_TYPES).find( - t => t.label.toLowerCase() === rawType.toLowerCase() - ); - return knownType ? `${knownType.system}|${knownType.code}` : rawType; -} - /** @@ -49,9 +34,11 @@ function resolveDocumentType(rawType) { * patient.identifier — same semantics, alternate FHIR parameter name. * * Optional query parameter: - * type — tipo de documento a buscar. Acepta las etiquetas conocidas - * (IPS, MeOW, IT) o un token FHIR (`system|code`, ej: `http://loinc.org|60591-5`). - * Si se omite, devuelve documentos de cualquier tipo. + * type — token FHIR de DocumentReference.type (`system|code`, `|code` o `code`), + * ej: `http://loinc.org|60591-5` (IPS), `http://loinc.org|56445-0` (MeOW), + * `http://loinc.org|57133-1` (IT). Se pasa tal cual al Bus, sin traducir + * alias propios, para no apartarse de la semántica estándar de búsqueda + * por token de FHIR. Si se omite, devuelve documentos de cualquier tipo. */ async function listDocumentReference(req, res, next) { try { @@ -59,7 +46,7 @@ async function listDocumentReference(req, res, next) { if (!localPatientIdentifier) { throw createError(400, 'Missing required query parameter: subject or patient.identifier'); } - const documentType = resolveDocumentType(req.query.type); + const documentType = req.query.type; const token = await getBusToken( config.bus.url, config.bus.jwtSecret, diff --git a/bus-gateway/docs/iti67.mmd b/bus-gateway/docs/iti67.mmd index e3889c3..54342cc 100644 --- a/bus-gateway/docs/iti67.mmd +++ b/bus-gateway/docs/iti67.mmd @@ -8,9 +8,9 @@ sequenceDiagram participant IndiceNacion as Indice Documentos end participant NodoDominio2 as Nodo B - Note over HIS_A,FederadorNacion: Tipos soportados: IPS, MeOW, IT (parámetro opcional type) + Note over HIS_A,FederadorNacion: Tipos soportados (LOINC): 60591-5 IPS, 56445-0 MeOW, 57133-1 IT (parámetro opcional type=system|code) Note over HIS_A,FederadorNacion: 1. Busqueda y resolución de Identidad - HIS_A->>NodoDominio: ITI67: Solicita los documentos asociados al paciente por su identificador local, opcionalmente filtrando por tipo
[GET /DocumentReference?patient.identifier=&type=] + HIS_A->>NodoDominio: ITI67: Solicita los documentos asociados al paciente por su identificador local, opcionalmente filtrando por tipo
[GET /DocumentReference?patient.identifier=&type=] NodoDominio->>FederadorNacion: Busca el paciente por su identificador local
[GET /Patient?identifier=] FederadorNacion-->>NodoDominio: 200 OK (Patient Searchset) Note over NodoDominio,IndiceNacion: 2. Busqueda de Metadatos