@htilabs/platform-common-models 0.6.0 → 0.7.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +44 -0
  2. package/dist/config/index.cjs +191 -0
  3. package/dist/config/index.cjs.map +1 -0
  4. package/dist/config/index.d.cts +101 -0
  5. package/dist/config/index.d.ts +101 -0
  6. package/dist/config/index.js +165 -0
  7. package/dist/config/index.js.map +1 -0
  8. package/dist/constants/index.cjs +46 -5
  9. package/dist/constants/index.cjs.map +1 -1
  10. package/dist/constants/index.d.cts +1 -1
  11. package/dist/constants/index.d.ts +1 -1
  12. package/dist/constants/index.js +42 -5
  13. package/dist/constants/index.js.map +1 -1
  14. package/dist/cvcs/index.cjs +321 -0
  15. package/dist/cvcs/index.cjs.map +1 -1
  16. package/dist/cvcs/index.d.cts +789 -436
  17. package/dist/cvcs/index.d.ts +789 -436
  18. package/dist/cvcs/index.js +318 -0
  19. package/dist/cvcs/index.js.map +1 -1
  20. package/dist/index.cjs +424 -6
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +94 -3
  23. package/dist/index.d.ts +94 -3
  24. package/dist/index.js +412 -6
  25. package/dist/index.js.map +1 -1
  26. package/dist/{platform-auth-CjC57132.d.cts → platform-auth-C97LpsRd.d.cts} +8 -4
  27. package/dist/{platform-auth-CjC57132.d.ts → platform-auth-C97LpsRd.d.ts} +8 -4
  28. package/dist/schemas/index.cjs +43 -6
  29. package/dist/schemas/index.cjs.map +1 -1
  30. package/dist/schemas/index.d.cts +4 -0
  31. package/dist/schemas/index.d.ts +4 -0
  32. package/dist/schemas/index.js +43 -6
  33. package/dist/schemas/index.js.map +1 -1
  34. package/dist/types/index.d.cts +2 -2
  35. package/dist/types/index.d.ts +2 -2
  36. package/package.json +9 -2
  37. package/src/__tests__/__snapshots__/cvc-sot.snap +12 -0
  38. package/src/__tests__/cvc-sot-snapshot.test.ts +24 -0
  39. package/src/__tests__/cvc-structural.test.ts +3 -0
  40. package/src/__tests__/runtime-contract-validator.test.ts +556 -0
  41. package/src/config/fixtures/valid.yaml +90 -0
  42. package/src/config/index.ts +352 -0
  43. package/src/constants/ic.ts +49 -6
  44. package/src/cvcs/hmisSex.v1.0.0.json +89 -0
  45. package/src/cvcs/index.ts +6 -0
  46. package/src/cvcs/juvenileJusticeEpisodeType.v1.0.0.json +96 -0
  47. package/src/cvcs/recencyBand.v1.0.0.json +124 -0
  48. package/src/generated/cvc-enums.ts +59 -0
  49. package/src/index.ts +20 -0
  50. package/src/schemas/common.ts +4 -0
@@ -0,0 +1,96 @@
1
+ {
2
+ "domain": "juvenile_justice_episode_type",
3
+ "name": "Core Juvenile Justice Episode Type",
4
+ "version": "1.0.0",
5
+ "levels": {
6
+ "0": "Unknown or Missing",
7
+ "1": "Episode Type"
8
+ },
9
+ "entries": [
10
+ {
11
+ "code": "197-000-000-000-000-000-000",
12
+ "key": "missingness_root",
13
+ "title": "Unknown, Redacted, or Missing",
14
+ "selectable": false,
15
+ "parentCode": null,
16
+ "childCodes": [
17
+ "197-000-000-000-000-000-001",
18
+ "197-000-000-000-000-000-002",
19
+ "197-000-000-000-000-000-003"
20
+ ],
21
+ "definition": "Root group for values indicating absent, withheld, or uncollected data."
22
+ },
23
+ {
24
+ "code": "197-000-000-000-000-000-001",
25
+ "key": "unknown",
26
+ "title": "Unknown",
27
+ "selectable": true,
28
+ "parentCode": "197-000-000-000-000-000-000",
29
+ "childCodes": [],
30
+ "definition": "Value is unknown at time of entry."
31
+ },
32
+ {
33
+ "code": "197-000-000-000-000-000-002",
34
+ "key": "anonymous",
35
+ "title": "Anonymous",
36
+ "selectable": true,
37
+ "parentCode": "197-000-000-000-000-000-000",
38
+ "childCodes": [],
39
+ "definition": "Value is intentionally withheld or redacted."
40
+ },
41
+ {
42
+ "code": "197-000-000-000-000-000-003",
43
+ "key": "data_not_collected",
44
+ "title": "Data not collected",
45
+ "selectable": true,
46
+ "parentCode": "197-000-000-000-000-000-000",
47
+ "childCodes": [],
48
+ "definition": "No attempt was made to collect the value."
49
+ },
50
+ {
51
+ "code": "197-001-000-000-000-000-000",
52
+ "key": "detention_stay",
53
+ "title": "Detention stay",
54
+ "selectable": true,
55
+ "parentCode": null,
56
+ "childCodes": [],
57
+ "definition": "A period of confinement in a juvenile detention facility."
58
+ },
59
+ {
60
+ "code": "197-002-000-000-000-000-000",
61
+ "key": "diversion_program",
62
+ "title": "Diversion program",
63
+ "selectable": true,
64
+ "parentCode": null,
65
+ "childCodes": [],
66
+ "definition": "Participation in a program that diverts a youth away from formal juvenile court processing."
67
+ },
68
+ {
69
+ "code": "197-003-000-000-000-000-000",
70
+ "key": "pending_adjudication",
71
+ "title": "Pending charges / adjudication process",
72
+ "selectable": true,
73
+ "parentCode": null,
74
+ "childCodes": [],
75
+ "definition": "An open juvenile case awaiting adjudication."
76
+ },
77
+ {
78
+ "code": "197-004-000-000-000-000-000",
79
+ "key": "probation_supervision",
80
+ "title": "Probation / community supervision (juvenile)",
81
+ "selectable": true,
82
+ "parentCode": null,
83
+ "childCodes": [],
84
+ "definition": "Court-ordered supervision of a youth in the community rather than in confinement."
85
+ },
86
+ {
87
+ "code": "197-005-000-000-000-000-000",
88
+ "key": "residential_jj_placement",
89
+ "title": "Residential JJ placement",
90
+ "selectable": true,
91
+ "parentCode": null,
92
+ "childCodes": [],
93
+ "definition": "Placement in a residential juvenile justice facility (e.g. training school, residential treatment)."
94
+ }
95
+ ]
96
+ }
@@ -0,0 +1,124 @@
1
+ {
2
+ "domain": "recency_band",
3
+ "name": "Core Recency Band",
4
+ "version": "1.0.0",
5
+ "levels": {
6
+ "0": "Unknown or Missing",
7
+ "1": "Recency Band"
8
+ },
9
+ "entries": [
10
+ {
11
+ "code": "137-000-000-000-000-000-000",
12
+ "key": "missingness_root",
13
+ "title": "Unknown, Redacted, or Missing",
14
+ "selectable": false,
15
+ "parentCode": null,
16
+ "childCodes": [
17
+ "137-000-000-000-000-000-001",
18
+ "137-000-000-000-000-000-002",
19
+ "137-000-000-000-000-000-003",
20
+ "137-000-000-000-000-000-004"
21
+ ],
22
+ "definition": "Root group for values indicating absent, withheld, or uncollected data."
23
+ },
24
+ {
25
+ "code": "137-000-000-000-000-000-001",
26
+ "key": "unknown",
27
+ "title": "Unknown",
28
+ "selectable": true,
29
+ "parentCode": "137-000-000-000-000-000-000",
30
+ "childCodes": [],
31
+ "definition": "Value is unknown at time of entry."
32
+ },
33
+ {
34
+ "code": "137-000-000-000-000-000-002",
35
+ "key": "anonymous",
36
+ "title": "Anonymous",
37
+ "selectable": true,
38
+ "parentCode": "137-000-000-000-000-000-000",
39
+ "childCodes": [],
40
+ "definition": "Value is intentionally withheld or redacted."
41
+ },
42
+ {
43
+ "code": "137-000-000-000-000-000-003",
44
+ "key": "data_not_collected",
45
+ "title": "Data not collected",
46
+ "selectable": true,
47
+ "parentCode": "137-000-000-000-000-000-000",
48
+ "childCodes": [],
49
+ "definition": "No attempt was made to collect the value."
50
+ },
51
+ {
52
+ "code": "137-000-000-000-000-000-004",
53
+ "key": "prefer_not_to_answer",
54
+ "title": "Client prefers not to answer",
55
+ "selectable": true,
56
+ "parentCode": "137-000-000-000-000-000-000",
57
+ "childCodes": [],
58
+ "definition": "Client was offered the opportunity to self-identify and explicitly declined to provide the value."
59
+ },
60
+ {
61
+ "code": "137-001-000-000-000-000-000",
62
+ "key": "less_than_3_years",
63
+ "title": "Less than 3 years ago",
64
+ "selectable": true,
65
+ "parentCode": null,
66
+ "childCodes": [],
67
+ "definition": "The asserted event occurred less than 3 years ago."
68
+ },
69
+ {
70
+ "code": "137-002-000-000-000-000-000",
71
+ "key": "months_3_to_6",
72
+ "title": "3-6 months ago",
73
+ "selectable": true,
74
+ "parentCode": null,
75
+ "childCodes": [],
76
+ "definition": "The asserted event occurred between 3 and 6 months ago."
77
+ },
78
+ {
79
+ "code": "137-003-000-000-000-000-000",
80
+ "key": "months_6_to_12",
81
+ "title": "6-12 months ago",
82
+ "selectable": true,
83
+ "parentCode": null,
84
+ "childCodes": [],
85
+ "definition": "The asserted event occurred between 6 and 12 months ago."
86
+ },
87
+ {
88
+ "code": "137-004-000-000-000-000-000",
89
+ "key": "one_year_or_more",
90
+ "title": "One year or more",
91
+ "selectable": true,
92
+ "parentCode": null,
93
+ "childCodes": [],
94
+ "definition": "The asserted event occurred one year or more ago (without further granularity)."
95
+ },
96
+ {
97
+ "code": "137-005-000-000-000-000-000",
98
+ "key": "ten_plus_years",
99
+ "title": "10+ years ago",
100
+ "selectable": true,
101
+ "parentCode": null,
102
+ "childCodes": [],
103
+ "definition": "The asserted event occurred 10 or more years ago."
104
+ },
105
+ {
106
+ "code": "137-006-000-000-000-000-000",
107
+ "key": "within_3_months",
108
+ "title": "Within past 3 months",
109
+ "selectable": true,
110
+ "parentCode": null,
111
+ "childCodes": [],
112
+ "definition": "The asserted event occurred within the past 3 months."
113
+ },
114
+ {
115
+ "code": "137-007-000-000-000-000-000",
116
+ "key": "years_3_to_10",
117
+ "title": "3-10 years ago",
118
+ "selectable": true,
119
+ "parentCode": null,
120
+ "childCodes": [],
121
+ "definition": "The asserted event occurred between 3 and 10 years ago."
122
+ }
123
+ ]
124
+ }
@@ -1474,3 +1474,62 @@ export const FrequencyCadenceKeys = {
1474
1474
  } as const;
1475
1475
 
1476
1476
  export type FrequencyCadenceKey = keyof typeof FrequencyCadenceKeys;
1477
+
1478
+ /**
1479
+ * Key → positional code map for the `recency_band` CVC domain.
1480
+ *
1481
+ * Domain: `recency_band` · Version: 1.0.0 · Entries: 12
1482
+ */
1483
+ export const RecencyBandKeys = {
1484
+ missingness_root: "137-000-000-000-000-000-000",
1485
+ unknown: "137-000-000-000-000-000-001",
1486
+ anonymous: "137-000-000-000-000-000-002",
1487
+ data_not_collected: "137-000-000-000-000-000-003",
1488
+ prefer_not_to_answer: "137-000-000-000-000-000-004",
1489
+ less_than_3_years: "137-001-000-000-000-000-000",
1490
+ months_3_to_6: "137-002-000-000-000-000-000",
1491
+ months_6_to_12: "137-003-000-000-000-000-000",
1492
+ one_year_or_more: "137-004-000-000-000-000-000",
1493
+ ten_plus_years: "137-005-000-000-000-000-000",
1494
+ within_3_months: "137-006-000-000-000-000-000",
1495
+ years_3_to_10: "137-007-000-000-000-000-000",
1496
+ } as const;
1497
+
1498
+ export type RecencyBandKey = keyof typeof RecencyBandKeys;
1499
+
1500
+ /**
1501
+ * Key → positional code map for the `juvenile_justice_episode_type` CVC domain.
1502
+ *
1503
+ * Domain: `juvenile_justice_episode_type` · Version: 1.0.0 · Entries: 9
1504
+ */
1505
+ export const JuvenileJusticeEpisodeTypeKeys = {
1506
+ missingness_root: "197-000-000-000-000-000-000",
1507
+ unknown: "197-000-000-000-000-000-001",
1508
+ anonymous: "197-000-000-000-000-000-002",
1509
+ data_not_collected: "197-000-000-000-000-000-003",
1510
+ detention_stay: "197-001-000-000-000-000-000",
1511
+ diversion_program: "197-002-000-000-000-000-000",
1512
+ pending_adjudication: "197-003-000-000-000-000-000",
1513
+ probation_supervision: "197-004-000-000-000-000-000",
1514
+ residential_jj_placement: "197-005-000-000-000-000-000",
1515
+ } as const;
1516
+
1517
+ export type JuvenileJusticeEpisodeTypeKey = keyof typeof JuvenileJusticeEpisodeTypeKeys;
1518
+
1519
+ /**
1520
+ * Key → positional code map for the `hmis_sex` CVC domain.
1521
+ *
1522
+ * Domain: `hmis_sex` · Version: 1.0.0 · Entries: 8
1523
+ */
1524
+ export const HmisSexKeys = {
1525
+ missingness_root: "067-000-000-000-000-000-000",
1526
+ unknown: "067-000-000-000-000-000-001",
1527
+ anonymous: "067-000-000-000-000-000-002",
1528
+ data_not_collected: "067-000-000-000-000-000-003",
1529
+ client_doesn_t_know: "067-000-000-000-000-000-004",
1530
+ client_prefers_not_to_answer: "067-000-000-000-000-000-005",
1531
+ female: "067-001-000-000-000-000-000",
1532
+ male: "067-002-000-000-000-000-000",
1533
+ } as const;
1534
+
1535
+ export type HmisSexKey = keyof typeof HmisSexKeys;
package/src/index.ts CHANGED
@@ -88,3 +88,23 @@ export { compileModel as compileCvcEntryModel } from "./models/cvcEntryModel.js"
88
88
  // filesystem access. See `./cvcs/index.ts` for the full list and naming.
89
89
 
90
90
  export * from "./cvcs/index.js";
91
+
92
+ // ─── SOT-first CVC flat-array aliases ───────────────────────────────────────
93
+ // Legacy-shaped `CVC_<N>_VALUES` arrays for CVCs that are SOT-native (no
94
+ // ic.ts constants). Derived from the SOT JSON envelope's `entries` filtered
95
+ // to `selectable: true` so the SOT JSON remains the single source of truth
96
+ // AND the non-selectable `missingness_root` grouping code is excluded (it
97
+ // would otherwise fail schema enum validation on write).
98
+
99
+ import recencyBandSot from "./cvcs/recencyBand.v1.0.0.json" with { type: "json" };
100
+ import juvenileJusticeEpisodeTypeSot from "./cvcs/juvenileJusticeEpisodeType.v1.0.0.json" with { type: "json" };
101
+
102
+ const selectableCodes = (envelope: {
103
+ entries: ReadonlyArray<{ code: string; selectable: boolean }>;
104
+ }): string[] =>
105
+ envelope.entries.filter((e) => e.selectable).map((e) => e.code);
106
+
107
+ export const CVC_137_VALUES: string[] = selectableCodes(recencyBandSot);
108
+ export const CVC_197_VALUES: string[] = selectableCodes(
109
+ juvenileJusticeEpisodeTypeSot,
110
+ );
@@ -42,6 +42,10 @@ export const personNameSchema = new Schema(
42
42
  alias: Boolean,
43
43
  isUnknown: Boolean,
44
44
  isAnonymous: Boolean,
45
+ // Shape flag: this person has only one name (e.g., Madonna). A mononym
46
+ // can itself be legal, a nickname, a trade name, etc. — it's orthogonal
47
+ // to nameType, not a value of it.
48
+ isMononym: Boolean,
45
49
  },
46
50
  { _id: false },
47
51
  );