Compare commits
5 Commits
e1b461f6a2
...
afe6f59ae0
| Author | SHA1 | Date | |
|---|---|---|---|
| afe6f59ae0 | |||
| 1a0f7b76b8 | |||
| a873231843 | |||
| d2a6132f11 | |||
| 28acb2b130 |
@ -1,5 +1,5 @@
|
||||
const config = require('../config');
|
||||
const { postPatient, putPatient, getPatientById } = require('../services/patient');
|
||||
const { createPatient: busCreatePatient, updatePatient: busUpdatePatient, findPatientById } = require('../services/patient');
|
||||
const { getBusToken} = require('../utils/busAuth');
|
||||
|
||||
/**
|
||||
@ -11,8 +11,8 @@ const { getBusToken} = require('../utils/busAuth');
|
||||
async function createPatient(req, res, next) {
|
||||
try {
|
||||
const token = await getBusToken(config.bus.url, config.bus.jwtSecret, config.bus.issuer, config.bus.mpiScope);
|
||||
const response = await postPatient(token, req.body)
|
||||
const patientResponse = await getPatientById(token, response.headers['location']);
|
||||
const response = await busCreatePatient(token, req.body)
|
||||
const patientResponse = await findPatientById(token, response.headers['location']);
|
||||
res.status(200).json(patientResponse.data);
|
||||
} catch (err) {
|
||||
next(err);
|
||||
@ -26,7 +26,7 @@ async function createPatient(req, res, next) {
|
||||
async function updatePatient(req, res, next) {
|
||||
try {
|
||||
const token = await getBusToken(config.bus.url, config.bus.jwtSecret, config.bus.issuer, config.bus.mpiScope);
|
||||
const response = await putPatient(token, req.body)
|
||||
const response = await busUpdatePatient(token, req.body)
|
||||
res.status(200).json(response.data);
|
||||
} catch (err) {
|
||||
next(err);
|
||||
|
||||
@ -2,8 +2,8 @@ const axios = require('axios');
|
||||
const createError = require('http-errors');
|
||||
const config = require('../config');
|
||||
const { getBusToken, createBusRequest } = require('../utils/busAuth');
|
||||
const { searchPatient } = require('../services/patient');
|
||||
const { postDocumentReference, fetchDocumentReference } = require('../services/documentReference');
|
||||
const { findPatient } = require('../services/patient');
|
||||
const { createDocumentReference, findDocumentReferenceById } = require('../services/documentReference');
|
||||
const { logger } = require('../utils/logger');
|
||||
const { v4: uuidv4 } = require('uuid');
|
||||
|
||||
@ -62,7 +62,7 @@ async function getBusCustodianIdentifier() {
|
||||
|
||||
async function getBusPatientReference(patient, token) {
|
||||
const localIdentifier = extractLocalIdentifier(patient);
|
||||
const nationalPatientResponse = await searchPatient(token, { identifier: `${localIdentifier.system}|${localIdentifier.value}` });
|
||||
const nationalPatientResponse = await findPatient(token, { identifier: `${localIdentifier.system}|${localIdentifier.value}` });
|
||||
const nationalPatientBundle = nationalPatientResponse.data;
|
||||
if (nationalPatientBundle.total == 0) {
|
||||
throw createError(404, 'Patient does not exists');
|
||||
@ -120,8 +120,8 @@ async function createBusDocumentReference(token, localIPSDocument, localPatient)
|
||||
},
|
||||
],
|
||||
};
|
||||
const response = await postDocumentReference(token, busDocumentReference);
|
||||
const created = await fetchDocumentReference(token, response.headers['location']);
|
||||
const response = await createDocumentReference(token, busDocumentReference);
|
||||
const created = await findDocumentReferenceById(token, response.headers['location']);
|
||||
return created.data;
|
||||
}
|
||||
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
const createError = require('http-errors');
|
||||
const config = require('../config');
|
||||
const { getBusToken } = require('../utils/busAuth');
|
||||
const { getPatientById, searchPatient } = require('../services/patient');
|
||||
const { searchDocumentReferenceByPatient } = require('../services/documentReference');
|
||||
const { findPatient } = require('../services/patient');
|
||||
const { findDocumentReferenceByPatient } = require('../services/documentReference');
|
||||
|
||||
const NATIONAL_ID_SYSTEM = 'https://federador.msal.gob.ar/patient-id';
|
||||
|
||||
@ -15,12 +15,12 @@ function extractNationalIdentifier(patient) {
|
||||
}
|
||||
|
||||
async function getPatient(token, identifier) {
|
||||
const response = await searchPatient(token, { identifier: identifier });
|
||||
const response = await findPatient(token, { identifier: identifier });
|
||||
return Promise.resolve(response.data.entry[0].fullUrl);
|
||||
}
|
||||
|
||||
async function getDocumentReferencesForPatient(token, patient) {
|
||||
const response = await searchDocumentReferenceByPatient(token, patient)
|
||||
const response = await findDocumentReferenceByPatient(token, patient)
|
||||
return Promise.resolve(response.data);
|
||||
}
|
||||
/**
|
||||
@ -36,7 +36,7 @@ async function getDocumentReferencesForPatient(token, patient) {
|
||||
* Required query parameter:
|
||||
* subject — local Patient ID in the Bus.
|
||||
*/
|
||||
async function findDocumentReferences(req, res, next) {
|
||||
async function listDocumentReference(req, res, next) {
|
||||
try {
|
||||
const localPatientIdentifier = req.query.subject;
|
||||
if (!localPatientIdentifier) {
|
||||
@ -65,4 +65,4 @@ async function findDocumentReferences(req, res, next) {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { findDocumentReferences };
|
||||
module.exports = { listDocumentReference };
|
||||
|
||||
@ -2,12 +2,12 @@ const createError = require('http-errors');
|
||||
const axios = require('axios');
|
||||
|
||||
|
||||
async function getRemoteDocument(url){
|
||||
async function getRemoteDocument(url) {
|
||||
const response = await axios.get(parsedUrl.toString(), {
|
||||
responseType: 'arraybuffer',
|
||||
headers: {
|
||||
Accept: req.headers['accept'] || '*/*',
|
||||
},
|
||||
responseType: 'arraybuffer',
|
||||
headers: {
|
||||
Accept: req.headers['accept'] || '*/*',
|
||||
},
|
||||
});
|
||||
return response
|
||||
}
|
||||
@ -23,7 +23,7 @@ async function getRemoteDocument(url){
|
||||
* 2. This gateway performs a P2P GET to that URL, bypassing the Bus.
|
||||
* 3. The raw document (PDF, XML, etc.) is forwarded back to HIS_A.
|
||||
*/
|
||||
async function download(req, res, next) {
|
||||
async function getBundleById(req, res, next) {
|
||||
try {
|
||||
const url = req.query.url;
|
||||
if (!url) {
|
||||
@ -52,4 +52,4 @@ async function download(req, res, next) {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { download };
|
||||
module.exports = { getBundleById };
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
const config = require('../config');
|
||||
const { getBusToken, createBusRequest } = require('../utils/busAuth');
|
||||
const { searchPatient, getPatientById } = require('../services/patient');
|
||||
const { findPatient, findPatientById } = require('../services/patient');
|
||||
|
||||
/**
|
||||
* ITI-78: Mobile Patient Demographics Query (PDQm)
|
||||
@ -8,10 +8,10 @@ const { searchPatient, getPatientById } = require('../services/patient');
|
||||
* GET /fhir/Patient
|
||||
* Forwards the raw FHIR query parameters to the Bus and returns the Bundle result.
|
||||
*/
|
||||
async function queryPatientDemographics(req, res, next) {
|
||||
async function listPatient(req, res, next) {
|
||||
try {
|
||||
const token = await getBusToken(config.bus.url, config.bus.jwtSecret, config.bus.issuer, config.bus.mpiScope);
|
||||
const response = await searchPatient(token, req.query);
|
||||
const response = await findPatient(token, req.query);
|
||||
res.status(200).json(response.data);
|
||||
} catch (err) {
|
||||
next(err);
|
||||
@ -22,15 +22,15 @@ async function queryPatientDemographics(req, res, next) {
|
||||
* GET /fhir/Patient/:id
|
||||
* Forwards the request to the Bus and returns the Patient resource.
|
||||
*/
|
||||
async function findPatientById(req, res, next) {
|
||||
async function getPatientById(req, res, next) {
|
||||
try {
|
||||
const { id } = req.params;
|
||||
const token = await getBusToken(config.bus.url, config.bus.jwtSecret, config.bus.issuer, config.bus.mpiScope);
|
||||
const response = await getPatientById(token, id)
|
||||
const response = await findPatientById(token, id)
|
||||
res.status(200).json(response.data);
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { queryPatientDemographics, getPatientById: findPatientById };
|
||||
module.exports = { listPatient, getPatientById };
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { findDocumentReferences } = require('../controllers/iti67');
|
||||
const { listDocumentReference } = require('../controllers/iti67');
|
||||
|
||||
// ITI-67: Find Document References
|
||||
// TODO: Cambiar ruta por ITI67
|
||||
router.get('/iti67', findDocumentReferences);
|
||||
router.get('/iti67', listDocumentReference);
|
||||
|
||||
module.exports = router;
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { download } = require('../controllers/iti68');
|
||||
const { getBundleById } = require('../controllers/iti68');
|
||||
|
||||
// ITI-68: Retrieve Document → GET /fhir/Binary?url=[URL_Directa]
|
||||
router.get('/Binary', download);
|
||||
router.get('/Bundle', getBundleById);
|
||||
|
||||
module.exports = router;
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { queryPatientDemographics, getPatientById } = require('../controllers/iti78');
|
||||
const { listPatient, getPatientById } = require('../controllers/iti78');
|
||||
|
||||
// ITI-78: Mobile Patient Demographics Query
|
||||
// TOOD: Cambiar ruta por ITI78
|
||||
router.get('/iti78', queryPatientDemographics);
|
||||
router.get('/iti78', listPatient);
|
||||
router.get('/iti78/:id', getPatientById);
|
||||
|
||||
module.exports = router;
|
||||
|
||||
@ -11,10 +11,10 @@ function maskPrivateURL(patientId) {
|
||||
return patientId.replace(LOCAL_URL, INDICE_ATENCION_URL);
|
||||
}
|
||||
|
||||
async function fetchDocumentReference(token, id) {
|
||||
async function findDocumentReferenceById(token, id) {
|
||||
const request = createBusRequest(token);
|
||||
const response = await request.get(
|
||||
URL.parse(id, INDICE_ATENCION_URL)
|
||||
URL.parse(`${INDICE_ATENCION_URL}/${id}`)
|
||||
);
|
||||
return response;
|
||||
}
|
||||
@ -28,7 +28,7 @@ async function fetchDocumentReference(token, id) {
|
||||
* @returns {Promise<object>} The created DocumentReference resource returned by the registry.
|
||||
* @todo Agregar system http://federador.msal.gob.ar/uri para armar el identificador del custodian: http://federador.msal.gob.ar/uri|<custodianId>
|
||||
*/
|
||||
async function postDocumentReference(token, documentReference) {
|
||||
async function createDocumentReference(token, documentReference) {
|
||||
const request = createBusRequest(token);
|
||||
const response = await request.post(
|
||||
URL.parse(INDICE_ATENCION_URL),
|
||||
@ -46,7 +46,7 @@ async function postDocumentReference(token, documentReference) {
|
||||
* @param {string} subjectValue - Identifier value of the patient.
|
||||
* @returns {Promise<object>} FHIR Bundle (searchset) with matching DocumentReferences.
|
||||
*/
|
||||
async function searchDocumentReferenceBySubject(token, subjectSystem, subjectValue) {
|
||||
async function findDocumentReferenceBySubject(token, subjectSystem, subjectValue) {
|
||||
const request = createBusRequest(token);
|
||||
const response = await request.get(
|
||||
URL.parse(INDICE_ATENCION_URL),
|
||||
@ -65,7 +65,7 @@ async function searchDocumentReferenceBySubject(token, subjectSystem, subjectVal
|
||||
* @param {string} patientId - Internal patient ID in the document registry.
|
||||
* @returns {Promise<object>} FHIR Bundle (searchset) with matching DocumentReferences.
|
||||
*/
|
||||
async function searchDocumentReferenceByPatient(token, patientId) {
|
||||
async function findDocumentReferenceByPatient(token, patientId) {
|
||||
const request = createBusRequest(token);
|
||||
const response = await request.get(
|
||||
URL.parse(INDICE_ATENCION_URL),
|
||||
@ -101,9 +101,9 @@ async function searchDocumentReference(token, subject, custodian, type) {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
fetchDocumentReference,
|
||||
postDocumentReference,
|
||||
searchDocumentReferenceBySubject,
|
||||
searchDocumentReferenceByPatient,
|
||||
findDocumentReferenceById,
|
||||
createDocumentReference,
|
||||
findDocumentReferenceBySubject,
|
||||
findDocumentReferenceByPatient,
|
||||
searchDocumentReference,
|
||||
};
|
||||
|
||||
@ -18,7 +18,7 @@ function maskPrivateURL(patientId) {
|
||||
* @param {object} patient - The Patient resource.
|
||||
* @returns {Promise<object>} Response data from the MPI.
|
||||
*/
|
||||
async function postPatient(token, patient) {
|
||||
async function createPatient(token, patient) {
|
||||
const request = createBusRequest(token);
|
||||
const response = await request.post(
|
||||
URL.parse(MPI_URL),
|
||||
@ -29,7 +29,7 @@ async function postPatient(token, patient) {
|
||||
}
|
||||
|
||||
|
||||
async function putPatient(token, patient, id) {
|
||||
async function updatePatient(token, patient, id) {
|
||||
const request = createBusRequest(token);
|
||||
const response = await request.put(
|
||||
URL.parse(`${MPI_URL}/${id}`),
|
||||
@ -54,7 +54,7 @@ async function putPatient(token, patient, id) {
|
||||
* @param {string} [criteria.gender] - Gender (male | female | other | unknown)
|
||||
* @returns {Promise<object>} FHIR Bundle (searchset) with matching patients.
|
||||
*/
|
||||
async function searchPatient(token, criteria = {}) {
|
||||
async function findPatient(token, criteria = {}) {
|
||||
const request = createBusRequest(token);
|
||||
|
||||
const params = {};
|
||||
@ -93,7 +93,7 @@ async function searchPatient(token, criteria = {}) {
|
||||
* @param {string} id - Logical Patient ID.
|
||||
* @returns {Promise<object>} FHIR Patient resource.
|
||||
*/
|
||||
async function getPatientById(token, id) {
|
||||
async function findPatientById(token, id) {
|
||||
const request = createBusRequest(token);
|
||||
const response = await request.get(
|
||||
URL.parse(`${MPI_URL}/${id}`)
|
||||
@ -109,7 +109,7 @@ async function getPatientById(token, id) {
|
||||
* @param {number} [count] - Maximum number of results to return (must be > 0).
|
||||
* @returns {Promise<object>} FHIR Bundle (searchset) with match scores.
|
||||
*/
|
||||
async function matchPatient(token, patient, count) {
|
||||
async function findPatientByMatch(token, patient, count) {
|
||||
const request = createBusRequest(token);
|
||||
const parameters = {
|
||||
resourceType: 'Parameters',
|
||||
@ -135,4 +135,4 @@ async function matchPatient(token, patient, count) {
|
||||
return response;
|
||||
}
|
||||
|
||||
module.exports = { putPatient, postPatient, getPatientById, searchPatient, matchPatient };
|
||||
module.exports = { createPatient, updatePatient, findPatient, findPatientById, findPatientByMatch };
|
||||
|
||||
@ -66,7 +66,7 @@ services:
|
||||
image: postgres:16-alpine
|
||||
restart: always
|
||||
volumes:
|
||||
- db-data:/var/lib/postgresql/data
|
||||
- gdhcn-data:/var/lib/postgresql/data
|
||||
networks:
|
||||
- hapi-network
|
||||
environment:
|
||||
@ -122,6 +122,9 @@ volumes:
|
||||
hapi-data:
|
||||
name: hapi-data
|
||||
driver: local
|
||||
gdhcn-data:
|
||||
name: gdhcn-data
|
||||
driver: local
|
||||
secrets:
|
||||
ssl_cert:
|
||||
file: ${SSL_CERT_PATH:-./certs/server.crt}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user