ReprocessChangedConfigurations
Overview
ReprocessChangedConfigurationsTask identifies visits and accounts affected by configuration changes and queues them for reprocessing. When configurations like AutoSendLetterConfig, Bundle, AutoBenefitsRule, or InsuranceMap are modified, this task ensures all associated visits and accounts are flagged for recalculation.
Use this task when: You need to propagate configuration changes (pricing rules, insurance mappings, auto-send settings, etc.) to existing visits or accounts that were processed using the old configuration.
Don't use this task when:
- Processing new visits/accounts (they will use current configurations automatically)
- Making configuration changes that should not affect historical data
- You need immediate reprocessing (this task only queues items; subsequent tasks consume the queue)
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
ReprocessVisits |
bool |
No | false |
When true, identifies visits affected by changed configurations and adds them to the VisitReprocessQueueItem table for later consumption by VisitLoader |
ReprocessAccounts |
bool |
No | false |
When true, identifies accounts affected by changed InsuranceMap configurations, truncates AccountsToReprocess table, and populates it with affected accounts |
Execution Flow
flowchart TD
A[Start ReprocessChangedConfigurations] --> B{ReprocessVisits = true?}
B -->|Yes| C[Process AutoSendLetterConfigs]
B -->|No| D{ReprocessAccounts = true?}
C --> E[Process Bundles]
E --> F[Process AutoBenefitsRules]
F --> G[Process InsuranceMaps for Visits]
G --> D
D -->|Yes| H[Truncate AccountsToReprocess table]
H --> I[Process InsuranceMaps for Accounts]
I --> J[Populate AccountsToReprocess]
D -->|No| K[End]
J --> K
style C fill:#e1f5ff
style E fill:#e1f5ff
style F fill:#e1f5ff
style G fill:#e1f5ff
style H fill:#ffe1e1
style I fill:#e1f5ff
style J fill:#fff4e1
Processing Algorithm
The task uses a two-phase approach for each configuration type:
Visit Reprocessing (when ReprocessVisits = true)
For each configuration type (AutoSend, Bundle, AutoBenefits, InsuranceMap):
- Identify Changed Configs: Query configs where
NeedsReprocessing = trueflag is set - Turn Off Flags: Clear the
NeedsReprocessingflag on identified configs - Find Affected Visits: Query visits associated with each changed config
- Filter by Schedule: Only queue visits with
ScheduledTime > CurrentDateTime(future visits only) - Create Queue Items: Add entries to
VisitReprocessQueueItemtable with visit key and config key - Delete Duplicates: Remove existing queue items for the same config before adding new ones
Account Reprocessing (when ReprocessAccounts = true)
For InsuranceMap configurations only:
- Truncate Queue: Clear the entire
AccountsToReprocesstable - Identify Changed Maps: Query InsuranceMaps where
ReprocessFlagindicates account reprocessing needed - Adjust Flags: Update
ReprocessFlag(e.g.,ReprocessVisitsAndAccounts→ReprocessVisits,ReprocessAccounts→None) - Find Affected Accounts: Query accounts using the source insurance IDs from changed maps
- Populate Queue: Insert affected accounts into
AccountsToReprocesstable
Example Execution
Scenario: Modified an InsuranceMap for "Blue Cross PPO" that affects 500 visits and 200 accounts:
1. ReprocessVisits = true:
- Find InsuranceMap with NeedsReprocessing flag
- Clear the flag
- Query 500 visits associated with "Blue Cross PPO"
- Filter to 300 future visits (200 are past)
- Add 300 entries to VisitReprocessQueueItem
2. ReprocessAccounts = true:
- Truncate AccountsToReprocess (removes all existing rows)
- Find InsuranceMap with ReprocessFlag = ReprocessAccounts
- Adjust flag to None
- Query 200 accounts with "Blue Cross PPO" as source insurance
- Insert 200 accounts into AccountsToReprocess
Usage Examples
Example 1: Reprocess visits after changing auto-send letter configurations
var task = new ReprocessChangedConfigurationsTask
{
ReprocessVisits = true,
ReprocessAccounts = false
// Only queue visits; accounts are not affected by auto-send changes
};
Example 2: Reprocess accounts after insurance mapping changes
var task = new ReprocessChangedConfigurationsTask
{
ReprocessVisits = false,
ReprocessAccounts = true
// Only queue accounts affected by insurance map changes
};
Example 3: Reprocess both visits and accounts after insurance map updates
var task = new ReprocessChangedConfigurationsTask
{
ReprocessVisits = true,
ReprocessAccounts = true
// Common scenario: InsuranceMap changes affect both visits and accounts
};
Example 4: Part of a larger pipeline
// Step 1: User modifies Bundle configuration in UI
// (System sets NeedsReprocessing = true on the Bundle entity)
// Step 2: Scheduled job runs this task
var queueTask = new ReprocessChangedConfigurationsTask
{
ReprocessVisits = true,
ReprocessAccounts = false
};
// Result: Affected visits are added to VisitReprocessQueueItem
// Step 3: VisitLoader consumes VisitReprocessQueueItem
// (Subsequent scheduled job processes the queue and recalculates visits)
Related Tasks Comparison
| Task | Scope | Trigger | Queue Behavior | Use Case |
|---|---|---|---|---|
| ReprocessChangedConfigurations | Multiple configs → Queue | Configuration changes | Queues items for later processing | Propagate config changes to existing data |
ProcessAccountData |
Single facility/insurance → Direct processing | Manual or scheduled | Immediate processing, no queue | Recalculate specific account estimates |
BatchProcessAccountData |
Multiple facilities/insurances → Direct processing | Manual or scheduled | Immediate processing, no queue | Bulk account recalculation across criteria |
LoadEntitiesFromQuery |
SQL query → Entity loading | SQL-driven | N/A | Load arbitrary entities from custom queries |
Key Differentiators:
- ReprocessChangedConfigurations is configuration-change-driven (automatic flagging when configs change)
- ProcessAccountData tasks are criteria-driven (facility, insurance, date range)
- ReprocessChangedConfigurations uses a two-step process (queue → consume), while Process tasks execute immediately
- Only ReprocessChangedConfigurations automatically tracks which configurations changed
Performance Considerations
Database Impact
- Tables Read:
- Configuration tables:
AutoSendLetterConfig,Bundle,AutoBenefitsRule,InsuranceMap - Data tables:
Visit,Account
- Configuration tables:
- Tables Written:
VisitReprocessQueueItem(inserts; deletes before insert)AccountsToReprocess(truncated, then bulk insert)- Configuration tables (flag updates)
- Query Patterns:
- Config queries: Simple WHERE clauses filtering by flags
- Visit/Account queries: Joins on configuration keys (indexed lookups)
- Visit filter: Date comparison to exclude past visits
- Bulk Operations:
- Uses bulk inserts for queue items
- Truncate operation for AccountsToReprocess (fast)
Optimization Tips
| Scenario | Recommendation | Rationale |
|---|---|---|
| Large visit counts | Run during off-hours | Visit queries can be expensive for widely-used configs |
| Frequent config changes | Batch config changes, run task once | Reduces duplicate visits in queue |
| Mixed visit/account reprocessing | Run separately if possible | Allows different scheduling based on downstream load |
| Old visits in queue | Implement queue cleanup job | Only future visits are queued, but queue can accumulate |