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 Patients API provides endpoints for creating, viewing, updating, and searching patient records. All endpoints require authentication. Base Path:/patients/
Endpoints
List Patients
patients_list in apps/patients/views.py:13
Query Parameters
Search term to filter by patient name (nombre), last name (apellido), or document number (documento). Case-insensitive partial matching.
Filter by current month in program (mes_capita). Valid values: 1-18.
Page number for pagination. Returns 10 patients per page.
Response
Returns HTML template with:Range object (1-19) for month filter options
Current search query value
Current month filter value
Example Request
Implementation Notes
- Only returns patients with
ingresos__estado='ACTIVO' - Uses
distinct()to avoid duplicate results from JOIN - Month filter (mes_capita) requires iteration as it’s a model property
- Optimized for Render deployment with 10 items per page
Create Patient
create_patient in apps/patients/views.py:63
POST Parameters
All parameters are form-encoded. Required fields marked with *:Patient’s first name. Max 100 characters.
Patient’s last name. Max 100 characters.
Document type. Options:
RC, TI, CC, CE, PA, PEUnique document number. Max 20 characters.
Birth date in YYYY-MM-DD format.
Gender. Options:
M (Masculino), F (Femenino), O (Otro)Colombian department. See full list in models.py:17-50.
City name. See available options in models.py:52-95.
Residential zone. Options:
URBANA, RURALPhone number. Max 20 characters.
Mobile number. Max 20 characters.
Marital status. Options:
SOLTERO, CASADO, UNIÓN LIBRE, VIUDO, DIVORCIADOHealth entity. Options:
ECOPETROL, SANITASSocioeconomic stratum. Options: 1-6.
Weight in kilograms. Max 5 digits, 2 decimal places.
Height in meters. Max 4 digits, 2 decimal places.
Abdominal perimeter in cm. Max 5 digits, 2 decimal places.
Neck circumference in cm. Max 5 digits, 2 decimal places.
Referring physician name. Max 100 characters.
Physician specialty. Max 100 characters.
Clinical diagnosis. Currently only supports:
G47.3 (Apnea del Sueño)Program type. Options:
PROGRAMA AOS, PROGRAMA INSOMNIOCapita value. Max 10 digits, 2 decimal places.
Program start date (for Ingreso). Defaults to current date if not provided.
Response
Success (302): Redirects to/patients/ with success message
Validation Error (200): Re-displays form with error messages
Automatic Ingreso Creation
Fromapps/patients/views.py:80-84:
estado='ACTIVO'fecha_iniciofrom form or current datemes_capitacalculated as 1
Get Patient Details
patient_detail in apps/patients/views.py:97
URL Parameters
Patient’s unique identifier
POST Parameters
Accepts same parameters as Create Patient endpoint. Updates existing patient record.Response
Returns HTML template with:Complete patient record
Pre-filled form for editing
Current active Ingreso entry (estado=‘ACTIVO’)
Ingreso Date Update
Fromapps/patients/views.py:112-115:
fecha_inicio_programa also updates the active Ingreso’s start date.
List Followups (Ingresos Manager)
followups_manager in apps/patients/views.py:136
Query Parameters
Search by document, nombre, or apellido. Case-insensitive.
Page number. Returns 10 patients per page.
Response
Paginated patient list with prefetched ingresos
Current search query
Total number of matching patients
Optimization
Usesprefetch_related('ingresos') to avoid N+1 queries when displaying multiple ingresos per patient.
Patient Model Structure
Fromapps/patients/models.py:6:
Core Fields
id- Auto-incrementing primary keynombre- First name (CharField, max 100)apellido- Last name (CharField, max 100)tipo_documento- Document type (choices)documento- Document number (CharField, unique, max 20)fecha_nacimiento- Birth date (DateField)genero- Gender (choices)
Contact & Location
departamento- Colombian department (choices)ciudad- City (choices)zona- Urban/Rural (choices)telefono- Phone (CharField, max 20)celular- Mobile (CharField, max 20)estado_civil- Marital status (choices)
Medical Data
peso- Weight in kg (DecimalField, 5,2)altura- Height in meters (DecimalField, 4,2)perimetro_abdominal- Abdominal perimeter in cm (DecimalField, 5,2)cuello- Neck circumference in cm (DecimalField, 5,2)diagnostico_clinico- Clinical diagnosis (choices)medico_remitente- Referring physician (CharField, max 100)especialidad- Specialty (CharField, max 100)
Program Information
entidad_salud- Health entity (choices)estrato- Socioeconomic stratum (IntegerField, 1-6)programa- Program type (choices)valor_capita- Capita value (DecimalField, 10,2, default 259783)
Computed Properties
Fromapps/patients/models.py:128-146:
Related Endpoints
Ingresos API
Manage patient program entries and status changes
Exams API
View clinical data for patients