Case Study 2: MedClaim Claims Sort for Batch Adjudication
Background
MedClaim Health Services processes approximately 500,000 insurance claims per month. Claims arrive from multiple sources: electronic data interchange (EDI) feeds from hospitals, physician office submissions, pharmacy claims, and manual paper claims that have been keyed into the system.
Before claims can be adjudicated (evaluated for payment), they must be sorted into provider order. The adjudication engine processes all claims for a single provider together, loading the provider's contract terms once and applying them to all that provider's claims. This "provider batch" approach is dramatically more efficient than processing claims in random order.
The Problem
James Okafor's team has identified two issues with the current claims sort:
-
Duplicate claims: When a provider's EDI system times out, it often resubmits the same claim. These duplicates must be detected and removed before adjudication, or the provider will be paid twice.
-
Invalid provider numbers: Occasionally, claims arrive with provider numbers that do not match any provider in MedClaim's network. These must be routed to a manual review queue rather than processed through automated adjudication.
Sarah Kim adds a business requirement: "We need the sorted output grouped by provider, and within each provider, claims should be in date order. But we also need a separate count of claims per provider for our operations dashboard."
Requirements
- Validate provider numbers (must match pattern 'PRVnnnnnnn')
- Sort valid claims by provider number (ascending), then claim date (ascending)
- Detect duplicate claim IDs in the OUTPUT PROCEDURE (duplicates will be adjacent after sorting by claim ID within the INPUT PROCEDURE's pre-check, but the main sort is by provider)
- Route invalid provider claims to a manual review file
- Route duplicate claims to a duplicates file
- Produce the sorted, deduplicated output for the adjudication engine
- Generate per-provider claim counts for the operations dashboard
Design Approach
James designs a two-pass approach:
Pass 1: Sort by claim ID to detect duplicates Pass 2: Sort deduplicated claims by provider + date for adjudication
However, after discussing with Tomás Rivera, they realize a single-pass approach is possible: sort by provider and date (the required output order), then use the OUTPUT PROCEDURE to detect duplicates by checking claim ID (which requires maintaining a small lookup structure or accepting that duplicates might not be adjacent).
The team settles on a practical compromise: sort by provider + date, and in the OUTPUT PROCEDURE, track the last N claim IDs seen (since duplicates usually arrive close together in time). For guaranteed deduplication, a separate pre-sort on claim ID could be added.
Key Code: Provider Validation
1200-VALIDATE-PROVIDER.
IF WW-PROVIDER-NUM(1:3) NOT = 'PRV'
MOVE 'INVALID PREFIX' TO WE-REASON
PERFORM 1500-WRITE-REVIEW
ELSE IF WW-PROVIDER-NUM(4:7) NOT NUMERIC
MOVE 'NON-NUMERIC SUFFIX' TO WE-REASON
PERFORM 1500-WRITE-REVIEW
ELSE
RELEASE SORT-CLAIM FROM WS-CLAIM-WORK
ADD 1 TO WS-RELEASED-CNT
END-IF.
Key Code: Dashboard Statistics in OUTPUT PROCEDURE
2000-WRITE-ADJUDICATION.
OPEN OUTPUT ADJ-SORTED
OPEN OUTPUT DASHBOARD-RPT
OPEN OUTPUT DUP-FILE
RETURN SORT-WORK INTO WS-CLAIM-WORK
AT END
SET EOF-SORT TO TRUE
NOT AT END
MOVE WW-PROVIDER-NUM TO WS-PREV-PROVIDER
MOVE 1 TO WS-PROV-CLAIM-CNT
WRITE ADJ-SORTED-REC FROM WS-CLAIM-WORK
ADD 1 TO WS-WRITTEN-CNT
END-RETURN
PERFORM 2100-PROCESS-SORTED
UNTIL EOF-SORT
PERFORM 2200-WRITE-PROV-STATS
CLOSE ADJ-SORTED DASHBOARD-RPT DUP-FILE.
2100-PROCESS-SORTED.
RETURN SORT-WORK INTO WS-CLAIM-WORK
AT END
SET EOF-SORT TO TRUE
NOT AT END
IF WW-PROVIDER-NUM NOT = WS-PREV-PROVIDER
PERFORM 2200-WRITE-PROV-STATS
MOVE WW-PROVIDER-NUM TO WS-PREV-PROVIDER
MOVE ZERO TO WS-PROV-CLAIM-CNT
END-IF
ADD 1 TO WS-PROV-CLAIM-CNT
WRITE ADJ-SORTED-REC FROM WS-CLAIM-WORK
ADD 1 TO WS-WRITTEN-CNT
END-RETURN.
2200-WRITE-PROV-STATS.
INITIALIZE DASHBOARD-REC
STRING WS-PREV-PROVIDER ' CLAIMS: '
WS-PROV-CLAIM-CNT
DELIMITED BY SIZE
INTO DASHBOARD-REC
WRITE DASHBOARD-REC.
Results and Impact
After deploying MCSORT01:
- Duplicate detection: Average of 342 duplicate claims caught per monthly run, saving approximately $1.2 million in potential double payments annually
- Invalid providers: Average of 89 claims per run routed to manual review instead of failing in the adjudication engine
- Performance: The sort processes 500,000 claims in approximately 45 seconds — well within the batch window
- Dashboard: Operations now has real-time visibility into claim volumes by provider, enabling better workload planning
Discussion Questions
- Why does sorting by provider + date make the adjudication engine more efficient than processing claims in arrival order?
- What are the trade-offs of the "last N claim IDs" duplicate detection approach versus a guaranteed full deduplication pass?
- How would you modify this program if MedClaim needed to process claims from multiple states with different provider numbering formats?
- What would happen if a provider submitted 50,000 claims in a single batch? How would this affect the sort and downstream processing?
- Sarah Kim wants to add a threshold: if any single provider has more than 5,000 claims in a day, flag it for fraud review. Where in the program would you add this check?