diff --git a/src/controllers/andesPrescription.controller.ts b/src/controllers/andesPrescription.controller.ts index d188efd..d469f8f 100644 --- a/src/controllers/andesPrescription.controller.ts +++ b/src/controllers/andesPrescription.controller.ts @@ -241,12 +241,16 @@ class AndesPrescriptionController implements BaseController { }; public verificarReceta = async (req: Request, res: Response): Promise => { - const { dni, conceptId } = req.query; + const { dni, conceptId, sexo } = req.query; if (!dni || !conceptId) { return res.status(400).json({ mensaje: 'Se requieren los parámetros dni y conceptId' }); } + if (!sexo) { + return res.status(400).json({ mensaje: 'Se requiere el parámetro sexo del paciente' }); + } + try { // Consulta la DB local por DNI del paciente (identificador común entre sistemas) const estadosValidos = ['vigente', 'pendiente']; @@ -259,8 +263,8 @@ class AndesPrescriptionController implements BaseController { 'estadoDispensaActual.tipo': { $nin: estadosDispensaExcluidos } }).lean(); - // Consulta a Andes por documento y conceptId utilizando el endpoint especifico - const verificacionAndes = await AndesService.verificarRecetaExistente(dni as string, conceptId as string).catch(() => null); + // Consulta a Andes por documento, conceptId y sexo utilizando el endpoint especifico + const verificacionAndes = await AndesService.verificarRecetaExistente(dni as string, conceptId as string, sexo as string).catch(() => null); const recetasAndes = verificacionAndes && verificacionAndes.existe && verificacionAndes.receta ? [verificacionAndes.receta] : []; diff --git a/src/services/andesService.ts b/src/services/andesService.ts index 285729c..ddc0b8d 100644 --- a/src/services/andesService.ts +++ b/src/services/andesService.ts @@ -319,21 +319,18 @@ class AndesService { /** * Verifica si existe una receta vigente para un paciente y medicamento (por conceptId SNOMED) en ANDES */ - public async verificarRecetaExistente(dni: string, conceptId: string): Promise { + public async verificarRecetaExistente(dni: string, conceptId: string, sexo: string): Promise { try { const url = `${this.baseURL}/modules/recetas/verificar`; - console.log('fullUrl', url); const response: AxiosResponse = await axios.get(url, { - params: { documento: dni, conceptId }, + params: { documento: dni, conceptId, sexo }, headers: { Authorization: this.token, 'Content-Type': 'application/json' } }); - console.log('response', response.data); - return response.data; } catch (error) { // eslint-disable-next-line no-console