psytools 0.3.1 → 0.4.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 +31 -14
- package/SOURCES.md +63 -33
- package/dist/cjs/assessment.d.ts +6 -4
- package/dist/cjs/assessment.js +10 -6
- package/dist/cjs/errors.d.ts +4 -2
- package/dist/cjs/evaluation.d.ts +10 -5
- package/dist/cjs/evaluation.js +68 -31
- package/dist/cjs/i18n.d.ts +1 -1
- package/dist/cjs/i18n.js +2 -2
- package/dist/cjs/index.d.ts +5 -3
- package/dist/cjs/index.js +4 -2
- package/dist/cjs/inventories/aq10.js +37 -5
- package/dist/cjs/inventories/asrs6.js +30 -6
- package/dist/cjs/inventories/audit.d.ts +10 -0
- package/dist/cjs/inventories/audit.js +322 -0
- package/dist/cjs/inventories/common.js +10 -0
- package/dist/cjs/inventories/dass21.js +77 -19
- package/dist/cjs/inventories/gad7.js +25 -5
- package/dist/cjs/inventories/index.d.ts +4 -2
- package/dist/cjs/inventories/index.js +7 -1
- package/dist/cjs/inventories/mini-ipip.d.ts +11 -0
- package/dist/cjs/inventories/mini-ipip.js +370 -0
- package/dist/cjs/inventories/phq9.js +32 -6
- package/dist/cjs/inventories/who5.js +33 -5
- package/dist/cjs/types.d.ts +30 -1
- package/dist/esm/assessment.d.ts +6 -4
- package/dist/esm/assessment.js +11 -7
- package/dist/esm/errors.d.ts +4 -2
- package/dist/esm/evaluation.d.ts +10 -5
- package/dist/esm/evaluation.js +68 -31
- package/dist/esm/i18n.d.ts +1 -1
- package/dist/esm/i18n.js +1 -1
- package/dist/esm/index.d.ts +5 -3
- package/dist/esm/index.js +2 -2
- package/dist/esm/inventories/aq10.js +37 -5
- package/dist/esm/inventories/asrs6.js +30 -6
- package/dist/esm/inventories/audit.d.ts +10 -0
- package/dist/esm/inventories/audit.js +319 -0
- package/dist/esm/inventories/common.js +10 -0
- package/dist/esm/inventories/dass21.js +77 -19
- package/dist/esm/inventories/gad7.js +25 -5
- package/dist/esm/inventories/index.d.ts +4 -2
- package/dist/esm/inventories/index.js +5 -1
- package/dist/esm/inventories/mini-ipip.d.ts +11 -0
- package/dist/esm/inventories/mini-ipip.js +367 -0
- package/dist/esm/inventories/phq9.js +32 -6
- package/dist/esm/inventories/who5.js +33 -5
- package/dist/esm/types.d.ts +30 -1
- package/package.json +6 -2
- package/schema/assessment-definition.schema.json +15 -3
- package/src/assessment.ts +15 -9
- package/src/errors.ts +25 -2
- package/src/evaluation.ts +103 -30
- package/src/i18n.ts +1 -1
- package/src/index.ts +8 -1
- package/src/inventories/aq10.ts +39 -5
- package/src/inventories/asrs6.ts +32 -6
- package/src/inventories/audit.ts +325 -0
- package/src/inventories/common.ts +10 -0
- package/src/inventories/dass21.ts +78 -19
- package/src/inventories/gad7.ts +26 -5
- package/src/inventories/index.ts +14 -2
- package/src/inventories/mini-ipip.ts +372 -0
- package/src/inventories/phq9.ts +33 -6
- package/src/inventories/who5.ts +34 -5
- package/src/types.ts +38 -6
package/src/types.ts
CHANGED
|
@@ -63,6 +63,30 @@ export interface ScoreFlag {
|
|
|
63
63
|
label: LocalizedText;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
/** How a scorer treats unanswered items among the ones it uses. */
|
|
67
|
+
export type MissingDataStrategy = "ignore" | "prorate" | "require-complete";
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Missing-data policy for declarative scoring. Applies when incomplete
|
|
71
|
+
* answers reach the scorer (raw answer maps, or `allowIncomplete`).
|
|
72
|
+
*
|
|
73
|
+
* - `ignore` (default): unanswered items contribute nothing — partial
|
|
74
|
+
* totals understate severity, so use deliberately.
|
|
75
|
+
* - `prorate`: the raw score is scaled up by totalItems / answeredItems
|
|
76
|
+
* and rounded before any multiplier, per scale/subscale.
|
|
77
|
+
* - `require-complete`: evaluation throws `incomplete_response` when any
|
|
78
|
+
* contributing item is unanswered.
|
|
79
|
+
*/
|
|
80
|
+
export interface MissingDataPolicy {
|
|
81
|
+
strategy: MissingDataStrategy;
|
|
82
|
+
/**
|
|
83
|
+
* Minimum answered contributing items (per scale/subscale) needed to
|
|
84
|
+
* produce a score; below it evaluation throws `incomplete_response`.
|
|
85
|
+
* Defaults to 1 for `prorate`, 0 otherwise.
|
|
86
|
+
*/
|
|
87
|
+
minAnswered?: number;
|
|
88
|
+
}
|
|
89
|
+
|
|
66
90
|
/** Sums all answers into a single total score (PHQ-9, GAD-7, ...). */
|
|
67
91
|
export interface SumScoring {
|
|
68
92
|
kind: "sum";
|
|
@@ -71,6 +95,7 @@ export interface SumScoring {
|
|
|
71
95
|
/** Severity bands the (multiplied) total is matched against. */
|
|
72
96
|
bands?: ScoreBand[];
|
|
73
97
|
flags?: ScoreFlag[];
|
|
98
|
+
missing?: MissingDataPolicy;
|
|
74
99
|
}
|
|
75
100
|
|
|
76
101
|
/** One subscale of a multi-scale scoring definition. */
|
|
@@ -90,6 +115,8 @@ export interface SubscaleScoring {
|
|
|
90
115
|
kind: "subscales";
|
|
91
116
|
subscales: SubscaleDefinition[];
|
|
92
117
|
flags?: ScoreFlag[];
|
|
118
|
+
/** Applied to each subscale independently. */
|
|
119
|
+
missing?: MissingDataPolicy;
|
|
93
120
|
}
|
|
94
121
|
|
|
95
122
|
/** One item of a `count` scoring: when it counts as screen-positive. */
|
|
@@ -112,6 +139,8 @@ export interface CountScoring {
|
|
|
112
139
|
/** Bands the positive-item count is matched against. */
|
|
113
140
|
bands?: ScoreBand[];
|
|
114
141
|
flags?: ScoreFlag[];
|
|
142
|
+
/** `prorate` scales the positive count by totalItems / answeredItems. */
|
|
143
|
+
missing?: MissingDataPolicy;
|
|
115
144
|
}
|
|
116
145
|
|
|
117
146
|
/** Declarative, serializable scoring rules built into psytools. */
|
|
@@ -172,14 +201,17 @@ export interface ResponseData {
|
|
|
172
201
|
meta?: Record<string, unknown>;
|
|
173
202
|
}
|
|
174
203
|
|
|
204
|
+
/** Codes a validation issue can carry (a subset of `PsytoolsErrorCode`). */
|
|
205
|
+
export type ValidationIssueCode =
|
|
206
|
+
| "unknown_question"
|
|
207
|
+
| "invalid_value"
|
|
208
|
+
| "missing_answer"
|
|
209
|
+
| "duplicate_question"
|
|
210
|
+
| "malformed";
|
|
211
|
+
|
|
175
212
|
/** A single validation problem. */
|
|
176
213
|
export interface ValidationIssue {
|
|
177
|
-
code:
|
|
178
|
-
| "unknown_question"
|
|
179
|
-
| "invalid_value"
|
|
180
|
-
| "missing_answer"
|
|
181
|
-
| "duplicate_question"
|
|
182
|
-
| "malformed";
|
|
214
|
+
code: ValidationIssueCode;
|
|
183
215
|
message: string;
|
|
184
216
|
questionId?: string;
|
|
185
217
|
}
|