@htilabs/platform-common-models 0.1.0-beta.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.
Files changed (48) hide show
  1. package/dist/constants/index.cjs +1379 -0
  2. package/dist/constants/index.cjs.map +1 -0
  3. package/dist/constants/index.d.cts +528 -0
  4. package/dist/constants/index.d.ts +528 -0
  5. package/dist/constants/index.js +1252 -0
  6. package/dist/constants/index.js.map +1 -0
  7. package/dist/index.cjs +2138 -0
  8. package/dist/index.cjs.map +1 -0
  9. package/dist/index.d.cts +5 -0
  10. package/dist/index.d.ts +5 -0
  11. package/dist/index.js +1986 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/models/index.cjs +661 -0
  14. package/dist/models/index.cjs.map +1 -0
  15. package/dist/models/index.d.cts +204 -0
  16. package/dist/models/index.d.ts +204 -0
  17. package/dist/models/index.js +636 -0
  18. package/dist/models/index.js.map +1 -0
  19. package/dist/schemas/index.cjs +1405 -0
  20. package/dist/schemas/index.cjs.map +1 -0
  21. package/dist/schemas/index.d.cts +312 -0
  22. package/dist/schemas/index.d.ts +312 -0
  23. package/dist/schemas/index.js +1353 -0
  24. package/dist/schemas/index.js.map +1 -0
  25. package/dist/scoring-rule-BOkG46I3.d.cts +1179 -0
  26. package/dist/scoring-rule-BOkG46I3.d.ts +1179 -0
  27. package/dist/types/index.cjs +19 -0
  28. package/dist/types/index.cjs.map +1 -0
  29. package/dist/types/index.d.cts +1 -0
  30. package/dist/types/index.d.ts +1 -0
  31. package/dist/types/index.js +1 -0
  32. package/dist/types/index.js.map +1 -0
  33. package/package.json +81 -0
  34. package/src/constants/ic.ts +1630 -0
  35. package/src/constants/index.ts +11 -0
  36. package/src/index.ts +30 -0
  37. package/src/models/formModel.ts +30 -0
  38. package/src/models/index.ts +72 -0
  39. package/src/models/questionModel.ts +30 -0
  40. package/src/models/scoringRuleModel.ts +33 -0
  41. package/src/models/sectionModel.ts +30 -0
  42. package/src/schemas/common.ts +118 -0
  43. package/src/schemas/form.ts +125 -0
  44. package/src/schemas/index.ts +70 -0
  45. package/src/schemas/question.ts +297 -0
  46. package/src/schemas/scoring-rule.ts +169 -0
  47. package/src/schemas/section.ts +158 -0
  48. package/src/types/index.ts +47 -0
@@ -0,0 +1,1630 @@
1
+ /**
2
+ * @htilabs/platform-common-models — Information Concept (IC) Constants
3
+ * ENUM integer values matching victim services data standards.
4
+ *
5
+ * Each IC constant object is `as const` so values are narrow literal types.
6
+ * Label records provide display text for UI rendering.
7
+ */
8
+
9
+ // ─── Data Quality (Per-Field Declined States) ───────────────────────
10
+ // HMIS-aligned data quality indicators for demographics and contact fields.
11
+ // Used as companion fields (e.g., sexDataQuality, raceDataQuality) to track
12
+ // why data is missing. Absence of the field (undefined) means data was provided.
13
+
14
+ export const DATA_QUALITY = {
15
+ /** Client does not know the answer. */
16
+ CLIENT_DOESNT_KNOW: "client_doesnt_know",
17
+ /** Client explicitly declined to provide the information. */
18
+ CLIENT_PREFERS_NOT_TO_ANSWER: "client_prefers_not_to_answer",
19
+ /** Data was not collected during this interaction. */
20
+ DATA_NOT_COLLECTED: "data_not_collected",
21
+ } as const;
22
+
23
+ export type DataQualityValue = (typeof DATA_QUALITY)[keyof typeof DATA_QUALITY];
24
+
25
+ /** Tuple of valid DATA_QUALITY values for enum constraints (preserves literal types). */
26
+ export const DATA_QUALITY_VALUES = [
27
+ DATA_QUALITY.CLIENT_DOESNT_KNOW,
28
+ DATA_QUALITY.CLIENT_PREFERS_NOT_TO_ANSWER,
29
+ DATA_QUALITY.DATA_NOT_COLLECTED,
30
+ ] as const;
31
+
32
+ export const DATA_QUALITY_LABELS: Record<DataQualityValue, string> = {
33
+ [DATA_QUALITY.CLIENT_DOESNT_KNOW]: "Client Doesn't Know",
34
+ [DATA_QUALITY.CLIENT_PREFERS_NOT_TO_ANSWER]: "Client Declined",
35
+ [DATA_QUALITY.DATA_NOT_COLLECTED]: "Not Collected",
36
+ };
37
+
38
+ export const DATA_QUALITY_DESCRIPTIONS: Record<DataQualityValue, string> = {
39
+ [DATA_QUALITY.CLIENT_DOESNT_KNOW]: "Client does not know the answer",
40
+ [DATA_QUALITY.CLIENT_PREFERS_NOT_TO_ANSWER]:
41
+ "Client explicitly declined to provide this information",
42
+ [DATA_QUALITY.DATA_NOT_COLLECTED]:
43
+ "Data was not collected during this interaction",
44
+ };
45
+
46
+ // ─── IC-5: Victimization / Abuse Types ──────────────────────────────
47
+
48
+ export const IC_5_VICTIMIZATION = {
49
+ DV: 1,
50
+ SA: 2,
51
+ DMST: 3,
52
+ ST: 4,
53
+ LT: 5,
54
+ OTHER: 99,
55
+ } as const;
56
+
57
+ export type IC5Value =
58
+ (typeof IC_5_VICTIMIZATION)[keyof typeof IC_5_VICTIMIZATION];
59
+
60
+ export const IC_5_LABELS: Record<IC5Value, string> = {
61
+ [IC_5_VICTIMIZATION.DV]: "DV",
62
+ [IC_5_VICTIMIZATION.SA]: "SA",
63
+ [IC_5_VICTIMIZATION.DMST]: "DMST",
64
+ [IC_5_VICTIMIZATION.ST]: "ST",
65
+ [IC_5_VICTIMIZATION.LT]: "LT",
66
+ [IC_5_VICTIMIZATION.OTHER]: "Other",
67
+ };
68
+
69
+ export const IC_5_FULL_LABELS: Record<IC5Value, string> = {
70
+ [IC_5_VICTIMIZATION.DV]: "Domestic Violence",
71
+ [IC_5_VICTIMIZATION.SA]: "Sexual Assault",
72
+ [IC_5_VICTIMIZATION.DMST]: "Domestic Minor Sex Trafficking",
73
+ [IC_5_VICTIMIZATION.ST]: "Sex Trafficking",
74
+ [IC_5_VICTIMIZATION.LT]: "Labor Trafficking",
75
+ [IC_5_VICTIMIZATION.OTHER]: "Other",
76
+ };
77
+
78
+ // ─── IC-13: Relationship Types ──────────────────────────────────────
79
+
80
+ export const IC_13_RELATIONSHIP_TYPE = {
81
+ SPOUSE: 1,
82
+ PARTNER: 2,
83
+ PARENT: 3,
84
+ CHILD: 4,
85
+ SIBLING: 5,
86
+ OTHER_FAMILY: 6,
87
+ ROOMMATE: 7,
88
+ FRIEND: 8,
89
+ COWORKER: 9,
90
+ ACQUAINTANCE: 10,
91
+ STRANGER: 11,
92
+ OTHER: 99,
93
+ } as const;
94
+
95
+ export type IC13Value =
96
+ (typeof IC_13_RELATIONSHIP_TYPE)[keyof typeof IC_13_RELATIONSHIP_TYPE];
97
+
98
+ export const IC_13_LABELS: Record<IC13Value, string> = {
99
+ 1: "Spouse",
100
+ 2: "Partner / Significant Other",
101
+ 3: "Parent / Guardian",
102
+ 4: "Child / Dependent",
103
+ 5: "Sibling",
104
+ 6: "Other Family Member",
105
+ 7: "Roommate / Housemate",
106
+ 8: "Friend",
107
+ 9: "Coworker",
108
+ 10: "Acquaintance",
109
+ 11: "Stranger",
110
+ 99: "Other",
111
+ };
112
+
113
+ export const IC_13_RELATIONSHIP_ABBREV: Record<IC13Value, string> = {
114
+ 1: "SP",
115
+ 2: "PTR",
116
+ 3: "P/G",
117
+ 4: "CHD",
118
+ 5: "SIB",
119
+ 6: "FAM",
120
+ 7: "RM",
121
+ 8: "FRD",
122
+ 9: "CW",
123
+ 10: "ACQ",
124
+ 11: "STR",
125
+ 99: "OTH",
126
+ };
127
+
128
+ /**
129
+ * IC-13 relationship priority groups.
130
+ * Order: Familial > Romantic > Close social > Business > Other social > ungrouped.
131
+ * Used by the UI to sort and group relationship dropdown options.
132
+ */
133
+ export interface IC13PriorityGroup {
134
+ label: string;
135
+ codes: readonly IC13Value[];
136
+ }
137
+
138
+ export const IC_13_PRIORITY_GROUPS: readonly IC13PriorityGroup[] = [
139
+ {
140
+ label: "Familial",
141
+ codes: [
142
+ IC_13_RELATIONSHIP_TYPE.PARENT,
143
+ IC_13_RELATIONSHIP_TYPE.CHILD,
144
+ IC_13_RELATIONSHIP_TYPE.SIBLING,
145
+ IC_13_RELATIONSHIP_TYPE.OTHER_FAMILY,
146
+ ],
147
+ },
148
+ {
149
+ label: "Romantic",
150
+ codes: [IC_13_RELATIONSHIP_TYPE.SPOUSE, IC_13_RELATIONSHIP_TYPE.PARTNER],
151
+ },
152
+ {
153
+ label: "Close Social",
154
+ codes: [IC_13_RELATIONSHIP_TYPE.ROOMMATE, IC_13_RELATIONSHIP_TYPE.FRIEND],
155
+ },
156
+ {
157
+ label: "Business",
158
+ codes: [IC_13_RELATIONSHIP_TYPE.COWORKER],
159
+ },
160
+ {
161
+ label: "Other Social",
162
+ codes: [
163
+ IC_13_RELATIONSHIP_TYPE.ACQUAINTANCE,
164
+ IC_13_RELATIONSHIP_TYPE.STRANGER,
165
+ ],
166
+ },
167
+ {
168
+ label: "Other",
169
+ codes: [IC_13_RELATIONSHIP_TYPE.OTHER],
170
+ },
171
+ ] as const;
172
+
173
+ /**
174
+ * IC-13 reverse-context labels: frames the relationship FROM the person
175
+ * TO the Primary Victim. E.g., "Parent of victim" means the person IS
176
+ * the parent of the victim.
177
+ */
178
+ export const IC_13_REVERSE_CONTEXT_LABELS: Record<IC13Value, string> = {
179
+ 1: "Spouse of victim",
180
+ 2: "Partner of victim",
181
+ 3: "Parent / Guardian of victim",
182
+ 4: "Child / Dependent of victim",
183
+ 5: "Sibling of victim",
184
+ 6: "Other family of victim",
185
+ 7: "Roommate of victim",
186
+ 8: "Friend of victim",
187
+ 9: "Coworker of victim",
188
+ 10: "Acquaintance of victim",
189
+ 11: "Stranger to victim",
190
+ 99: "Other relationship to victim",
191
+ };
192
+
193
+ /**
194
+ * Sort IC-13 relationship codes by priority group order.
195
+ * Codes not in any group are appended at the end.
196
+ */
197
+ export function sortRelationshipsByPriority(codes: number[]): number[] {
198
+ const orderMap = new Map<number, number>();
199
+ let order = 0;
200
+ for (const group of IC_13_PRIORITY_GROUPS) {
201
+ for (const code of group.codes) {
202
+ orderMap.set(code, order++);
203
+ }
204
+ }
205
+ return [...codes].sort((a, b) => {
206
+ const oa = orderMap.get(a) ?? 999;
207
+ const ob = orderMap.get(b) ?? 999;
208
+ return oa - ob;
209
+ });
210
+ }
211
+
212
+ /**
213
+ * IC-13 relationship categories — groups relationship types by domain.
214
+ * Display priority order: familial > romantic > close_social > business > other_social > ungrouped.
215
+ */
216
+ const R = IC_13_RELATIONSHIP_TYPE;
217
+
218
+ export const IC_13_CATEGORIES = {
219
+ familial: [
220
+ R.PARENT,
221
+ R.CHILD,
222
+ R.SIBLING,
223
+ R.OTHER_FAMILY,
224
+ ] as readonly IC13Value[],
225
+ romantic: [R.SPOUSE, R.PARTNER] as readonly IC13Value[],
226
+ close_social: [R.FRIEND, R.ROOMMATE] as readonly IC13Value[],
227
+ business: [R.COWORKER] as readonly IC13Value[],
228
+ other_social: [R.ACQUAINTANCE, R.STRANGER] as readonly IC13Value[],
229
+ ungrouped: [R.OTHER] as readonly IC13Value[],
230
+ } as const;
231
+
232
+ export type IC13Category = keyof typeof IC_13_CATEGORIES;
233
+
234
+ /** Display priority order for IC-13 categories (highest priority first). */
235
+ export const IC_13_CATEGORY_ORDER: readonly IC13Category[] = [
236
+ "familial",
237
+ "romantic",
238
+ "close_social",
239
+ "business",
240
+ "other_social",
241
+ "ungrouped",
242
+ ];
243
+
244
+ // ─── CVC-126: Relationship Dynamics & Concerns ─────────────────────
245
+ // These are NOT relationship types (IC-13). They are attributes
246
+ // (multi-select axes) on a PersonRelationship record.
247
+
248
+ export const RELATIONSHIP_DYNAMICS = {
249
+ APPEARS_CONTROLLING: "appears_controlling",
250
+ CONTROLS_FINANCES: "controls_finances",
251
+ CONTROLS_DOCUMENTATION: "controls_documentation",
252
+ EMOTIONAL_VERBAL_ABUSE: "emotional_verbal_abuse",
253
+ PHYSICAL_ABUSE: "physical_abuse",
254
+ SEXUAL_ABUSE: "sexual_abuse",
255
+ THREATS_OF_HARM: "threats_of_harm",
256
+ THREATS_OF_LEGAL_TROUBLE: "threats_of_legal_trouble",
257
+ AGE_DISPARITY: "age_disparity",
258
+ HAS_KIDS_WITH: "has_kids_with",
259
+ } as const;
260
+
261
+ export type RelationshipDynamicValue =
262
+ (typeof RELATIONSHIP_DYNAMICS)[keyof typeof RELATIONSHIP_DYNAMICS];
263
+
264
+ export const RELATIONSHIP_DYNAMICS_LABELS: Record<
265
+ RelationshipDynamicValue,
266
+ string
267
+ > = {
268
+ appears_controlling: "Appears Controlling",
269
+ controls_finances: "Controls Finances",
270
+ controls_documentation: "Controls Documentation",
271
+ emotional_verbal_abuse: "Emotional / Verbal Abuse",
272
+ physical_abuse: "Physical Abuse",
273
+ sexual_abuse: "Sexual Abuse",
274
+ threats_of_harm: "Threats of Harm",
275
+ threats_of_legal_trouble: "Threats of Legal Trouble",
276
+ age_disparity: "Age Disparity",
277
+ has_kids_with: "Has Kids With",
278
+ };
279
+
280
+ export const RELATIONSHIP_DYNAMICS_VALUES = Object.values(
281
+ RELATIONSHIP_DYNAMICS,
282
+ ) as readonly RelationshipDynamicValue[];
283
+
284
+ export const RELATIONSHIP_CONCERNS = {
285
+ SAFETY: "safety",
286
+ CUSTODY: "custody",
287
+ IMMIGRATION: "immigration",
288
+ FINANCIAL: "financial",
289
+ HOUSING: "housing",
290
+ SUBSTANCE_USE: "substance_use",
291
+ MENTAL_HEALTH: "mental_health",
292
+ CHILD_WELFARE: "child_welfare",
293
+ } as const;
294
+
295
+ export type RelationshipConcernValue =
296
+ (typeof RELATIONSHIP_CONCERNS)[keyof typeof RELATIONSHIP_CONCERNS];
297
+
298
+ export const RELATIONSHIP_CONCERNS_LABELS: Record<
299
+ RelationshipConcernValue,
300
+ string
301
+ > = {
302
+ safety: "Safety",
303
+ custody: "Custody",
304
+ immigration: "Immigration",
305
+ financial: "Financial",
306
+ housing: "Housing",
307
+ substance_use: "Substance Use",
308
+ mental_health: "Mental Health",
309
+ child_welfare: "Child Welfare",
310
+ };
311
+
312
+ export const RELATIONSHIP_CONCERNS_VALUES = Object.values(
313
+ RELATIONSHIP_CONCERNS,
314
+ ) as readonly RelationshipConcernValue[];
315
+
316
+ // ─── IC-48: Service Categories ──────────────────────────────────────
317
+
318
+ export interface ServiceCategoryChild {
319
+ id: number;
320
+ label: string;
321
+ }
322
+
323
+ export interface ServiceCategory {
324
+ id: number;
325
+ label: string;
326
+ children: ServiceCategoryChild[];
327
+ }
328
+
329
+ export const IC_48_SERVICE_CATEGORIES: ServiceCategory[] = [
330
+ {
331
+ id: 1,
332
+ label: "Crisis Intervention",
333
+ children: [
334
+ { id: 101, label: "Crisis Hotline Services" },
335
+ { id: 102, label: "Safety Planning" },
336
+ { id: 103, label: "Emergency Transportation" },
337
+ { id: 104, label: "Crisis Counseling" },
338
+ ],
339
+ },
340
+ {
341
+ id: 2,
342
+ label: "Shelter / Housing",
343
+ children: [
344
+ { id: 201, label: "Emergency Shelter" },
345
+ { id: 202, label: "Transitional Housing" },
346
+ { id: 203, label: "Permanent Housing Assistance" },
347
+ { id: 204, label: "Relocation Assistance" },
348
+ ],
349
+ },
350
+ {
351
+ id: 3,
352
+ label: "Legal Services",
353
+ children: [
354
+ { id: 301, label: "Protection Order Assistance" },
355
+ { id: 302, label: "Legal Representation" },
356
+ { id: 303, label: "Court Advocacy" },
357
+ { id: 304, label: "Immigration Legal Services" },
358
+ ],
359
+ },
360
+ {
361
+ id: 4,
362
+ label: "Mental Health",
363
+ children: [
364
+ { id: 401, label: "Individual Counseling" },
365
+ { id: 402, label: "Group Counseling" },
366
+ { id: 403, label: "Trauma-Specific Therapy" },
367
+ { id: 404, label: "Substance Abuse Treatment" },
368
+ ],
369
+ },
370
+ {
371
+ id: 5,
372
+ label: "Medical / Health",
373
+ children: [
374
+ { id: 501, label: "Medical Care" },
375
+ { id: 502, label: "Forensic Exam" },
376
+ { id: 503, label: "Dental Care" },
377
+ { id: 504, label: "Prescription Assistance" },
378
+ ],
379
+ },
380
+ {
381
+ id: 6,
382
+ label: "Case Management",
383
+ children: [
384
+ { id: 601, label: "Needs Assessment" },
385
+ { id: 602, label: "Service Coordination" },
386
+ { id: 603, label: "Benefits Enrollment" },
387
+ { id: 604, label: "Document Retrieval" },
388
+ ],
389
+ },
390
+ {
391
+ id: 7,
392
+ label: "Financial Assistance",
393
+ children: [
394
+ { id: 701, label: "Emergency Funds" },
395
+ { id: 702, label: "Employment Assistance" },
396
+ { id: 703, label: "Job Training" },
397
+ { id: 704, label: "Financial Literacy" },
398
+ ],
399
+ },
400
+ {
401
+ id: 8,
402
+ label: "Law Enforcement",
403
+ children: [
404
+ { id: 801, label: "Report Filing" },
405
+ { id: 802, label: "Victim Notification" },
406
+ { id: 803, label: "Investigation Referral" },
407
+ ],
408
+ },
409
+ ];
410
+
411
+ // ─── IC-49: Service Mechanism ───────────────────────────────────────
412
+
413
+ export const IC_49_SERVICE_MECHANISM = {
414
+ // Level 0 — Unknown / Not Collected
415
+ DATA_NOT_COLLECTED: -2,
416
+ ANONYMOUS: -1,
417
+ UNKNOWN: 0,
418
+ // Level 1
419
+ SUPPORT_VIA_REFERRAL: 3,
420
+ INFORMATIONAL_SUPPORT: 4,
421
+ // Level 2
422
+ DIRECT_STAFF_CONTRACTOR: 1,
423
+ FINANCIAL_MATERIAL_ASSISTANCE: 2,
424
+ // Mutually exclusive — no other mechanisms when selected
425
+ SUPPORT_IDENTIFIED_NOT_ADMINISTERED: 5,
426
+ } as const;
427
+
428
+ export type IC49Value =
429
+ (typeof IC_49_SERVICE_MECHANISM)[keyof typeof IC_49_SERVICE_MECHANISM];
430
+
431
+ export const IC_49_LABELS: Record<IC49Value, string> = {
432
+ [IC_49_SERVICE_MECHANISM.DATA_NOT_COLLECTED]: "Data Not Collected",
433
+ [IC_49_SERVICE_MECHANISM.ANONYMOUS]: "Anonymous",
434
+ [IC_49_SERVICE_MECHANISM.UNKNOWN]: "Unknown",
435
+ [IC_49_SERVICE_MECHANISM.SUPPORT_VIA_REFERRAL]: "Support via Referral",
436
+ [IC_49_SERVICE_MECHANISM.INFORMATIONAL_SUPPORT]: "Informational Support",
437
+ [IC_49_SERVICE_MECHANISM.DIRECT_STAFF_CONTRACTOR]:
438
+ "Direct Staff / Contractor",
439
+ [IC_49_SERVICE_MECHANISM.FINANCIAL_MATERIAL_ASSISTANCE]:
440
+ "Financial / Material Assistance",
441
+ [IC_49_SERVICE_MECHANISM.SUPPORT_IDENTIFIED_NOT_ADMINISTERED]:
442
+ "Support Identified, Not Administered",
443
+ };
444
+
445
+ export const IC_49_DESCRIPTIONS: Record<IC49Value, string> = {
446
+ [IC_49_SERVICE_MECHANISM.DATA_NOT_COLLECTED]:
447
+ "Mechanism data was not collected",
448
+ [IC_49_SERVICE_MECHANISM.ANONYMOUS]:
449
+ "Client is anonymous — mechanism not trackable",
450
+ [IC_49_SERVICE_MECHANISM.UNKNOWN]: "Mechanism unknown",
451
+ [IC_49_SERVICE_MECHANISM.SUPPORT_VIA_REFERRAL]:
452
+ "Connected to external provider for service delivery",
453
+ [IC_49_SERVICE_MECHANISM.INFORMATIONAL_SUPPORT]:
454
+ "Information, education, or resource list provided",
455
+ [IC_49_SERVICE_MECHANISM.DIRECT_STAFF_CONTRACTOR]:
456
+ "Service delivered directly by agency staff or contractor",
457
+ [IC_49_SERVICE_MECHANISM.FINANCIAL_MATERIAL_ASSISTANCE]:
458
+ "Financial aid, gift cards, vouchers, or material goods",
459
+ [IC_49_SERVICE_MECHANISM.SUPPORT_IDENTIFIED_NOT_ADMINISTERED]:
460
+ "Service need identified but not administered during this session",
461
+ };
462
+
463
+ // ─── IC-56: Service Delivery Channel (Contact Method) ───────────────
464
+
465
+ export const IC_56_SERVICE_DELIVERY_CHANNEL = {
466
+ IN_PERSON: 1,
467
+ ON_SCENE: 2,
468
+ PHONE: 3,
469
+ EMAIL_TEXT_CHAT: 4,
470
+ VIRTUAL: 5,
471
+ } as const;
472
+
473
+ export type IC56Value =
474
+ (typeof IC_56_SERVICE_DELIVERY_CHANNEL)[keyof typeof IC_56_SERVICE_DELIVERY_CHANNEL];
475
+
476
+ export const IC_56_LABELS: Record<IC56Value, string> = {
477
+ [IC_56_SERVICE_DELIVERY_CHANNEL.IN_PERSON]: "In Person",
478
+ [IC_56_SERVICE_DELIVERY_CHANNEL.ON_SCENE]: "On-scene",
479
+ [IC_56_SERVICE_DELIVERY_CHANNEL.PHONE]: "Phone",
480
+ [IC_56_SERVICE_DELIVERY_CHANNEL.EMAIL_TEXT_CHAT]: "Email / Text / Chat",
481
+ [IC_56_SERVICE_DELIVERY_CHANNEL.VIRTUAL]: "Virtual",
482
+ };
483
+
484
+ export const IC_56_DESCRIPTIONS: Record<IC56Value, string> = {
485
+ [IC_56_SERVICE_DELIVERY_CHANNEL.IN_PERSON]:
486
+ "Office / shelter / clinic / other in-person setting",
487
+ [IC_56_SERVICE_DELIVERY_CHANNEL.ON_SCENE]:
488
+ "Field response / crisis response / mobile advocacy",
489
+ [IC_56_SERVICE_DELIVERY_CHANNEL.PHONE]: "Phone call",
490
+ [IC_56_SERVICE_DELIVERY_CHANNEL.EMAIL_TEXT_CHAT]:
491
+ "Email, text message, or chat",
492
+ [IC_56_SERVICE_DELIVERY_CHANNEL.VIRTUAL]: "Virtual / video call",
493
+ };
494
+
495
+ // ─── IC-57: Service Audience / Beneficiary ──────────────────────────
496
+
497
+ export const IC_57_SERVICE_AUDIENCE = {
498
+ CLIENT_VICTIM: 1,
499
+ THIRD_PARTY: 2,
500
+ DEPENDENT_SECONDARY: 3,
501
+ CLIENT_GROUPS: 4,
502
+ } as const;
503
+
504
+ export type IC57Value =
505
+ (typeof IC_57_SERVICE_AUDIENCE)[keyof typeof IC_57_SERVICE_AUDIENCE];
506
+
507
+ export const IC_57_LABELS: Record<IC57Value, string> = {
508
+ [IC_57_SERVICE_AUDIENCE.CLIENT_VICTIM]: "Client / Victim",
509
+ [IC_57_SERVICE_AUDIENCE.THIRD_PARTY]: "Third-Party",
510
+ [IC_57_SERVICE_AUDIENCE.DEPENDENT_SECONDARY]: "Dependent / Secondary Victim",
511
+ [IC_57_SERVICE_AUDIENCE.CLIENT_GROUPS]: "Client Groups",
512
+ };
513
+
514
+ // ─── IC-58: Referral Entity Category ────────────────────────────────
515
+
516
+ export const IC_58_REFERRAL_ENTITY = {
517
+ UNKNOWN: 0,
518
+ INTERNAL: 1,
519
+ INDIVIDUAL_SELF: 2,
520
+ INDIVIDUAL_FAMILY: 3,
521
+ INDIVIDUAL_PEER: 4,
522
+ INDIVIDUAL_OTHER: 5,
523
+ // External organization parent categories
524
+ EXTERNAL_HOUSING_SHELTER: 10,
525
+ EXTERNAL_HOTLINE: 11,
526
+ EXTERNAL_JUSTICE: 12,
527
+ EXTERNAL_OUTREACH: 13,
528
+ EXTERNAL_TEMPORARY_SHELTER: 14,
529
+ EXTERNAL_RESIDENTIAL: 15,
530
+ EXTERNAL_HEALTH: 16,
531
+ EXTERNAL_EDUCATION: 17,
532
+ EXTERNAL_LAW_ENFORCEMENT: 18,
533
+ EXTERNAL_OTHER: 19,
534
+ // Justice & Protective Systems children
535
+ EXTERNAL_CHILD_WELFARE: 20,
536
+ EXTERNAL_JUVENILE_JUSTICE: 21,
537
+ EXTERNAL_COURTS: 22,
538
+ EXTERNAL_CORRECTIONS: 23,
539
+ // Health / Behavioral Health children
540
+ EXTERNAL_INPATIENT_PSYCH: 24,
541
+ EXTERNAL_HEALTHCARE_PROVIDER: 25,
542
+ // Victim + Community Service Providers
543
+ EXTERNAL_VICTIM_COMMUNITY: 26,
544
+ EXTERNAL_CAC: 27,
545
+ EXTERNAL_VSP: 28,
546
+ EXTERNAL_COMMUNITY_PROVIDER: 29,
547
+ // Other children
548
+ EXTERNAL_EMPLOYER: 30,
549
+ EXTERNAL_BENEFITS: 31,
550
+ } as const;
551
+
552
+ export type IC58Value =
553
+ (typeof IC_58_REFERRAL_ENTITY)[keyof typeof IC_58_REFERRAL_ENTITY];
554
+
555
+ export const IC_58_LABELS: Record<IC58Value, string> = {
556
+ 0: "Unknown",
557
+ 1: "Internal referral",
558
+ 2: "Self-referred / walk-in",
559
+ 3: "Family / guardian / friend / foster parent",
560
+ 4: "Peer / another client",
561
+ 5: "Other individual",
562
+ // External organization categories (Level 1B)
563
+ 10: "Housing / Shelter Continuum",
564
+ 11: "Hotline",
565
+ 12: "Justice & Protective Systems",
566
+ 13: "Outreach Project",
567
+ 14: "Temporary Shelter",
568
+ 15: "Residential Project",
569
+ 16: "Health / Behavioral Health",
570
+ 17: "Education",
571
+ 18: "Law Enforcement / Police",
572
+ 19: "Other External",
573
+ // Justice & Protective Systems children
574
+ 20: "Child Welfare / CPS",
575
+ 21: "Juvenile Justice",
576
+ 22: "Courts or Prosecution",
577
+ 23: "Correction / Probation",
578
+ // Health / Behavioral Health children
579
+ 24: "Inpatient Psychiatric Facility",
580
+ 25: "Healthcare Provider",
581
+ // Victim + Community Service Providers
582
+ 26: "Victim + Community Service Providers",
583
+ 27: "Child Advocacy Center (CAC)",
584
+ 28: "Victim Service Provider",
585
+ 29: "Community-Based Service Provider",
586
+ // Other children
587
+ 30: "Employer",
588
+ 31: "Benefits / Public Assistance Office",
589
+ };
590
+
591
+ export interface ReferralBranch {
592
+ value?: number;
593
+ label: string;
594
+ description: string;
595
+ children?: { value: number; label: string }[];
596
+ }
597
+
598
+ export const IC_58_PRIMARY_BRANCHES: Record<string, ReferralBranch> = {
599
+ INTERNAL: {
600
+ value: 1,
601
+ label: "Internal referral (from my agency)",
602
+ description: "From within another program/unit within your agency.",
603
+ },
604
+ INDIVIDUAL: {
605
+ label: "Individual",
606
+ description: "Self / family / peer / other individual.",
607
+ children: [
608
+ { value: 2, label: "Self-referred / walk-in" },
609
+ { value: 3, label: "Family / guardian / friend / foster parent" },
610
+ { value: 4, label: "Peer / another client" },
611
+ { value: 5, label: "Other individual" },
612
+ ],
613
+ },
614
+ EXTERNAL: {
615
+ label: "External organization",
616
+ description: "Another organization or system referred.",
617
+ children: [
618
+ { value: 10, label: "Housing / Shelter Continuum" },
619
+ { value: 11, label: "Hotline" },
620
+ { value: 12, label: "Justice & Protective Systems" },
621
+ { value: 13, label: "Outreach Project" },
622
+ { value: 14, label: "Temporary Shelter" },
623
+ { value: 15, label: "Residential Project" },
624
+ { value: 16, label: "Health / Behavioral Health" },
625
+ { value: 17, label: "Education" },
626
+ { value: 18, label: "Law Enforcement / Police" },
627
+ { value: 19, label: "Other External" },
628
+ { value: 20, label: "Child Welfare / CPS" },
629
+ { value: 21, label: "Juvenile Justice" },
630
+ { value: 22, label: "Courts or Prosecution" },
631
+ { value: 23, label: "Correction / Probation" },
632
+ { value: 24, label: "Inpatient Psychiatric Facility" },
633
+ { value: 25, label: "Healthcare Provider" },
634
+ { value: 26, label: "Victim + Community Service Providers" },
635
+ { value: 27, label: "Child Advocacy Center (CAC)" },
636
+ { value: 28, label: "Victim Service Provider" },
637
+ { value: 29, label: "Community-Based Service Provider" },
638
+ { value: 30, label: "Employer" },
639
+ { value: 31, label: "Benefits / Public Assistance Office" },
640
+ ],
641
+ },
642
+ UNKNOWN: {
643
+ value: 0,
644
+ label: "Unknown",
645
+ description: "Referral source not documented.",
646
+ },
647
+ };
648
+
649
+ // ─── IC-58: Organization Type Groups (tiered browse) ─────────────────
650
+
651
+ export interface OrgTypeGroup {
652
+ value: number;
653
+ label: string;
654
+ description?: string;
655
+ children: { value: number; label: string }[];
656
+ }
657
+
658
+ export const IC_58_ORG_TYPE_GROUPS: OrgTypeGroup[] = [
659
+ {
660
+ value: 10,
661
+ label: "Housing / Shelter Continuum",
662
+ children: [
663
+ { value: 13, label: "Outreach Project" },
664
+ { value: 14, label: "Temporary Shelter" },
665
+ { value: 15, label: "Residential Project" },
666
+ ],
667
+ },
668
+ {
669
+ value: 12,
670
+ label: "Justice & Protective Systems",
671
+ children: [
672
+ { value: 20, label: "Child Welfare / CPS" },
673
+ { value: 21, label: "Juvenile Justice" },
674
+ { value: 18, label: "Law Enforcement / Police" },
675
+ { value: 22, label: "Courts or Prosecution" },
676
+ { value: 23, label: "Correction / Probation" },
677
+ ],
678
+ },
679
+ {
680
+ value: 11,
681
+ label: "Hotline",
682
+ description: "Crisis hotline or call center",
683
+ children: [],
684
+ },
685
+ {
686
+ value: 16,
687
+ label: "Health / Behavioral Health",
688
+ children: [
689
+ { value: 24, label: "Inpatient Psychiatric Facility" },
690
+ { value: 25, label: "Healthcare Provider" },
691
+ ],
692
+ },
693
+ {
694
+ value: 26,
695
+ label: "Victim + Community Service Providers",
696
+ children: [
697
+ { value: 27, label: "Child Advocacy Center (CAC)" },
698
+ { value: 28, label: "Victim Service Provider" },
699
+ { value: 29, label: "Community-Based Service Provider" },
700
+ ],
701
+ },
702
+ {
703
+ value: 17,
704
+ label: "Education",
705
+ children: [],
706
+ },
707
+ {
708
+ value: 19,
709
+ label: "Other External",
710
+ children: [
711
+ { value: 30, label: "Employer" },
712
+ { value: 31, label: "Benefits / Public Assistance Office" },
713
+ ],
714
+ },
715
+ ];
716
+
717
+ // ─── IC-58: Tiered External Organization Categories ──────────────────
718
+
719
+ export interface IC58ExternalCategory {
720
+ id: number;
721
+ label: string;
722
+ description: string;
723
+ children: { id: number; label: string }[];
724
+ }
725
+
726
+ /**
727
+ * Tiered organization type structure for External referral sources.
728
+ * Parent categories are collapsible; leaf children are selectable.
729
+ * Based on core_referral_entity_category codebook from Notion.
730
+ */
731
+ export const IC_58_EXTERNAL_TIERED: IC58ExternalCategory[] = [
732
+ {
733
+ id: 10,
734
+ label: "Housing / Shelter Continuum",
735
+ description: "Outreach, emergency shelter, residential programs",
736
+ children: [
737
+ { id: 13, label: "Outreach Project" },
738
+ { id: 14, label: "Temporary Shelter" },
739
+ { id: 15, label: "Residential Project" },
740
+ ],
741
+ },
742
+ {
743
+ id: 12,
744
+ label: "Justice & Protective Systems",
745
+ description: "Law enforcement, courts, child welfare",
746
+ children: [
747
+ { id: 20, label: "Child Welfare / CPS" },
748
+ { id: 21, label: "Juvenile Justice" },
749
+ { id: 18, label: "Law Enforcement / Police" },
750
+ { id: 22, label: "Courts or Prosecution" },
751
+ { id: 23, label: "Correction / Probation" },
752
+ ],
753
+ },
754
+ {
755
+ id: 11,
756
+ label: "Hotline",
757
+ description: "Crisis hotline or call center",
758
+ children: [],
759
+ },
760
+ {
761
+ id: 16,
762
+ label: "Health / Behavioral Health",
763
+ description: "Healthcare providers, mental health facilities",
764
+ children: [
765
+ { id: 24, label: "Inpatient Psychiatric Facility" },
766
+ { id: 25, label: "Healthcare Provider" },
767
+ ],
768
+ },
769
+ {
770
+ id: 26,
771
+ label: "Victim + Community Service Providers",
772
+ description: "Victim services, advocacy, community-based programs",
773
+ children: [
774
+ { id: 27, label: "Child Advocacy Center (CAC)" },
775
+ { id: 28, label: "Victim Service Provider" },
776
+ { id: 29, label: "Community-Based Service Provider" },
777
+ ],
778
+ },
779
+ {
780
+ id: 17,
781
+ label: "Education",
782
+ description: "Schools, academic institutions",
783
+ children: [],
784
+ },
785
+ {
786
+ id: 19,
787
+ label: "Other External",
788
+ description: "Other external organization or system",
789
+ children: [
790
+ { id: 30, label: "Employer" },
791
+ { id: 31, label: "Benefits / Public Assistance Office" },
792
+ ],
793
+ },
794
+ ];
795
+
796
+ // ─── IC-59: Service State ───────────────────────────────────────────
797
+
798
+ export const IC_59_SERVICE_STATE = {
799
+ IDENTIFIED: 1,
800
+ REFERRED: 2,
801
+ IN_PROGRESS: 3,
802
+ COMPLETED: 4,
803
+ DECLINED: 5,
804
+ } as const;
805
+
806
+ export type IC59Value =
807
+ (typeof IC_59_SERVICE_STATE)[keyof typeof IC_59_SERVICE_STATE];
808
+
809
+ export const IC_59_LABELS: Record<IC59Value, string> = {
810
+ [IC_59_SERVICE_STATE.IDENTIFIED]: "Identified",
811
+ [IC_59_SERVICE_STATE.REFERRED]: "Referred",
812
+ [IC_59_SERVICE_STATE.IN_PROGRESS]: "In Progress",
813
+ [IC_59_SERVICE_STATE.COMPLETED]: "Completed",
814
+ [IC_59_SERVICE_STATE.DECLINED]: "Declined",
815
+ };
816
+
817
+ // ─── IC-49: Referral Outcome (conditional on SUPPORT_VIA_REFERRAL) ──
818
+
819
+ export const IC_49_REFERRAL_OUTCOME = {
820
+ UNKNOWN: 0,
821
+ ATTAINED: 1,
822
+ NOT_ATTAINED: 2,
823
+ } as const;
824
+
825
+ export type IC49ReferralOutcomeValue =
826
+ (typeof IC_49_REFERRAL_OUTCOME)[keyof typeof IC_49_REFERRAL_OUTCOME];
827
+
828
+ export const IC_49_REFERRAL_OUTCOME_LABELS: Record<
829
+ IC49ReferralOutcomeValue,
830
+ string
831
+ > = {
832
+ [IC_49_REFERRAL_OUTCOME.UNKNOWN]: "Unknown",
833
+ [IC_49_REFERRAL_OUTCOME.ATTAINED]: "Attained",
834
+ [IC_49_REFERRAL_OUTCOME.NOT_ATTAINED]: "Not Attained",
835
+ };
836
+
837
+ // ─── IC-49: Referral Verification Status ────────────────────────────
838
+
839
+ export const IC_49_REFERRAL_VERIFICATION = {
840
+ REFERRAL_MADE: 1,
841
+ CONFIRMED_RECEIVED: 2,
842
+ } as const;
843
+
844
+ export type IC49ReferralVerificationValue =
845
+ (typeof IC_49_REFERRAL_VERIFICATION)[keyof typeof IC_49_REFERRAL_VERIFICATION];
846
+
847
+ export const IC_49_REFERRAL_VERIFICATION_LABELS: Record<
848
+ IC49ReferralVerificationValue,
849
+ string
850
+ > = {
851
+ [IC_49_REFERRAL_VERIFICATION.REFERRAL_MADE]: "Referral Made",
852
+ [IC_49_REFERRAL_VERIFICATION.CONFIRMED_RECEIVED]:
853
+ "Confirmed Received / Connected",
854
+ };
855
+
856
+ // ─── Session States ─────────────────────────────────────────────────
857
+
858
+ export const SESSION_STATES = {
859
+ INITIALIZED: 1,
860
+ ACTION_NEEDED: 2,
861
+ PENDING_SAVE: 3,
862
+ CLOSED: 4,
863
+ DISCARDED: 5,
864
+ } as const;
865
+
866
+ export type SessionStateValue =
867
+ (typeof SESSION_STATES)[keyof typeof SESSION_STATES];
868
+
869
+ export const SESSION_STATE_LABELS: Record<SessionStateValue, string> = {
870
+ [SESSION_STATES.INITIALIZED]: "Initialized",
871
+ [SESSION_STATES.ACTION_NEEDED]: "Action Needed",
872
+ [SESSION_STATES.PENDING_SAVE]: "Pending Save",
873
+ [SESSION_STATES.CLOSED]: "Closed",
874
+ [SESSION_STATES.DISCARDED]: "Discarded",
875
+ };
876
+
877
+ // ─── Record States ──────────────────────────────────────────────────
878
+
879
+ export const RECORD_STATES = {
880
+ OPEN: 1,
881
+ CLAIMED: 2,
882
+ SUBMITTED_NO_SHARES: 3,
883
+ SUBMITTED_WITH_SHARES: 4,
884
+ CLOSED: 5,
885
+ } as const;
886
+
887
+ export type RecordStateValue =
888
+ (typeof RECORD_STATES)[keyof typeof RECORD_STATES];
889
+
890
+ export const RECORD_STATE_LABELS: Record<RecordStateValue, string> = {
891
+ [RECORD_STATES.OPEN]: "Open",
892
+ [RECORD_STATES.CLAIMED]: "Claimed",
893
+ [RECORD_STATES.SUBMITTED_NO_SHARES]: "Submitted (No Shares)",
894
+ [RECORD_STATES.SUBMITTED_WITH_SHARES]: "Submitted (With Shares)",
895
+ [RECORD_STATES.CLOSED]: "Closed",
896
+ };
897
+
898
+ // ─── Interaction Type ────────────────────────────────────────────────
899
+
900
+ export const INTERACTION_TYPES = {
901
+ HOTLINE_CALL: 1,
902
+ LAP_INCIDENT: 2,
903
+ FIELD_RESPONSE: 3,
904
+ EMAIL_CRISIS: 4,
905
+ OTHER: 99,
906
+ } as const;
907
+
908
+ export type InteractionTypeValue =
909
+ (typeof INTERACTION_TYPES)[keyof typeof INTERACTION_TYPES];
910
+
911
+ /** Tuple of valid INTERACTION_TYPES values for schema constraints. */
912
+ export const VALID_INTERACTION_TYPES = Object.values(
913
+ INTERACTION_TYPES,
914
+ ) as readonly InteractionTypeValue[];
915
+
916
+ /** Tuple of valid RECORD_STATES values for schema constraints. */
917
+ export const VALID_RECORD_STATES = Object.values(
918
+ RECORD_STATES,
919
+ ) as readonly RecordStateValue[];
920
+
921
+ export const INTERACTION_TYPE_LABELS: Record<InteractionTypeValue, string> = {
922
+ [INTERACTION_TYPES.HOTLINE_CALL]: "Hotline Call",
923
+ [INTERACTION_TYPES.LAP_INCIDENT]: "LAP Incident",
924
+ [INTERACTION_TYPES.FIELD_RESPONSE]: "Field Response",
925
+ [INTERACTION_TYPES.EMAIL_CRISIS]: "Email Crisis",
926
+ [INTERACTION_TYPES.OTHER]: "Other",
927
+ };
928
+
929
+ // ─── CVC-130: Incident Involvement Role ─────────────────────────────
930
+ // MECE "one slot" per person per incident. Determines Person Type.
931
+
932
+ export const INCIDENT_INVOLVEMENT_ROLE = {
933
+ VICTIM_PRIMARY: "victim_primary",
934
+ VICTIM_SECONDARY: "victim_secondary",
935
+ VICTIM_OTHER: "victim_other",
936
+ DEPENDENT: "dependent",
937
+ WITNESS: "witness",
938
+ OFFENDER: "offender",
939
+ UNKNOWN: "unknown",
940
+ ANONYMOUS: "anonymous",
941
+ NOT_COLLECTED: "not_collected",
942
+ } as const;
943
+
944
+ export type IncidentInvolvementRoleValue =
945
+ (typeof INCIDENT_INVOLVEMENT_ROLE)[keyof typeof INCIDENT_INVOLVEMENT_ROLE];
946
+
947
+ export const INCIDENT_INVOLVEMENT_ROLE_LABELS: Record<
948
+ IncidentInvolvementRoleValue,
949
+ string
950
+ > = {
951
+ [INCIDENT_INVOLVEMENT_ROLE.VICTIM_PRIMARY]: "Primary Victim",
952
+ [INCIDENT_INVOLVEMENT_ROLE.VICTIM_SECONDARY]: "Secondary Victim",
953
+ [INCIDENT_INVOLVEMENT_ROLE.VICTIM_OTHER]: "Other Victim",
954
+ [INCIDENT_INVOLVEMENT_ROLE.DEPENDENT]: "Dependent",
955
+ [INCIDENT_INVOLVEMENT_ROLE.WITNESS]: "Witness",
956
+ [INCIDENT_INVOLVEMENT_ROLE.OFFENDER]: "Offender",
957
+ [INCIDENT_INVOLVEMENT_ROLE.UNKNOWN]: "Unknown",
958
+ [INCIDENT_INVOLVEMENT_ROLE.ANONYMOUS]: "Anonymous",
959
+ [INCIDENT_INVOLVEMENT_ROLE.NOT_COLLECTED]: "Not Collected",
960
+ };
961
+
962
+ /** Involvement roles available for selection in Thread UI (excludes victim_other and not_collected). */
963
+ export const THREAD_INVOLVEMENT_ROLES = [
964
+ INCIDENT_INVOLVEMENT_ROLE.VICTIM_PRIMARY,
965
+ INCIDENT_INVOLVEMENT_ROLE.VICTIM_SECONDARY,
966
+ INCIDENT_INVOLVEMENT_ROLE.DEPENDENT,
967
+ INCIDENT_INVOLVEMENT_ROLE.WITNESS,
968
+ INCIDENT_INVOLVEMENT_ROLE.OFFENDER,
969
+ INCIDENT_INVOLVEMENT_ROLE.UNKNOWN,
970
+ INCIDENT_INVOLVEMENT_ROLE.ANONYMOUS,
971
+ ] as const;
972
+
973
+ // ─── Person Roles (Legacy Display Labels) ───────────────────────────
974
+ // Retained for frontend display label mapping. New code should use
975
+ // INCIDENT_INVOLVEMENT_ROLE for data values and
976
+ // INCIDENT_INVOLVEMENT_ROLE_LABELS for display.
977
+
978
+ export const PERSON_ROLES = {
979
+ VICTIM_CLIENT: "Victim / Client",
980
+ CALLER_REPORTER: "Caller / Reporter",
981
+ DEPENDENT: "Dependent / Secondary Victim",
982
+ OFFENDER: "Offender",
983
+ PERSONNEL: "Personnel / Staff",
984
+ OTHER: "Other",
985
+ } as const;
986
+
987
+ export type PersonRoleValue = (typeof PERSON_ROLES)[keyof typeof PERSON_ROLES];
988
+
989
+ /**
990
+ * Maps IncidentInvolvementRoleValue (enum key stored on PersonInteracted) to
991
+ * the corresponding PersonRoleValue display string used in the UI.
992
+ *
993
+ * PersonnelPerson always receives PERSON_ROLES.PERSONNEL regardless of their
994
+ * personInvolvementRole — handle that case before consulting this map.
995
+ *
996
+ * All victim variants (primary, secondary, other) resolve to VICTIM_CLIENT
997
+ * because Thread treats them uniformly in the person block UI.
998
+ */
999
+ export const INCIDENT_INVOLVEMENT_ROLE_TO_PERSON_ROLE: Record<
1000
+ IncidentInvolvementRoleValue,
1001
+ PersonRoleValue
1002
+ > = {
1003
+ [INCIDENT_INVOLVEMENT_ROLE.VICTIM_PRIMARY]: PERSON_ROLES.VICTIM_CLIENT,
1004
+ [INCIDENT_INVOLVEMENT_ROLE.VICTIM_SECONDARY]: PERSON_ROLES.VICTIM_CLIENT,
1005
+ [INCIDENT_INVOLVEMENT_ROLE.VICTIM_OTHER]: PERSON_ROLES.VICTIM_CLIENT,
1006
+ [INCIDENT_INVOLVEMENT_ROLE.DEPENDENT]: PERSON_ROLES.DEPENDENT,
1007
+ [INCIDENT_INVOLVEMENT_ROLE.WITNESS]: PERSON_ROLES.CALLER_REPORTER,
1008
+ [INCIDENT_INVOLVEMENT_ROLE.OFFENDER]: PERSON_ROLES.OFFENDER,
1009
+ [INCIDENT_INVOLVEMENT_ROLE.UNKNOWN]: PERSON_ROLES.OTHER,
1010
+ [INCIDENT_INVOLVEMENT_ROLE.ANONYMOUS]: PERSON_ROLES.OTHER,
1011
+ [INCIDENT_INVOLVEMENT_ROLE.NOT_COLLECTED]: PERSON_ROLES.OTHER,
1012
+ };
1013
+
1014
+ // ─── IC-4: Age Type ────────────────────────────────────────────────
1015
+
1016
+ export const IC_4_AGE_TYPE = {
1017
+ EXACT_DOB: 1,
1018
+ APPROXIMATE: 2,
1019
+ ESTIMATED_RANGE: 3,
1020
+ UNKNOWN: 99,
1021
+ } as const;
1022
+
1023
+ export type IC4Value = (typeof IC_4_AGE_TYPE)[keyof typeof IC_4_AGE_TYPE];
1024
+
1025
+ export const IC_4_LABELS: Record<IC4Value, string> = {
1026
+ [IC_4_AGE_TYPE.EXACT_DOB]: "Exact Date of Birth",
1027
+ [IC_4_AGE_TYPE.APPROXIMATE]: "Approximate Age",
1028
+ [IC_4_AGE_TYPE.ESTIMATED_RANGE]: "Estimated Range",
1029
+ [IC_4_AGE_TYPE.UNKNOWN]: "Unknown",
1030
+ };
1031
+
1032
+ // ─── IC-22: Core Sex ───────────────────────────────────────────────
1033
+
1034
+ export const IC_22_CORE_SEX = {
1035
+ FEMALE: 1,
1036
+ MALE: 2,
1037
+ INTERSEX: 3,
1038
+ UNKNOWN: 99,
1039
+ } as const;
1040
+
1041
+ export type IC22Value = (typeof IC_22_CORE_SEX)[keyof typeof IC_22_CORE_SEX];
1042
+
1043
+ export const IC_22_LABELS: Record<IC22Value, string> = {
1044
+ [IC_22_CORE_SEX.FEMALE]: "Female",
1045
+ [IC_22_CORE_SEX.MALE]: "Male",
1046
+ [IC_22_CORE_SEX.INTERSEX]: "Intersex",
1047
+ [IC_22_CORE_SEX.UNKNOWN]: "Unknown",
1048
+ };
1049
+
1050
+ // ─── IC-23: Core Gender Identity ───────────────────────────────────
1051
+
1052
+ export const IC_23_CORE_GENDER_IDENTITY = {
1053
+ FEMALE: 1,
1054
+ MALE: 2,
1055
+ NON_BINARY: 3,
1056
+ TRANSGENDER_FEMALE: 4,
1057
+ TRANSGENDER_MALE: 5,
1058
+ UNKNOWN: 99,
1059
+ } as const;
1060
+
1061
+ export type IC23Value =
1062
+ (typeof IC_23_CORE_GENDER_IDENTITY)[keyof typeof IC_23_CORE_GENDER_IDENTITY];
1063
+
1064
+ export const IC_23_LABELS: Record<IC23Value, string> = {
1065
+ [IC_23_CORE_GENDER_IDENTITY.FEMALE]: "Female",
1066
+ [IC_23_CORE_GENDER_IDENTITY.MALE]: "Male",
1067
+ [IC_23_CORE_GENDER_IDENTITY.NON_BINARY]: "Non-Binary",
1068
+ [IC_23_CORE_GENDER_IDENTITY.TRANSGENDER_FEMALE]: "Transgender Female",
1069
+ [IC_23_CORE_GENDER_IDENTITY.TRANSGENDER_MALE]: "Transgender Male",
1070
+ [IC_23_CORE_GENDER_IDENTITY.UNKNOWN]: "Unknown",
1071
+ };
1072
+
1073
+ // ─── IC-24: Race ───────────────────────────────────────────────────
1074
+
1075
+ export const IC_24_RACE = {
1076
+ AMERICAN_INDIAN_ALASKA_NATIVE: 1,
1077
+ ASIAN: 2,
1078
+ BLACK_AFRICAN_AMERICAN: 3,
1079
+ NATIVE_HAWAIIAN_PACIFIC_ISLANDER: 4,
1080
+ WHITE: 5,
1081
+ MULTIPLE_RACES: 6,
1082
+ UNKNOWN: 99,
1083
+ } as const;
1084
+
1085
+ export type IC24Value = (typeof IC_24_RACE)[keyof typeof IC_24_RACE];
1086
+
1087
+ export const IC_24_LABELS: Record<IC24Value, string> = {
1088
+ [IC_24_RACE.AMERICAN_INDIAN_ALASKA_NATIVE]: "American Indian / Alaska Native",
1089
+ [IC_24_RACE.ASIAN]: "Asian",
1090
+ [IC_24_RACE.BLACK_AFRICAN_AMERICAN]: "Black / African American",
1091
+ [IC_24_RACE.NATIVE_HAWAIIAN_PACIFIC_ISLANDER]:
1092
+ "Native Hawaiian / Pacific Islander",
1093
+ [IC_24_RACE.WHITE]: "White",
1094
+ [IC_24_RACE.MULTIPLE_RACES]: "Multiple Races",
1095
+ [IC_24_RACE.UNKNOWN]: "Unknown",
1096
+ };
1097
+
1098
+ // ─── IC-25: Ethnicity ──────────────────────────────────────────────
1099
+
1100
+ export const IC_25_ETHNICITY = {
1101
+ HISPANIC_LATINO: 1,
1102
+ NOT_HISPANIC_LATINO: 2,
1103
+ UNKNOWN: 99,
1104
+ } as const;
1105
+
1106
+ export type IC25Value = (typeof IC_25_ETHNICITY)[keyof typeof IC_25_ETHNICITY];
1107
+
1108
+ export const IC_25_LABELS: Record<IC25Value, string> = {
1109
+ [IC_25_ETHNICITY.HISPANIC_LATINO]: "Hispanic / Latino",
1110
+ [IC_25_ETHNICITY.NOT_HISPANIC_LATINO]: "Not Hispanic / Latino",
1111
+ [IC_25_ETHNICITY.UNKNOWN]: "Unknown",
1112
+ };
1113
+
1114
+ // ─── Special Accommodations ──────────────────────────────────────────
1115
+
1116
+ export const ACCOMMODATION_OPTIONS = {
1117
+ HEARING_IMPAIRED: "hearing_impaired",
1118
+ VISION_IMPAIRED: "vision_impaired",
1119
+ MOBILITY_LIMITATION: "mobility_limitation",
1120
+ COGNITIVE_DEVELOPMENTAL: "cognitive_developmental",
1121
+ LANGUAGE_INTERPRETER: "language_interpreter",
1122
+ OTHER: "other",
1123
+ } as const;
1124
+
1125
+ export type AccommodationValue =
1126
+ (typeof ACCOMMODATION_OPTIONS)[keyof typeof ACCOMMODATION_OPTIONS];
1127
+
1128
+ export const ACCOMMODATION_LABELS: Record<AccommodationValue, string> = {
1129
+ [ACCOMMODATION_OPTIONS.HEARING_IMPAIRED]: "Hearing Impaired",
1130
+ [ACCOMMODATION_OPTIONS.VISION_IMPAIRED]: "Vision Impaired",
1131
+ [ACCOMMODATION_OPTIONS.MOBILITY_LIMITATION]: "Mobility Limitation",
1132
+ [ACCOMMODATION_OPTIONS.COGNITIVE_DEVELOPMENTAL]: "Cognitive / Developmental",
1133
+ [ACCOMMODATION_OPTIONS.LANGUAGE_INTERPRETER]: "Language / Interpreter",
1134
+ [ACCOMMODATION_OPTIONS.OTHER]: "Other",
1135
+ };
1136
+
1137
+ // ─── Minor / Adult Status ──────────────────────────────────────────
1138
+
1139
+ export const MINOR_ADULT_STATUS = {
1140
+ MINOR: 1,
1141
+ ADULT: 2,
1142
+ UNKNOWN: 99,
1143
+ } as const;
1144
+
1145
+ export type MinorAdultStatusValue =
1146
+ (typeof MINOR_ADULT_STATUS)[keyof typeof MINOR_ADULT_STATUS];
1147
+
1148
+ export const MINOR_ADULT_STATUS_LABELS: Record<MinorAdultStatusValue, string> =
1149
+ {
1150
+ [MINOR_ADULT_STATUS.MINOR]: "Minor (under 18)",
1151
+ [MINOR_ADULT_STATUS.ADULT]: "Adult (18+)",
1152
+ [MINOR_ADULT_STATUS.UNKNOWN]: "Unknown",
1153
+ };
1154
+
1155
+ // ─── Apparent Age (Observational) ─────────────────────────────────────
1156
+
1157
+ export const APPARENT_AGE = {
1158
+ CHILD: "child",
1159
+ TEEN: "teen",
1160
+ YOUNG_ADULT: "young_adult",
1161
+ ADULT: "adult",
1162
+ MIDDLE_AGE: "middle_age",
1163
+ SENIOR: "senior",
1164
+ } as const;
1165
+
1166
+ export type ApparentAgeValue = (typeof APPARENT_AGE)[keyof typeof APPARENT_AGE];
1167
+
1168
+ export const APPARENT_AGE_LABELS: Record<ApparentAgeValue, string> = {
1169
+ [APPARENT_AGE.CHILD]: "Child",
1170
+ [APPARENT_AGE.TEEN]: "Teen",
1171
+ [APPARENT_AGE.YOUNG_ADULT]: "Young Adult",
1172
+ [APPARENT_AGE.ADULT]: "Adult",
1173
+ [APPARENT_AGE.MIDDLE_AGE]: "Middle Age",
1174
+ [APPARENT_AGE.SENIOR]: "Senior",
1175
+ };
1176
+
1177
+ // ─── Age Bin Reporting (VOCA/OVC) ─────────────────────────────────────
1178
+
1179
+ export const AGE_BIN_REPORTING = {
1180
+ AGE_0_12: "age_0_12",
1181
+ AGE_13_17: "age_13_17",
1182
+ AGE_18_24: "age_18_24",
1183
+ AGE_25_59: "age_25_59",
1184
+ AGE_60_PLUS: "age_60_plus",
1185
+ NOT_REPORTED: "not_reported",
1186
+ NOT_TRACKED: "not_tracked",
1187
+ } as const;
1188
+
1189
+ export type AgeBinReportingValue =
1190
+ (typeof AGE_BIN_REPORTING)[keyof typeof AGE_BIN_REPORTING];
1191
+
1192
+ export const AGE_BIN_REPORTING_LABELS: Record<AgeBinReportingValue, string> = {
1193
+ [AGE_BIN_REPORTING.AGE_0_12]: "0–12 years",
1194
+ [AGE_BIN_REPORTING.AGE_13_17]: "13–17 years",
1195
+ [AGE_BIN_REPORTING.AGE_18_24]: "18–24 years",
1196
+ [AGE_BIN_REPORTING.AGE_25_59]: "25–59 years",
1197
+ [AGE_BIN_REPORTING.AGE_60_PLUS]: "60+ years",
1198
+ [AGE_BIN_REPORTING.NOT_REPORTED]: "Not Reported",
1199
+ [AGE_BIN_REPORTING.NOT_TRACKED]: "Not Tracked",
1200
+ };
1201
+
1202
+ export const AGE_BIN_REPORTING_IS_MINOR: Record<
1203
+ AgeBinReportingValue,
1204
+ boolean | null
1205
+ > = {
1206
+ [AGE_BIN_REPORTING.AGE_0_12]: true,
1207
+ [AGE_BIN_REPORTING.AGE_13_17]: true,
1208
+ [AGE_BIN_REPORTING.AGE_18_24]: false,
1209
+ [AGE_BIN_REPORTING.AGE_25_59]: false,
1210
+ [AGE_BIN_REPORTING.AGE_60_PLUS]: false,
1211
+ [AGE_BIN_REPORTING.NOT_REPORTED]: null,
1212
+ [AGE_BIN_REPORTING.NOT_TRACKED]: null,
1213
+ };
1214
+
1215
+ /** Derive VOCA age bin from numeric age */
1216
+ export function deriveAgeBinFromAge(age: number): AgeBinReportingValue {
1217
+ // Validate input: must be finite integer in reasonable range
1218
+ if (!Number.isFinite(age) || !Number.isInteger(age) || age < 0 || age > 150) {
1219
+ return AGE_BIN_REPORTING.NOT_REPORTED;
1220
+ }
1221
+ if (age <= 12) return AGE_BIN_REPORTING.AGE_0_12;
1222
+ if (age <= 17) return AGE_BIN_REPORTING.AGE_13_17;
1223
+ if (age <= 24) return AGE_BIN_REPORTING.AGE_18_24;
1224
+ if (age <= 59) return AGE_BIN_REPORTING.AGE_25_59;
1225
+ return AGE_BIN_REPORTING.AGE_60_PLUS;
1226
+ }
1227
+
1228
+ // ─── Quick Start Templates ──────────────────────────────────────────
1229
+
1230
+ export const QUICK_START_TEMPLATES = {
1231
+ HOTLINE_CALL: "hotline_call",
1232
+ LAP_INCIDENT: "lap_incident",
1233
+ HT_REFERRAL: "ht_referral",
1234
+ FIELD_RESPONSE: "field_response",
1235
+ EMAIL_CRISIS: "email_crisis",
1236
+ OTHER: "other",
1237
+ } as const;
1238
+
1239
+ export type QuickStartTemplateId =
1240
+ (typeof QUICK_START_TEMPLATES)[keyof typeof QUICK_START_TEMPLATES];
1241
+
1242
+ export const QUICK_START_LABELS: Record<QuickStartTemplateId, string> = {
1243
+ hotline_call: "Hotline Call",
1244
+ lap_incident: "LAP Incident",
1245
+ ht_referral: "HT Referral",
1246
+ field_response: "Field Response",
1247
+ email_crisis: "Email / Crisis",
1248
+ other: "Other",
1249
+ };
1250
+
1251
+ export const QUICK_START_CONFIG: Record<
1252
+ QuickStartTemplateId,
1253
+ { contactMethod: number; interactionType: number; intakeFormKey?: string }
1254
+ > = {
1255
+ hotline_call: {
1256
+ contactMethod: IC_56_SERVICE_DELIVERY_CHANNEL.PHONE,
1257
+ interactionType: INTERACTION_TYPES.HOTLINE_CALL,
1258
+ intakeFormKey: "hotline_call",
1259
+ },
1260
+ lap_incident: {
1261
+ contactMethod: IC_56_SERVICE_DELIVERY_CHANNEL.ON_SCENE,
1262
+ interactionType: INTERACTION_TYPES.LAP_INCIDENT,
1263
+ },
1264
+ ht_referral: {
1265
+ contactMethod: IC_56_SERVICE_DELIVERY_CHANNEL.IN_PERSON,
1266
+ interactionType: INTERACTION_TYPES.OTHER,
1267
+ },
1268
+ field_response: {
1269
+ contactMethod: IC_56_SERVICE_DELIVERY_CHANNEL.ON_SCENE,
1270
+ interactionType: INTERACTION_TYPES.FIELD_RESPONSE,
1271
+ },
1272
+ email_crisis: {
1273
+ contactMethod: IC_56_SERVICE_DELIVERY_CHANNEL.PHONE,
1274
+ interactionType: INTERACTION_TYPES.EMAIL_CRISIS,
1275
+ },
1276
+ other: {
1277
+ contactMethod: IC_56_SERVICE_DELIVERY_CHANNEL.PHONE,
1278
+ interactionType: INTERACTION_TYPES.OTHER,
1279
+ },
1280
+ };
1281
+
1282
+ // ─── Submission States ─────────────────────────────────────────
1283
+
1284
+ export const SUBMISSION_STATES = {
1285
+ IN_PROGRESS: 1,
1286
+ SUBMITTED: 2,
1287
+ LOCKED: 3,
1288
+ } as const;
1289
+
1290
+ export type SubmissionStateValue =
1291
+ (typeof SUBMISSION_STATES)[keyof typeof SUBMISSION_STATES];
1292
+
1293
+ export const SUBMISSION_STATE_LABELS: Record<SubmissionStateValue, string> = {
1294
+ [SUBMISSION_STATES.IN_PROGRESS]: "In Progress",
1295
+ [SUBMISSION_STATES.SUBMITTED]: "Submitted",
1296
+ [SUBMISSION_STATES.LOCKED]: "Locked",
1297
+ };
1298
+
1299
+ // ─── Form Status ───────────────────────────────────────────────
1300
+
1301
+ export const FORM_STATUS = {
1302
+ DRAFT: "draft",
1303
+ ACTIVE: "active",
1304
+ DEPRECATED: "deprecated",
1305
+ } as const;
1306
+
1307
+ export type FormStatusValue = (typeof FORM_STATUS)[keyof typeof FORM_STATUS];
1308
+
1309
+ export const FORM_STATUS_LABELS: Record<FormStatusValue, string> = {
1310
+ [FORM_STATUS.DRAFT]: "Draft",
1311
+ [FORM_STATUS.ACTIVE]: "Active",
1312
+ [FORM_STATUS.DEPRECATED]: "Deprecated",
1313
+ };
1314
+
1315
+ // ─── Question Format ───────────────────────────────────────────
1316
+
1317
+ export const QUESTION_FORMAT = {
1318
+ EXCLUSIVE: "exclusive",
1319
+ INCLUSIVE: "inclusive",
1320
+ DROPDOWN: "dropdown",
1321
+ BINARY: "binary",
1322
+ TEXT: "text",
1323
+ NUMBER: "number",
1324
+ DATE: "date",
1325
+ MULTISELECT: "multiselect",
1326
+ } as const;
1327
+
1328
+ /** @deprecated Use KNOWN_QUESTION_FORMATS from schemas/forms */
1329
+ export type QuestionFormatValue =
1330
+ (typeof QUESTION_FORMAT)[keyof typeof QUESTION_FORMAT];
1331
+
1332
+ export const QUESTION_FORMAT_LABELS: Record<string, string> = {
1333
+ [QUESTION_FORMAT.EXCLUSIVE]: "Single Select (Radio)",
1334
+ [QUESTION_FORMAT.INCLUSIVE]: "Multi Select (Checkbox)",
1335
+ [QUESTION_FORMAT.DROPDOWN]: "Dropdown",
1336
+ [QUESTION_FORMAT.BINARY]: "Yes / No",
1337
+ [QUESTION_FORMAT.TEXT]: "Text",
1338
+ [QUESTION_FORMAT.NUMBER]: "Number",
1339
+ [QUESTION_FORMAT.DATE]: "Date",
1340
+ [QUESTION_FORMAT.MULTISELECT]: "Multi Select (Dropdown)",
1341
+ };
1342
+
1343
+ // ─── App Scope ─────────────────────────────────────────────────
1344
+
1345
+ export const APP_SCOPE = {
1346
+ THREAD: "thread",
1347
+ PAVE: "pave",
1348
+ BOTH: "both",
1349
+ } as const;
1350
+
1351
+ export type AppScopeValue = (typeof APP_SCOPE)[keyof typeof APP_SCOPE];
1352
+
1353
+ // ─── Form Type ─────────────────────────────────────────────────
1354
+
1355
+ export const FORM_TYPE = {
1356
+ SCREENING: "screening",
1357
+ INTAKE: "intake",
1358
+ ASSESSMENT: "assessment",
1359
+ DEMOGRAPHICS: "demographics",
1360
+ } as const;
1361
+
1362
+ export type FormTypeValue = (typeof FORM_TYPE)[keyof typeof FORM_TYPE];
1363
+
1364
+ export const FORM_TYPE_LABELS: Record<FormTypeValue, string> = {
1365
+ [FORM_TYPE.SCREENING]: "Screening",
1366
+ [FORM_TYPE.INTAKE]: "Intake",
1367
+ [FORM_TYPE.ASSESSMENT]: "Assessment",
1368
+ [FORM_TYPE.DEMOGRAPHICS]: "Demographics",
1369
+ };
1370
+
1371
+ // ─── User Status ─────────────────────────────────────────────────
1372
+ // Platform-level user account status codes
1373
+
1374
+ export const USER_STATUS = {
1375
+ CREATED: 0,
1376
+ PENDING_APPROVAL: 1,
1377
+ APPROVED: 2,
1378
+ DENIED: 3,
1379
+ INVITED: 4,
1380
+ REVOKED: 5,
1381
+ } as const;
1382
+
1383
+ export type UserStatusValue = (typeof USER_STATUS)[keyof typeof USER_STATUS];
1384
+
1385
+ export const USER_STATUS_LABELS: Record<UserStatusValue, string> = {
1386
+ [USER_STATUS.CREATED]: "Created",
1387
+ [USER_STATUS.PENDING_APPROVAL]: "Pending Approval",
1388
+ [USER_STATUS.APPROVED]: "Approved",
1389
+ [USER_STATUS.DENIED]: "Denied",
1390
+ [USER_STATUS.INVITED]: "Invited",
1391
+ [USER_STATUS.REVOKED]: "Revoked",
1392
+ };
1393
+
1394
+ // ─── CVC-69: Incident Participation Role ────────────────────────────
1395
+ // Multi-valued: 0+ per person per session. Describes session participation.
1396
+
1397
+ export const INCIDENT_PARTICIPATION_ROLE = {
1398
+ CLIENT_SUBJECT: "client_subject", // Exactly 1 per session
1399
+ CALLER_SELF: "caller_self",
1400
+ CALLER_THIRD_PARTY: "caller_third_party",
1401
+ REPORTER: "reporter",
1402
+ FAMILY_MEMBER_OR_GUARDIAN: "family_member_or_guardian",
1403
+ FRIEND_OR_PEER: "friend_or_peer",
1404
+ SERVICE_PROVIDER_STAFF: "service_provider_staff",
1405
+ MEDICAL_PROVIDER_STAFF: "medical_provider_staff",
1406
+ UNKNOWN: "unknown",
1407
+ ANONYMOUS: "anonymous",
1408
+ NOT_COLLECTED: "not_collected",
1409
+ } as const;
1410
+
1411
+ export type IncidentParticipationRoleValue =
1412
+ (typeof INCIDENT_PARTICIPATION_ROLE)[keyof typeof INCIDENT_PARTICIPATION_ROLE];
1413
+
1414
+ export const INCIDENT_PARTICIPATION_ROLE_VALUES = [
1415
+ INCIDENT_PARTICIPATION_ROLE.CLIENT_SUBJECT,
1416
+ INCIDENT_PARTICIPATION_ROLE.CALLER_SELF,
1417
+ INCIDENT_PARTICIPATION_ROLE.CALLER_THIRD_PARTY,
1418
+ INCIDENT_PARTICIPATION_ROLE.REPORTER,
1419
+ INCIDENT_PARTICIPATION_ROLE.FAMILY_MEMBER_OR_GUARDIAN,
1420
+ INCIDENT_PARTICIPATION_ROLE.FRIEND_OR_PEER,
1421
+ INCIDENT_PARTICIPATION_ROLE.SERVICE_PROVIDER_STAFF,
1422
+ INCIDENT_PARTICIPATION_ROLE.MEDICAL_PROVIDER_STAFF,
1423
+ INCIDENT_PARTICIPATION_ROLE.UNKNOWN,
1424
+ INCIDENT_PARTICIPATION_ROLE.ANONYMOUS,
1425
+ INCIDENT_PARTICIPATION_ROLE.NOT_COLLECTED,
1426
+ ] as const;
1427
+
1428
+ export const INCIDENT_PARTICIPATION_ROLE_LABELS: Record<
1429
+ IncidentParticipationRoleValue,
1430
+ string
1431
+ > = {
1432
+ [INCIDENT_PARTICIPATION_ROLE.CLIENT_SUBJECT]: "Client / Subject-of-Record",
1433
+ [INCIDENT_PARTICIPATION_ROLE.CALLER_SELF]: "Caller (Self)",
1434
+ [INCIDENT_PARTICIPATION_ROLE.CALLER_THIRD_PARTY]: "Caller (Third Party)",
1435
+ [INCIDENT_PARTICIPATION_ROLE.REPORTER]: "Reporter / Information Source",
1436
+ [INCIDENT_PARTICIPATION_ROLE.FAMILY_MEMBER_OR_GUARDIAN]:
1437
+ "Family Member or Guardian",
1438
+ [INCIDENT_PARTICIPATION_ROLE.FRIEND_OR_PEER]: "Friend or Peer",
1439
+ [INCIDENT_PARTICIPATION_ROLE.SERVICE_PROVIDER_STAFF]:
1440
+ "Service Provider Staff",
1441
+ [INCIDENT_PARTICIPATION_ROLE.MEDICAL_PROVIDER_STAFF]:
1442
+ "Medical Provider Staff",
1443
+ [INCIDENT_PARTICIPATION_ROLE.UNKNOWN]: "Unknown",
1444
+ [INCIDENT_PARTICIPATION_ROLE.ANONYMOUS]: "Anonymous",
1445
+ [INCIDENT_PARTICIPATION_ROLE.NOT_COLLECTED]: "Not Collected",
1446
+ };
1447
+
1448
+ /**
1449
+ * Participation role category groupings for UI organization.
1450
+ *
1451
+ * Note: UNKNOWN, ANONYMOUS, and NOT_COLLECTED are intentionally excluded.
1452
+ * These are data quality states, not selectable participation roles.
1453
+ * Handle them via separate UI controls (e.g., "Unknown" / "Anonymous" buttons).
1454
+ */
1455
+ export const PARTICIPATION_ROLE_CATEGORIES = {
1456
+ CLIENT: [INCIDENT_PARTICIPATION_ROLE.CLIENT_SUBJECT],
1457
+ CALLER_REPORTER: [
1458
+ INCIDENT_PARTICIPATION_ROLE.CALLER_SELF,
1459
+ INCIDENT_PARTICIPATION_ROLE.CALLER_THIRD_PARTY,
1460
+ INCIDENT_PARTICIPATION_ROLE.REPORTER,
1461
+ ],
1462
+ SUPPORT_NETWORK: [
1463
+ INCIDENT_PARTICIPATION_ROLE.FAMILY_MEMBER_OR_GUARDIAN,
1464
+ INCIDENT_PARTICIPATION_ROLE.FRIEND_OR_PEER,
1465
+ ],
1466
+ SYSTEM_PROFESSIONAL: [
1467
+ INCIDENT_PARTICIPATION_ROLE.SERVICE_PROVIDER_STAFF,
1468
+ INCIDENT_PARTICIPATION_ROLE.MEDICAL_PROVIDER_STAFF,
1469
+ ],
1470
+ } as const;
1471
+
1472
+ /** All participation roles assigned to a victim who is also the caller. */
1473
+ export const CALLER_IS_VICTIM_ROLES: IncidentParticipationRoleValue[] = [
1474
+ INCIDENT_PARTICIPATION_ROLE.CLIENT_SUBJECT,
1475
+ INCIDENT_PARTICIPATION_ROLE.CALLER_SELF,
1476
+ INCIDENT_PARTICIPATION_ROLE.REPORTER,
1477
+ ];
1478
+
1479
+ // ─── Person Display Category ────────────────────────────────────────
1480
+ // 5 UI groupings for displaying persons based on involvement role.
1481
+
1482
+ export const PERSON_DISPLAY_CATEGORY = {
1483
+ PRIMARY_VICTIM: "primary_victim",
1484
+ ELIGIBLE_FAMILY: "eligible_family",
1485
+ OFFENDER: "offender",
1486
+ THIRD_PARTY: "third_party",
1487
+ PERSONNEL: "personnel",
1488
+ } as const;
1489
+
1490
+ export type PersonDisplayCategoryValue =
1491
+ (typeof PERSON_DISPLAY_CATEGORY)[keyof typeof PERSON_DISPLAY_CATEGORY];
1492
+
1493
+ export const PERSON_DISPLAY_CATEGORY_LABELS: Record<
1494
+ PersonDisplayCategoryValue,
1495
+ string
1496
+ > = {
1497
+ [PERSON_DISPLAY_CATEGORY.PRIMARY_VICTIM]: "Primary Victim",
1498
+ [PERSON_DISPLAY_CATEGORY.ELIGIBLE_FAMILY]: "Eligible Family Member",
1499
+ [PERSON_DISPLAY_CATEGORY.OFFENDER]: "Offender",
1500
+ [PERSON_DISPLAY_CATEGORY.THIRD_PARTY]: "Third Party",
1501
+ [PERSON_DISPLAY_CATEGORY.PERSONNEL]: "Personnel",
1502
+ };
1503
+
1504
+ // ─── Person Type ────────────────────────────────────────────────────
1505
+ // The 4 canonical person model types in the platform.
1506
+
1507
+ export const PERSON_TYPE = {
1508
+ PROTECTED: "ProtectedPerson",
1509
+ PERPETRATOR: "PerpetratorPerson",
1510
+ PERSONNEL: "PersonnelPerson",
1511
+ THIRD_PARTY: "ThirdPartyPerson",
1512
+ } as const;
1513
+
1514
+ export type PersonTypeValue = (typeof PERSON_TYPE)[keyof typeof PERSON_TYPE];
1515
+
1516
+ /** Tuple of valid PERSON_TYPE values for schema consumption. */
1517
+ export const PERSON_TYPE_VALUES = [
1518
+ PERSON_TYPE.PROTECTED,
1519
+ PERSON_TYPE.PERPETRATOR,
1520
+ PERSON_TYPE.PERSONNEL,
1521
+ PERSON_TYPE.THIRD_PARTY,
1522
+ ] as const;
1523
+
1524
+ // ─── Involvement Role → Person Type Mapping ─────────────────────────
1525
+
1526
+ /**
1527
+ * Static mapping from involvement role to person type.
1528
+ *
1529
+ * Note: Returns `null` for UNKNOWN and NOT_COLLECTED because these roles
1530
+ * require contextual handling. For these cases, use `getPersonTypeForRole()`
1531
+ * which applies conditional logic (e.g., preserving Personnel context).
1532
+ *
1533
+ * @see getPersonTypeForRole for the recommended API with null handling
1534
+ */
1535
+ export const INVOLVEMENT_ROLE_TO_PERSON_TYPE: Record<
1536
+ IncidentInvolvementRoleValue,
1537
+ PersonTypeValue | null
1538
+ > = {
1539
+ [INCIDENT_INVOLVEMENT_ROLE.VICTIM_PRIMARY]: PERSON_TYPE.PROTECTED,
1540
+ [INCIDENT_INVOLVEMENT_ROLE.VICTIM_SECONDARY]: PERSON_TYPE.PROTECTED,
1541
+ [INCIDENT_INVOLVEMENT_ROLE.VICTIM_OTHER]: PERSON_TYPE.PROTECTED,
1542
+ [INCIDENT_INVOLVEMENT_ROLE.DEPENDENT]: PERSON_TYPE.PROTECTED,
1543
+ [INCIDENT_INVOLVEMENT_ROLE.WITNESS]: PERSON_TYPE.THIRD_PARTY,
1544
+ [INCIDENT_INVOLVEMENT_ROLE.OFFENDER]: PERSON_TYPE.PERPETRATOR,
1545
+ // unknown defaults to ThirdParty unless context indicates Personnel
1546
+ [INCIDENT_INVOLVEMENT_ROLE.UNKNOWN]: null, // Conditional — use getPersonTypeForRole()
1547
+ [INCIDENT_INVOLVEMENT_ROLE.ANONYMOUS]: PERSON_TYPE.THIRD_PARTY,
1548
+ [INCIDENT_INVOLVEMENT_ROLE.NOT_COLLECTED]: null,
1549
+ };
1550
+
1551
+ /**
1552
+ * Get the person type for an involvement role.
1553
+ * For 'unknown', preserves PersonnelPerson if provided as context, otherwise defaults to ThirdPartyPerson.
1554
+ * Returns null for 'not_collected' (data quality state — cannot infer person type).
1555
+ */
1556
+ export function getPersonTypeForRole(
1557
+ role: IncidentInvolvementRoleValue,
1558
+ contextPersonType?: PersonTypeValue,
1559
+ ): PersonTypeValue | null {
1560
+ // NOT_COLLECTED is a data quality state, not a role — cannot infer person type
1561
+ if (role === INCIDENT_INVOLVEMENT_ROLE.NOT_COLLECTED) {
1562
+ return null;
1563
+ }
1564
+ // UNKNOWN: only Personnel context is preserved; all others default to ThirdPartyPerson
1565
+ if (role === INCIDENT_INVOLVEMENT_ROLE.UNKNOWN) {
1566
+ return contextPersonType === PERSON_TYPE.PERSONNEL
1567
+ ? PERSON_TYPE.PERSONNEL
1568
+ : PERSON_TYPE.THIRD_PARTY;
1569
+ }
1570
+ return INVOLVEMENT_ROLE_TO_PERSON_TYPE[role] ?? PERSON_TYPE.THIRD_PARTY;
1571
+ }
1572
+
1573
+ /**
1574
+ * Get the display category for a person based on involvement role and person type.
1575
+ * Handles the conditional 'unknown' case where PersonnelPerson → Personnel category.
1576
+ */
1577
+ export function getDisplayCategoryForRole(
1578
+ role: IncidentInvolvementRoleValue,
1579
+ personType?: PersonTypeValue,
1580
+ ): PersonDisplayCategoryValue {
1581
+ switch (role) {
1582
+ case INCIDENT_INVOLVEMENT_ROLE.VICTIM_PRIMARY:
1583
+ return PERSON_DISPLAY_CATEGORY.PRIMARY_VICTIM;
1584
+
1585
+ case INCIDENT_INVOLVEMENT_ROLE.DEPENDENT:
1586
+ case INCIDENT_INVOLVEMENT_ROLE.VICTIM_SECONDARY:
1587
+ return PERSON_DISPLAY_CATEGORY.ELIGIBLE_FAMILY;
1588
+
1589
+ case INCIDENT_INVOLVEMENT_ROLE.OFFENDER:
1590
+ return PERSON_DISPLAY_CATEGORY.OFFENDER;
1591
+
1592
+ case INCIDENT_INVOLVEMENT_ROLE.WITNESS:
1593
+ case INCIDENT_INVOLVEMENT_ROLE.ANONYMOUS:
1594
+ return PERSON_DISPLAY_CATEGORY.THIRD_PARTY;
1595
+
1596
+ case INCIDENT_INVOLVEMENT_ROLE.UNKNOWN:
1597
+ // Conditional: PersonnelPerson → Personnel, otherwise Third Party
1598
+ if (personType === PERSON_TYPE.PERSONNEL) {
1599
+ return PERSON_DISPLAY_CATEGORY.PERSONNEL;
1600
+ }
1601
+ return PERSON_DISPLAY_CATEGORY.THIRD_PARTY;
1602
+
1603
+ case INCIDENT_INVOLVEMENT_ROLE.VICTIM_OTHER:
1604
+ // Not reachable in Thread, but map to Eligible Family if it occurs
1605
+ return PERSON_DISPLAY_CATEGORY.ELIGIBLE_FAMILY;
1606
+
1607
+ case INCIDENT_INVOLVEMENT_ROLE.NOT_COLLECTED:
1608
+ default:
1609
+ return PERSON_DISPLAY_CATEGORY.THIRD_PARTY;
1610
+ }
1611
+ }
1612
+
1613
+ // ─── Default Participation Roles by Display Category ───────────────
1614
+ // When toggling "Involved" on, these are the default participation roles.
1615
+
1616
+ export const DEFAULT_PARTICIPATION_ROLE_BY_CATEGORY: Record<
1617
+ PersonDisplayCategoryValue,
1618
+ IncidentParticipationRoleValue | null
1619
+ > = {
1620
+ [PERSON_DISPLAY_CATEGORY.PRIMARY_VICTIM]:
1621
+ INCIDENT_PARTICIPATION_ROLE.CLIENT_SUBJECT,
1622
+ [PERSON_DISPLAY_CATEGORY.ELIGIBLE_FAMILY]:
1623
+ INCIDENT_PARTICIPATION_ROLE.FAMILY_MEMBER_OR_GUARDIAN,
1624
+ // Offenders are classified by involvement (CVC-130), not session participation (CVC-69)
1625
+ [PERSON_DISPLAY_CATEGORY.OFFENDER]: null,
1626
+ [PERSON_DISPLAY_CATEGORY.THIRD_PARTY]:
1627
+ INCIDENT_PARTICIPATION_ROLE.FRIEND_OR_PEER,
1628
+ [PERSON_DISPLAY_CATEGORY.PERSONNEL]:
1629
+ INCIDENT_PARTICIPATION_ROLE.SERVICE_PROVIDER_STAFF,
1630
+ };