ProcessScenarioModel
Overview
ProcessScenarioModelTask processes scenario models that are in Queued status, calculating account estimates for all facility and insurance combinations defined in each model. It uses scenario-specific pricing logic (ScenarioFeeLogic) to generate what-if analysis results for contract modeling and pricing analysis.
Use this task when: You need to execute scenario model calculations after users have configured scenario models and marked them ready for processing (Queued status).
Don't use this task when: Processing regular account data (use BatchProcessAccountDataTask instead), processing individual accounts (use targeted account processing), or when scenario models haven't been properly configured yet.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| None | - | - | - | This task has no configurable parameters. It automatically processes all scenario models in Queued status. |
Execution Flow
Processing Algorithm
The ProcessScenarioModel task performs scenario-based account estimation with the following workflow:
Scenario Processing Loop
For each scenario model, the task:
- Clears Previous Results: Deletes all existing scenario estimate data for the model key
- Creates Scenario Engine: Instantiates a calculation engine using the model's
ScenarioFeeLogicKey - Iterates Combinations: Processes all facility × insurance combinations defined in the model
- Filters Accounts: Selects accounts matching:
- Facility from model's
Facilitieslist - Insurance from model's
Insuranceslist - Bill type matching model's
BillType(if specified) - Service dates within model's
StartDatetoEndDaterange (if specified)
- Facility from model's
- Calculates Estimates: Runs pricing calculation using scenario-specific fee logic
- Tags Results: Associates all estimates with the
ScenarioModelKeyfor scenario isolation - Bulk Saves: Inserts estimates in batches of 100,000 rows
Scenario Data Isolation
All scenario results are stored separately from production estimates:
AccountEstimateScenarioModeltable (instead ofAccountEstimate)AccountEstimateChargeScenarioModeltable (instead ofAccountEstimateCharge)AccountEstimateCalculationScenarioModeltable (instead ofAccountEstimateCalculation)
This ensures scenario analysis doesn't interfere with production data.
Example Execution
Given a scenario model configured to analyze Medicare vs Commercial pricing:
ScenarioModel SM-001
Name: "Medicare vs Commercial Comparison"
Status: Queued
ScenarioFeeLogicKey: "SFL-MEDICARE-TEST"
Facilities: ["FAC-001", "FAC-002"]
Insurances: ["INS-MEDICARE", "INS-AETNA"]
BillType: "Inpatient"
StartDate: 2025-01-01
EndDate: 2025-12-31
Step 1: Mark model as Running
SM-001.Status = Running
Step 2: Clear existing scenario data
DELETE FROM AccountEstimateScenarioModel WHERE ScenarioModelKey = 'SM-001'
DELETE FROM AccountEstimateChargeScenarioModel WHERE ScenarioModelKey = 'SM-001'
DELETE FROM AccountEstimateCalculationScenarioModel WHERE ScenarioModelKey = 'SM-001'
Step 3: Process facility × insurance combinations (4 total)
Combination 1: FAC-001 × INS-MEDICARE
- Get accounts: FacilityKey='FAC-001', InsuranceKey='INS-MEDICARE', BillType='Inpatient', ServiceDate BETWEEN 2025-01-01 AND 2025-12-31
- Found 250 accounts
- Calculate estimates using SFL-MEDICARE-TEST fee logic
- Tag all results with ScenarioModelKey = 'SM-001'
- Bulk insert 250 estimates
Combination 2: FAC-001 × INS-AETNA
- Get accounts: FacilityKey='FAC-001', InsuranceKey='INS-AETNA', BillType='Inpatient', ServiceDate BETWEEN 2025-01-01 AND 2025-12-31
- Found 180 accounts
- Calculate estimates using SFL-MEDICARE-TEST fee logic
- Tag all results with ScenarioModelKey = 'SM-001'
- Bulk insert 180 estimates
Combination 3: FAC-002 × INS-MEDICARE
- Found 300 accounts
- Process and bulk insert
Combination 4: FAC-002 × INS-AETNA
- Found 220 accounts
- Process and bulk insert
Step 4: Mark model as Complete
SM-001.Status = Complete
Total: 950 accounts processed across 4 facility/insurance combinations
Usage Examples
Example 1: Basic task execution (processes all queued models)
var task = new ProcessScenarioModelTask();
// Automatically processes all scenario models with Status = Queued
Example 2: Scheduled job for nightly scenario processing
// Run scenario processing overnight when system load is lower
var job = new Job
{
Key = "JOB-PROCESS-SCENARIOS",
DisplayName = "Process Queued Scenario Models",
Tasks = new List<Task>
{
new ProcessScenarioModelTask()
},
Schedule = "0 2 * * *" // Run at 2 AM daily
};
Example 3: Chaining with scenario model creation
// Pattern: Create scenario models via API, then process in batch
// User creates scenario models through UI, sets Status = Queued
// Job picks them up and processes
var job = new Job
{
DisplayName = "Scenario Processing Pipeline",
Tasks = new List<Task>
{
new ProcessScenarioModelTask()
}
};
// This task will process:
// - All scenario models where Status = Queued
// - Changes status to Running → Complete
// - Results isolated in scenario-specific tables
Related Tasks Comparison
| Task | Scope | Pricing Logic | Data Isolation | Use Case |
|---|---|---|---|---|
| ProcessScenarioModel | Scenario models (Status=Queued) | ScenarioFeeLogic | Separate scenario tables | What-if pricing analysis and contract modeling |
BatchProcessAccountData |
Facilities × Insurances × Bill Types | Production FeeLogic | Production tables | Regular account estimate recalculation |
ChargeAnalysis |
All combinations (charges × facilities × insurances × providers) | Production FeeLogic | Analysis tables | Comprehensive pricing matrix generation |
Key Differentiators:
- ProcessScenarioModel uses scenario-specific fee logic (
ScenarioFeeLogic) and stores results in isolated scenario tables - BatchProcessAccountData uses production fee logic and updates production account estimates
- ChargeAnalysis generates pricing analysis at the charge level (not account level)
- ProcessScenarioModel is driven by scenario model configuration (user-defined combinations)
- BatchProcessAccountData is driven by task parameters (facility choices, insurance sets)
Performance Considerations
Database Impact
- Bulk Copy Operations: Uses bulk copy with 100,000 row batch size for high-volume inserts
- Tables Written:
AccountEstimateScenarioModel- Account-level estimatesAccountEstimateChargeScenarioModel- Charge-level estimatesAccountEstimateCalculationScenarioModel- Calculation detailsScenarioModel- Status updates (Running → Complete)
- Data Clearing: Each scenario model's data is cleared before reprocessing (DELETE operations)
- No Transactions: Each facility/insurance combination is processed independently without transactions
Optimization Tips
| Scenario | Recommendation | Rationale |
|---|---|---|
| Large account volumes | Limit date ranges in scenario model configuration | Reduces accounts per facility/insurance combination |
| Multiple scenarios | Process during off-peak hours | Avoid competing with production estimate calculations |
| Repeated scenario runs | Archive or delete old scenario data periodically | Prevents scenario tables from growing unbounded |
| Slow scenario processing | Review ScenarioFeeLogic complexity | Complex fee logic increases calculation time per account |