How luisuriarte/oe-module-coverage-latam works
Purpose and host integration
This is a PHP 8.1+ custom module for OpenEMR 8+ that adds LATAM insurance-coverage workflows without modifying OpenEMR tables: prior authorizations, procedure-frequency checks, time-bounded provider/payer agreements, and periodic settlement batches. It runs inside the OpenEMR session, ACL, database, and module lifecycle.
• openemr.bootstrap.php
• moduleConfig.php
• index.php
Entry points and UI/API boundary
OpenEMR loads the module bootstrap, which registers module behavior/menu and triggers initial country-pack setup. The operational UI is a single dashboard with tab-specific JavaScript. Browser actions call PHP JSON endpoints; these endpoints require the OpenEMR session and bridge UI requests to repositories/services.
• pages/dashboard.php
• pages/api/auth_rules.php
• pages/api/batches.php
Persistence model and OpenEMR boundary
Installation creates 12 isolated covl_* tables, while foreign keys/references connect to OpenEMR’s patients, encounters, billing, insurers, providers, facilities, and code catalogs. The module uses native OpenEMR SQL access rather than an ORM. Settlement items enforce separation from the native claim flow; both systems can coexist.
• sql/install.sql
• src/Repository/AuthorizationRepository.php
• src/Repository/SettlementBatchRepository.php
Authorization and integration pipeline
AuthorizationService evaluates payer/code/plan rules, resolves a payer-specific integration adapter, persists the authorization and state history, and can later link it to a clinical encounter. Adapter contracts isolate external insurer APIs; the included manual adapter provides an always-available operational fallback. Results cross this boundary through typed DTO/contracts.
• src/Service/AuthorizationService.php
• src/Service/AdapterRegistry.php
• src/Adapter/ManualFallbackAdapter.php
Coverage validation stages
Frequency validation combines configured rules with native billed procedures and still-active, unlinked authorizations, returning whether the procedure is allowed plus violation severity/timing. Provider coverage independently validates a provider × insurer agreement for a requested date, supporting agenda/check-in integration points.
• src/Service/FrequencyCheckService.php
• src/Service/ProviderCoverageService.php
• src/Repository/FrequencyRulesRepository.php
Settlement and administration workflows
Administrative APIs manage authorization/frequency rules, provider agreements, and settlement batches. Batch progression groups native billing items by insurer/period and supports controlled status transitions, payments, disputes, and item-level management. Insurer data remains owned by OpenEMR’s insurance_companies.
• pages/api/frequency_rules.php
• pages/api/providers.php
• src/Repository/SettlementBatchRepository.php
Country-pack and code-catalog provisioning
Country JSON packs define localized code types, authorization/frequency defaults, and local-to-standard code mappings. Import is transactional and idempotent; Argentina is auto-imported on first active access. A separate SQL catalog provisions Spanish CPT4 descriptions used by code search, alongside supported native terminology sources.
• src/Service/CountryPackInstaller.php
• src/Service/CountryPackImporter.php
• packs/ar.json
Main entry points: install.sql covl_* schema · auth_rules.php Administration APIs · FrequencyCheckService.php Frequency check service · openemr.bootstrap.php Module bootstrap
Components 19
OpenEMR host
Module runs within native OpenEMR runtime and data ownership.
- OpenEMR runtime · Provides session, ACL, lifecycle, SQL access, and native clinical data.
- Native clinical & insurer data · Patients, encounters, billing, insurers, providers, facilities, and code catalogs remain host-owned.
Module UI & APIs
- Module bootstrap · Registers module behavior and starts first-use provisioning.
openemr.bootstrap.php - Coverage dashboard · Single operational dashboard with tab-specific browser actions.
pages/dashboard.php - Administration APIs · Manages authorization rules, frequency rules, provider agreements, and batches.
pages/api/auth_rules.php - Settlement batch API
pages/api/batches.php
Coverage workflows
- Authorization service · Evaluates payer/code/plan rules, creates authorization state, and links encounters.
src/Service/AuthorizationService.php - Adapter registry · Selects the payer-specific authorization adapter.
src/Service/AdapterRegistry.php - Frequency check service · Combines rules, billed procedures, and active unlinked authorizations.
src/Service/FrequencyCheckService.php - Provider coverage service · Validates provider × insurer agreements for a requested date.
src/Service/ProviderCoverageService.php - Settlement workflow · Groups native billing by insurer and period; supports payments, disputes, and item management.
src/Repository/SettlementBatchRepository.php
Module persistence
- covl_* schema · Twelve isolated tables for coverage workflows and settlement items.
sql/install.sql - Authorization repository · Persists authorizations, links, and state history through native SQL.
src/Repository/AuthorizationRepository.php - Frequency rules repository
src/Repository/FrequencyRulesRepository.php - Settlement batch repository · Manages batches, items, and controlled settlement state.
src/Repository/SettlementBatchRepository.php
Payer integration & provisioning
- Manual fallback adapter · Always-available operational fallback for insurer authorization.
src/Adapter/ManualFallbackAdapter.php - Country-pack installer · Triggers transactional, idempotent country-pack import on active access.
src/Service/CountryPackInstaller.php - Country-pack importer · Imports localized code types, defaults, and code mappings.
src/Service/CountryPackImporter.php - Argentina country pack · Auto-imported on first active access.
packs/ar.json
Connections 25
- OpenEMR runtime → Module bootstrap: loads module
- Module bootstrap → Coverage dashboard: registers UI
- Module bootstrap → Country-pack installer: initial setup
- Coverage dashboard → Administration APIs: browser JSON actions
- Coverage dashboard → Settlement batch API: batch actions
- Administration APIs → Authorization service: authorization requests
- Administration APIs → Frequency check service: frequency checks
- Administration APIs → Provider coverage service: agreement checks
- Settlement batch API → Settlement workflow: batch progression
- Authorization service → Adapter registry: resolves adapter
- Adapter registry → Manual fallback adapter: fallback
- Authorization service → Authorization repository: persists state
- Frequency check service → Frequency rules repository: loads configured rules
- Frequency check service → Authorization repository: checks active authorizations
- Frequency check service → Native clinical & insurer data: reads billed procedures
- Provider coverage service → covl_* schema: reads agreements
- Settlement workflow → Settlement batch repository: manages batches/items
- Settlement workflow → Native clinical & insurer data: groups billing by insurer/period
- Authorization repository → covl_* schema: native SQL
- Frequency rules repository → covl_* schema: native SQL
- Settlement batch repository → covl_* schema: native SQL
- covl_* schema → Native clinical & insurer data: references host records
- Country-pack installer → Country-pack importer: runs import
- Country-pack importer → Argentina country pack: loads definitions
- Country-pack importer → covl_* schema: provisions defaults