Repository navigation
RUP - Condicion Paciente #2340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
martinebucarey
wants to merge
1
commit into
master
Choose a base branch
from
RUP-condicion-paciente
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+171
−1
Open
RUP - Condicion Paciente #2340
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| --- | ||
| tags: | ||
| - rup | ||
| - turnos | ||
| scope: | ||
| - api | ||
| - app | ||
| --- | ||
|
|
||
| # ADR 0002: Condición del paciente en turnos y prestaciones | ||
|
|
||
| - **Estado:** Aceptado | ||
| - **Fecha:** 2026-10-30 | ||
| - **Repos afectados:** `api` | ||
|
|
||
| > **Este documento es vivo.** Los cambios que afecten el almacenamiento o la validación de | ||
| > `condicionPaciente` en turnos o prestaciones deben actualizar este ADR. | ||
|
|
||
| ## Contexto | ||
|
|
||
| Los flujos de turnos y prestaciones necesitan registrar la condición del paciente asociada | ||
| a la atención. El dato requiere un conjunto de valores controlado, debe poder omitirse y no | ||
| debe modificarse en una prestación que ya fue validada. | ||
|
|
||
| ## Decisión | ||
|
|
||
| Agregar el campo opcional `condicionPaciente` a los modelos de turnos y prestaciones, con | ||
| estos valores permitidos: | ||
|
|
||
| - `ambulatorio` | ||
| - `internado` | ||
| - `guardia` | ||
|
|
||
| La lista de valores y su validación se centralizan en `modules/rup/condicion-paciente.ts` | ||
| para reutilizarlas en los flujos de ambos módulos. Los esquemas de persistencia limitan el | ||
| campo a esos valores. | ||
|
|
||
| Las rutas validan el dato antes de procesarlo: | ||
|
|
||
| - La creación de prestaciones y su actualización mediante `estadoPush` rechazan valores | ||
| inválidos. En `estadoPush`, no se permite cambiar la condición si la prestación ya está | ||
| validada. | ||
| - La asignación de turnos y la creación de sobreturnos rechazan condiciones inválidas. En | ||
| los sobreturnos, los valores vacíos o nulos se tratan como dato no informado. | ||
| - La asignación de un turno guarda la condición recibida. Al liberar o reutilizar un turno, | ||
| se limpia la condición anterior para evitar que se herede en otra atención. | ||
|
|
||
| ## Alternativas consideradas | ||
|
|
||
| Los cambios revisados no documentan otras alternativas consideradas. | ||
|
|
||
| ## Consecuencias | ||
|
|
||
| **Positivas** | ||
|
|
||
| - Prestaciones y turnos pueden guardar la condición sin hacer obligatorio el dato para | ||
| registros existentes o nuevas solicitudes que lo omitan. | ||
| - Los valores aceptados son consistentes entre validación de rutas y esquemas de persistencia. | ||
| - La condición no persiste accidentalmente al liberar o reutilizar un turno. | ||
|
|
||
| **Negativas / a vigilar** | ||
|
|
||
| - Los consumidores de estas rutas deben enviar uno de los valores definidos cuando informen | ||
| `condicionPaciente`. | ||
| - La condición de una prestación validada no puede modificarse mediante `estadoPush`. | ||
|
|
||
| ## Alcance y puntos abiertos | ||
|
|
||
| El alcance documentado comprende la persistencia y validación de `condicionPaciente` en los | ||
| flujos de prestaciones y turnos descritos en este ADR. Los cambios TypeScript revisados no | ||
| identifican puntos abiertos adicionales. | ||
|
|
||
| ## Historial de cambios del documento | ||
|
|
||
| | Fecha | Cambio | | ||
| |---|---| | ||
| | 2026-10-30 | Versión inicial, basada en los cambios TypeScript locales. | | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| export const CONDICIONES_PACIENTE = ['ambulatorio', 'internado', 'guardia']; | ||
|
|
||
| export function condicionPacienteValida(condicionPaciente: any): boolean { | ||
| return typeof condicionPaciente === 'string' && CONDICIONES_PACIENTE.indexOf(condicionPaciente) !== -1; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import { Prestacion } from './prestacion'; | ||
|
|
||
| describe('PrestacionSchema condicionPaciente', () => { | ||
| const solicitud = { fecha: new Date() }; | ||
|
|
||
| it('permite omitir la condición en prestaciones existentes o sin informar', () => { | ||
| const prestacion = new Prestacion({ noNominalizada: false, solicitud }); | ||
|
|
||
| expect(prestacion.validateSync()?.errors.condicionPaciente).toBeUndefined(); | ||
| }); | ||
|
|
||
| it.each(['ambulatorio', 'internado', 'guardia'])('acepta la condición %s', condicionPaciente => { | ||
| const prestacion = new Prestacion({ | ||
| noNominalizada: false, | ||
| solicitud, | ||
| condicionPaciente | ||
| }); | ||
|
|
||
| expect(prestacion.validateSync()?.errors.condicionPaciente).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('rechaza valores fuera del conjunto permitido', () => { | ||
| const prestacion = new Prestacion({ | ||
| noNominalizada: false, | ||
| solicitud, | ||
| condicionPaciente: 'desconocido' | ||
| }); | ||
|
|
||
| expect(prestacion.validateSync()?.errors.condicionPaciente).toBeDefined(); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ import { getAccesosVirtuales } from '../../turnos/controller/turnosController'; | |
| import * as cie10 from './../../../core/term/schemas/cie10'; | ||
| import { ECLQueriesCtr } from './../../../core/tm/eclqueries.routes'; | ||
| import { handleHttpRequest } from '../../../utils/requestHandler'; | ||
| import { condicionPacienteValida } from '../../rup/condicion-paciente'; | ||
|
|
||
| export async function getAgendaById(agendaId) { | ||
| return await Agenda.findById(agendaId); | ||
|
|
@@ -135,6 +136,7 @@ export async function liberarTurno(req, data, turno) { | |
| turno.tipoTurno = undefined; | ||
| turno.link = undefined; | ||
| turno.motivoConsulta = undefined; | ||
| turno.condicionPaciente = undefined; | ||
| turno.webexLinks = null; | ||
| turno.updatedAt = new Date(); | ||
| turno.updatedBy = req.user.usuario || req.user; | ||
|
|
@@ -434,6 +436,13 @@ export async function actualizarPaciente(pacienteTurno: any, req: any) { | |
| } | ||
|
|
||
| // Agenda | ||
| export function condicionPacienteSobreturnoValida(sobreturno): boolean { | ||
| if (sobreturno && (sobreturno.condicionPaciente === null || sobreturno.condicionPaciente === '')) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. en |
||
| delete sobreturno.condicionPaciente; | ||
| } | ||
| return !sobreturno || sobreturno.condicionPaciente === undefined || condicionPacienteValida(sobreturno.condicionPaciente); | ||
| } | ||
|
|
||
| export async function agregarSobreturno(req, data) { | ||
| const sobreturno = req.body.sobreturno; | ||
| if (sobreturno) { | ||
|
|
@@ -1605,6 +1614,7 @@ export function agendaNueva(data, clon, req) { | |
| turno.fechaHoraDacion = undefined; | ||
| turno.link = undefined; | ||
| turno.motivoConsulta = undefined; | ||
| turno.condicionPaciente = undefined; | ||
| turno.usuarioDacion = undefined; | ||
| turno.profesional = undefined; | ||
| turno.horaAsistencia = undefined; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit de docs: este ADR quedó en
docs/adr-condicion-paciente-….md(root).El de doble firma está en
docs/rup/0001-….¿Unificamos convención? Sugerencia:
docs/adr/odocs/rup/+ numeración global (0001, 0002) + tags en frontmatter.