psytools 0.4.0 → 0.5.1
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 +29 -4
- package/SOURCES.md +16 -1
- package/dist/cjs/errors.d.ts +1 -1
- package/dist/cjs/i18n.d.ts +21 -1
- package/dist/cjs/i18n.js +136 -0
- package/dist/cjs/index.d.ts +4 -2
- package/dist/cjs/index.js +19 -14
- package/dist/cjs/inventories/aq10.js +5 -64
- package/dist/cjs/inventories/asrs6.js +6 -49
- package/dist/cjs/inventories/audit.js +9 -116
- package/dist/cjs/inventories/common.js +0 -20
- package/dist/cjs/inventories/dass21.js +19 -130
- package/dist/cjs/inventories/gad7.js +5 -40
- package/dist/cjs/inventories/index.d.ts +11 -2
- package/dist/cjs/inventories/index.js +22 -3
- package/dist/cjs/inventories/mini-ipip.js +1 -132
- package/dist/cjs/inventories/phq9.js +6 -53
- package/dist/cjs/inventories/who5.js +5 -56
- package/dist/cjs/locales/de/aq10.d.ts +4 -0
- package/dist/cjs/locales/de/aq10.js +53 -0
- package/dist/cjs/locales/de/asrs6.d.ts +4 -0
- package/dist/cjs/locales/de/asrs6.js +42 -0
- package/dist/cjs/locales/de/audit.d.ts +4 -0
- package/dist/cjs/locales/de/audit.js +80 -0
- package/dist/cjs/locales/de/dass21.d.ts +4 -0
- package/dist/cjs/locales/de/dass21.js +114 -0
- package/dist/cjs/locales/de/gad7.d.ts +4 -0
- package/dist/cjs/locales/de/gad7.js +46 -0
- package/dist/cjs/locales/de/mini-ipip.d.ts +4 -0
- package/dist/cjs/locales/de/mini-ipip.js +97 -0
- package/dist/cjs/locales/de/phq9.d.ts +4 -0
- package/dist/cjs/locales/de/phq9.js +56 -0
- package/dist/cjs/locales/de/who5.d.ts +4 -0
- package/dist/cjs/locales/de/who5.js +41 -0
- package/dist/cjs/locales/es/aq10.d.ts +4 -0
- package/dist/cjs/locales/es/aq10.js +53 -0
- package/dist/cjs/locales/es/asrs6.d.ts +4 -0
- package/dist/cjs/locales/es/asrs6.js +42 -0
- package/dist/cjs/locales/es/audit.d.ts +4 -0
- package/dist/cjs/locales/es/audit.js +80 -0
- package/dist/cjs/locales/es/dass21.d.ts +4 -0
- package/dist/cjs/locales/es/dass21.js +114 -0
- package/dist/cjs/locales/es/gad7.d.ts +4 -0
- package/dist/cjs/locales/es/gad7.js +46 -0
- package/dist/cjs/locales/es/mini-ipip.d.ts +4 -0
- package/dist/cjs/locales/es/mini-ipip.js +97 -0
- package/dist/cjs/locales/es/phq9.d.ts +4 -0
- package/dist/cjs/locales/es/phq9.js +56 -0
- package/dist/cjs/locales/es/who5.d.ts +4 -0
- package/dist/cjs/locales/es/who5.js +41 -0
- package/dist/cjs/locales/index.d.ts +12 -0
- package/dist/cjs/locales/index.js +63 -0
- package/dist/cjs/locales/tr/aq10.d.ts +4 -0
- package/dist/cjs/locales/tr/aq10.js +53 -0
- package/dist/cjs/locales/tr/asrs6.d.ts +4 -0
- package/dist/cjs/locales/tr/asrs6.js +42 -0
- package/dist/cjs/locales/tr/audit.d.ts +4 -0
- package/dist/cjs/locales/tr/audit.js +80 -0
- package/dist/cjs/locales/tr/dass21.d.ts +4 -0
- package/dist/cjs/locales/tr/dass21.js +114 -0
- package/dist/cjs/locales/tr/gad7.d.ts +4 -0
- package/dist/cjs/locales/tr/gad7.js +46 -0
- package/dist/cjs/locales/tr/mini-ipip.d.ts +4 -0
- package/dist/cjs/locales/tr/mini-ipip.js +97 -0
- package/dist/cjs/locales/tr/phq9.d.ts +4 -0
- package/dist/cjs/locales/tr/phq9.js +56 -0
- package/dist/cjs/locales/tr/who5.d.ts +4 -0
- package/dist/cjs/locales/tr/who5.js +41 -0
- package/dist/cjs/locales/zh/aq10.d.ts +4 -0
- package/dist/cjs/locales/zh/aq10.js +53 -0
- package/dist/cjs/locales/zh/asrs6.d.ts +4 -0
- package/dist/cjs/locales/zh/asrs6.js +42 -0
- package/dist/cjs/locales/zh/audit.d.ts +4 -0
- package/dist/cjs/locales/zh/audit.js +80 -0
- package/dist/cjs/locales/zh/dass21.d.ts +4 -0
- package/dist/cjs/locales/zh/dass21.js +114 -0
- package/dist/cjs/locales/zh/gad7.d.ts +4 -0
- package/dist/cjs/locales/zh/gad7.js +46 -0
- package/dist/cjs/locales/zh/mini-ipip.d.ts +4 -0
- package/dist/cjs/locales/zh/mini-ipip.js +97 -0
- package/dist/cjs/locales/zh/phq9.d.ts +4 -0
- package/dist/cjs/locales/zh/phq9.js +56 -0
- package/dist/cjs/locales/zh/who5.d.ts +4 -0
- package/dist/cjs/locales/zh/who5.js +41 -0
- package/dist/cjs/types.d.ts +30 -0
- package/dist/esm/errors.d.ts +1 -1
- package/dist/esm/i18n.d.ts +21 -1
- package/dist/esm/i18n.js +134 -0
- package/dist/esm/index.d.ts +4 -2
- package/dist/esm/index.js +2 -1
- package/dist/esm/inventories/aq10.js +5 -64
- package/dist/esm/inventories/asrs6.js +6 -49
- package/dist/esm/inventories/audit.js +9 -116
- package/dist/esm/inventories/common.js +0 -20
- package/dist/esm/inventories/dass21.js +19 -130
- package/dist/esm/inventories/gad7.js +5 -40
- package/dist/esm/inventories/index.d.ts +11 -2
- package/dist/esm/inventories/index.js +22 -3
- package/dist/esm/inventories/mini-ipip.js +1 -132
- package/dist/esm/inventories/phq9.js +6 -53
- package/dist/esm/inventories/who5.js +5 -56
- package/dist/esm/locales/de/aq10.d.ts +4 -0
- package/dist/esm/locales/de/aq10.js +51 -0
- package/dist/esm/locales/de/asrs6.d.ts +4 -0
- package/dist/esm/locales/de/asrs6.js +40 -0
- package/dist/esm/locales/de/audit.d.ts +4 -0
- package/dist/esm/locales/de/audit.js +78 -0
- package/dist/esm/locales/de/dass21.d.ts +4 -0
- package/dist/esm/locales/de/dass21.js +112 -0
- package/dist/esm/locales/de/gad7.d.ts +4 -0
- package/dist/esm/locales/de/gad7.js +44 -0
- package/dist/esm/locales/de/mini-ipip.d.ts +4 -0
- package/dist/esm/locales/de/mini-ipip.js +95 -0
- package/dist/esm/locales/de/phq9.d.ts +4 -0
- package/dist/esm/locales/de/phq9.js +54 -0
- package/dist/esm/locales/de/who5.d.ts +4 -0
- package/dist/esm/locales/de/who5.js +39 -0
- package/dist/esm/locales/es/aq10.d.ts +4 -0
- package/dist/esm/locales/es/aq10.js +51 -0
- package/dist/esm/locales/es/asrs6.d.ts +4 -0
- package/dist/esm/locales/es/asrs6.js +40 -0
- package/dist/esm/locales/es/audit.d.ts +4 -0
- package/dist/esm/locales/es/audit.js +78 -0
- package/dist/esm/locales/es/dass21.d.ts +4 -0
- package/dist/esm/locales/es/dass21.js +112 -0
- package/dist/esm/locales/es/gad7.d.ts +4 -0
- package/dist/esm/locales/es/gad7.js +44 -0
- package/dist/esm/locales/es/mini-ipip.d.ts +4 -0
- package/dist/esm/locales/es/mini-ipip.js +95 -0
- package/dist/esm/locales/es/phq9.d.ts +4 -0
- package/dist/esm/locales/es/phq9.js +54 -0
- package/dist/esm/locales/es/who5.d.ts +4 -0
- package/dist/esm/locales/es/who5.js +39 -0
- package/dist/esm/locales/index.d.ts +12 -0
- package/dist/esm/locales/index.js +59 -0
- package/dist/esm/locales/tr/aq10.d.ts +4 -0
- package/dist/esm/locales/tr/aq10.js +51 -0
- package/dist/esm/locales/tr/asrs6.d.ts +4 -0
- package/dist/esm/locales/tr/asrs6.js +40 -0
- package/dist/esm/locales/tr/audit.d.ts +4 -0
- package/dist/esm/locales/tr/audit.js +78 -0
- package/dist/esm/locales/tr/dass21.d.ts +4 -0
- package/dist/esm/locales/tr/dass21.js +112 -0
- package/dist/esm/locales/tr/gad7.d.ts +4 -0
- package/dist/esm/locales/tr/gad7.js +44 -0
- package/dist/esm/locales/tr/mini-ipip.d.ts +4 -0
- package/dist/esm/locales/tr/mini-ipip.js +95 -0
- package/dist/esm/locales/tr/phq9.d.ts +4 -0
- package/dist/esm/locales/tr/phq9.js +54 -0
- package/dist/esm/locales/tr/who5.d.ts +4 -0
- package/dist/esm/locales/tr/who5.js +39 -0
- package/dist/esm/locales/zh/aq10.d.ts +4 -0
- package/dist/esm/locales/zh/aq10.js +51 -0
- package/dist/esm/locales/zh/asrs6.d.ts +4 -0
- package/dist/esm/locales/zh/asrs6.js +40 -0
- package/dist/esm/locales/zh/audit.d.ts +4 -0
- package/dist/esm/locales/zh/audit.js +78 -0
- package/dist/esm/locales/zh/dass21.d.ts +4 -0
- package/dist/esm/locales/zh/dass21.js +112 -0
- package/dist/esm/locales/zh/gad7.d.ts +4 -0
- package/dist/esm/locales/zh/gad7.js +44 -0
- package/dist/esm/locales/zh/mini-ipip.d.ts +4 -0
- package/dist/esm/locales/zh/mini-ipip.js +95 -0
- package/dist/esm/locales/zh/phq9.d.ts +4 -0
- package/dist/esm/locales/zh/phq9.js +54 -0
- package/dist/esm/locales/zh/who5.d.ts +4 -0
- package/dist/esm/locales/zh/who5.js +39 -0
- package/dist/esm/types.d.ts +30 -0
- package/package.json +21 -1
- package/src/errors.ts +1 -0
- package/src/i18n.ts +176 -1
- package/src/index.ts +4 -1
- package/src/inventories/aq10.ts +5 -64
- package/src/inventories/asrs6.ts +6 -49
- package/src/inventories/audit.ts +9 -116
- package/src/inventories/common.ts +0 -20
- package/src/inventories/dass21.ts +19 -130
- package/src/inventories/gad7.ts +5 -40
- package/src/inventories/index.ts +27 -3
- package/src/inventories/mini-ipip.ts +1 -132
- package/src/inventories/phq9.ts +6 -53
- package/src/inventories/who5.ts +5 -56
- package/src/locales/de/aq10.ts +54 -0
- package/src/locales/de/asrs6.ts +43 -0
- package/src/locales/de/audit.ts +81 -0
- package/src/locales/de/dass21.ts +115 -0
- package/src/locales/de/gad7.ts +47 -0
- package/src/locales/de/mini-ipip.ts +98 -0
- package/src/locales/de/phq9.ts +57 -0
- package/src/locales/de/who5.ts +42 -0
- package/src/locales/es/aq10.ts +54 -0
- package/src/locales/es/asrs6.ts +43 -0
- package/src/locales/es/audit.ts +81 -0
- package/src/locales/es/dass21.ts +115 -0
- package/src/locales/es/gad7.ts +47 -0
- package/src/locales/es/mini-ipip.ts +98 -0
- package/src/locales/es/phq9.ts +57 -0
- package/src/locales/es/who5.ts +42 -0
- package/src/locales/index.ts +64 -0
- package/src/locales/tr/aq10.ts +54 -0
- package/src/locales/tr/asrs6.ts +43 -0
- package/src/locales/tr/audit.ts +81 -0
- package/src/locales/tr/dass21.ts +115 -0
- package/src/locales/tr/gad7.ts +47 -0
- package/src/locales/tr/mini-ipip.ts +98 -0
- package/src/locales/tr/phq9.ts +57 -0
- package/src/locales/tr/who5.ts +42 -0
- package/src/locales/zh/aq10.ts +54 -0
- package/src/locales/zh/asrs6.ts +43 -0
- package/src/locales/zh/audit.ts +81 -0
- package/src/locales/zh/dass21.ts +115 -0
- package/src/locales/zh/gad7.ts +47 -0
- package/src/locales/zh/mini-ipip.ts +98 -0
- package/src/locales/zh/phq9.ts +57 -0
- package/src/locales/zh/who5.ts +42 -0
- package/src/types.ts +25 -0
package/src/i18n.ts
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
AssessmentDefinition,
|
|
3
|
+
AssessmentOption,
|
|
4
|
+
InventoryLocalePack,
|
|
5
|
+
LocalizedText,
|
|
6
|
+
ScoreBand,
|
|
7
|
+
ScoreFlag,
|
|
8
|
+
ScoringDefinition,
|
|
9
|
+
} from "./types.ts";
|
|
10
|
+
import { PsytoolsError } from "./errors.ts";
|
|
2
11
|
|
|
3
12
|
/**
|
|
4
13
|
* Resolves a `LocalizedText` to a string for the given locale.
|
|
@@ -27,6 +36,172 @@ export function localizeText(
|
|
|
27
36
|
return first ?? "";
|
|
28
37
|
}
|
|
29
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Merges a locale pack into a definition, returning a new definition that
|
|
41
|
+
* additionally carries the pack's language in every localized text. The
|
|
42
|
+
* original definition and the pack are not modified.
|
|
43
|
+
*
|
|
44
|
+
* Packs may be partial (untranslated entries keep their existing locales),
|
|
45
|
+
* but entries referencing unknown question/band/flag/subscale ids or
|
|
46
|
+
* mismatched option counts throw `invalid_argument`.
|
|
47
|
+
*/
|
|
48
|
+
export function applyLocale(
|
|
49
|
+
definition: AssessmentDefinition,
|
|
50
|
+
pack: InventoryLocalePack,
|
|
51
|
+
): AssessmentDefinition {
|
|
52
|
+
if (pack.id !== definition.id) {
|
|
53
|
+
throw new PsytoolsError(
|
|
54
|
+
"invalid_argument",
|
|
55
|
+
`Locale pack "${pack.id}" (${pack.locale}) does not belong to assessment "${definition.id}"`,
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
const set = (text: LocalizedText, value: string | undefined): LocalizedText =>
|
|
59
|
+
value === undefined ? text : { ...text, [pack.locale]: value };
|
|
60
|
+
const setOptions = (
|
|
61
|
+
options: AssessmentOption[],
|
|
62
|
+
labels: string[] | undefined,
|
|
63
|
+
where: string,
|
|
64
|
+
): AssessmentOption[] => {
|
|
65
|
+
if (!labels) return options;
|
|
66
|
+
if (labels.length !== options.length) {
|
|
67
|
+
throw new PsytoolsError(
|
|
68
|
+
"invalid_argument",
|
|
69
|
+
`Locale pack "${pack.id}/${pack.locale}": ${where} has ${labels.length} labels for ${options.length} options`,
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
return options.map((option, i) => ({ ...option, label: set(option.label, labels[i]) }));
|
|
73
|
+
};
|
|
74
|
+
const setBands = (
|
|
75
|
+
bands: ScoreBand[] | undefined,
|
|
76
|
+
packBands: Record<string, string> | undefined,
|
|
77
|
+
): ScoreBand[] | undefined =>
|
|
78
|
+
bands?.map((band) => ({ ...band, label: set(band.label, packBands?.[band.id]) }));
|
|
79
|
+
const setFlags = (
|
|
80
|
+
flags: ScoreFlag[] | undefined,
|
|
81
|
+
packFlags: Record<string, string> | undefined,
|
|
82
|
+
): ScoreFlag[] | undefined =>
|
|
83
|
+
flags?.map((flag) => ({ ...flag, label: set(flag.label, packFlags?.[flag.id]) }));
|
|
84
|
+
|
|
85
|
+
for (const questionId of Object.keys(pack.questions)) {
|
|
86
|
+
if (!definition.questions.some((q) => q.id === questionId)) {
|
|
87
|
+
throw new PsytoolsError(
|
|
88
|
+
"invalid_argument",
|
|
89
|
+
`Locale pack "${pack.id}/${pack.locale}" references unknown question "${questionId}"`,
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
let scoring: ScoringDefinition | undefined;
|
|
95
|
+
if (definition.scoring) {
|
|
96
|
+
const s = definition.scoring;
|
|
97
|
+
if (s.kind === "subscales") {
|
|
98
|
+
scoring = {
|
|
99
|
+
...s,
|
|
100
|
+
subscales: s.subscales.map((subscale) => {
|
|
101
|
+
const entry = pack.subscales?.[subscale.id];
|
|
102
|
+
return {
|
|
103
|
+
...subscale,
|
|
104
|
+
label: set(subscale.label, entry?.label),
|
|
105
|
+
...(subscale.bands ? { bands: setBands(subscale.bands, entry?.bands) } : {}),
|
|
106
|
+
};
|
|
107
|
+
}),
|
|
108
|
+
...(s.flags ? { flags: setFlags(s.flags, pack.flags) } : {}),
|
|
109
|
+
};
|
|
110
|
+
} else {
|
|
111
|
+
scoring = {
|
|
112
|
+
...s,
|
|
113
|
+
...(s.bands ? { bands: setBands(s.bands, pack.bands) } : {}),
|
|
114
|
+
...(s.flags ? { flags: setFlags(s.flags, pack.flags) } : {}),
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
...definition,
|
|
121
|
+
title: set(definition.title, pack.title),
|
|
122
|
+
...(definition.description ? { description: set(definition.description, pack.description) } : {}),
|
|
123
|
+
...(definition.instructions ? { instructions: set(definition.instructions, pack.instructions) } : {}),
|
|
124
|
+
options: setOptions(definition.options, pack.options, "options"),
|
|
125
|
+
questions: definition.questions.map((question) => {
|
|
126
|
+
const entry = pack.questions[question.id];
|
|
127
|
+
if (!entry) return question;
|
|
128
|
+
return {
|
|
129
|
+
...question,
|
|
130
|
+
text: set(question.text, entry.text),
|
|
131
|
+
...(question.options
|
|
132
|
+
? { options: setOptions(question.options, entry.options, `question "${question.id}"`) }
|
|
133
|
+
: {}),
|
|
134
|
+
};
|
|
135
|
+
}),
|
|
136
|
+
...(scoring ? { scoring } : {}),
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Returns a copy of a definition containing only the given locales in every
|
|
142
|
+
* localized text (questions, options, bands, flags, subscales). The
|
|
143
|
+
* definition's `defaultLocale` is always kept as the fallback.
|
|
144
|
+
*
|
|
145
|
+
* Use this at the server boundary to avoid shipping unused languages to a
|
|
146
|
+
* client: `res.json(pickLocales(phq9, [userLocale]))`. The original
|
|
147
|
+
* definition is not modified.
|
|
148
|
+
*/
|
|
149
|
+
export function pickLocales(
|
|
150
|
+
definition: AssessmentDefinition,
|
|
151
|
+
locales: string[],
|
|
152
|
+
): AssessmentDefinition {
|
|
153
|
+
const keep = new Set([...locales, definition.defaultLocale]);
|
|
154
|
+
const pick = (text: LocalizedText): LocalizedText => {
|
|
155
|
+
const out: LocalizedText = {};
|
|
156
|
+
for (const [locale, value] of Object.entries(text)) {
|
|
157
|
+
if (keep.has(locale)) out[locale] = value;
|
|
158
|
+
}
|
|
159
|
+
return out;
|
|
160
|
+
};
|
|
161
|
+
const pickOptions = (options: AssessmentOption[]): AssessmentOption[] =>
|
|
162
|
+
options.map((option) => ({ ...option, label: pick(option.label) }));
|
|
163
|
+
const pickBands = (bands: ScoreBand[]): ScoreBand[] =>
|
|
164
|
+
bands.map((band) => ({ ...band, label: pick(band.label) }));
|
|
165
|
+
const pickFlags = (flags: ScoreFlag[]): ScoreFlag[] =>
|
|
166
|
+
flags.map((flag) => ({ ...flag, label: pick(flag.label) }));
|
|
167
|
+
|
|
168
|
+
let scoring: ScoringDefinition | undefined;
|
|
169
|
+
if (definition.scoring) {
|
|
170
|
+
const s = definition.scoring;
|
|
171
|
+
if (s.kind === "subscales") {
|
|
172
|
+
scoring = {
|
|
173
|
+
...s,
|
|
174
|
+
subscales: s.subscales.map((subscale) => ({
|
|
175
|
+
...subscale,
|
|
176
|
+
label: pick(subscale.label),
|
|
177
|
+
...(subscale.bands ? { bands: pickBands(subscale.bands) } : {}),
|
|
178
|
+
})),
|
|
179
|
+
...(s.flags ? { flags: pickFlags(s.flags) } : {}),
|
|
180
|
+
};
|
|
181
|
+
} else {
|
|
182
|
+
scoring = {
|
|
183
|
+
...s,
|
|
184
|
+
...(s.bands ? { bands: pickBands(s.bands) } : {}),
|
|
185
|
+
...(s.flags ? { flags: pickFlags(s.flags) } : {}),
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return {
|
|
191
|
+
...definition,
|
|
192
|
+
title: pick(definition.title),
|
|
193
|
+
...(definition.description ? { description: pick(definition.description) } : {}),
|
|
194
|
+
...(definition.instructions ? { instructions: pick(definition.instructions) } : {}),
|
|
195
|
+
options: pickOptions(definition.options),
|
|
196
|
+
questions: definition.questions.map((question) => ({
|
|
197
|
+
...question,
|
|
198
|
+
text: pick(question.text),
|
|
199
|
+
...(question.options ? { options: pickOptions(question.options) } : {}),
|
|
200
|
+
})),
|
|
201
|
+
...(scoring ? { scoring } : {}),
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
|
|
30
205
|
/** Collects the union of locales present in a set of localized texts. */
|
|
31
206
|
export function collectLocales(
|
|
32
207
|
texts: Array<LocalizedText | undefined>,
|
package/src/index.ts
CHANGED
|
@@ -15,6 +15,7 @@ export type {
|
|
|
15
15
|
ScoringDefinition,
|
|
16
16
|
ValidationIssueCode,
|
|
17
17
|
AnswerMap,
|
|
18
|
+
InventoryLocalePack,
|
|
18
19
|
ResponseStatus,
|
|
19
20
|
ResponseData,
|
|
20
21
|
ValidationIssue,
|
|
@@ -33,7 +34,9 @@ export type {
|
|
|
33
34
|
|
|
34
35
|
export { PsytoolsError } from "./errors.ts";
|
|
35
36
|
export type { PsytoolsErrorCode } from "./errors.ts";
|
|
36
|
-
export { localizeText, collectLocales } from "./i18n.ts";
|
|
37
|
+
export { localizeText, collectLocales, pickLocales, applyLocale } from "./i18n.ts";
|
|
38
|
+
export { localePacks, availableLocales } from "./locales/index.ts";
|
|
39
|
+
export type { LocalePackLoader } from "./locales/index.ts";
|
|
37
40
|
export { Assessment, validateDefinition } from "./assessment.ts";
|
|
38
41
|
export { AssessmentResponse } from "./response.ts";
|
|
39
42
|
export { evaluate } from "./evaluation.ts";
|
package/src/inventories/aq10.ts
CHANGED
|
@@ -15,42 +15,30 @@ export const aq10: AssessmentDefinition = {
|
|
|
15
15
|
version: "1.0.0",
|
|
16
16
|
title: {
|
|
17
17
|
en: "Autism Spectrum Quotient (AQ-10) — Adult",
|
|
18
|
-
tr: "Otizm Spektrum Anketi (AQ-10) — Yetişkin",
|
|
19
|
-
de: "Autismus-Spektrum-Quotient (AQ-10) — Erwachsene",
|
|
20
|
-
zh: "自闭症谱系商数问卷(AQ-10)— 成人版",
|
|
21
|
-
es: "Cociente del Espectro Autista (AQ-10) — Adultos",
|
|
22
18
|
},
|
|
23
19
|
description: {
|
|
24
20
|
en: "A 10-item screening questionnaire for autistic traits in adults, condensed from the 50-item Autism Spectrum Quotient.",
|
|
25
|
-
tr: "50 maddelik Otizm Spektrum Anketi'nden kısaltılmış, yetişkinlerde otistik özellikleri taramak için 10 maddelik bir ölçek.",
|
|
26
|
-
de: "Ein 10-Item-Screeningfragebogen für autistische Merkmale bei Erwachsenen, verkürzt aus dem 50-Item-Autismus-Spektrum-Quotienten.",
|
|
27
|
-
zh: "一份用于筛查成人自闭症特质的10条目问卷,由50条目的自闭症谱系商数量表精简而成。",
|
|
28
|
-
es: "Un cuestionario de cribado de 10 ítems para rasgos autistas en adultos, condensado a partir del Cociente del Espectro Autista de 50 ítems.",
|
|
29
21
|
},
|
|
30
22
|
instructions: {
|
|
31
23
|
en: "For each statement, select the answer that best describes you.",
|
|
32
|
-
tr: "Her ifade için sizi en iyi tanımlayan yanıtı işaretleyin.",
|
|
33
|
-
de: "Wählen Sie zu jeder Aussage die Antwort, die Sie am besten beschreibt.",
|
|
34
|
-
zh: "请针对每条陈述,选择最符合您情况的答案。",
|
|
35
|
-
es: "Para cada afirmación, seleccione la respuesta que mejor lo describa.",
|
|
36
24
|
},
|
|
37
25
|
defaultLocale: "en",
|
|
38
26
|
options: [
|
|
39
27
|
{
|
|
40
28
|
value: 0,
|
|
41
|
-
label: { en: "Definitely disagree"
|
|
29
|
+
label: { en: "Definitely disagree" },
|
|
42
30
|
},
|
|
43
31
|
{
|
|
44
32
|
value: 1,
|
|
45
|
-
label: { en: "Slightly disagree"
|
|
33
|
+
label: { en: "Slightly disagree" },
|
|
46
34
|
},
|
|
47
35
|
{
|
|
48
36
|
value: 2,
|
|
49
|
-
label: { en: "Slightly agree"
|
|
37
|
+
label: { en: "Slightly agree" },
|
|
50
38
|
},
|
|
51
39
|
{
|
|
52
40
|
value: 3,
|
|
53
|
-
label: { en: "Definitely agree"
|
|
41
|
+
label: { en: "Definitely agree" },
|
|
54
42
|
},
|
|
55
43
|
],
|
|
56
44
|
questions: [
|
|
@@ -58,20 +46,12 @@ export const aq10: AssessmentDefinition = {
|
|
|
58
46
|
id: "aq10-1",
|
|
59
47
|
text: {
|
|
60
48
|
en: "I often notice small sounds when others do not",
|
|
61
|
-
tr: "Başkalarının fark etmediği küçük sesleri sıklıkla fark ederim",
|
|
62
|
-
de: "Ich nehme oft leise Geräusche wahr, die andere nicht bemerken",
|
|
63
|
-
zh: "我经常注意到别人注意不到的微小声音",
|
|
64
|
-
es: "A menudo noto pequeños sonidos que otras personas no perciben",
|
|
65
49
|
},
|
|
66
50
|
},
|
|
67
51
|
{
|
|
68
52
|
id: "aq10-2",
|
|
69
53
|
text: {
|
|
70
54
|
en: "I usually concentrate more on the whole picture, rather than the small details",
|
|
71
|
-
tr: "Genellikle küçük ayrıntılardan çok resmin bütününe odaklanırım",
|
|
72
|
-
de: "Ich konzentriere mich meist mehr auf das Gesamtbild als auf die kleinen Details",
|
|
73
|
-
zh: "我通常更关注事情的整体,而不是小细节",
|
|
74
|
-
es: "Normalmente me concentro más en la imagen global que en los pequeños detalles",
|
|
75
55
|
},
|
|
76
56
|
reverseScored: true,
|
|
77
57
|
},
|
|
@@ -79,10 +59,6 @@ export const aq10: AssessmentDefinition = {
|
|
|
79
59
|
id: "aq10-3",
|
|
80
60
|
text: {
|
|
81
61
|
en: "I find it easy to do more than one thing at once",
|
|
82
|
-
tr: "Aynı anda birden fazla iş yapmak benim için kolaydır",
|
|
83
|
-
de: "Es fällt mir leicht, mehrere Dinge gleichzeitig zu tun",
|
|
84
|
-
zh: "我觉得同时做几件事情很容易",
|
|
85
|
-
es: "Me resulta fácil hacer más de una cosa a la vez",
|
|
86
62
|
},
|
|
87
63
|
reverseScored: true,
|
|
88
64
|
},
|
|
@@ -90,10 +66,6 @@ export const aq10: AssessmentDefinition = {
|
|
|
90
66
|
id: "aq10-4",
|
|
91
67
|
text: {
|
|
92
68
|
en: "If there is an interruption, I can switch back to what I was doing very quickly",
|
|
93
|
-
tr: "Bir kesinti olursa, yapmakta olduğum işe çok hızlı bir şekilde geri dönebilirim",
|
|
94
|
-
de: "Wenn ich unterbrochen werde, kann ich sehr schnell zu meiner Tätigkeit zurückkehren",
|
|
95
|
-
zh: "如果被打断,我能很快回到原来正在做的事情上",
|
|
96
|
-
es: "Si hay una interrupción, puedo volver muy rápidamente a lo que estaba haciendo",
|
|
97
69
|
},
|
|
98
70
|
reverseScored: true,
|
|
99
71
|
},
|
|
@@ -101,10 +73,6 @@ export const aq10: AssessmentDefinition = {
|
|
|
101
73
|
id: "aq10-5",
|
|
102
74
|
text: {
|
|
103
75
|
en: "I find it easy to 'read between the lines' when someone is talking to me",
|
|
104
|
-
tr: "Biri benimle konuşurken 'satır aralarını okumak' benim için kolaydır",
|
|
105
|
-
de: "Es fällt mir leicht, 'zwischen den Zeilen zu lesen', wenn jemand mit mir spricht",
|
|
106
|
-
zh: "当别人和我说话时,我觉得'听出言外之意'很容易",
|
|
107
|
-
es: "Me resulta fácil 'leer entre líneas' cuando alguien me está hablando",
|
|
108
76
|
},
|
|
109
77
|
reverseScored: true,
|
|
110
78
|
},
|
|
@@ -112,10 +80,6 @@ export const aq10: AssessmentDefinition = {
|
|
|
112
80
|
id: "aq10-6",
|
|
113
81
|
text: {
|
|
114
82
|
en: "I know how to tell if someone listening to me is getting bored",
|
|
115
|
-
tr: "Beni dinleyen birinin sıkılmaya başladığını nasıl anlayacağımı bilirim",
|
|
116
|
-
de: "Ich erkenne, ob jemand, der mir zuhört, sich zu langweilen beginnt",
|
|
117
|
-
zh: "我知道如何判断听我说话的人是否开始感到厌烦",
|
|
118
|
-
es: "Sé darme cuenta de si la persona que me escucha se está aburriendo",
|
|
119
83
|
},
|
|
120
84
|
reverseScored: true,
|
|
121
85
|
},
|
|
@@ -123,30 +87,18 @@ export const aq10: AssessmentDefinition = {
|
|
|
123
87
|
id: "aq10-7",
|
|
124
88
|
text: {
|
|
125
89
|
en: "When I'm reading a story I find it difficult to work out the characters' intentions",
|
|
126
|
-
tr: "Bir öykü okurken karakterlerin niyetlerini anlamakta zorlanırım",
|
|
127
|
-
de: "Wenn ich eine Geschichte lese, fällt es mir schwer, die Absichten der Figuren zu erkennen",
|
|
128
|
-
zh: "读故事时,我很难弄清人物的意图",
|
|
129
|
-
es: "Cuando leo una historia, me resulta difícil deducir las intenciones de los personajes",
|
|
130
90
|
},
|
|
131
91
|
},
|
|
132
92
|
{
|
|
133
93
|
id: "aq10-8",
|
|
134
94
|
text: {
|
|
135
95
|
en: "I like to collect information about categories of things (e.g. types of car, types of bird, types of train, types of plant etc)",
|
|
136
|
-
tr: "Belirli kategorilerdeki şeyler hakkında bilgi toplamayı severim (örneğin araba türleri, kuş türleri, tren türleri, bitki türleri vb.)",
|
|
137
|
-
de: "Ich sammle gern Informationen über Kategorien von Dingen (z. B. Auto-, Vogel-, Zug- oder Pflanzenarten)",
|
|
138
|
-
zh: "我喜欢收集各类事物的信息(例如汽车的类型、鸟的种类、火车的类型、植物的种类等)",
|
|
139
|
-
es: "Me gusta recopilar información sobre categorías de cosas (p. ej., tipos de coches, de aves, de trenes, de plantas, etc.)",
|
|
140
96
|
},
|
|
141
97
|
},
|
|
142
98
|
{
|
|
143
99
|
id: "aq10-9",
|
|
144
100
|
text: {
|
|
145
101
|
en: "I find it easy to work out what someone is thinking or feeling just by looking at their face",
|
|
146
|
-
tr: "Sadece yüzüne bakarak birinin ne düşündüğünü ya da hissettiğini anlamak benim için kolaydır",
|
|
147
|
-
de: "Es fällt mir leicht, allein am Gesicht abzulesen, was jemand denkt oder fühlt",
|
|
148
|
-
zh: "我觉得只看别人的脸就能轻松看出对方在想什么或有什么感受",
|
|
149
|
-
es: "Me resulta fácil deducir lo que alguien piensa o siente con solo mirarle la cara",
|
|
150
102
|
},
|
|
151
103
|
reverseScored: true,
|
|
152
104
|
},
|
|
@@ -154,15 +106,12 @@ export const aq10: AssessmentDefinition = {
|
|
|
154
106
|
id: "aq10-10",
|
|
155
107
|
text: {
|
|
156
108
|
en: "I find it difficult to work out people's intentions",
|
|
157
|
-
tr: "İnsanların niyetlerini anlamakta zorlanırım",
|
|
158
|
-
de: "Es fällt mir schwer, die Absichten anderer Menschen zu erkennen",
|
|
159
|
-
zh: "我很难弄清别人的意图",
|
|
160
|
-
es: "Me resulta difícil deducir las intenciones de las personas",
|
|
161
109
|
},
|
|
162
110
|
},
|
|
163
111
|
],
|
|
164
112
|
scoring: {
|
|
165
113
|
kind: "count",
|
|
114
|
+
missing: { strategy: "require-complete" },
|
|
166
115
|
items: [
|
|
167
116
|
{ questionId: "aq10-1", minValue: 2 },
|
|
168
117
|
{ questionId: "aq10-2", minValue: 2 },
|
|
@@ -182,10 +131,6 @@ export const aq10: AssessmentDefinition = {
|
|
|
182
131
|
max: 5,
|
|
183
132
|
label: {
|
|
184
133
|
en: "Below screening threshold",
|
|
185
|
-
tr: "Tarama eşiğinin altında",
|
|
186
|
-
de: "Unterhalb der Screening-Schwelle",
|
|
187
|
-
zh: "低于筛查阈值",
|
|
188
|
-
es: "Por debajo del umbral de cribado",
|
|
189
134
|
},
|
|
190
135
|
},
|
|
191
136
|
{
|
|
@@ -194,10 +139,6 @@ export const aq10: AssessmentDefinition = {
|
|
|
194
139
|
max: 10,
|
|
195
140
|
label: {
|
|
196
141
|
en: "At or above threshold — consider referral for a specialist autism assessment",
|
|
197
|
-
tr: "Eşikte ya da üzerinde — uzman otizm değerlendirmesine yönlendirme düşünülmelidir",
|
|
198
|
-
de: "An oder über der Schwelle — Überweisung zu einer spezialisierten Autismus-Diagnostik erwägen",
|
|
199
|
-
zh: "达到或超过阈值——建议考虑转介进行自闭症专科评估",
|
|
200
|
-
es: "En el umbral o por encima — considere la derivación para una evaluación especializada de autismo",
|
|
201
142
|
},
|
|
202
143
|
},
|
|
203
144
|
],
|
package/src/inventories/asrs6.ts
CHANGED
|
@@ -14,97 +14,62 @@ export const asrs6: AssessmentDefinition = {
|
|
|
14
14
|
version: "1.0.0",
|
|
15
15
|
title: {
|
|
16
16
|
en: "Adult ADHD Self-Report Scale (ASRS-v1.1) Screener",
|
|
17
|
-
tr: "Erişkin DEHB Kendi Bildirim Ölçeği (ASRS-v1.1) Tarama Formu",
|
|
18
|
-
de: "Selbstbeurteilungsskala für ADHS bei Erwachsenen (ASRS-v1.1) Screener",
|
|
19
|
-
zh: "成人ADHD自评量表(ASRS-v1.1)筛查问卷",
|
|
20
|
-
es: "Escala de Autoevaluación del TDAH en Adultos (ASRS-v1.1) — Cuestionario de cribado",
|
|
21
17
|
},
|
|
22
18
|
description: {
|
|
23
19
|
en: "A 6-item screener for adult attention-deficit/hyperactivity disorder, drawn from the WHO's full 18-item ASRS.",
|
|
24
|
-
tr: "DSÖ'nün 18 maddelik tam ASRS ölçeğinden türetilmiş, erişkin dikkat eksikliği/hiperaktivite bozukluğu için 6 maddelik bir tarama aracı.",
|
|
25
|
-
de: "Ein 6-Item-Screener für Aufmerksamkeitsdefizit-/Hyperaktivitätsstörung bei Erwachsenen, abgeleitet aus der vollständigen 18-Item-ASRS der WHO.",
|
|
26
|
-
zh: "一份包含6个条目的成人注意缺陷/多动障碍筛查问卷,摘自世界卫生组织完整的18条目ASRS量表。",
|
|
27
|
-
es: "Un cuestionario de cribado de 6 ítems para el trastorno por déficit de atención e hiperactividad en adultos, extraído de la ASRS completa de 18 ítems de la OMS.",
|
|
28
20
|
},
|
|
29
21
|
instructions: {
|
|
30
22
|
en: "As you answer each question, select the option that best describes how you have felt and conducted yourself over the past 6 months.",
|
|
31
|
-
tr: "Her soruyu yanıtlarken, son 6 ay içinde kendinizi nasıl hissettiğinizi ve nasıl davrandığınızı en iyi tanımlayan seçeneği işaretleyin.",
|
|
32
|
-
de: "Wählen Sie bei jeder Frage die Option, die am besten beschreibt, wie Sie sich in den letzten 6 Monaten gefühlt und verhalten haben.",
|
|
33
|
-
zh: "回答每个问题时,请选择最能描述您在过去6个月中的感受和行为表现的选项。",
|
|
34
|
-
es: "Al responder cada pregunta, seleccione la opción que mejor describa cómo se ha sentido y comportado durante los últimos 6 meses.",
|
|
35
23
|
},
|
|
36
24
|
defaultLocale: "en",
|
|
37
25
|
options: [
|
|
38
|
-
{ value: 0, label: { en: "Never"
|
|
39
|
-
{ value: 1, label: { en: "Rarely"
|
|
40
|
-
{ value: 2, label: { en: "Sometimes"
|
|
41
|
-
{ value: 3, label: { en: "Often"
|
|
42
|
-
{ value: 4, label: { en: "Very often"
|
|
26
|
+
{ value: 0, label: { en: "Never" } },
|
|
27
|
+
{ value: 1, label: { en: "Rarely" } },
|
|
28
|
+
{ value: 2, label: { en: "Sometimes" } },
|
|
29
|
+
{ value: 3, label: { en: "Often" } },
|
|
30
|
+
{ value: 4, label: { en: "Very often" } },
|
|
43
31
|
],
|
|
44
32
|
questions: [
|
|
45
33
|
{
|
|
46
34
|
id: "asrs6-1",
|
|
47
35
|
text: {
|
|
48
36
|
en: "How often do you have trouble wrapping up the final details of a project, once the challenging parts have been done?",
|
|
49
|
-
tr: "Bir işin zor kısımlarını tamamladıktan sonra, son ayrıntıları toparlayıp işi bitirmekte ne sıklıkla güçlük yaşarsınız?",
|
|
50
|
-
de: "Wie oft haben Sie Schwierigkeiten, die letzten Details eines Projekts abzuschließen, nachdem die schwierigen Teile erledigt sind?",
|
|
51
|
-
zh: "在完成一项工作中最具挑战性的部分之后,您在收尾处理最后细节时遇到困难的频率有多高?",
|
|
52
|
-
es: "¿Con qué frecuencia tiene dificultades para ultimar los detalles finales de un proyecto, una vez terminadas las partes más difíciles?",
|
|
53
37
|
},
|
|
54
38
|
},
|
|
55
39
|
{
|
|
56
40
|
id: "asrs6-2",
|
|
57
41
|
text: {
|
|
58
42
|
en: "How often do you have difficulty getting things in order when you have to do a task that requires organization?",
|
|
59
|
-
tr: "Organizasyon gerektiren bir iş yapmanız gerektiğinde, işleri sıraya koymakta ne sıklıkla güçlük çekersiniz?",
|
|
60
|
-
de: "Wie oft haben Sie Schwierigkeiten, Ordnung in Dinge zu bringen, wenn Sie eine Aufgabe erledigen müssen, die Organisation erfordert?",
|
|
61
|
-
zh: "当您需要完成一项讲求条理的任务时,您在把事情安排得井井有条方面遇到困难的频率有多高?",
|
|
62
|
-
es: "¿Con qué frecuencia tiene dificultades para poner las cosas en orden cuando debe realizar una tarea que requiere organización?",
|
|
63
43
|
},
|
|
64
44
|
},
|
|
65
45
|
{
|
|
66
46
|
id: "asrs6-3",
|
|
67
47
|
text: {
|
|
68
48
|
en: "How often do you have problems remembering appointments or obligations?",
|
|
69
|
-
tr: "Randevularınızı ya da yükümlülüklerinizi hatırlamakta ne sıklıkla güçlük çekersiniz?",
|
|
70
|
-
de: "Wie oft haben Sie Probleme, sich an Termine oder Verpflichtungen zu erinnern?",
|
|
71
|
-
zh: "您忘记约会或应办事项的频率有多高?",
|
|
72
|
-
es: "¿Con qué frecuencia tiene problemas para recordar citas u obligaciones?",
|
|
73
49
|
},
|
|
74
50
|
},
|
|
75
51
|
{
|
|
76
52
|
id: "asrs6-4",
|
|
77
53
|
text: {
|
|
78
54
|
en: "When you have a task that requires a lot of thought, how often do you avoid or delay getting started?",
|
|
79
|
-
tr: "Çok fazla düşünmeyi gerektiren bir işiniz olduğunda, başlamayı ne sıklıkla erteler ya da başlamaktan kaçınırsınız?",
|
|
80
|
-
de: "Wie oft vermeiden oder verzögern Sie den Beginn einer Aufgabe, die viel Nachdenken erfordert?",
|
|
81
|
-
zh: "当您有一项需要动很多脑筋的任务时,您回避或拖延着手去做的频率有多高?",
|
|
82
|
-
es: "Cuando tiene una tarea que requiere pensar mucho, ¿con qué frecuencia evita o retrasa empezarla?",
|
|
83
55
|
},
|
|
84
56
|
},
|
|
85
57
|
{
|
|
86
58
|
id: "asrs6-5",
|
|
87
59
|
text: {
|
|
88
60
|
en: "How often do you fidget or squirm with your hands or feet when you have to sit down for a long time?",
|
|
89
|
-
tr: "Uzun süre oturmanız gerektiğinde, ne sıklıkla ellerinizi ya da ayaklarınızı kıpırdatır veya yerinizde kımıldanırsınız?",
|
|
90
|
-
de: "Wie oft zappeln Sie mit Händen oder Füßen, wenn Sie längere Zeit sitzen müssen?",
|
|
91
|
-
zh: "当您必须长时间坐着时,您手脚不停地动、坐立不安的频率有多高?",
|
|
92
|
-
es: "¿Con qué frecuencia mueve o agita las manos o los pies cuando tiene que permanecer sentado durante mucho tiempo?",
|
|
93
61
|
},
|
|
94
62
|
},
|
|
95
63
|
{
|
|
96
64
|
id: "asrs6-6",
|
|
97
65
|
text: {
|
|
98
66
|
en: "How often do you feel overly active and compelled to do things, like you were driven by a motor?",
|
|
99
|
-
tr: "Ne sıklıkla, sanki bir motor tarafından sürülüyormuşçasına kendinizi aşırı hareketli ve bir şeyler yapmaya zorlanmış hissedersiniz?",
|
|
100
|
-
de: "Wie oft fühlen Sie sich übermäßig aktiv und getrieben, Dinge zu tun, als würden Sie von einem Motor angetrieben?",
|
|
101
|
-
zh: "您感到自己过度活跃、不得不做些什么、就像被马达驱动着一样的频率有多高?",
|
|
102
|
-
es: "¿Con qué frecuencia se siente demasiado activo y con la necesidad de hacer cosas, como si lo impulsara un motor?",
|
|
103
67
|
},
|
|
104
68
|
},
|
|
105
69
|
],
|
|
106
70
|
scoring: {
|
|
107
71
|
kind: "count",
|
|
72
|
+
missing: { strategy: "require-complete" },
|
|
108
73
|
items: [
|
|
109
74
|
{ questionId: "asrs6-1", minValue: 2 },
|
|
110
75
|
{ questionId: "asrs6-2", minValue: 2 },
|
|
@@ -120,10 +85,6 @@ export const asrs6: AssessmentDefinition = {
|
|
|
120
85
|
max: 3,
|
|
121
86
|
label: {
|
|
122
87
|
en: "Symptoms not consistent with adult ADHD",
|
|
123
|
-
tr: "Belirtiler erişkin DEHB ile uyumlu değil",
|
|
124
|
-
de: "Symptome nicht mit ADHS im Erwachsenenalter vereinbar",
|
|
125
|
-
zh: "症状与成人ADHD不相符",
|
|
126
|
-
es: "Síntomas no compatibles con TDAH en adultos",
|
|
127
88
|
},
|
|
128
89
|
},
|
|
129
90
|
{
|
|
@@ -132,10 +93,6 @@ export const asrs6: AssessmentDefinition = {
|
|
|
132
93
|
max: 6,
|
|
133
94
|
label: {
|
|
134
95
|
en: "Symptoms highly consistent with adult ADHD — further investigation warranted",
|
|
135
|
-
tr: "Belirtiler erişkin DEHB ile yüksek düzeyde uyumlu — ileri değerlendirme gerekir",
|
|
136
|
-
de: "Symptome in hohem Maße mit ADHS im Erwachsenenalter vereinbar — weitere Abklärung angezeigt",
|
|
137
|
-
zh: "症状与成人ADHD高度相符——建议作进一步评估",
|
|
138
|
-
es: "Síntomas altamente compatibles con TDAH en adultos — se recomienda una evaluación adicional",
|
|
139
96
|
},
|
|
140
97
|
},
|
|
141
98
|
],
|