Calculation type

AccountLevelSqlAdjustment

Runs an admin-authored raw SQL query once for the whole account using summed account totals, overwrites the account-level allowed amount with the query's scalar result, and zeroes every non-ignored charge-level detail; throws if the returned scalar is NULL but is a silent no-op if the query returns no rows.

0
uses
0
customers
Adjustment
category
Account
applies at

Unused

This type appears in no customer's configuration in the snapshot.

What it computes

charged/allowed start from charge[0] and are summed with every non-ignored charge i=1..N-1's AmountCharged/detail.Amount; Units/ProviderID/BillType/Codes come from charge[0] only. sql = calc.AmountQuery with placeholders substituted (note: {ServiceDate} uses MakeDateTimeLiteral here vs MakeDateLiteral in the Charge-level sibling). Execute once; if a row is returned and column 0 is NULL, throw 'Amount was null'; otherwise Details[0].Adjust(reader.GetDecimal(0), calc), then for every non-ignored charge i>=1, detail.Adjust(0.0M, calc). If the query returns zero rows, neither the throw, the account Adjust, nor the per-charge zeroing happens -- the adjustment is a completely silent no-op.

Parameters

KeyMeaning
AmountQueryRaw SQL text (same placeholder set as SqlExpression) returning the new total account allowed amount in column 0; exposed as the overridden 'Query' property inherited from SqlCalculation.

Gotchas

(1) A query returning zero rows produces total silence: no exception, no Adjust call at all, not even the per-charge zeroing -- easy to mistake for 'ran but changed nothing' when in fact the account-level Amount is left at whatever the base/prior adjustments computed. (2) Uses MakeDateTimeLiteral for {ServiceDate} while the near-identical SqlExpression and ChargeLevelSqlAdjustment methods use MakeDateLiteral -- a subtle formatting divergence between three otherwise-parallel SQL-adjustment code paths. (3) Timed with one Stopwatch spanning the whole method (single performanceStats entry per invocation), unlike ChargeLevelSqlAdjustment which times each charge's query separately.

In the source

class · /home/cary/src/mdc/MdClarity/MDClarity/MDClarityCore/Backend/CustomerDataModel.cs:1086
calculator · /home/cary/src/mdc/MdClarity/MDClarity/MDClarityCore/Backend/CalculationEngine.cs:1639 (private method CalculateAccountLevelSqlAdjustment; no separate Calculators/ class)
dispatch · /home/cary/src/mdc/MdClarity/MDClarity/MDClarityCore/Backend/CalculationEngine.cs:818-820 (case AccountLevelSqlAdjustment accountLevelSqlAdjustment: CalculateAccountLevelSqlAdjustment(...);) inside ApplyAdjustment

CONFIRMED