workspace-v1/projects/erp-suite/apps/verticales/clinicas/database
Adrian Flores Cortes 967ab360bb Initial commit: Workspace v1 with 3-layer architecture
Structure:
- control-plane/: Registries, SIMCO directives, CI/CD templates
- projects/: Gamilit, ERP-Suite, Trading-Platform, Betting-Analytics
- shared/: Libs catalog, knowledge-base

Key features:
- Centralized port, domain, database, and service registries
- 23 SIMCO directives + 6 fundamental principles
- NEXUS agent profiles with delegation rules
- Validation scripts for workspace integrity
- Dockerfiles for all services
- Path aliases for quick reference

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 00:35:19 -06:00
..
init Initial commit: Workspace v1 with 3-layer architecture 2025-12-23 00:35:19 -06:00
HERENCIA-ERP-CORE.md Initial commit: Workspace v1 with 3-layer architecture 2025-12-23 00:35:19 -06:00
README.md Initial commit: Workspace v1 with 3-layer architecture 2025-12-23 00:35:19 -06:00

Base de Datos - ERP Clínicas

Resumen

Aspecto Valor
Schema principal clinica
Tablas específicas 13
ENUMs 4
Hereda de ERP-Core 144 tablas (12 schemas)

Prerequisitos

  1. ERP-Core instalado con todos sus schemas:

    • auth, core, financial, inventory, purchase, sales, projects, analytics, system, billing, crm, hr
  2. Extensiones PostgreSQL:

    • pgcrypto (encriptación)
    • pg_trgm (búsqueda de texto)

Orden de Ejecución DDL

# 1. Instalar ERP-Core primero
cd apps/erp-core/database
./scripts/reset-database.sh

# 2. Instalar extensión Clínicas
cd apps/verticales/clinicas/database
psql $DATABASE_URL -f init/00-extensions.sql
psql $DATABASE_URL -f init/01-create-schemas.sql
psql $DATABASE_URL -f init/02-rls-functions.sql
psql $DATABASE_URL -f init/03-clinical-tables.sql
psql $DATABASE_URL -f init/04-seed-data.sql

Tablas Implementadas

Schema: clinica (13 tablas)

Tabla Módulo Descripción
specialties CL-002 Catálogo de especialidades médicas
doctors CL-002 Médicos (extiende hr.employees)
patients CL-001 Pacientes (extiende core.partners)
patient_contacts CL-001 Contactos de emergencia
patient_insurance CL-001 Información de seguros
appointment_slots CL-002 Horarios disponibles
appointments CL-002 Citas médicas
medical_records CL-003 Expediente clínico electrónico
consultations CL-003 Consultas realizadas
vital_signs CL-003 Signos vitales
diagnoses CL-003 Diagnósticos (CIE-10)
prescriptions CL-003 Recetas médicas
prescription_items CL-003 Medicamentos en receta

ENUMs

Enum Valores
appointment_status scheduled, confirmed, in_progress, completed, cancelled, no_show
patient_gender male, female, other, prefer_not_to_say
blood_type A+, A-, B+, B-, AB+, AB-, O+, O-, unknown
consultation_status draft, in_progress, completed, cancelled

Row Level Security

Todas las tablas tienen RLS habilitado con aislamiento por tenant:

tenant_id = current_setting('app.current_tenant_id', true)::UUID

Consideraciones de Seguridad

  • NOM-024-SSA3-2012: Expediente clínico electrónico
  • Datos sensibles: medical_records, consultations requieren encriptación
  • Auditoría completa: Todas las tablas tienen campos de auditoría

Referencias