Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/diegolozadev/DataMed/llms.txt

Use this file to discover all available pages before exploring further.

Overview

The Exams API provides endpoints for viewing and registering clinical data including monitoring, psychology, nutrition, pneumology, polysomnography, and medical equipment records. Base Path: /exams/patients/<patient_id>/
All exam endpoints are patient-specific and require a valid patient_id in the URL path.

Patient Clinical History

View Clinical History

GET /exams/patients/<int:patient_id>/clinical/
View complete clinical history for a patient’s active program entry. View Function: patient_clinical in apps/exams/views.py:13

URL Parameters

patient_id
integer
required
Patient’s unique identifier

Response Context

patient
Patient object
Complete patient record
ingreso_actual
Ingreso object
Current active Ingreso entry (filters all exam data)
ultima_cita
Seguimiento object
Most recent followup appointment
monitoreos
array
List of Monitoreo records, ordered by most recent
sesiones_psicologia
array
List of Psicologia records, ordered by most recent
sesiones_nutricion
array
List of Nutricion records, ordered by most recent
sesiones_neumologia
array
List of Neumologia records, ordered by most recent
basales
array
List of PolisomnografiaBasal records, ordered by most recent
titulaciones
array
List of PolisomnografiaTitulacion records, ordered by most recent
equipos_medicos
array
List of EquipoMedico records, ordered by most recent
seguimientos_adaptacion
array
List of SeguimientoAdaptacion records, ordered by most recent

Key Behavior

From apps/exams/views.py:23-36:
ingreso_actual = patient.ingresos.filter(estado='ACTIVO').first()

if ingreso_actual:
    monitoreos = Monitoreo.objects.filter(ingreso=ingreso_actual).order_by('-id')
    # ... other exams filtered by ingreso_actual
Important: All exam data is filtered by the active Ingreso. When a new program cycle starts, previous exam data is not displayed.

Monitoring (Monitoreo)

Register Monitoring Data

GET  /exams/patients/<int:patient_id>/register_monitoreo/
POST /exams/patients/<int:patient_id>/register_monitoreo/
Register technical monitoring data and adaptation followup notes. View Function: register_monitoreo in apps/exams/views.py:63

URL Parameters

patient_id
integer
required
Patient’s unique identifier

POST Parameters - Technical Monitoring

Submit with btn_monitoreo button:
uso_diario
decimal
required
Daily usage percentage. Max 5 digits, 2 decimal places.
dias_uso_horas_4
decimal
required
Days with >4 hours usage. Max 5 digits, 2 decimal places.
horas_uso_diario
decimal
required
Average daily usage hours. Max 5 digits, 2 decimal places.
hipopnea_basal
decimal
required
Basal IAH value (copied from last PSG Basal). Max 5 digits, 2 decimal places.
hipopnea_residual
decimal
required
Residual IAH value. Max 5 digits, 2 decimal places.
porcentaje_correccion
decimal
required
Correction percentage: ((Basal - Residual) / Basal) * 100. Max 5 digits, 2 decimal places.
modo_ventilatorio
string
required
Ventilatory mode. Options: CPAP, BPAP, BPAP ST
presion_ipap
decimal
required
IPAP pressure setting. Max 5 digits, 2 decimal places.
presion_epap
decimal
EPAP pressure setting (for BPAP modes). Max 5 digits, 2 decimal places.
frecuencia_respiratoria
integer
Respiratory rate in breaths per minute (rpm).
mascara_cpap
string
required
Mask type. Options: PILLOW NASAL, NASAL, ORONASAL
tamano_mascara
string
required
Mask size. Options: SMALL, MEDIUM, LARGE
etco2_promedio
decimal
Average EtCO2 measurement. Max 5 digits, 2 decimal places.

POST Parameters - Contact Notes

Submit with btn_contacto button:
observaciones
text
required
Followup/contact observations and notes.

Response

Success (302): Redirects to /exams/patients/<patient_id>/clinical/ with success message Validation Error (200): Re-displays form with errors, maintains active tab

Basal IAH Pre-fill

From apps/exams/views.py:78-80:
psg = PolisomnografiaBasal.objects.filter(ingreso=ingreso_actual).last()
valor_basal = psg.iah if psg else 0
form = MonitoreoForm(initial={'hipopnea_basal': valor_basal})
The form automatically pre-fills hipopnea_basal from the most recent basal polysomnography.

Psychology (Psicología)

Register Psychology Session

GET  /exams/patients/<int:patient_id>/register_psicologia/
POST /exams/patients/<int:patient_id>/register_psicologia/
Register psychology evaluation data. View Function: register_psicologia in apps/exams/views.py:122

POST Parameters

inventario_depre_beck
integer
required
Beck Depression Inventory score.
inventario_ansiedad_beck
integer
required
Beck Anxiety Inventory score.
escala_atenas
integer
required
Athens Insomnia Scale score.

Response

Success (302): Redirects to clinical history with success message Validation Error (200): Re-displays form with errors

Nutrition (Nutrición)

Register Nutrition Session

GET  /exams/patients/<int:patient_id>/register_nutricion/
POST /exams/patients/<int:patient_id>/register_nutricion/
Register nutrition evaluation data. View Function: register_nutricion in apps/exams/views.py:154

POST Parameters

estado_nutricional
string
required
Nutritional status. Options: DESNUTRICIÓN, EUTRÓFICO, SOBREPESO, OBESIDAD I, OBESIDAD II, OBESIDAD III
carbohidratos_pct
decimal
required
Carbohydrate percentage. Max 5 digits, 2 decimal places.
rumiacion
string
required
Rumination presence. Options: SI, NO
cafeina
decimal
required
Caffeine consumption level. Max 5 digits, 2 decimal places.

Response

Success (302): Redirects to clinical history with success message Validation Error (200): Re-displays form with errors

Pneumology (Neumología)

Register Pneumology Consultation

GET  /exams/patients/<int:patient_id>/register_neumologia/
POST /exams/patients/<int:patient_id>/register_neumologia/
Register pneumology consultation data. View Function: register_neumologia in apps/exams/views.py:189

POST Parameters

fecha_consulta
date
required
Consultation date in YYYY-MM-DD format.
medico_tratante
string
required
Treating physician name. Max 100 characters.
especialidad
string
required
Physician specialty. Max 200 characters.

Response

Success (302): Redirects to clinical history with success message Validation Error (200): Re-displays form with errors

Polysomnography - Basal

Register Basal Polysomnography

GET  /exams/patients/<int:patient_id>/register_basal/
POST /exams/patients/<int:patient_id>/register_basal/
Register baseline polysomnography results. View Function: register_basal in apps/exams/views.py:218

POST Parameters

fecha_basal
date
required
Basal PSG date in YYYY-MM-DD format.
iah
decimal
required
Apnea-Hypopnea Index (IAH). Max 5 digits, 2 decimal places.
severidad_apnea
string
required
Apnea severity. Options: LEVE, MODERADA, NORMAL, GRAVE
ido
decimal
required
Oxygen Desaturation Index (IDO). Max 5 digits, 2 decimal places.
eficiencia
decimal
required
Sleep efficiency percentage. Max 5 digits, 2 decimal places.

Response

Success (302): Redirects to clinical history with success message Validation Error (200): Re-displays form with errors

Usage in Monitoring

The most recent basal IAH value is automatically used to pre-fill monitoring forms.

Polysomnography - Titration

Register Titration Polysomnography

GET  /exams/patients/<int:patient_id>/register_titulacion/
POST /exams/patients/<int:patient_id>/register_titulacion/
Register titration polysomnography results. View Function: register_titulacion in apps/exams/views.py:247

POST Parameters

tipo_titulacion
string
Titration type. Options: CPAP, BPAP, BPAP ST
fecha_titulacion
date
required
Titration date in YYYY-MM-DD format.
presion_ipap
decimal
required
Titrated IPAP pressure. Max 5 digits, 2 decimal places.
presion_epap
decimal
Titrated EPAP pressure (for BPAP). Max 5 digits, 2 decimal places.
frecuencia_respiratoria
integer
Respiratory rate in breaths per minute (rpm).
talla_mascara
string
default:"No especificado"
Mask size. Options: SMALL, MEDIUM, LARGE
tipo_mascara
string
default:"No especificado"
Mask type. Options: PILLOW NASAL, NASAL, ORONASAL

Response

Success (302): Redirects to clinical history with success message Validation Error (200): Re-displays form with errors

Medical Equipment

Register Medical Equipment

GET  /exams/patients/<int:patient_id>/register_equipo_medico/
POST /exams/patients/<int:patient_id>/register_equipo_medico/
Register medical equipment assignment to patient. View Function: register_equipo_medico in apps/exams/views.py:277

POST Parameters

tipo_mascara_eq_medico
string
required
Mask type. Options: PILLOW NASAL, NASAL, ORONASAL
referencia_mascara
string
default:"No especificado"
Mask reference/model. Max 100 characters.
talla_mascara
string
required
Mask size. Options: SMALL, MEDIUM, LARGE
marca_equipo
string
required
Equipment brand. Options: BMC, RESMED, PHILIPS RESPIRONICS, SEFAN, RESVENT, CURATIVE, PRISMA, DEVILBIS
serial_equipo
string
required
Equipment serial number. Max 100 characters.
modo_ventilatorio
string
required
Ventilatory mode. Options: CPAP, BiPAP, BiPAP ST

Response

Success (302): Redirects to clinical history with success message Validation Error (200): Re-displays form with errors

Common Patterns

Automatic Field Assignment

All exam registration endpoints automatically set:
exam.ingreso = ingreso_actual        # Links to active Ingreso
exam.registrado_por = request.user   # Tracks who registered
exam.save()

Active Ingreso Filtering

All endpoints work exclusively with the patient’s active Ingreso:
ingreso_actual = patient.ingresos.filter(estado='ACTIVO').first()
If a patient has no active Ingreso, exam registration will fail. Ensure the patient has an active program entry before registering exams.

Success Messages

From apps/exams/views.py:96:
messages.success(request, mark_safe(
    f'<i class="fa-solid fa-circle-check"></i> '
    f'Adaptación registrada para {patient.nombre} exitosamente'
))
Success messages use Django’s messages framework and support HTML formatting.

Timestamps

All exam models include:
created_at = models.DateTimeField(auto_now_add=True)
Automatic timestamp when record is created.

Model Structures

Monitoreo Model

From apps/exams/models.py:8:
  • ingreso (ForeignKey) - Links to Ingreso
  • registrado_por (ForeignKey) - User who registered
  • Technical metrics (uso_diario, dias_uso_horas_4, horas_uso_diario)
  • IAH values (hipopnea_basal, hipopnea_residual, porcentaje_correccion)
  • Equipment settings (modo_ventilatorio, presiones, mascara)
  • created_at (DateTime) - Auto-timestamp

Psicologia Model

From apps/exams/models.py:68:
  • ingreso (ForeignKey)
  • registrado_por (ForeignKey)
  • inventario_depre_beck (Integer)
  • inventario_ansiedad_beck (Integer)
  • escala_atenas (Integer)
  • created_at (DateTime)

Other Exam Models

All exam models follow similar structure:
  • Foreign key to Ingreso
  • Foreign key to User (registrado_por)
  • Exam-specific fields
  • Automatic created_at timestamp

Patients API

View patient demographics and details

Ingresos API

Manage program entries that organize exam data