clinica-dental/orchestration/directivas/TRIGGER-COHERENCIA-CAPAS.md
rckrdmrd ebdab354e8 [clinica-dental] feat: Add SaaS documentation from erp-clinicas chain
- Add orchestration/directivas/ with TRIGGER-COHERENCIA-CAPAS.md and
  TRIGGER-INVENTARIOS.md adapted for dental domain
- Add orchestration/agents/perfiles/ with specialized agents:
  - PERFIL-ODONTOLOGO-AGENT.yml (domain expert)
  - PERFIL-DDL-DENTAL-AGENT.yml (database specialist)
  - _INDEX.yml (agents catalog)
- Add MAPA-DOCUMENTACION.yml with full heritage chain references:
  - template-saas (origin/PROVIDER)
  - erp-core (abuelo/INTERMEDIATE)
  - erp-clinicas (padre/CONSUMER)
- Include normative references: NOM-013-SSA2-2015, NOM-004-SSA3-2012, COFEPRIS
- Define @DENTAL_ prefixed aliases for project navigation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 19:46:21 -06:00

166 lines
4.4 KiB
Markdown

# TRIGGER: Coherencia Entre Capas - Clinica Dental
**ID:** TRIGGER-DENTAL-COHERENCIA
**Version:** 1.0.0
**Proyecto:** clinica-dental
**Hereda de:** @ERP_TRIGGER_COHERENCIA -> @CLINICAS_TRIGGER_COHERENCIA
**Alias:** @DENTAL_TRIGGER_COHERENCIA
---
## Proposito
Validar que cada objeto creado en una capa tenga su correspondiente en las demas capas, manteniendo coherencia DDL - Backend - Frontend, con validaciones especificas para el dominio odontologico.
## Cadena de Herencia
```
template-saas (PROVIDER)
|
v
erp-core (INTERMEDIATE)
|
v
erp-clinicas (CONSUMER)
|
v
clinica-dental (SUB-VERTICAL) <- ESTE PROYECTO
```
## Activacion
### Automatica
- Creacion/modificacion de tabla DDL en schema `sub_dental`
- Creacion/modificacion de entity TypeORM en modulos dentales
- Creacion/modificacion de endpoint API especifico dental
### Manual
- Comando: `@DENTAL_VALIDATE_COHERENCE`
- Pre-commit hook
## Reglas de Validacion
### DDL -> Backend (OBLIGATORIO)
```yaml
regla_1:
condicion: "Nueva tabla DDL creada en sub_dental.*"
accion: "Verificar entity correspondiente existe"
bloquea: true
regla_2:
condicion: "Columna agregada a tabla dental"
accion: "Verificar campo en entity existe"
bloquea: true
regla_3:
condicion: "Constraint FK agregado a tabla dental"
accion: "Verificar relacion TypeORM existe"
bloquea: true
```
### Backend -> Frontend (CONDICIONAL)
```yaml
regla_4:
condicion: "Endpoint CRUD dental creado"
accion: "Verificar hook/servicio frontend existe"
bloquea: false # Solo warning
regla_5:
condicion: "DTO dental modificado"
accion: "Verificar tipos TypeScript frontend"
bloquea: false
```
## Validaciones Especificas Clinica Dental
### Modulos CDT (Clinica Dental)
| Modulo | DDL Schema | Backend Path | Frontend Path |
|--------|------------|--------------|---------------|
| CDT-001 Odontograma | sub_dental.odontograms, tooth_* | modules/odontograma/ | pages/odontograma/ |
| CDT-002 Tratamientos | sub_dental.dental_treatments | modules/tratamientos-dentales/ | pages/tratamientos/ |
| CDT-003 Ortodoncia | sub_dental.orthodontic_* | modules/ortodoncia/ | pages/ortodoncia/ |
| CDT-004 Protesis | sub_dental.prosthetics | modules/protesis/ | pages/protesis/ |
| CDT-005 Radiografias | sub_dental.dental_xrays | modules/radiografias/ | pages/radiografias/ |
| CDT-006 Presupuestos | sub_dental.dental_quotes | modules/presupuestos/ | pages/presupuestos/ |
### Coherencia de Nombres
```
DDL: sub_dental.tabla_nombre (snake_case)
Entity: TablaNombre (PascalCase)
Service: tabla-nombre.service.ts (kebab-case)
Controller: tabla-nombre.controller.ts (kebab-case)
```
## Validaciones Normativas (NOM-013-SSA2-2015)
### Campos Obligatorios para Expediente Clinico Dental
```yaml
validacion_normativa:
condicion: "Entity de expediente dental"
campos_requeridos:
- "historia_clinica_general"
- "examen_extraoral"
- "examen_intraoral"
- "odontograma_inicial"
- "diagnostico_presuntivo"
- "plan_tratamiento"
- "consentimiento_informado"
referencia_normativa: "NOM-013-SSA2-2015"
bloquea: true
```
### Integridad de Odontograma
```yaml
validacion_odontograma:
condicion: "Tabla odontograms creada/modificada"
reglas:
- "32 piezas dentales adulto o 20 deciduos"
- "Estado por superficie (5 superficies por pieza)"
- "Codigos CIE-10 para diagnosticos"
bloquea: true
```
## Excepciones Permitidas
1. **Tablas M:N gestionadas por TypeORM**
- Documentar en ENTITIES-CATALOG.md
2. **Tablas de auditoria/sistema**
- Prefijo: `_audit_dental`, `_system_dental`
3. **Tablas heredadas de erp-clinicas**
- No requieren entity local si se usa la del padre
4. **Vistas para reportes NOM**
- Documentar en DATABASE-SCHEMA.md
## Metricas
| Metrica | Objetivo | Actual |
|---------|----------|--------|
| Coherencia DDL-Entity | 100% | TBD |
| Coherencia Entity-Service | 100% | TBD |
| Coherencia API-Frontend | 95% | TBD |
| Cumplimiento NOM-013 | 100% | TBD |
## Referencias
- `@DENTAL_DEF_DB` - DATABASE-SCHEMA.md
- `@DENTAL_DEF_ENTITIES` - ENTITIES-CATALOG.md
- `@CLINICAS_TRIGGER_COHERENCIA` - Trigger padre en erp-clinicas
- `@ERP_TRIGGER_COHERENCIA` - Trigger abuelo en erp-core
- `@WS_TRIGGER_COHERENCIA` - Trigger raiz del workspace
---
**Normativa Aplicable:**
- NOM-013-SSA2-2015: Prevencion y control de enfermedades bucales
- NOM-004-SSA3-2012: Del expediente clinico
- COFEPRIS: Regulacion de consultorios dentales