How eduardoarsocca/integracao_natura works
This is a clinical-study integration service that synchronizes REDCap event records into PoloTrial. A webhook receives an event, dispatch selects a stage-specific handler, and that handler reads REDCap data and creates or updates participants, visits, procedures, executors, or participant status in PoloTrial. The repository also provides a CLI and reusable synchronization helpers. The main routing and several handlers are excerpted; relationships based only on the source index are marked dashed where invocation is not shown.
Main entry points: dispatch.py Event dispatcher · redcap_client.py REDCap client · generic_visit.py Generic visits · polotrial_client.py PoloTrial client
Components 19
Event ingress
- Webhook receiver
src/integracao/webhook.py - CLI runner
src/integracao/cli.py - Event dispatcher
src/integracao/dispatch.py
Synchronization workflows
- V1 screening
src/integracao/events/v1_screening.py - V2 randomization
src/integracao/events/v2_randomizacao.py - Generic visits
src/integracao/events/generic_visit.py - Status updates
src/integracao/events/status_atualization.py - Visit catalog
src/integracao/visits_catalog.py
Sync core
- Sync engine
src/integracao/sync_engine.py - Date utilities
src/integracao/utils.py - Runtime configuration
src/integracao/config.py - Logging setup
src/integracao/logging_conf.py
Service adapters
- REDCap client
src/integracao/redcap_client.py - PoloTrial client
src/integracao/polotrial_client.py
Domain mappings
- Field and procedure maps
src/integracao/mappings - REDCap event names
src/integracao/redcap_unique_event_names.py
Other components
- REDCap event
- REDCap API
- PoloTrial API
Connections 31
- REDCap event → Webhook receiver: sends event
- Webhook receiver → Event dispatcher: routes event
src/integracao/webhook.py - CLI runner → Event dispatcher: dispatches event
src/integracao/cli.py - Event dispatcher → V1 screening: dispatches V1
src/integracao/dispatch.py - Event dispatcher → V2 randomization: dispatches V2
src/integracao/dispatch.py - Event dispatcher → Generic visits: dispatches visit
src/integracao/dispatch.py - Event dispatcher → Status updates: dispatches status
src/integracao/dispatch.py - Event dispatcher → Visit catalog: checks events
src/integracao/dispatch.py - Generic visits → Visit catalog: uses visit config
src/integracao/events/generic_visit.py - V1 screening → REDCap client: exports records
src/integracao/events/v1_screening.py - V1 screening → PoloTrial client: syncs screening
src/integracao/events/v1_screening.py - V1 screening → Field and procedure maps: matches procedures
src/integracao/events/v1_screening.py - V2 randomization → REDCap client: exports records
src/integracao/events/v2_randomizacao.py - V2 randomization → PoloTrial client: syncs randomization
src/integracao/events/v2_randomizacao.py - V2 randomization → Field and procedure maps: maps procedures
src/integracao/events/v2_randomizacao.py - Generic visits → REDCap client: exports visit data
src/integracao/events/generic_visit.py - Generic visits → PoloTrial client: syncs visit
src/integracao/events/generic_visit.py - Generic visits → Sync engine: calls sync helpers
src/integracao/events/generic_visit.py - Generic visits → Field and procedure maps: resolves visit name
src/integracao/events/generic_visit.py - Status updates → REDCap client: exports status
src/integracao/events/status_atualization.py - Status updates → PoloTrial client: updates status
src/integracao/events/status_atualization.py - Status updates → Field and procedure maps: maps site and status
src/integracao/events/status_atualization.py - Sync engine → REDCap client: reads record
src/integracao/sync_engine.py - Sync engine → PoloTrial client: updates visit
src/integracao/sync_engine.py - Sync engine → Field and procedure maps: uses site codes
src/integracao/sync_engine.py - Date utilities → REDCap client: uses client type
src/integracao/utils.py - REDCap client → REDCap API: calls API
src/integracao/redcap_client.py - PoloTrial client → PoloTrial API: calls API
src/integracao/polotrial_client.py - Webhook receiver → Runtime configuration: loads settings
src/integracao/webhook.py - Webhook receiver → Logging setup: configures logs
src/integracao/webhook.py - Event dispatcher → REDCap event names: uses event names