Conjunto completo de servidores de prueba para protocolos de salud FHIR R4 y HL7 v2.x, con autenticación OAuth 2.0 y características de seguridad para el desarrollo y testing de aplicaciones de salud.
Este workspace contiene dos proyectos principales:
- FHIR Testing Server - Servidor API REST FHIR R4 con SMART on FHIR
- HL7 Message Processor - Procesador de mensajes HL7 v2.x con validación
- OAuth 2.0 con JWT tokens
- CORS configurado
- Rate limiting con nginx
- Consideraciones HIPAA para datos de salud
- Headers de seguridad (HSTS, XSS Protection, etc.)
- Patient resources (crear, leer, buscar)
- Observation resources (signos vitales, laboratorios)
- CapabilityStatement con metadatos del servidor
- SMART on FHIR OAuth discovery
- Validación de recursos FHIR
- Procesamiento de mensajes ADT, ORU, y más
- Validación de estructura de mensajes
- Almacenamiento de mensajes procesados
- Búsqueda y filtrado de mensajes
- Estadísticas de procesamiento
- Python 3.11+
- Docker y Docker Compose
- Git
# Clonar el repositorio
git clone <repository-url>
cd saludProtocols
# Opción 1: Ejecutar con Docker Compose (recomendado)
docker-compose up -d
# Opción 2: Ejecutar localmente
# FHIR Server
cd fhir-testing-server
cp .env.example .env
pip install -r requirements.txt
python app.py
# HL7 Processor (nueva terminal)
cd ../hl7-message-processor
cp .env.example .env
pip install -r requirements.txt
python app.pyCon Docker Compose:
- Gateway Nginx: http://localhost
- Documentación: http://localhost/docs
- FHIR Metadata: http://localhost/fhir/metadata
- HL7 Health: http://localhost:8081/health
Ejecución local:
- FHIR Server: http://localhost:8080
- HL7 Processor: http://localhost:8081
# Obtener token de acceso
curl -X POST http://localhost:8080/oauth/token \
-H "Content-Type: application/json" \
-d '{
"grant_type": "client_credentials",
"client_id": "fhir-test-client",
"client_secret": "test-secret"
}'# Usar el token obtenido anteriormente
curl -X POST http://localhost:8080/fhir/Patient \
-H "Authorization: Bearer <tu-token>" \
-H "Content-Type: application/json" \
-d '{
"resourceType": "Patient",
"name": [{
"use": "official",
"given": ["Juan"],
"family": "Pérez"
}],
"gender": "male",
"birthDate": "1990-05-15",
"active": true
}'# Autenticarse en HL7 processor
curl -X POST http://localhost:8081/oauth/token \
-H "Content-Type: application/json" \
-d '{
"grant_type": "client_credentials",
"client_id": "hl7-test-client",
"client_secret": "test-secret"
}'
# Procesar mensaje ADT^A01
curl -X POST http://localhost:8081/hl7/process \
-H "Authorization: Bearer <tu-token>" \
-H "Content-Type: application/json" \
-d '{
"message": "MSH|^~\\&|SENDING_APP|FACILITY|RECEIVING_APP|FACILITY|20240121120000||ADT^A01|12345|P|2.5\rPID|1|123456|123456^^^HOSPITAL^MR||PÉREZ^JUAN^MIGUEL||19900515|M|||123 MAIN ST^^CITY^STATE^12345"
}'Usa los clientes Python incluidos:
# Probar FHIR API
cd fhir-testing-server
python test_client.py
# Probar HL7 Processor
cd hl7-message-processor
python test_client.pysaludProtocols/
├── .github/
│ └── copilot-instructions.md
├── fhir-testing-server/
│ ├── app.py # Servidor Flask FHIR
│ ├── test_client.py # Cliente de pruebas
│ ├── requirements.txt # Dependencias Python
│ ├── Dockerfile # Imagen Docker
│ └── .env.example # Variables de entorno
├── hl7-message-processor/
│ ├── app.py # Procesador Flask HL7
│ ├── test_client.py # Cliente de pruebas
│ ├── requirements.txt # Dependencias Python
│ ├── Dockerfile # Imagen Docker
│ └── .env.example # Variables de entorno
├── docker-compose.yml # Orquestación de contenedores
├── nginx.conf # Configuración del gateway
└── README.md # Esta documentación
Copia los archivos .env.example a .env y personaliza:
FHIR Server (.env):
SECRET_KEY=tu-clave-secreta-fhir
CLIENT_ID=fhir-test-client
CLIENT_SECRET=tu-client-secret
PORT=8080HL7 Processor (.env):
SECRET_KEY=tu-clave-secreta-hl7
CLIENT_ID=hl7-test-client
CLIENT_SECRET=tu-client-secret
PORT=8081IMPORTANTE: Antes de usar en producción:
- Cambiar claves secretas en archivos
.env - Configurar HTTPS con certificados SSL
- Usar base de datos real (PostgreSQL, MongoDB)
- Implementar logging y auditoría
- Configurar firewall y VPN
- Habilitar CORS solo para dominios específicos
- Implementar rate limiting más estricto
- Encriptación en tránsito y reposo
- Auditoría de todos los accesos
- Autenticación fuerte (2FA recomendado)
- Control de acceso basado en roles
- Logs de seguridad detallados
Endpoints de salud disponibles:
GET /health- Estado del servidorGET /fhir/metadata- Capacidades FHIR- Docker health checks configurados
| Endpoint | Método | Descripción |
|---|---|---|
/oauth/token |
POST | Obtener token OAuth 2.0 |
/fhir/metadata |
GET | CapabilityStatement |
/fhir/Patient |
POST | Crear paciente |
/fhir/Patient/{id} |
GET | Obtener paciente |
/fhir/Patient |
GET | Buscar pacientes |
/fhir/Observation |
POST | Crear observación |
/fhir/Observation/{id} |
GET | Obtener observación |
| Endpoint | Método | Descripción |
|---|---|---|
/oauth/token |
POST | Obtener token OAuth 2.0 |
/hl7/process |
POST | Procesar mensaje HL7 |
/hl7/validate |
POST | Validar mensaje HL7 |
/hl7/messages |
GET | Listar mensajes procesados |
/hl7/messages/{id} |
GET | Obtener mensaje específico |
- Puerto ocupado: Cambiar puertos en
.envodocker-compose.yml - Token expirado: Obtener nuevo token de
/oauth/token - CORS error: Verificar configuración de headers
- Mensaje HL7 inválido: Usar herramientas de validación
# Ver logs de contenedores
docker-compose logs -f fhir-server
docker-compose logs -f hl7-processor
# Logs en tiempo real
docker-compose logs -f- Fork el proyecto
- Crear rama feature (
git checkout -b feature/nueva-funcionalidad) - Commit cambios (
git commit -m 'Agregar nueva funcionalidad') - Push a la rama (
git push origin feature/nueva-funcionalidad) - Crear Pull Request
MIT License - ver archivo LICENSE para detalles.
Este proyecto es para testing y desarrollo. No usar en producción sin las debidas modificaciones de seguridad.