@htilabs/platform-common-models 0.17.0 → 0.18.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/dist/agency-BHv54o79.d.ts +484 -0
- package/dist/agency-Ca4pCOOf.d.ts +342 -0
- package/dist/agency-DYCv839V.d.cts +342 -0
- package/dist/agency-Djp57S71.d.cts +484 -0
- package/dist/constants/index.cjs +952 -0
- package/dist/constants/index.cjs.map +1 -1
- package/dist/constants/index.d.cts +3 -1
- package/dist/constants/index.d.ts +3 -1
- package/dist/constants/index.js +920 -0
- package/dist/constants/index.js.map +1 -1
- package/dist/{cvcEntry-ctHTp2df.d.cts → cvcEntry-0BIB9sen.d.cts} +36 -36
- package/dist/{cvcEntry-ctHTp2df.d.ts → cvcEntry-0BIB9sen.d.ts} +36 -36
- package/dist/cvcs/index.cjs +114 -62
- package/dist/cvcs/index.cjs.map +1 -1
- package/dist/cvcs/index.d.cts +112 -59
- package/dist/cvcs/index.d.ts +112 -59
- package/dist/cvcs/index.js +114 -62
- package/dist/cvcs/index.js.map +1 -1
- package/dist/enums/index.cjs +1 -0
- package/dist/enums/index.cjs.map +1 -1
- package/dist/enums/index.d.cts +2 -1
- package/dist/enums/index.d.ts +2 -1
- package/dist/enums/index.js +1 -0
- package/dist/enums/index.js.map +1 -1
- package/dist/{index-4DiJrn7y.d.ts → index-CDoqrfc1.d.ts} +1 -1
- package/dist/{index-qreOzXYS.d.cts → index-Zu_mOJRn.d.cts} +1 -1
- package/dist/index.cjs +1654 -1077
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -4
- package/dist/index.d.ts +6 -4
- package/dist/index.js +1600 -1076
- package/dist/index.js.map +1 -1
- package/dist/models/index.d.cts +2 -2
- package/dist/models/index.d.ts +2 -2
- package/dist/org-type-BYQb9Qzq.d.ts +366 -0
- package/dist/org-type-D_FG4KdN.d.cts +366 -0
- package/dist/{platform-auth-CrF5U_JH.d.cts → platform-auth-CvAYFVhK.d.cts} +39 -0
- package/dist/{platform-auth-CrF5U_JH.d.ts → platform-auth-CvAYFVhK.d.ts} +39 -0
- package/dist/schemas/index.cjs +977 -2
- package/dist/schemas/index.cjs.map +1 -1
- package/dist/schemas/index.d.cts +14 -11
- package/dist/schemas/index.d.ts +14 -11
- package/dist/schemas/index.js +962 -1
- package/dist/schemas/index.js.map +1 -1
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/validation/index.cjs +894 -2
- package/dist/validation/index.cjs.map +1 -1
- package/dist/validation/index.d.cts +5 -1
- package/dist/validation/index.d.ts +5 -1
- package/dist/validation/index.js +884 -1
- package/dist/validation/index.js.map +1 -1
- package/package.json +26 -27
- package/src/__tests__/__snapshots__/cvc-sot.snap +2 -2
- package/src/__tests__/cvc-sot-snapshot.test.ts +5 -5
- package/src/__tests__/cvc-structural.test.ts +1 -1
- package/src/__tests__/org-type-contract.test.ts +1353 -0
- package/src/__tests__/referral-entity-category-canon.test.ts +255 -81
- package/src/constants/ic.ts +45 -0
- package/src/constants/index.ts +1 -0
- package/src/constants/org-type.ts +703 -0
- package/src/cvcs/index.ts +1 -1
- package/src/cvcs/{referralEntityCategory.v1.1.0.json → referralEntityCategory.v1.2.0.json} +111 -59
- package/src/generated/cvc-enums.ts +2 -1
- package/src/index.ts +23 -0
- package/src/schemas/agency.ts +481 -0
- package/src/schemas/index.ts +24 -0
- package/src/validation/agency.ts +119 -0
- package/src/validation/index.ts +1 -0
- package/dist/team-C4LJ5Tex.d.cts +0 -333
- package/dist/team-C4LJ5Tex.d.ts +0 -333
|
@@ -17,11 +17,13 @@
|
|
|
17
17
|
*
|
|
18
18
|
* It also pins the compatibility contract (consumers persist these KEYS):
|
|
19
19
|
* every v1.0.0 key is still an entry at its v1.0.0 positional code, and the
|
|
20
|
-
*
|
|
20
|
+
* four new leaves exist.
|
|
21
21
|
*
|
|
22
|
-
* And it pins the ONE
|
|
23
|
-
*
|
|
24
|
-
*
|
|
22
|
+
* And it pins the ONE deliberately irregular shape: `02-02-01-00` Hotline was
|
|
23
|
+
* HELD until 0.18.0 and is now carried at the next free ordinal (048-006-003)
|
|
24
|
+
* with its two canon children RE-PARENTED under it — their v1.0.0 codes do
|
|
25
|
+
* not move (a positional code is identity; `parentCode` is hierarchy). See
|
|
26
|
+
* `HOTLINE_REPARENTED` in scripts/gen-referral-entity-category.py.
|
|
25
27
|
*/
|
|
26
28
|
|
|
27
29
|
import { readFileSync } from "node:fs";
|
|
@@ -33,7 +35,12 @@ import { describe, it, expect } from "vitest";
|
|
|
33
35
|
import { ReferralEntityCategoryKeys } from "../generated/cvc-enums.js";
|
|
34
36
|
|
|
35
37
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
36
|
-
const FILE = path.join(
|
|
38
|
+
const FILE = path.join(
|
|
39
|
+
here,
|
|
40
|
+
"..",
|
|
41
|
+
"cvcs",
|
|
42
|
+
"referralEntityCategory.v1.2.0.json",
|
|
43
|
+
);
|
|
37
44
|
|
|
38
45
|
interface Entry {
|
|
39
46
|
code: string;
|
|
@@ -44,13 +51,18 @@ interface Entry {
|
|
|
44
51
|
childCodes: string[];
|
|
45
52
|
definition: string | null;
|
|
46
53
|
canonicalCode?: string;
|
|
54
|
+
enumConstant?: string;
|
|
47
55
|
}
|
|
48
56
|
interface Envelope {
|
|
49
57
|
domain: string;
|
|
50
58
|
version: string;
|
|
51
59
|
_status: string;
|
|
52
60
|
_source: string;
|
|
53
|
-
_supersedes: {
|
|
61
|
+
_supersedes: {
|
|
62
|
+
version: string;
|
|
63
|
+
keyMap: Record<string, string | null>;
|
|
64
|
+
retiredCodes: unknown[];
|
|
65
|
+
};
|
|
54
66
|
_notCarried: { canonicalCode: string; name: string; reason: string }[];
|
|
55
67
|
entries: Entry[];
|
|
56
68
|
}
|
|
@@ -75,17 +87,33 @@ const CANON: readonly (readonly [string, string, string | null, boolean])[] = [
|
|
|
75
87
|
["00-00-02-00", "anonymous", null, true],
|
|
76
88
|
["00-00-03-00", "data_not_collected", null, true],
|
|
77
89
|
["01-00-01-00", "self_referred", "Self-referred", true],
|
|
78
|
-
[
|
|
90
|
+
[
|
|
91
|
+
"01-00-02-00",
|
|
92
|
+
"family_guardian_friend",
|
|
93
|
+
"Family/guardian/friend/foster parent",
|
|
94
|
+
true,
|
|
95
|
+
],
|
|
79
96
|
["01-00-03-00", "peer", "Peer / another client", true],
|
|
80
97
|
["01-00-04-00", "other_individual", "Other individual", true],
|
|
81
|
-
[
|
|
98
|
+
[
|
|
99
|
+
"02-01-00-00",
|
|
100
|
+
"housing_shelter_continuum",
|
|
101
|
+
"Housing / Shelter continuum",
|
|
102
|
+
false,
|
|
103
|
+
],
|
|
82
104
|
["02-01-01-00", "outreach_project", "Outreach Project", true],
|
|
83
105
|
["02-01-02-00", "temporary_shelter", "Temporary Shelter", true],
|
|
84
106
|
["02-01-03-00", "residential_project", "Residential Project", true],
|
|
85
107
|
["02-02-00-00", "hotlines", "Hotlines", false],
|
|
108
|
+
["02-02-01-00", "hotline", "Hotline", true],
|
|
86
109
|
["02-02-01-01", "national_hotline", "National hotline", true],
|
|
87
110
|
["02-02-01-02", "local_other_hotline", "Local/other hotline", true],
|
|
88
|
-
[
|
|
111
|
+
[
|
|
112
|
+
"02-03-00-00",
|
|
113
|
+
"justice_protective_systems",
|
|
114
|
+
"Justice & Protective Systems",
|
|
115
|
+
false,
|
|
116
|
+
],
|
|
89
117
|
["02-03-01-00", "child_welfare_cps", "Child Welfare / CPS", true],
|
|
90
118
|
["02-03-02-00", "juvenile_justice", "Juvenile Justice", true],
|
|
91
119
|
["02-03-03-00", "law_enforcement", "Law enforcement / Police", true],
|
|
@@ -97,9 +125,24 @@ const CANON: readonly (readonly [string, string, string | null, boolean])[] = [
|
|
|
97
125
|
["02-03-04-00", "courts_prosecution", "Courts or prosecution", true],
|
|
98
126
|
["02-03-05-00", "correction_probation", "Correction / probation", true],
|
|
99
127
|
// Notion label; the yaml port omits "(APS)".
|
|
100
|
-
[
|
|
101
|
-
|
|
102
|
-
|
|
128
|
+
[
|
|
129
|
+
"02-03-06-00",
|
|
130
|
+
"adult_protective_services",
|
|
131
|
+
"Adult Protective Services (APS)",
|
|
132
|
+
true,
|
|
133
|
+
],
|
|
134
|
+
[
|
|
135
|
+
"02-04-00-00",
|
|
136
|
+
"health_behavioral_health",
|
|
137
|
+
"Health / behavioral health",
|
|
138
|
+
false,
|
|
139
|
+
],
|
|
140
|
+
[
|
|
141
|
+
"02-04-01-00",
|
|
142
|
+
"inpatient_psychiatric_facility",
|
|
143
|
+
"Inpatient psychiatric facility",
|
|
144
|
+
true,
|
|
145
|
+
],
|
|
103
146
|
[
|
|
104
147
|
"02-04-02-00",
|
|
105
148
|
"healthcare_provider",
|
|
@@ -107,7 +150,12 @@ const CANON: readonly (readonly [string, string, string | null, boolean])[] = [
|
|
|
107
150
|
true,
|
|
108
151
|
],
|
|
109
152
|
["02-05-00-00", "education", "Education", false],
|
|
110
|
-
[
|
|
153
|
+
[
|
|
154
|
+
"02-05-01-00",
|
|
155
|
+
"school_academic_institution",
|
|
156
|
+
"School / academic institution",
|
|
157
|
+
true,
|
|
158
|
+
],
|
|
111
159
|
[
|
|
112
160
|
"02-06-00-00",
|
|
113
161
|
"victim_community_service_providers",
|
|
@@ -128,14 +176,29 @@ const CANON: readonly (readonly [string, string, string | null, boolean])[] = [
|
|
|
128
176
|
true,
|
|
129
177
|
],
|
|
130
178
|
["02-06-04-00", "legal_services_provider", "Legal services provider", true],
|
|
131
|
-
[
|
|
179
|
+
[
|
|
180
|
+
"02-07-00-00",
|
|
181
|
+
"coordination_governance",
|
|
182
|
+
"Coordination & Governance",
|
|
183
|
+
false,
|
|
184
|
+
],
|
|
132
185
|
["02-07-01-00", "mdt", "Multidisciplinary team (MDT)", true],
|
|
133
186
|
["02-07-02-00", "coalition", "Coalition (state/regional coalition)", true],
|
|
134
187
|
["02-08-00-00", "internal", "Internal", false],
|
|
135
|
-
[
|
|
188
|
+
[
|
|
189
|
+
"02-08-01-00",
|
|
190
|
+
"own_agency_internal",
|
|
191
|
+
"Own agency / internal referral",
|
|
192
|
+
true,
|
|
193
|
+
],
|
|
136
194
|
["02-09-00-00", "other_entity", "Other", false],
|
|
137
195
|
["02-09-01-00", "employer", "Employer", true],
|
|
138
|
-
[
|
|
196
|
+
[
|
|
197
|
+
"02-09-02-00",
|
|
198
|
+
"benefits_public_assistance_office",
|
|
199
|
+
"Benefits/public assistance office",
|
|
200
|
+
true,
|
|
201
|
+
],
|
|
139
202
|
["02-09-03-00", "other_organization", "Other Organization", true],
|
|
140
203
|
];
|
|
141
204
|
|
|
@@ -149,53 +212,88 @@ const CANON: readonly (readonly [string, string, string | null, boolean])[] = [
|
|
|
149
212
|
const CANON_DEFINITIONS: Readonly<Record<string, string | null>> = {
|
|
150
213
|
"00-00-01-00": "Referral entity category unknown.",
|
|
151
214
|
"00-00-02-00": "Referral entity category withheld or redacted.",
|
|
152
|
-
"00-00-03-00":
|
|
153
|
-
|
|
154
|
-
"01-00-
|
|
155
|
-
|
|
156
|
-
"01-00-
|
|
157
|
-
|
|
158
|
-
"
|
|
159
|
-
|
|
215
|
+
"00-00-03-00":
|
|
216
|
+
"Referral entity category not collected or no signal captured.",
|
|
217
|
+
"01-00-01-00":
|
|
218
|
+
"Client initiated contact or presented for services without a third-party referrer.",
|
|
219
|
+
"01-00-02-00":
|
|
220
|
+
"A caregiver, family member, or close personal support person initiated the referral.",
|
|
221
|
+
"01-00-03-00":
|
|
222
|
+
"Another current or former client initiated or encouraged the referral.",
|
|
223
|
+
"01-00-04-00":
|
|
224
|
+
"A non-family individual initiated the referral (e.g., neighbor, community member, clergy).",
|
|
225
|
+
"02-01-00-00":
|
|
226
|
+
"Primary function is outreach engagement, emergency shelter, or residential shelter/housing programs.",
|
|
227
|
+
"02-01-01-00":
|
|
228
|
+
"Street/community outreach program that engaged the client prior to enrollment.",
|
|
229
|
+
"02-01-02-00":
|
|
230
|
+
"Emergency/crisis shelter or short-term temporary housing program.",
|
|
160
231
|
"02-01-03-00": "Longer-term residential or transitional living program.",
|
|
161
|
-
"02-02-00-00":
|
|
232
|
+
"02-02-00-00":
|
|
233
|
+
"Crisis lines or call centers that connect a person to services.",
|
|
234
|
+
"02-02-01-00":
|
|
235
|
+
"Crisis hotline or call center that connected the client to services.",
|
|
162
236
|
"02-02-01-01": "National-level hotline network.",
|
|
163
237
|
"02-02-01-02": "Local/regional hotline or non-national hotline.",
|
|
164
238
|
"02-03-00-00": null,
|
|
165
|
-
"02-03-01-00":
|
|
166
|
-
|
|
167
|
-
"02-03-
|
|
239
|
+
"02-03-01-00":
|
|
240
|
+
"Government child protection agency responsible for investigating child abuse/neglect and ensuring child safety.",
|
|
241
|
+
"02-03-02-00":
|
|
242
|
+
"Juvenile probation/detention/court-related juvenile justice system initiated the referral.",
|
|
243
|
+
"02-03-03-00":
|
|
244
|
+
"Law enforcement agency initiated the referral (local/state/federal).",
|
|
168
245
|
"02-03-03-01": "City/county police or sheriff.",
|
|
169
|
-
"02-03-03-02":
|
|
246
|
+
"02-03-03-02":
|
|
247
|
+
"State-level law enforcement agency (e.g., state police/highway patrol/state bureau of investigation) acting in an official capacity.",
|
|
170
248
|
"02-03-03-03": "Federal law enforcement agency (e.g., FBI, DHS/ICE).",
|
|
171
249
|
"02-03-03-04": "Tribal police.",
|
|
172
|
-
"02-03-03-05":
|
|
250
|
+
"02-03-03-05":
|
|
251
|
+
"Other law enforcement entity, or law enforcement type is unknown.",
|
|
173
252
|
"02-03-04-00": "Court or prosecution entity (not law enforcement).",
|
|
174
|
-
"02-03-05-00":
|
|
175
|
-
|
|
176
|
-
"02-
|
|
253
|
+
"02-03-05-00":
|
|
254
|
+
"Corrections, probation, parole, or community supervision entity (not law enforcement).",
|
|
255
|
+
"02-03-06-00":
|
|
256
|
+
"Government adult protection agency responsible for investigating abuse, neglect, self-neglect, or exploitation of vulnerable or older adults and ensuring their safety. Adult analog of Child Welfare / CPS.",
|
|
257
|
+
"02-04-00-00":
|
|
258
|
+
"Hospitals and healthcare providers (including mental health inpatient facilities).",
|
|
177
259
|
"02-04-01-00": "Inpatient psychiatric hospital or psychiatric facility.",
|
|
178
|
-
"02-04-02-00":
|
|
260
|
+
"02-04-02-00":
|
|
261
|
+
"Any non-inpatient healthcare provider (clinic, hospital, outpatient provider, behavioral health clinic, SANE program, substance abuse clinic, etc.).",
|
|
179
262
|
"02-05-00-00": "Parent category for education-related institutions.",
|
|
180
263
|
"02-05-01-00": "School system or educational institution.",
|
|
181
|
-
"02-06-00-00":
|
|
182
|
-
|
|
183
|
-
"02-06-
|
|
184
|
-
|
|
185
|
-
"02-06-
|
|
186
|
-
|
|
187
|
-
"02-
|
|
188
|
-
|
|
189
|
-
"02-
|
|
190
|
-
|
|
191
|
-
"02-
|
|
192
|
-
|
|
193
|
-
"02-
|
|
194
|
-
|
|
264
|
+
"02-06-00-00":
|
|
265
|
+
"Parent category for victim service providers and community-based service providers.",
|
|
266
|
+
"02-06-01-00":
|
|
267
|
+
"A child-centered multidisciplinary center coordinating investigation and services (forensic interview, coordination, referrals, sometimes medical or therapy) for child victims.",
|
|
268
|
+
"02-06-02-00":
|
|
269
|
+
"Organization whose primary mission is to provide services to victims/survivors of crime (VOCA-aligned breadth: rape crisis centers, DV/dating-violence/stalking programs, anti-trafficking programs, child victim centers, homicide-survivor organizations, and similar). Whether the organization is specifically a DV/SA victim service provider — the fact HMIS 2.01 needs (Comparable Database) — is a separate per-organization attribute, self-attested by the organization at onboarding (Platform survey / Agency Hub “My agency info”), not part of this category.",
|
|
270
|
+
"02-06-03-00":
|
|
271
|
+
"The residual community-based provider (“other community-based service provider”): a non-VSP offering practical support services, navigation, or stabilization resources that is not primarily a VSP, a legal services provider, a housing/shelter project, a government justice agency, a healthcare provider, a school, a hotline, or a public benefits office. (Ex: youth drop-in center; food pantry; reentry program.)",
|
|
272
|
+
"02-06-04-00":
|
|
273
|
+
"Civil legal aid organization, immigration attorneys, victim-rights law clinic, or similar provider of legal help to the client. Distinct from Courts or prosecution (the justice-system entity itself): this is getting a lawyer's help, not being referred into proceedings.",
|
|
274
|
+
"02-07-00-00":
|
|
275
|
+
"Parent category for coordination and governance bodies (e.g., MDTs, coalitions).",
|
|
276
|
+
"02-07-01-00":
|
|
277
|
+
"A case-level team: professionals from multiple agencies (law enforcement, child welfare, medical, advocacy) who review and coordinate individual cases together; referrals arise out of case review. (E.g., a county trafficking MDT or a CAC-based team.)",
|
|
278
|
+
"02-07-02-00":
|
|
279
|
+
"A state or regional membership body of organizations coordinating at the system level — training, standards, policy, funding — not individual cases; referrals from a coalition are typically warm handoffs to a member organization.",
|
|
280
|
+
"02-08-00-00":
|
|
281
|
+
"Parent category for internal referrals within the same umbrella agency.",
|
|
282
|
+
"02-08-01-00":
|
|
283
|
+
"Client was referred from another program or unit within the same umbrella agency.",
|
|
284
|
+
"02-09-00-00":
|
|
285
|
+
"Parent category for other organizations not captured by the primary sectors.",
|
|
286
|
+
"02-09-01-00":
|
|
287
|
+
"Employer, HR, or employee assistance program initiated the referral.",
|
|
288
|
+
"02-09-02-00":
|
|
289
|
+
"Government office administering public benefits or eligibility and enrollment (e.g., SNAP, TANF, Medicaid, SSA).",
|
|
290
|
+
"02-09-03-00":
|
|
291
|
+
"Other organization not otherwise captured by the listed categories.",
|
|
195
292
|
};
|
|
196
293
|
|
|
197
294
|
/** The canon row deliberately NOT carried (generator `HELD`). */
|
|
198
|
-
|
|
295
|
+
/** The canon row carried late (0.18.0) at a minted ordinal, with its children re-parented. */
|
|
296
|
+
const HOTLINE_CANON_CODE = "02-02-01-00";
|
|
199
297
|
|
|
200
298
|
const code = (...segs: number[]): string =>
|
|
201
299
|
[48, ...segs, ...Array(6 - segs.length).fill(0)]
|
|
@@ -253,7 +351,12 @@ const V1_0_0: Readonly<Record<string, string>> = {
|
|
|
253
351
|
const ADDED: readonly (readonly [string, string, string])[] = [
|
|
254
352
|
["adult_protective_services", code(7, 6), "justice_protective_systems"],
|
|
255
353
|
["school_academic_institution", code(9, 1), "education"],
|
|
256
|
-
[
|
|
354
|
+
[
|
|
355
|
+
"legal_services_provider",
|
|
356
|
+
code(10, 4),
|
|
357
|
+
"victim_community_service_providers",
|
|
358
|
+
],
|
|
359
|
+
["hotline", code(6, 3), "hotlines"], // 0.18.0 — next free ordinal under Hotlines
|
|
257
360
|
];
|
|
258
361
|
|
|
259
362
|
/** Canon's parent of a canon code, read off the code itself. */
|
|
@@ -266,24 +369,28 @@ function canonParent(c: string): string | null {
|
|
|
266
369
|
}
|
|
267
370
|
|
|
268
371
|
describe("CVC-48 referral_entity_category — canon v1.3 mirror", () => {
|
|
269
|
-
it("is v1.
|
|
372
|
+
it("is v1.2.0 of the referral_entity_category domain, pinned to its canon source", () => {
|
|
270
373
|
expect(env.domain).toBe("referral_entity_category");
|
|
271
|
-
expect(env.version).toBe("1.
|
|
272
|
-
expect(env._source).toMatch(
|
|
374
|
+
expect(env.version).toBe("1.2.0");
|
|
375
|
+
expect(env._source).toMatch(
|
|
376
|
+
/core_referral_entity_category\.yaml @ [0-9a-f]{8} /,
|
|
377
|
+
);
|
|
273
378
|
expect(env._source).toContain("yaml v1.3");
|
|
274
379
|
expect(env._status.startsWith("CANONICAL")).toBe(true);
|
|
275
380
|
});
|
|
276
381
|
|
|
277
|
-
it("carries exactly the
|
|
382
|
+
it("carries exactly the 46 canon codes in the table, each once (+ missingness_root)", () => {
|
|
278
383
|
const carried = env.entries
|
|
279
384
|
.filter((e) => e.canonicalCode !== undefined)
|
|
280
385
|
.map((e) => e.canonicalCode);
|
|
281
386
|
expect([...carried].sort()).toEqual(CANON.map((r) => r[0]).sort());
|
|
282
|
-
expect(new Set(carried).size).toBe(
|
|
283
|
-
expect(
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
387
|
+
expect(new Set(carried).size).toBe(46);
|
|
388
|
+
expect(
|
|
389
|
+
env.entries
|
|
390
|
+
.filter((e) => e.canonicalCode === undefined)
|
|
391
|
+
.map((e) => e.key),
|
|
392
|
+
).toEqual(["missingness_root"]);
|
|
393
|
+
expect(env.entries.length).toBe(47);
|
|
287
394
|
});
|
|
288
395
|
|
|
289
396
|
for (const [canonCode, key, name, selectable] of CANON) {
|
|
@@ -292,14 +399,14 @@ describe("CVC-48 referral_entity_category — canon v1.3 mirror", () => {
|
|
|
292
399
|
expect(e.canonicalCode).toBe(canonCode);
|
|
293
400
|
if (name !== null) expect(e.title).toBe(name);
|
|
294
401
|
expect(e.selectable).toBe(selectable);
|
|
295
|
-
expect(e.definition, "canon definition").toBe(
|
|
296
|
-
|
|
402
|
+
expect(e.definition, "canon definition").toBe(
|
|
403
|
+
CANON_DEFINITIONS[canonCode],
|
|
404
|
+
);
|
|
405
|
+
const parent =
|
|
406
|
+
e.parentCode === null ? null : (byCode.get(e.parentCode) ?? null);
|
|
297
407
|
const want = canonParent(canonCode);
|
|
298
408
|
if (canonCode.startsWith("00-")) {
|
|
299
409
|
expect(parent?.key).toBe("missingness_root");
|
|
300
|
-
} else if (want === HELD_CANON_CODE) {
|
|
301
|
-
// Canon parent is the held Hotline row: sits under ITS parent instead.
|
|
302
|
-
expect(parent?.canonicalCode).toBe(canonParent(HELD_CANON_CODE));
|
|
303
410
|
} else {
|
|
304
411
|
expect(parent?.canonicalCode ?? null).toBe(want);
|
|
305
412
|
}
|
|
@@ -314,7 +421,9 @@ describe("CVC-48 referral_entity_category — canon v1.3 mirror", () => {
|
|
|
314
421
|
|
|
315
422
|
it("Education is a heading; School / academic institution is its only leaf", () => {
|
|
316
423
|
expect(get("education").selectable).toBe(false);
|
|
317
|
-
expect(get("education").childCodes).toEqual([
|
|
424
|
+
expect(get("education").childCodes).toEqual([
|
|
425
|
+
get("school_academic_institution").code,
|
|
426
|
+
]);
|
|
318
427
|
});
|
|
319
428
|
|
|
320
429
|
it("Law enforcement / Police is selectable and keeps its five optional children", () => {
|
|
@@ -322,18 +431,24 @@ describe("CVC-48 referral_entity_category — canon v1.3 mirror", () => {
|
|
|
322
431
|
expect(get("law_enforcement").childCodes.length).toBe(5);
|
|
323
432
|
});
|
|
324
433
|
|
|
325
|
-
it("canon Hotline (02-02-01-00) is
|
|
326
|
-
|
|
327
|
-
expect(
|
|
328
|
-
expect(
|
|
329
|
-
expect(
|
|
330
|
-
|
|
331
|
-
expect(
|
|
332
|
-
|
|
333
|
-
expect(get("
|
|
434
|
+
it("canon Hotline (02-02-01-00) is CARRIED since 0.18.0 at the next free ordinal, children re-parented, nothing held", () => {
|
|
435
|
+
const h = get("hotline");
|
|
436
|
+
expect(h.canonicalCode).toBe(HOTLINE_CANON_CODE);
|
|
437
|
+
expect(h.code).toBe(code(6, 3)); // minted, not renumbered: 001/002 are the children's v1.0.0 codes
|
|
438
|
+
expect(h.selectable).toBe(true);
|
|
439
|
+
expect(h.parentCode).toBe(get("hotlines").code);
|
|
440
|
+
expect(h.enumConstant).toBe("ORGANIZATION_CALLCENTERS_HOTLINE");
|
|
441
|
+
// Canon's tree is restored: the two children sit UNDER Hotline, codes unchanged.
|
|
442
|
+
expect(get("national_hotline").code).toBe(code(6, 1));
|
|
443
|
+
expect(get("local_other_hotline").code).toBe(code(6, 2));
|
|
444
|
+
expect(get("national_hotline").parentCode).toBe(h.code);
|
|
445
|
+
expect(get("local_other_hotline").parentCode).toBe(h.code);
|
|
446
|
+
expect(h.childCodes).toEqual([
|
|
334
447
|
get("national_hotline").code,
|
|
335
448
|
get("local_other_hotline").code,
|
|
336
449
|
]);
|
|
450
|
+
expect(get("hotlines").childCodes).toEqual([h.code]);
|
|
451
|
+
expect(env._notCarried).toEqual([]);
|
|
337
452
|
});
|
|
338
453
|
});
|
|
339
454
|
|
|
@@ -351,8 +466,9 @@ describe("CVC-48 v1.1.0 is ADDITIVE — stored v1.0.0 keys stay readable", () =>
|
|
|
351
466
|
|
|
352
467
|
it("every v1.0.0 key is still in the generated ReferralEntityCategoryKeys map", () => {
|
|
353
468
|
const generated = ReferralEntityCategoryKeys as Record<string, string>;
|
|
354
|
-
for (const [key, c] of Object.entries(V1_0_0))
|
|
355
|
-
|
|
469
|
+
for (const [key, c] of Object.entries(V1_0_0))
|
|
470
|
+
expect(generated[key], key).toBe(c);
|
|
471
|
+
expect(Object.keys(generated).length).toBe(47);
|
|
356
472
|
});
|
|
357
473
|
|
|
358
474
|
for (const [key, c, parentKey] of ADDED) {
|
|
@@ -360,11 +476,21 @@ describe("CVC-48 v1.1.0 is ADDITIVE — stored v1.0.0 keys stay readable", () =>
|
|
|
360
476
|
const e = get(key);
|
|
361
477
|
expect(e.code).toBe(c);
|
|
362
478
|
expect(e.selectable).toBe(true);
|
|
363
|
-
|
|
479
|
+
// `hotline` is the one added leaf with children: the two v1.0.0 hotline rows re-parented under it.
|
|
480
|
+
expect(e.childCodes).toEqual(
|
|
481
|
+
key === "hotline"
|
|
482
|
+
? [get("national_hotline").code, get("local_other_hotline").code]
|
|
483
|
+
: [],
|
|
484
|
+
);
|
|
364
485
|
expect(e.parentCode).toBe(get(parentKey).code);
|
|
365
486
|
expect(e.definition).toBeTruthy();
|
|
366
|
-
expect(
|
|
367
|
-
|
|
487
|
+
expect(
|
|
488
|
+
Object.values(V1_0_0),
|
|
489
|
+
`${key} reuses a v1.0.0 code`,
|
|
490
|
+
).not.toContain(c);
|
|
491
|
+
expect((ReferralEntityCategoryKeys as Record<string, string>)[key]).toBe(
|
|
492
|
+
c,
|
|
493
|
+
);
|
|
368
494
|
});
|
|
369
495
|
}
|
|
370
496
|
|
|
@@ -376,8 +502,56 @@ describe("CVC-48 v1.1.0 is ADDITIVE — stored v1.0.0 keys stay readable", () =>
|
|
|
376
502
|
|
|
377
503
|
it("_supersedes maps every v1.0.0 key to itself — nothing was renamed or retired", () => {
|
|
378
504
|
expect(env._supersedes.version).toBe("1.0.0");
|
|
379
|
-
expect(Object.keys(env._supersedes.keyMap).sort()).toEqual(
|
|
380
|
-
|
|
505
|
+
expect(Object.keys(env._supersedes.keyMap).sort()).toEqual(
|
|
506
|
+
Object.keys(V1_0_0).sort(),
|
|
507
|
+
);
|
|
508
|
+
for (const [k, v] of Object.entries(env._supersedes.keyMap))
|
|
509
|
+
expect(v, k).toBe(k);
|
|
381
510
|
expect(env._supersedes.retiredCodes).toEqual([]);
|
|
382
511
|
});
|
|
383
512
|
});
|
|
513
|
+
|
|
514
|
+
// ─── enumConstant: canon's Sean-spec constant (IC-58 § IV), carried per row ──
|
|
515
|
+
// The org registry's `type` column and PAVE's `agencies.typeId` spell the type
|
|
516
|
+
// this way; `constants/org-type.ts` resolves either spelling to the key.
|
|
517
|
+
describe("enumConstant (canon's Sean-spec constant) rides every canon-backed row", () => {
|
|
518
|
+
const ENUM: Array<[string, string]> = [
|
|
519
|
+
["unknown", "EMPTY_RESPONSE_UNKNOWN"],
|
|
520
|
+
["self_referred", "INDIVIDUAL_PERSON_SELFREFERRED"],
|
|
521
|
+
["housing_shelter_continuum", "ORGANIZATION_HOUSING"],
|
|
522
|
+
["hotlines", "ORGANIZATION_CALLCENTERS"],
|
|
523
|
+
["hotline", "ORGANIZATION_CALLCENTERS_HOTLINE"],
|
|
524
|
+
["national_hotline", "ORGANIZATION_CALLCENTERS_HOTLINE_NATIONAL"],
|
|
525
|
+
["justice_protective_systems", "ORGANIZATION_JUSTICE"],
|
|
526
|
+
["child_welfare_cps", "ORGANIZATION_JUSTICE_CHILDWELFARE"],
|
|
527
|
+
["law_enforcement", "ORGANIZATION_JUSTICE_LAWENFORCEMENT"],
|
|
528
|
+
["tribal_law_enforcement", "ORGANIZATION_JUSTICE_LAWENFORCEMENT_TRIBAL"],
|
|
529
|
+
["adult_protective_services", "ORGANIZATION_JUSTICE_ADULTPROTECTIVE"],
|
|
530
|
+
["healthcare_provider", "ORGANIZATION_HEALTH_HEALTHCARE"],
|
|
531
|
+
["school_academic_institution", "ORGANIZATION_EDUCATION_SCHOOL"],
|
|
532
|
+
["child_advocacy_center", "ORGANIZATION_COMMUNITY_CHILDADVOCACYCENTER"],
|
|
533
|
+
["victim_service_provider", "ORGANIZATION_COMMUNITY_VICTIMSERVICEPROVIDER"],
|
|
534
|
+
["legal_services_provider", "ORGANIZATION_COMMUNITY_LEGALSERVICES"],
|
|
535
|
+
["coalition", "ORGANIZATION_GOVERNANCE_COALITION"],
|
|
536
|
+
["own_agency_internal", "ORGANIZATION_INTERNAL_OWNAGENCY"],
|
|
537
|
+
["other_organization", "ORGANIZATION_OTHER_UNSPECIFIED"],
|
|
538
|
+
];
|
|
539
|
+
|
|
540
|
+
it("every canon-backed row carries one; the house missingness root carries none", () => {
|
|
541
|
+
for (const e of env.entries) {
|
|
542
|
+
if (e.canonicalCode === undefined) {
|
|
543
|
+
expect(e.enumConstant, e.key).toBeUndefined();
|
|
544
|
+
} else {
|
|
545
|
+
expect(e.enumConstant, e.key).toMatch(/^[A-Z][A-Z0-9_]+$/);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
const all = env.entries.map((e) => e.enumConstant).filter(Boolean);
|
|
549
|
+
expect(new Set(all).size).toBe(all.length);
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
for (const [key, constant] of ENUM) {
|
|
553
|
+
it(`${key} ↔ ${constant}`, () => {
|
|
554
|
+
expect(byKey.get(key)?.enumConstant).toBe(constant);
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
});
|
package/src/constants/ic.ts
CHANGED
|
@@ -833,7 +833,23 @@ export const IC_57_LABELS: Record<IC57Value, string> = {
|
|
|
833
833
|
};
|
|
834
834
|
|
|
835
835
|
// ─── IC-58: Referral Entity Category ────────────────────────────────
|
|
836
|
+
//
|
|
837
|
+
// DEPRECATED FOR ORGANIZATION TYPE (platform-common #190). The constants in
|
|
838
|
+
// this section are the positional-number spelling Thread's `Organization.type`
|
|
839
|
+
// and `CaseRecord.referralEntity` store. They are not a vocabulary of their
|
|
840
|
+
// own — IC-58 is the concept, CVC-48 is the codeset — and `constants/org-type.ts`
|
|
841
|
+
// is the one place an org type is defined and read.
|
|
836
842
|
|
|
843
|
+
/**
|
|
844
|
+
* @deprecated for ORGANIZATION TYPE — the positional numbers Thread stores. IC-58 is the Information
|
|
845
|
+
* Concept; its only live codeset is CVC-48 `core-referral_entity_category`,
|
|
846
|
+
* and the one vocabulary for an agency's / organization's type is
|
|
847
|
+
* `constants/org-type.ts` (`ORG_TYPE_KEYS`, `resolveOrgTypeKey`, the ruling-
|
|
848
|
+
* table classifiers). These numbers are CVC-48's hierarchy in positional form;
|
|
849
|
+
* they stay exported only so values already stored can be read. Bridge a
|
|
850
|
+
* stored number with `resolveOrgTypeKeyFromLegacyNumeric` /
|
|
851
|
+
* `LEGACY_NUMERIC_TO_REFERRAL_ENTITY_KEY`; never write a new one.
|
|
852
|
+
*/
|
|
837
853
|
export const IC_58_REFERRAL_ENTITY = {
|
|
838
854
|
UNKNOWN: 0,
|
|
839
855
|
INTERNAL: 1,
|
|
@@ -873,6 +889,16 @@ export const IC_58_REFERRAL_ENTITY = {
|
|
|
873
889
|
export type IC58Value =
|
|
874
890
|
(typeof IC_58_REFERRAL_ENTITY)[keyof typeof IC_58_REFERRAL_ENTITY];
|
|
875
891
|
|
|
892
|
+
/**
|
|
893
|
+
* @deprecated for ORGANIZATION TYPE — labels for the positional numbers; CVC-48 titles are `orgTypeLabel(key)`. IC-58 is the Information
|
|
894
|
+
* Concept; its only live codeset is CVC-48 `core-referral_entity_category`,
|
|
895
|
+
* and the one vocabulary for an agency's / organization's type is
|
|
896
|
+
* `constants/org-type.ts` (`ORG_TYPE_KEYS`, `resolveOrgTypeKey`, the ruling-
|
|
897
|
+
* table classifiers). These numbers are CVC-48's hierarchy in positional form;
|
|
898
|
+
* they stay exported only so values already stored can be read. Bridge a
|
|
899
|
+
* stored number with `resolveOrgTypeKeyFromLegacyNumeric` /
|
|
900
|
+
* `LEGACY_NUMERIC_TO_REFERRAL_ENTITY_KEY`; never write a new one.
|
|
901
|
+
*/
|
|
876
902
|
export const IC_58_LABELS: Record<IC58Value, string> = {
|
|
877
903
|
0: "Unknown",
|
|
878
904
|
1: "Internal referral",
|
|
@@ -976,6 +1002,16 @@ export interface OrgTypeGroup {
|
|
|
976
1002
|
children: { value: number; label: string }[];
|
|
977
1003
|
}
|
|
978
1004
|
|
|
1005
|
+
/**
|
|
1006
|
+
* @deprecated for ORGANIZATION TYPE — a picker tree over the positional numbers; pickers offer `ORG_TYPE_SELECTABLE_KEYS` grouped by `orgTypeSector`. IC-58 is the Information
|
|
1007
|
+
* Concept; its only live codeset is CVC-48 `core-referral_entity_category`,
|
|
1008
|
+
* and the one vocabulary for an agency's / organization's type is
|
|
1009
|
+
* `constants/org-type.ts` (`ORG_TYPE_KEYS`, `resolveOrgTypeKey`, the ruling-
|
|
1010
|
+
* table classifiers). These numbers are CVC-48's hierarchy in positional form;
|
|
1011
|
+
* they stay exported only so values already stored can be read. Bridge a
|
|
1012
|
+
* stored number with `resolveOrgTypeKeyFromLegacyNumeric` /
|
|
1013
|
+
* `LEGACY_NUMERIC_TO_REFERRAL_ENTITY_KEY`; never write a new one.
|
|
1014
|
+
*/
|
|
979
1015
|
export const IC_58_ORG_TYPE_GROUPS: OrgTypeGroup[] = [
|
|
980
1016
|
{
|
|
981
1017
|
value: 10,
|
|
@@ -1048,6 +1084,15 @@ export interface IC58ExternalCategory {
|
|
|
1048
1084
|
* Tiered organization type structure for External referral sources.
|
|
1049
1085
|
* Parent categories are collapsible; leaf children are selectable.
|
|
1050
1086
|
* Based on core_referral_entity_category codebook from Notion.
|
|
1087
|
+
*
|
|
1088
|
+
* @deprecated for ORGANIZATION TYPE — a tiered picker over the positional numbers; see `IC_58_ORG_TYPE_GROUPS`. IC-58 is the Information
|
|
1089
|
+
* Concept; its only live codeset is CVC-48 `core-referral_entity_category`,
|
|
1090
|
+
* and the one vocabulary for an agency's / organization's type is
|
|
1091
|
+
* `constants/org-type.ts` (`ORG_TYPE_KEYS`, `resolveOrgTypeKey`, the ruling-
|
|
1092
|
+
* table classifiers). These numbers are CVC-48's hierarchy in positional form;
|
|
1093
|
+
* they stay exported only so values already stored can be read. Bridge a
|
|
1094
|
+
* stored number with `resolveOrgTypeKeyFromLegacyNumeric` /
|
|
1095
|
+
* `LEGACY_NUMERIC_TO_REFERRAL_ENTITY_KEY`; never write a new one.
|
|
1051
1096
|
*/
|
|
1052
1097
|
export const IC_58_EXTERNAL_TIERED: IC58ExternalCategory[] = [
|
|
1053
1098
|
{
|
package/src/constants/index.ts
CHANGED