Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions modules/pacs/pacs.logs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Connections } from '../../connections';
import { Logger } from '@andes/log';

export const pacsLogs = new Logger({
connection: Connections.logs,
module: 'pacs',
type: 'pacs-operations',
application: 'andes',
bucketBy: 'd',
bucketSize: 100,
expiredAt: '1 M'
});
14 changes: 6 additions & 8 deletions modules/pacs/pacs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { DICOMPaciente } from './dicom/paciente-encode';
import { DICOMPrestacion } from './dicom/prestacion-encode';
import { PacsConfigController } from './pacs-config.controller';
import { createPaciente, createWorkList, enviarInforme, loginPacs, anularPacs } from './pacs-network';
import { userScheduler } from '../../config.private';
import { pacsLogs } from './pacs.logs';

export async function syncWorkList(prestacion: IPrestacion) {
try {
Expand All @@ -16,7 +18,6 @@ export async function syncWorkList(prestacion: IPrestacion) {
}

const organizacion = prestacion.ejecucion.organizacion;

const tipoPrestacion = prestacion.solicitud.tipoPrestacion;

if (!tipoPrestacion) {
Expand All @@ -27,10 +28,7 @@ export async function syncWorkList(prestacion: IPrestacion) {
if (config) {
const token = await loginPacs(config);


const uniqueID = `${config.ui}.${Date.now()}`;


const pacienteDICOM = DICOMPaciente(prestacion.paciente);
const prestacionDICOM = DICOMPrestacion(
prestacion,
Expand All @@ -44,8 +42,9 @@ export async function syncWorkList(prestacion: IPrestacion) {
await createPaciente(config, pacienteDICOM, token);
const response = await createWorkList(config, prestacionDICOM, token);
const dataResponse = response?.['00400100']?.['Value']?.[0]['00400009']?.['Value']?.[0];
const spsID = dataResponse || null;

const spsID = dataResponse || null;
pacsLogs.info('syncWorkList', { prestacion: prestacion.id, respuestaPacs: spsID, pacienteDICOM, prestacionDICOM }, userScheduler);
const query = prestacion.groupId ?
{ groupId: prestacion.groupId } :
{ _id: (prestacion as any)._id };
Expand All @@ -56,6 +55,7 @@ export async function syncWorkList(prestacion: IPrestacion) {
];
if (dataResponse) {
arrayMetadata.push({ key: 'pacs-spsID', valor: spsID }); // id de la orden
pacsLogs.info('syncWorkList', { prestacion: prestacion.id, respuestaPacs: arrayMetadata }, userScheduler);
}
await Prestacion.update(
query,
Expand All @@ -67,11 +67,9 @@ export async function syncWorkList(prestacion: IPrestacion) {
}
}
);

}
} catch (err) {
// [TODO] Logger
// console.error(err);
pacsLogs.error('syncWorkList', { prestacion: prestacion.id }, err, userScheduler);
}
}

Expand Down
2 changes: 1 addition & 1 deletion modules/rup/routes/prestacion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ export = router;


EventCore.on('rup:prestacion:validate', async (prestacion) => {
if (!prestacion.paciente.id || prestacion.paciente?.obraSocial?.nombre) {
if (!prestacion.paciente?.id || prestacion.paciente?.obraSocial?.nombre) {
return;
}
if (prestacion.solicitud.turno) {
Expand Down