Calculation type
Runs an admin-authored raw SQL query per non-ignored charge and, when the query returns a non-null scalar, adjusts that charge's allowed amount to the returned value; a NULL or empty result silently leaves the charge unchanged (no exception, unlike its account-level sibling).
For each non-ignored charge i=1..N-1: {Codes} = MakeCodesText(charge.Codes) concatenated with the account-row's codes (zeroChargeCodes), {ProviderID} = charge.ProviderID falling back to charge[0].ProviderID, {BillType} from charge[0] (not the individual charge), {Units}/{Charged}/{Allowed} from that charge/detail; execute calc.AmountQuery per-charge (own Stopwatch each iteration); if a row is returned and column 0 is non-null, detail.Adjust(reader.GetDecimal(0), calc); otherwise (no row, or NULL) the charge's amount is left unchanged -- no exception, unlike the account-level sibling.
| Key | Meaning |
|---|---|
| AmountQuery | Raw SQL text (same placeholder set as SqlExpression/AccountLevelSqlAdjustment) returning the charge's new allowed amount in column 0; exposed as the overridden 'Query' property inherited from SqlCalculation. |
Gotchas
(1) {BillType} is taken from charge[0] (the account-level pseudo-charge) for every line, not from the individual charge being priced -- a reimplementer who assumes each charge's own bill type is substituted will get the wrong value whenever a per-charge BillTypeKey could differ from charge[0]'s. (2) {Codes} silently includes charge[0]'s codes appended after the charge's own, same as SqlExpression's charge-level branch. (3) A query returning no rows or a NULL scalar is a completely silent no-op per charge -- there is no logging or exception, unlike AccountLevelSqlAdjustment which throws on an explicit NULL. (4) A fresh Stopwatch/performanceStats entry is created and recorded on every charge iteration (keyed by the same '{FeeLogic.Key}-{calc.Name}' string as the account-level and SqlExpression variants), so its timing entries accumulate once per charge rather than once per calculation run.
class · /home/cary/src/mdc/MdClarity/MDClarity/MDClarityCore/Backend/CustomerDataModel.cs:1108
calculator · /home/cary/src/mdc/MdClarity/MDClarity/MDClarityCore/Backend/CalculationEngine.cs:1701 (private method CalculateChargeLevelSqlAdjustment; no separate Calculators/ class)
dispatch · /home/cary/src/mdc/MdClarity/MDClarity/MDClarityCore/Backend/CalculationEngine.cs:821-823 (case ChargeLevelSqlAdjustment chargeLevelSqlAdjustment: CalculateChargeLevelSqlAdjustment(...);) inside ApplyAdjustment
CONFIRMED