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
DataMed uses django-import-export to provide robust data export capabilities through the Django admin interface. This allows you to export patient data, cycle information, and clinical records in multiple formats.Data export functionality is available through the Django Admin panel at
/admin/. You must have admin or staff permissions to access these features.Supported Export Formats
The import-export library supports multiple formats:Excel (.xlsx)
Recommended for data analysis and reporting
CSV
Compatible with most data tools and databases
JSON
Machine-readable format for API integration
YAML
Human-readable structured data format
TSV
Tab-separated values for text processing
HTML
Browser-viewable tables
Accessing Export Features
Select Model to Export
Choose the data type:
- Patients (apps.patients.Patient)
- Cycles/Ingresos (apps.patients.Ingreso)
- Clinical Exams (various models in apps.exams)
Exporting Patient Data
Patient Admin Configuration
The Patient model is configured with import-export capabilities:Available Patient Fields
When exporting patients, all model fields are included:Demographics
Demographics
- nombre
- apellido
- tipo_documento
- documento
- fecha_nacimiento
- genero
- departamento
- ciudad
- zona
- estado_civil
Contact Information
Contact Information
- telefono
- celular
Health Insurance
Health Insurance
- entidad_salud
- estrato
Clinical Measurements
Clinical Measurements
- peso
- altura
- perimetro_abdominal
- cuello
Program Information
Program Information
- medico_remitente
- especialidad
- diagnostico_clinico
- programa
- valor_capita
Filtering Before Export
You can filter data before exporting:- Use the admin list filters (programa, genero)
- Use the search box (nombre, apellido, documento)
- Apply filters, then click Export
- Only filtered records will be exported
Exporting Cycle Data (Ingresos)
Ingreso Resource Configuration
Exported Cycle Fields
- id: Cycle unique identifier
- paciente_id: Patient primary key reference
- fecha_inicio: Program start date
- fecha_fin: Program end date (if terminated)
- estado: ACTIVO, SUSPENDIDO, or TERMINADO
- motivo: Reason for status change
Exporting Clinical Exam Data
While clinical exam models can be exported through the admin, they may need to be configured first:Example: Enabling Export for Monitoreo
Available Clinical Exam Models
You can configure export for any of these models:- Monitoreo: CPAP/BiPAP monitoring data
- Psicologia: Psychology assessment scores
- Nutricion: Nutritional status records
- Neumologia: Pulmonology consultations
- PolisomnografiaBasal: Baseline sleep studies
- PolisomnografiaTitulacion: Titration studies
- EquipoMedico: Medical equipment assignments
- SeguimientoAdaptacion: Adaptation follow-up notes
To enable export for exam models, you need to update
apps/exams/admin.py and register each model with ImportExportModelAdmin.Data Import Capabilities
Import Process
Prepare Import File
Create an Excel or CSV file with the correct column names matching the model fields
Import Configuration for Ingresos
Custom Export Workflows
Generating Monthly Billing Reports
Generating Program Completion Reports
Exporting Clinical Data for Research
Custom Export Fields
You can customize which fields are exported by creating custom Resource classes:Exporting Computed Fields
To include computed properties likeedad or mes_capita in exports:
Pagination and Performance
Large exports may take time to process. The admin list view uses pagination (10 items per page), but exports process all filtered records.
Best Practices for Large Exports
- Filter First: Apply filters to reduce dataset size
- Use CSV: CSV format is faster than Excel for very large datasets
- Off-Peak Hours: Schedule large exports during low-traffic periods
- Chunked Processing: For massive datasets, consider exporting by date ranges
Security Considerations
Access Control
Data Protection Checklist
- ✅ Restrict admin access to authorized personnel only
- ✅ Use HTTPS for all admin traffic (configured in settings.py)
- ✅ Enable Django audit logging for exports
- ✅ Regularly review who has admin access
- ✅ Never commit exported files to version control
- ✅ Encrypt exported files containing PHI (Protected Health Information)
- ✅ Follow organizational data retention policies
Advanced: API-Based Export
For programmatic data access, consider implementing REST API endpoints:Configuration Reference
Settings.py Configuration
Import-Export Options
Common configuration options:Troubleshooting
Export button not visible
Export button not visible
Export file is empty
Export file is empty
Problem: Export generates empty fileSolutions:
- Check if filters are too restrictive
- Verify database contains matching records
- Review Resource class field configuration
- Check for errors in dehydrate methods
Foreign key export errors
Foreign key export errors
Problem: Related fields not exporting correctlySolution: Use
ForeignKeyWidget in Resource class:Performance issues with large exports
Performance issues with large exports
Problem: Export times out or is very slowSolutions:
- Apply filters to reduce dataset size
- Use CSV instead of Excel format
- Consider exporting in batches by date range
- Optimize database queries with select_related/prefetch_related
Related Documentation
Patient Registration
Learn about the patient data structure
Managing Cycles
Understand cycle data for reporting
Recording Exams
See what clinical data is available
django-import-export Docs
Official library documentation