Legacy Pipeline Atlas worker-1snapshot 2026-07-15

MDClarity · task primitive

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:


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):

  1. Identify Changed Configs: Query configs where NeedsReprocessing = true flag is set
  2. Turn Off Flags: Clear the NeedsReprocessing flag on identified configs
  3. Find Affected Visits: Query visits associated with each changed config
  4. Filter by Schedule: Only queue visits with ScheduledTime > CurrentDateTime (future visits only)
  5. Create Queue Items: Add entries to VisitReprocessQueueItem table with visit key and config key
  6. Delete Duplicates: Remove existing queue items for the same config before adding new ones

Account Reprocessing (when ReprocessAccounts = true)

For InsuranceMap configurations only:

  1. Truncate Queue: Clear the entire AccountsToReprocess table
  2. Identify Changed Maps: Query InsuranceMaps where ReprocessFlag indicates account reprocessing needed
  3. Adjust Flags: Update ReprocessFlag (e.g., ReprocessVisitsAndAccountsReprocessVisits, ReprocessAccountsNone)
  4. Find Affected Accounts: Query accounts using the source insurance IDs from changed maps
  5. Populate Queue: Insert affected accounts into AccountsToReprocess table

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:


Performance Considerations

Database Impact

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