@actuarial-ts/core 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -226
- package/dist/casualtyDiagnostics.d.ts +19 -49
- package/dist/casualtyDiagnostics.d.ts.map +1 -1
- package/dist/casualtyDiagnostics.js +84 -116
- package/dist/casualtyDiagnostics.js.map +1 -1
- package/dist/diagnosticAggregation.d.ts +29 -0
- package/dist/diagnosticAggregation.d.ts.map +1 -0
- package/dist/diagnosticAggregation.js +50 -0
- package/dist/diagnosticAggregation.js.map +1 -0
- package/dist/diagnosticDefinitions.d.ts +286 -0
- package/dist/diagnosticDefinitions.d.ts.map +1 -0
- package/dist/diagnosticDefinitions.js +1026 -0
- package/dist/diagnosticDefinitions.js.map +1 -0
- package/dist/diagnosticDerivations.d.ts +12 -0
- package/dist/diagnosticDerivations.d.ts.map +1 -0
- package/dist/diagnosticDerivations.js +80 -0
- package/dist/diagnosticDerivations.js.map +1 -0
- package/dist/diagnosticExposure.d.ts +51 -0
- package/dist/diagnosticExposure.d.ts.map +1 -0
- package/dist/diagnosticExposure.js +65 -0
- package/dist/diagnosticExposure.js.map +1 -0
- package/dist/diagnosticExpressions.d.ts +56 -0
- package/dist/diagnosticExpressions.d.ts.map +1 -0
- package/dist/diagnosticExpressions.js +104 -0
- package/dist/diagnosticExpressions.js.map +1 -0
- package/dist/diagnosticFormulas.d.ts +195 -0
- package/dist/diagnosticFormulas.d.ts.map +1 -0
- package/dist/diagnosticFormulas.js +85 -0
- package/dist/diagnosticFormulas.js.map +1 -0
- package/dist/diagnosticIdentity.d.ts +237 -0
- package/dist/diagnosticIdentity.d.ts.map +1 -0
- package/dist/diagnosticIdentity.js +454 -0
- package/dist/diagnosticIdentity.js.map +1 -0
- package/dist/diagnosticPeriods.d.ts +16 -0
- package/dist/diagnosticPeriods.d.ts.map +1 -0
- package/dist/diagnosticPeriods.js +98 -0
- package/dist/diagnosticPeriods.js.map +1 -0
- package/dist/diagnosticPreparation.d.ts +98 -0
- package/dist/diagnosticPreparation.d.ts.map +1 -0
- package/dist/diagnosticPreparation.js +169 -0
- package/dist/diagnosticPreparation.js.map +1 -0
- package/dist/diagnosticReview.d.ts +44 -0
- package/dist/diagnosticReview.d.ts.map +1 -0
- package/dist/diagnosticReview.js +84 -0
- package/dist/diagnosticReview.js.map +1 -0
- package/dist/diagnosticRules.d.ts +32 -0
- package/dist/diagnosticRules.d.ts.map +1 -0
- package/dist/diagnosticRules.js +32 -0
- package/dist/diagnosticRules.js.map +1 -0
- package/dist/diagnosticRunner.d.ts +85 -0
- package/dist/diagnosticRunner.d.ts.map +1 -0
- package/dist/diagnosticRunner.js +117 -0
- package/dist/diagnosticRunner.js.map +1 -0
- package/dist/index.d.ts +24 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +17 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +114 -0
- package/dist/types.js.map +1 -1
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +3 -0
- package/dist/version.js.map +1 -0
- package/package.json +2 -2
- package/src/casualtyDiagnostics.ts +79 -189
- package/src/diagnosticAggregation.ts +79 -0
- package/src/diagnosticDefinitions.ts +1375 -0
- package/src/diagnosticDerivations.ts +89 -0
- package/src/diagnosticExposure.ts +91 -0
- package/src/diagnosticExpressions.ts +173 -0
- package/src/diagnosticFormulas.ts +150 -0
- package/src/diagnosticIdentity.ts +767 -0
- package/src/diagnosticPeriods.ts +117 -0
- package/src/diagnosticPreparation.ts +233 -0
- package/src/diagnosticReview.ts +91 -0
- package/src/diagnosticRules.ts +69 -0
- package/src/diagnosticRunner.ts +110 -0
- package/src/index.ts +156 -1
- package/src/types.ts +161 -0
- package/src/version.ts +2 -0
- package/dist/metricDiagnostics.d.ts +0 -212
- package/dist/metricDiagnostics.d.ts.map +0 -1
- package/dist/metricDiagnostics.js +0 -627
- package/dist/metricDiagnostics.js.map +0 -1
- package/src/metricDiagnostics.ts +0 -876
|
@@ -1,124 +1,92 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { CASUALTY_FORMULA_TEMPLATES } from "./diagnosticFormulas.js";
|
|
2
|
+
import { DiagnosticValidationError } from "./types.js";
|
|
3
|
+
export { CASUALTY_FORMULA_TEMPLATES };
|
|
4
|
+
const m = (measureId) => ({ op: "measure", measureId });
|
|
4
5
|
const sub = (left, right) => ({ op: "subtract", left, right });
|
|
5
|
-
function
|
|
6
|
-
if (value ===
|
|
7
|
-
return
|
|
8
|
-
|
|
6
|
+
function validToken(value) {
|
|
7
|
+
if (value.length === 0 || /^[\t-\r ]|[\t-\r ]$/.test(value) || value.includes("\0"))
|
|
8
|
+
return false;
|
|
9
|
+
for (let index = 0; index < value.length; index++) {
|
|
10
|
+
const code = value.charCodeAt(index);
|
|
11
|
+
if (code >= 0xd800 && code <= 0xdbff) {
|
|
12
|
+
const next = value.charCodeAt(++index);
|
|
13
|
+
if (!(next >= 0xdc00 && next <= 0xdfff))
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
else if (code >= 0xdc00 && code <= 0xdfff)
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
return true;
|
|
9
20
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
closedNoPay: "closedNoPayCount",
|
|
14
|
-
closedWithPay: "closedWithPayCount",
|
|
15
|
-
exposure: "exposure",
|
|
16
|
-
paid250: "paid250",
|
|
17
|
-
incurred250: "incurred250",
|
|
18
|
-
paidPrimary: "paidPrimary",
|
|
19
|
-
incurredPrimary: "incurredPrimary",
|
|
20
|
-
};
|
|
21
|
-
function metric(id, displayName, description, unit, scale, numerator, denominator, numeratorLabel, denominatorLabel, basis, version, override, warningRules) {
|
|
22
|
-
const definition = {
|
|
23
|
-
id,
|
|
24
|
-
version,
|
|
25
|
-
displayName,
|
|
26
|
-
description,
|
|
27
|
-
unit,
|
|
28
|
-
scale,
|
|
29
|
-
numerator,
|
|
30
|
-
denominator,
|
|
31
|
-
numeratorLabel,
|
|
32
|
-
denominatorLabel,
|
|
33
|
-
basis,
|
|
34
|
-
requiredComponents: [...new Set([
|
|
35
|
-
...measureExpressionComponents(numerator),
|
|
36
|
-
...measureExpressionComponents(denominator),
|
|
37
|
-
])],
|
|
38
|
-
warningRules,
|
|
39
|
-
};
|
|
40
|
-
return { ...definition, ...definedProperties(override) };
|
|
21
|
+
function encodeBindingId(value) { return encodeURIComponent(value).replace(/[!'()*]/g, (character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`); }
|
|
22
|
+
function presentation(displayName, description, displayUnit, numeratorLabel, denominatorLabel) {
|
|
23
|
+
return { displayName, description, displayUnit, scale: 1, numeratorLabel, denominatorLabel };
|
|
41
24
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
};
|
|
54
|
-
const frequencyScale = options.frequencyScale ?? 1_000_000;
|
|
55
|
-
if (!Number.isFinite(frequencyScale) || frequencyScale <= 0) {
|
|
56
|
-
throw new ReservingError("BAD_RATIO", `Casualty frequency scale must be positive; got ${frequencyScale}`);
|
|
57
|
-
}
|
|
58
|
-
const version = options.definitionVersion ?? "casualty-quarterly-v1";
|
|
59
|
-
const frequencyUnit = options.frequencyUnit ?? (frequencyScale === 1_000_000
|
|
60
|
-
? "count-per-million"
|
|
61
|
-
: "count-per-exposure-scale");
|
|
62
|
-
const limitedBasis = options.basisLabels?.limited250 ?? "$250K pre-capped total";
|
|
63
|
-
const primaryBasis = options.basisLabels?.primary ?? "$1M capped indemnity plus unlimited expense";
|
|
64
|
-
const countBasis = options.basisLabels?.counts ?? "count";
|
|
65
|
-
const override = (id) => options.displayOverrides?.[id];
|
|
66
|
-
const nonClosedNoPay = sub(m(C.reported), m(C.closedNoPay));
|
|
67
|
-
return [
|
|
68
|
-
metric("reported-frequency", "Reported claim frequency", "Reported claims per scaled exposure units", frequencyUnit, frequencyScale, m(C.reported), m(C.exposure), "reported claims", "exposure", countBasis, version, override("reported-frequency")),
|
|
69
|
-
metric("open-frequency", "Open claim frequency", "Open claims per scaled exposure units", frequencyUnit, frequencyScale, m(C.open), m(C.exposure), "open claims", "exposure", countBasis, version, override("open-frequency")),
|
|
70
|
-
metric("closed-no-pay-frequency", "Closed-no-pay frequency", "Closed-no-pay claims per scaled exposure units", frequencyUnit, frequencyScale, m(C.closedNoPay), m(C.exposure), "closed-no-pay claims", "exposure", countBasis, version, override("closed-no-pay-frequency")),
|
|
71
|
-
metric("closed-with-pay-frequency", "Closed-with-pay frequency", "Closed-with-pay claims per scaled exposure units", frequencyUnit, frequencyScale, m(C.closedWithPay), m(C.exposure), "closed-with-pay claims", "exposure", countBasis, version, override("closed-with-pay-frequency")),
|
|
72
|
-
metric("non-closed-no-pay-frequency", "Non-closed-no-pay frequency", "Reported less closed-no-pay claims per scaled exposure units", frequencyUnit, frequencyScale, nonClosedNoPay, m(C.exposure), "reported less closed-no-pay claims", "exposure", countBasis, version, override("non-closed-no-pay-frequency")),
|
|
73
|
-
metric("closed-no-pay-share", "Closed-no-pay share", "Closed-no-pay claims divided by reported claims", "ratio", 1, m(C.closedNoPay), m(C.reported), "closed-no-pay claims", "reported claims", countBasis, version, override("closed-no-pay-share")),
|
|
74
|
-
metric("closed-with-pay-share", "Closed-with-pay share", "Closed-with-pay claims divided by reported claims", "ratio", 1, m(C.closedWithPay), m(C.reported), "closed-with-pay claims", "reported claims", countBasis, version, override("closed-with-pay-share")),
|
|
75
|
-
metric("closed-with-pay-share-of-non-cnp", "Closed-with-pay share of non-CNP claims", "Closed-with-pay claims divided by reported less closed-no-pay claims", "ratio", 1, m(C.closedWithPay), nonClosedNoPay, "closed-with-pay claims", "reported less closed-no-pay claims", countBasis, version, override("closed-with-pay-share-of-non-cnp")),
|
|
76
|
-
metric("open-share", "Open share", "Open claims divided by reported claims", "ratio", 1, m(C.open), m(C.reported), "open claims", "reported claims", countBasis, version, override("open-share")),
|
|
77
|
-
metric("open-share-of-non-cnp", "Open share of non-CNP claims", "Open claims divided by reported less closed-no-pay claims", "ratio", 1, m(C.open), nonClosedNoPay, "open claims", "reported less closed-no-pay claims", countBasis, version, override("open-share-of-non-cnp")),
|
|
78
|
-
metric("paid-to-incurred-250", "Paid-to-incurred ($250K)", "Paid divided by incurred on the pre-capped $250K basis", "ratio", 1, m(C.paid250), m(C.incurred250), "$250K paid", "$250K incurred", limitedBasis, version, override("paid-to-incurred-250"), paidWarning),
|
|
79
|
-
metric("paid-to-incurred-primary", "Paid-to-incurred (primary)", "Paid divided by incurred on the primary basis", "ratio", 1, m(C.paidPrimary), m(C.incurredPrimary), "primary paid", "primary incurred", primaryBasis, version, override("paid-to-incurred-primary"), paidWarning),
|
|
80
|
-
metric("incurred-250-per-exposure", "Incurred per exposure ($250K)", "$250K incurred divided by exposure", "currency-per-exposure", 1, m(C.incurred250), m(C.exposure), "$250K incurred", "exposure", limitedBasis, version, override("incurred-250-per-exposure")),
|
|
81
|
-
metric("incurred-primary-per-exposure", "Incurred per exposure (primary)", "Primary incurred divided by exposure", "currency-per-exposure", 1, m(C.incurredPrimary), m(C.exposure), "primary incurred", "exposure", primaryBasis, version, override("incurred-primary-per-exposure")),
|
|
82
|
-
metric("incurred-250-per-non-cnp", "Incurred severity ($250K)", "$250K incurred divided by reported less closed-no-pay claims", "currency-per-claim", 1, m(C.incurred250), nonClosedNoPay, "$250K incurred", "reported less closed-no-pay claims", limitedBasis, version, override("incurred-250-per-non-cnp")),
|
|
83
|
-
metric("incurred-primary-per-non-cnp", "Incurred severity (primary)", "Primary incurred divided by reported less closed-no-pay claims", "currency-per-claim", 1, m(C.incurredPrimary), nonClosedNoPay, "primary incurred", "reported less closed-no-pay claims", primaryBasis, version, override("incurred-primary-per-non-cnp")),
|
|
84
|
-
metric("paid-250-per-exposure", "Paid per exposure ($250K)", "$250K paid divided by exposure", "currency-per-exposure", 1, m(C.paid250), m(C.exposure), "$250K paid", "exposure", limitedBasis, version, override("paid-250-per-exposure")),
|
|
85
|
-
metric("paid-primary-per-exposure", "Paid per exposure (primary)", "Primary paid divided by exposure", "currency-per-exposure", 1, m(C.paidPrimary), m(C.exposure), "primary paid", "exposure", primaryBasis, version, override("paid-primary-per-exposure")),
|
|
86
|
-
metric("paid-250-per-closed-with-pay", "Paid severity ($250K)", "$250K paid divided by closed-with-pay claims", "currency-per-claim", 1, m(C.paid250), m(C.closedWithPay), "$250K paid", "closed-with-pay claims", limitedBasis, version, override("paid-250-per-closed-with-pay")),
|
|
87
|
-
metric("paid-primary-per-closed-with-pay", "Paid severity (primary)", "Primary paid divided by closed-with-pay claims", "currency-per-claim", 1, m(C.paidPrimary), m(C.closedWithPay), "primary paid", "closed-with-pay claims", primaryBasis, version, override("paid-primary-per-closed-with-pay")),
|
|
88
|
-
metric("case-250-per-open", "Case reserve per open claim ($250K)", "$250K incurred less paid divided by open claims", "currency-per-claim", 1, sub(m(C.incurred250), m(C.paid250)), m(C.open), "$250K incurred less paid", "open claims", limitedBasis, version, override("case-250-per-open")),
|
|
89
|
-
metric("case-primary-per-open", "Case reserve per open claim (primary)", "Primary incurred less paid divided by open claims", "currency-per-claim", 1, sub(m(C.incurredPrimary), m(C.paidPrimary)), m(C.open), "primary incurred less paid", "open claims", primaryBasis, version, override("case-primary-per-open")),
|
|
90
|
-
];
|
|
25
|
+
function overridePresentation(id, base, overrides) {
|
|
26
|
+
const override = overrides?.[id];
|
|
27
|
+
if (!override)
|
|
28
|
+
return base;
|
|
29
|
+
for (const [key, value] of Object.entries(override))
|
|
30
|
+
if (value === undefined)
|
|
31
|
+
throw new DiagnosticValidationError([{ domain: "configuration", code: "invalid-type", path: `$.presentationOverrides[${JSON.stringify(id)}].${key}`, message: "Presentation override cannot contain undefined" }]);
|
|
32
|
+
const result = { ...base, ...override };
|
|
33
|
+
if (!Number.isFinite(result.scale) || result.scale <= 0)
|
|
34
|
+
throw new DiagnosticValidationError([{ domain: "configuration", code: "invalid-number", path: `$.presentationOverrides[${JSON.stringify(id)}].scale`, message: "Presentation scale must be finite and positive" }]);
|
|
35
|
+
return result;
|
|
91
36
|
}
|
|
92
|
-
export
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
37
|
+
export function createCasualtyMetricInstances(input) {
|
|
38
|
+
for (const [key, value] of Object.entries({ ...input.counts, exposure: input.exposure }))
|
|
39
|
+
if (!validToken(value))
|
|
40
|
+
throw new DiagnosticValidationError([{ domain: "configuration", code: "invalid-string", path: `$.${key}`, message: "Measure binding must be a token" }]);
|
|
41
|
+
const ids = new Set();
|
|
42
|
+
for (const [index, binding] of input.amountBindings.entries()) {
|
|
43
|
+
if (!validToken(binding.id) || !validToken(binding.paid) || !validToken(binding.incurred))
|
|
44
|
+
throw new DiagnosticValidationError([{ domain: "configuration", code: "invalid-string", path: `$.amountBindings[${index}]`, message: "Amount binding fields must be tokens" }]);
|
|
45
|
+
if (ids.has(binding.id))
|
|
46
|
+
throw new DiagnosticValidationError([{ domain: "configuration", code: "duplicate-id", path: `$.amountBindings[${index}].id`, message: `Duplicate amount binding ${binding.id}` }]);
|
|
47
|
+
ids.add(binding.id);
|
|
101
48
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
displayName: options.primary?.displayName ?? "Primary: $1M capped indemnity plus unlimited expense",
|
|
115
|
-
paidMeasure: C.paidPrimary,
|
|
116
|
-
incurredMeasure: C.incurredPrimary,
|
|
117
|
-
paid: { op: "add", terms: [{ op: "claim-cap", measure: options.primary?.indemnityPaidMeasure ?? "indemnityPaid", limit }, { op: "measure", measure: options.primary?.expensePaidMeasure ?? "expensePaid" }] },
|
|
118
|
-
incurred: { op: "add", terms: [{ op: "claim-cap", measure: options.primary?.indemnityIncurredMeasure ?? "indemnityIncurred", limit }, { op: "measure", measure: options.primary?.expenseIncurredMeasure ?? "expenseIncurred" }] },
|
|
119
|
-
basis: "claim-level-cap",
|
|
120
|
-
},
|
|
49
|
+
const nonClosedNoPay = sub(m(input.counts.reported), m(input.counts.closedNoPay));
|
|
50
|
+
const countSpecs = [
|
|
51
|
+
["reported-frequency", "frequency", m(input.counts.reported), m(input.exposure), presentation("Reported frequency", "Reported count divided by exposure", "count per exposure", "reported", "exposure")],
|
|
52
|
+
["open-frequency", "frequency", m(input.counts.open), m(input.exposure), presentation("Open frequency", "Open count divided by exposure", "count per exposure", "open", "exposure")],
|
|
53
|
+
["closed-no-pay-frequency", "frequency", m(input.counts.closedNoPay), m(input.exposure), presentation("Closed-no-pay frequency", "Closed-no-pay count divided by exposure", "count per exposure", "closed-no-pay", "exposure")],
|
|
54
|
+
["closed-with-pay-frequency", "frequency", m(input.counts.closedWithPay), m(input.exposure), presentation("Closed-with-pay frequency", "Closed-with-pay count divided by exposure", "count per exposure", "closed-with-pay", "exposure")],
|
|
55
|
+
["non-closed-no-pay-frequency", "frequency", nonClosedNoPay, m(input.exposure), presentation("Non-closed-no-pay frequency", "Reported less closed-no-pay count divided by exposure", "count per exposure", "reported less closed-no-pay", "exposure")],
|
|
56
|
+
["closed-no-pay-share", "share", m(input.counts.closedNoPay), m(input.counts.reported), presentation("Closed-no-pay share", "Closed-no-pay count divided by reported count", "ratio", "closed-no-pay", "reported")],
|
|
57
|
+
["closed-with-pay-share", "share", m(input.counts.closedWithPay), m(input.counts.reported), presentation("Closed-with-pay share", "Closed-with-pay count divided by reported count", "ratio", "closed-with-pay", "reported")],
|
|
58
|
+
["closed-with-pay-share-of-non-closed-no-pay", "share", m(input.counts.closedWithPay), nonClosedNoPay, presentation("Closed-with-pay share of non-closed-no-pay", "Closed-with-pay count divided by reported less closed-no-pay count", "ratio", "closed-with-pay", "reported less closed-no-pay")],
|
|
59
|
+
["open-share", "share", m(input.counts.open), m(input.counts.reported), presentation("Open share", "Open count divided by reported count", "ratio", "open", "reported")],
|
|
60
|
+
["open-share-of-non-closed-no-pay", "share", m(input.counts.open), nonClosedNoPay, presentation("Open share of non-closed-no-pay", "Open count divided by reported less closed-no-pay count", "ratio", "open", "reported less closed-no-pay")],
|
|
121
61
|
];
|
|
62
|
+
const specs = [];
|
|
63
|
+
for (const [suffix, formulaId, numerator, denominator, display] of countSpecs) {
|
|
64
|
+
const id = `casualty/count/${suffix}`;
|
|
65
|
+
const bindings = formulaId === "frequency"
|
|
66
|
+
? { claims: numerator, exposure: denominator }
|
|
67
|
+
: { part: numerator, whole: denominator };
|
|
68
|
+
specs.push({ id, formulaId, bindings, presentation: display, rules: [] });
|
|
69
|
+
}
|
|
70
|
+
for (const binding of input.amountBindings) {
|
|
71
|
+
const prefix = `casualty/amount/${encodeBindingId(binding.id)}`;
|
|
72
|
+
const amountSpecs = [
|
|
73
|
+
["paid-to-incurred", "paid-to-incurred", { paid: m(binding.paid), incurred: m(binding.incurred) }, presentation("Paid to incurred", "Paid divided by incurred on the bound amount basis", "ratio", "paid", "incurred")],
|
|
74
|
+
["incurred-per-exposure", "amount-per-exposure", { amount: m(binding.incurred), exposure: m(input.exposure) }, presentation("Incurred per exposure", "Incurred divided by exposure", "amount per exposure", "incurred", "exposure")],
|
|
75
|
+
["incurred-per-non-closed-no-pay-claim", "amount-per-claim", { amount: m(binding.incurred), claims: nonClosedNoPay }, presentation("Incurred per non-closed-no-pay claim", "Incurred divided by reported less closed-no-pay count", "amount per claim", "incurred", "reported less closed-no-pay")],
|
|
76
|
+
["paid-per-exposure", "amount-per-exposure", { amount: m(binding.paid), exposure: m(input.exposure) }, presentation("Paid per exposure", "Paid divided by exposure", "amount per exposure", "paid", "exposure")],
|
|
77
|
+
["paid-per-closed-with-pay-claim", "amount-per-claim", { amount: m(binding.paid), claims: m(input.counts.closedWithPay) }, presentation("Paid per closed-with-pay claim", "Paid divided by closed-with-pay count", "amount per claim", "paid", "closed-with-pay")],
|
|
78
|
+
["case-per-open-claim", "case-per-open", { incurred: m(binding.incurred), paid: m(binding.paid), open: m(input.counts.open) }, presentation("Case reserve per open claim", "Incurred less paid divided by open count", "amount per claim", "incurred less paid", "open")],
|
|
79
|
+
];
|
|
80
|
+
for (const [suffix, formulaId, bindings, display] of amountSpecs) {
|
|
81
|
+
const id = `${prefix}/${suffix}`;
|
|
82
|
+
const rules = suffix === "paid-to-incurred" ? [{ id: `${id}/rule/paid-exceeds-incurred`, code: "paid-exceeds-incurred", message: "Paid exceeds incurred on the bound amount basis", severity: "warning", when: { left: { source: "calculation", field: "numerator" }, operator: "gt", right: { source: "calculation", field: "denominator" }, tolerance: { absolute: 0, relative: 0 } } }] : suffix === "case-per-open-claim" ? [{ id: `${id}/rule/negative-case`, code: "negative-case", message: "Incurred less paid is negative on the bound amount basis", severity: "warning", when: { left: { source: "calculation", field: "numerator" }, operator: "lt", right: { source: "constant", value: 0 }, tolerance: { absolute: 0, relative: 0 } } }] : [];
|
|
83
|
+
specs.push({ id, formulaId, bindings: { ...bindings }, presentation: display, rules });
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const validIds = new Set(specs.map((spec) => spec.id));
|
|
87
|
+
for (const key of Object.keys(input.presentationOverrides ?? {}))
|
|
88
|
+
if (!validIds.has(key))
|
|
89
|
+
throw new DiagnosticValidationError([{ domain: "configuration", code: "unknown-reference", path: `$.presentationOverrides[${JSON.stringify(key)}]`, message: "Presentation override names an unknown generated instance" }]);
|
|
90
|
+
return Object.freeze(specs.map((spec) => Object.freeze({ id: spec.id, version: "1.0.0", formulaId: spec.formulaId, bindings: spec.bindings, presentation: overridePresentation(spec.id, spec.presentation, input.presentationOverrides), rules: spec.rules })));
|
|
122
91
|
}
|
|
123
|
-
export const CASUALTY_AMOUNT_LAYERS = createCasualtyAmountLayers();
|
|
124
92
|
//# sourceMappingURL=casualtyDiagnostics.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"casualtyDiagnostics.js","sourceRoot":"","sources":["../src/casualtyDiagnostics.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"casualtyDiagnostics.js","sourceRoot":"","sources":["../src/casualtyDiagnostics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAGvD,OAAO,EAAE,0BAA0B,EAAE,CAAC;AAatC,MAAM,CAAC,GAAG,CAAC,SAAiB,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,SAAkB,EAAE,SAAS,EAAE,CAAC,CAAC;AACzE,MAAM,GAAG,GAAG,CAAC,IAA0B,EAAE,KAA2B,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,UAAmB,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;AAEpH,SAAS,UAAU,CAAC,KAAa;IAC/B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,qBAAqB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IAClG,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QAClD,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACrC,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;YAAC,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,EAAE,KAAK,CAAC,CAAC;YAAC,IAAI,CAAC,CAAC,IAAI,IAAI,MAAM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AG,QAAQ,EAAE,EAAE,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QACzF,CAAC;IACH,CAAC;IACD,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IACvD,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,qBAAqB,IAAI,EAAE,CAAC;QAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,MAAM,IAAI,yBAAyB,CAAC,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,2BAA2B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,EAAE,2DAA2D,EAAE,CAAC,CAAC,CAAC;IACvT,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,YAAY,EAAE,oBAAoB,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,YAAY,EAAE,KAAK,CAAC,qBAAqB,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;AAClQ,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { DiagnosticMeasureStats, DiagnosticMissingPolicy, DiagnosticSourceLocation } from "./diagnosticDefinitions.js";
|
|
2
|
+
export interface DiagnosticStructuralBlocker {
|
|
3
|
+
readonly code: string;
|
|
4
|
+
readonly message: string;
|
|
5
|
+
readonly sourceIds: readonly string[];
|
|
6
|
+
readonly sources: readonly DiagnosticSourceLocation[];
|
|
7
|
+
}
|
|
8
|
+
export interface DiagnosticMeasureContributionBase {
|
|
9
|
+
readonly sourceId: string;
|
|
10
|
+
readonly sources: readonly DiagnosticSourceLocation[];
|
|
11
|
+
readonly deduplicated: number;
|
|
12
|
+
}
|
|
13
|
+
export type DiagnosticMeasureContribution = (DiagnosticMeasureContributionBase & {
|
|
14
|
+
readonly status: "observed";
|
|
15
|
+
readonly value: number;
|
|
16
|
+
}) | (DiagnosticMeasureContributionBase & {
|
|
17
|
+
readonly status: "imputed-zero";
|
|
18
|
+
readonly value: 0;
|
|
19
|
+
}) | (DiagnosticMeasureContributionBase & {
|
|
20
|
+
readonly status: "missing";
|
|
21
|
+
readonly value: null;
|
|
22
|
+
}) | (DiagnosticMeasureContributionBase & {
|
|
23
|
+
readonly status: "non-finite";
|
|
24
|
+
readonly value: null;
|
|
25
|
+
readonly nonFiniteKind: "nan" | "positive-infinity" | "negative-infinity";
|
|
26
|
+
});
|
|
27
|
+
export declare function auditedDiagnosticContribution(sourceId: string, value: number | null | undefined, missing: DiagnosticMissingPolicy, sources?: readonly DiagnosticSourceLocation[], deduplicated?: number): DiagnosticMeasureContribution;
|
|
28
|
+
export declare function finalizeDiagnosticContributions(contributions: readonly DiagnosticMeasureContribution[], missingPolicy: DiagnosticMissingPolicy, blockers?: readonly DiagnosticStructuralBlocker[]): DiagnosticMeasureStats;
|
|
29
|
+
//# sourceMappingURL=diagnosticAggregation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnosticAggregation.d.ts","sourceRoot":"","sources":["../src/diagnosticAggregation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAE5H,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,C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QAAQ,GAAE,SAAS,2BAA2B,EAAO,GACpD,sBAAsB,CAoBxB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export function auditedDiagnosticContribution(sourceId, value, missing, sources = [], deduplicated = 0) {
|
|
2
|
+
const base = { sourceId, sources: Object.freeze([...sources]), deduplicated };
|
|
3
|
+
if (value === null || value === undefined)
|
|
4
|
+
return missing === "zero"
|
|
5
|
+
? Object.freeze({ ...base, status: "imputed-zero", value: 0 })
|
|
6
|
+
: Object.freeze({ ...base, status: "missing", value: null });
|
|
7
|
+
if (!Number.isFinite(value))
|
|
8
|
+
return Object.freeze({
|
|
9
|
+
...base,
|
|
10
|
+
status: "non-finite",
|
|
11
|
+
value: null,
|
|
12
|
+
nonFiniteKind: Number.isNaN(value) ? "nan" : value > 0 ? "positive-infinity" : "negative-infinity",
|
|
13
|
+
});
|
|
14
|
+
return Object.freeze({ ...base, status: "observed", value: Object.is(value, -0) ? 0 : value });
|
|
15
|
+
}
|
|
16
|
+
function neumaier(values) {
|
|
17
|
+
let sum = 0;
|
|
18
|
+
let correction = 0;
|
|
19
|
+
for (const value of values) {
|
|
20
|
+
const next = sum + value;
|
|
21
|
+
correction += Math.abs(sum) >= Math.abs(value) ? (sum - next) + value : (value - next) + sum;
|
|
22
|
+
sum = next;
|
|
23
|
+
if (!Number.isFinite(sum) || !Number.isFinite(correction))
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
const result = sum + correction;
|
|
27
|
+
return Number.isFinite(result) ? (Object.is(result, -0) ? 0 : result) : null;
|
|
28
|
+
}
|
|
29
|
+
export function finalizeDiagnosticContributions(contributions, missingPolicy, blockers = []) {
|
|
30
|
+
const ordered = [...contributions].sort((left, right) => left.sourceId < right.sourceId ? -1 : left.sourceId > right.sourceId ? 1 : 0);
|
|
31
|
+
const observed = ordered.filter((item) => item.status === "observed");
|
|
32
|
+
const imputed = ordered.filter((item) => item.status === "imputed-zero");
|
|
33
|
+
const missing = ordered.filter((item) => item.status === "missing").length + imputed.length;
|
|
34
|
+
const nonFinite = ordered.filter((item) => item.status === "non-finite").length;
|
|
35
|
+
const finiteSum = neumaier([...observed.map((item) => item.value), ...imputed.map(() => 0)]);
|
|
36
|
+
const blocked = blockers.length > 0;
|
|
37
|
+
const sum = nonFinite > 0 || blocked || finiteSum === null ? null : finiteSum;
|
|
38
|
+
const value = sum === null || (missingPolicy === "unknown" && missing > 0) ? null : sum;
|
|
39
|
+
return Object.freeze({
|
|
40
|
+
value,
|
|
41
|
+
sum,
|
|
42
|
+
observed: observed.length,
|
|
43
|
+
missing,
|
|
44
|
+
nonFinite,
|
|
45
|
+
imputedZero: imputed.length,
|
|
46
|
+
deduplicated: ordered.reduce((total, item) => total + item.deduplicated, 0),
|
|
47
|
+
structural: blockers.length,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=diagnosticAggregation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnosticAggregation.js","sourceRoot":"","sources":["../src/diagnosticAggregation.ts"],"names":[],"mappings":"AAqBA,MAAM,UAAU,6BAA6B,CAC3C,QAAgB,EAChB,KAAgC,EAChC,OAAgC,EAChC,UAA+C,EAAE,EACjD,YAAY,GAAG,CAAC;IAEhB,MAAM,IAAI,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,YAAY,EAAW,CAAC;IACvF,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,OAAO,KAAK,MAAM;YAClE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,cAAuB,EAAE,KAAK,EAAE,CAAU,EAAE,CAAC;YAChF,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,SAAkB,EAAE,KAAK,EAAE,IAAI,E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