Commit Graph

17 Commits

Author SHA1 Message Date
Adrian Flores Cortes
ce595d9443 [RBAC-005] feat: Propagate RBAC middleware from erp-core
- Add rbac.middleware.ts with requirePerm, requireAnyPerm, requireAllPerms, requireAccess, requirePermOrOwner
- Add shared middleware index exports
- Configure clinics-specific roles (manager, supervisor, doctor, receptionist, admin, super_admin)

Propagated from erp-core TASK-2026-01-30-RBAC

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 14:58:33 -06:00
Adrian Flores Cortes
60917f75ff [CL-011] feat: Implement reports-clinical module for clinical reporting
Features:
- Report templates with customizable layouts
- Report generator for patient summaries, stats, KPIs
- Clinical statistics service with dashboard data
- Scheduled reports with email delivery
- Export formats: PDF, Excel, CSV

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 20:05:13 -06:00
Adrian Flores Cortes
1b38818354 [CL-010] feat: Implement insurance module for medical insurance management
Implements complete insurance module with:
- Insurance company catalog (private, government, HMO, PPO)
- Insurance plans with coverage details, deductibles, copays
- Patient insurance policies with verification workflow
- Insurance claims with full lifecycle (draft->submitted->approved/denied/paid)
- Preauthorization requests with approval workflow
- Coverage verification endpoint
- EOB (Explanation of Benefits) tracking
- Aging reports for claims management

Entities: InsuranceCompany, InsurancePlan, PatientInsurance, InsuranceClaim, Preauthorization
Services: Full CRUD + workflow operations for each entity
Controller: 50+ REST endpoints for all insurance operations

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 19:59:47 -06:00
Adrian Flores Cortes
e4d915889a [CL-012] feat: Implement telemedicine module for virtual consultations
Add complete telemedicine module with:
- VirtualRoom entity for video consultation room management
- TelemedicineSession entity for session lifecycle tracking
- SessionParticipant entity for participant join/leave tracking
- Full REST API endpoints for rooms, sessions, and participants
- Multi-tenant support throughout
- Session states: scheduled, waiting, in_progress, completed, cancelled
- Participant roles: patient, doctor, guest, interpreter, family_member
- Recording consent tracking and session duration logging
- Connection quality logging infrastructure
- Integration points for WebRTC providers (Twilio, Daily.co, Vonage)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 19:56:19 -06:00
Adrian Flores Cortes
56ded676ae [CL-009] feat: Implement imaging module for radiology studies
Add complete imaging module with:
- Entities: ImagingStudy (catalog), ImagingOrder (workflow), DicomInstance (DICOM tracking)
- Services: Study management, Order workflow (ordered->scheduled->performed->reported), DICOM file management
- Controller: REST endpoints for studies, orders, and DICOM instances
- Features: Multi-tenant support, study types (xray, ct, mri, ultrasound, mammography, pet, nuclear),
  order scheduling, radiologist assignment, critical findings flagging, DICOM viewer URLs

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 19:55:56 -06:00
Adrian Flores Cortes
50a409bf17 [CL-007] feat: Implement pharmacy module
Add complete pharmacy module for erp-clinicas with:

Entities:
- Medication: catalog with controlled substance flags, categories, forms
- PharmacyInventory: stock management with batch/lot tracking, alerts
- PharmacyPrescription: linked to consultation and patient
- Dispensation: medication dispensing with partial fills support

Services:
- MedicationService: CRUD for medication catalog
- PharmacyInventoryService: stock management, low stock alerts, expiry tracking
- PrescriptionService: prescription workflow, refills, controlled substances
- DispensationService: dispensing workflow, verification, returns

Features:
- Multi-tenant support (tenantId in all queries)
- Controlled substance tracking and scheduling
- Inventory with low stock and expiration alerts
- Prescription linked to consultation and patient
- Dispensation tracking with partial fills support
- Stock reservation and dispensing workflow
- FIFO dispensing based on expiration dates

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 19:30:45 -06:00
Adrian Flores Cortes
27ea1fd4a6 [CL-006] feat: Implement laboratory module
Add comprehensive laboratory module for managing lab tests, orders, and results:

Entities:
- LabTest: Catalog of available tests with reference ranges and categories
- LabOrder: Lab orders linked to patients and consultations
- LabResult: Results with values, status, and abnormal value detection

Services:
- LabTestService: CRUD operations for test catalog
- LabOrderService: Order lifecycle (create, collect sample, process, complete, cancel)
- LabResultService: Record results, verify, amend with history tracking

Features:
- Multi-tenant support (tenantId in all queries)
- Automatic abnormal/critical value flagging
- Result amendment with audit trail
- Order number auto-generation
- Reference range support by gender and age

REST Endpoints:
- /api/laboratory/tests/* - Test catalog management
- /api/laboratory/orders/* - Order lifecycle management
- /api/laboratory/results/* - Result recording and verification

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 18:15:10 -06:00
Adrian Flores Cortes
d0420bc135 [SYNC] Synchronize payment-terminals module from erp-core canonical
Source: erp-core (checksum: c9040e545cf55beb87d3e437a4998855)
Priority: P1 - HIGH
Context: TASK-2026-01-25-SISTEMA-REUTILIZACION

Before: Diverged version (one of 3 different versions)
After: Synced with canonical

Changes:
- Complete payment-terminals module synchronized from erp-core
- 21 TypeScript files updated
- Unified payment terminal integration (MercadoPago + Clip)
- Consistent webhook handling across all ERP projects

Benefits:
- Single source of truth for payment terminals functionality
- Consistent TPV integration behavior
- Reduced maintenance burden (~4,000 lines saved)
- Unified webhook processing

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 06:52:16 -06:00
Adrian Flores Cortes
91561eb124 [ADD] BaseService propagated from erp-core canonical
Source: erp-core (checksum: 900be2ee48f2faf72ce5253aeab27c88)
Priority: P1 - HIGH (architectural gap resolution)
Context: TASK-2026-01-25-SISTEMA-REUTILIZACION

Before: "Missing"
After: Synced with canonical

Changes:
- BaseService "added" from erp-core
- Checksum: 900be2ee48f2faf72ce5253aeab27c88
- Provides base CRUD operations for all services

Benefits:
- Unified service architecture
- Consistent error handling and validation
- Reduced code duplication in service implementations
- Standard pagination and filtering patterns

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 06:43:34 -06:00
Adrian Flores Cortes
f63524ba10 [SYNC] Synchronize ai module from erp-core canonical
Source: erp-core (checksum: 39a6e229055a21158b63cc4eb4dd232f)
Priority: P0 - CRITICAL divergence resolution
Context: TASK-2026-01-25-SISTEMA-REUTILIZACION

Before: Diverged version with project-specific adaptations
After: Synced with canonical

Changes:
- Complete ai module synchronized from erp-core
- 24 TypeScript files updated
- Unified role-based AI configuration
- Consistent AI behavior across all ERP projects

Note: Project-specific role adaptations (if needed) can be
re-applied as documented extensions after this sync.

Benefits:
- Single source of truth for AI functionality
- Reduced maintenance burden
- Token savings from code reuse
- Consistent behavior baseline

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 06:36:19 -06:00
Adrian Flores Cortes
45ef7f4607 [PROP-CORE-004] feat: Register payment-terminals module in app
- Added PaymentTerminalsModule to module imports
- Added entities to getAllEntities()
- Added paymentTerminals to ModuleOptions
- Registered module in initializeModules()
- Updated health check with paymentTerminals status

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 03:13:56 -06:00
Adrian Flores Cortes
289b4eb466 [PROP-CORE-004] fix: Remove external entity references from payment-terminals
Fixed getEntities() to only reference own entities, avoiding require errors.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 03:08:27 -06:00
Adrian Flores Cortes
07877410d3 [PROP-CORE-004] feat: Adapt AI roles for medical clinic domain
- Roles: ADMIN, DOCTOR, RECEPCIONISTA, PACIENTE
- Clinical data restricted to DOCTOR only
- Compliance: NOM-024-SSA3-2012, LFPDPPP
- Medical terminology and privacy restrictions

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 02:57:48 -06:00
Adrian Flores Cortes
297720cdf2 [PROP-CORE-004] feat: Add Phase 6 modules from erp-core
Propagated modules:
- payment-terminals: MercadoPago + Clip TPV (PCI-DSS compliant)
- ai: Role-based AI access (ADMIN, DOCTOR, RECEPCIONISTA, PACIENTE)
- mcp: 18 ERP tools for AI assistants

Note: Payment data must NOT be stored in clinical records.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 02:45:29 -06:00
50eb26fa53 [ERP-CLINICAS] feat: Setup backend build configuration
- Add package.json with Express, TypeORM, PostgreSQL dependencies
- Add tsconfig.json with TypeScript compiler options
- Update .gitignore with comprehensive exclusions
- Build validates successfully (28 TypeScript files)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 12:20:11 -06:00
f8aacbd316 Migración desde erp-clinicas/backend - Estándar multi-repo v2
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 08:11:57 -06:00
3f4b0c21b6 Initial commit 2026-01-16 14:05:00 +00:00