@htilabs/platform-common-models 0.39.0 → 0.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -0
- package/dist/age/index.cjs +136 -0
- package/dist/age/index.cjs.map +1 -0
- package/dist/age/index.d.cts +136 -0
- package/dist/age/index.d.ts +136 -0
- package/dist/age/index.js +105 -0
- package/dist/age/index.js.map +1 -0
- package/dist/{index-DF469Qgd.d.cts → index-1pWiqEBC.d.cts} +1 -1
- package/dist/{index-BHSRMJvd.d.ts → index-uz57Fic9.d.ts} +1 -1
- package/dist/index.cjs +108 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +103 -0
- 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/schemas/index.d.cts +25 -25
- package/dist/schemas/index.d.ts +25 -25
- package/package.json +7 -1
- package/src/age/__tests__/ageFromDob.test.ts +192 -0
- package/src/age/ageFromDob.ts +269 -0
- package/src/age/index.ts +8 -0
- package/src/index.ts +4 -0
- package/dist/{cvcEntry-DQEoFVL2.d.cts → cvcEntry-DAuhe0cd.d.cts} +8 -8
- package/dist/{cvcEntry-DQEoFVL2.d.ts → cvcEntry-DAuhe0cd.d.ts} +8 -8
package/dist/index.cjs
CHANGED
|
@@ -231,6 +231,7 @@ __export(src_exports, {
|
|
|
231
231
|
DEFAULT_BOUND_STATE_LABELS: () => DEFAULT_BOUND_STATE_LABELS,
|
|
232
232
|
DEFAULT_BOUND_STATE_VALUES: () => DEFAULT_BOUND_STATE_VALUES,
|
|
233
233
|
DEFAULT_PARTICIPATION_ROLE_BY_CATEGORY: () => DEFAULT_PARTICIPATION_ROLE_BY_CATEGORY,
|
|
234
|
+
DOB_MIN_YEAR: () => DOB_MIN_YEAR,
|
|
234
235
|
DaIncidentArchiveReasonKeys: () => DaIncidentArchiveReasonKeys,
|
|
235
236
|
DaIncidentConfidenceKeys: () => DaIncidentConfidenceKeys,
|
|
236
237
|
DaIncidentDayApproxKeys: () => DaIncidentDayApproxKeys,
|
|
@@ -551,6 +552,8 @@ __export(src_exports, {
|
|
|
551
552
|
adminRolesSot: () => adminRoles_v2_0_0_default,
|
|
552
553
|
administeringJurisdictionSot: () => administeringJurisdiction_v1_0_0_default,
|
|
553
554
|
ageBinReportingSot: () => ageBinReporting_v1_0_0_default,
|
|
555
|
+
ageFromDob: () => ageFromDob,
|
|
556
|
+
ageInputFromStoredDob: () => ageInputFromStoredDob,
|
|
554
557
|
agencyOrgTypeSchemaDefinition: () => agencyOrgTypeSchemaDefinition,
|
|
555
558
|
announcementAudienceScopeSot: () => announcementAudienceScope_v1_0_0_default,
|
|
556
559
|
announcementResponseTypeSot: () => announcementResponseType_v1_0_0_default,
|
|
@@ -569,6 +572,7 @@ __export(src_exports, {
|
|
|
569
572
|
buildQuestionSchema: () => buildQuestionSchema,
|
|
570
573
|
buildScoringRuleSchema: () => buildScoringRuleSchema,
|
|
571
574
|
buildSectionSchema: () => buildSectionSchema,
|
|
575
|
+
calendarDateOf: () => calendarDateOf,
|
|
572
576
|
canonicalCoreIndicator: () => canonicalCoreIndicator,
|
|
573
577
|
canonicalIncidentParticipationRole: () => canonicalIncidentParticipationRole,
|
|
574
578
|
canonicalServiceState: () => canonicalServiceState,
|
|
@@ -728,6 +732,7 @@ __export(src_exports, {
|
|
|
728
732
|
nameTypeSot: () => nameType_v1_0_0_default,
|
|
729
733
|
needsAssessmentChangeTypeSot: () => needsAssessmentChangeType_v1_0_0_default,
|
|
730
734
|
needsResidentialAgainSot: () => needsResidentialAgain_v1_0_0_default,
|
|
735
|
+
normalizeDob: () => normalizeDob,
|
|
731
736
|
normalizeServiceMechanismKeys: () => normalizeServiceMechanismKeys,
|
|
732
737
|
normalizeServiceStampId: () => normalizeServiceStampId,
|
|
733
738
|
normalizeServiceStamps: () => normalizeServiceStamps,
|
|
@@ -15749,6 +15754,104 @@ function scopeMigrationsFromSot(sot) {
|
|
|
15749
15754
|
});
|
|
15750
15755
|
}
|
|
15751
15756
|
|
|
15757
|
+
// src/age/ageFromDob.ts
|
|
15758
|
+
var DOB_MIN_YEAR = 1850;
|
|
15759
|
+
function toNullableNumber(v) {
|
|
15760
|
+
if (v == null) return null;
|
|
15761
|
+
if (typeof v === "string" && v.trim() === "") return null;
|
|
15762
|
+
const n = typeof v === "number" ? v : Number(v);
|
|
15763
|
+
return Number.isFinite(n) ? n : null;
|
|
15764
|
+
}
|
|
15765
|
+
function toNullableMonth(v) {
|
|
15766
|
+
const n = toNullableNumber(v);
|
|
15767
|
+
return n != null && n >= 1 && n <= 12 ? n : null;
|
|
15768
|
+
}
|
|
15769
|
+
function toNullableDay(v) {
|
|
15770
|
+
const n = toNullableNumber(v);
|
|
15771
|
+
return n != null && n >= 1 && n <= 31 ? n : null;
|
|
15772
|
+
}
|
|
15773
|
+
function toNullableYear(v) {
|
|
15774
|
+
const n = toNullableNumber(v);
|
|
15775
|
+
return n != null && Number.isInteger(n) && n > 0 ? n : null;
|
|
15776
|
+
}
|
|
15777
|
+
function isDate(v) {
|
|
15778
|
+
return v instanceof Date || Object.prototype.toString.call(v) === "[object Date]";
|
|
15779
|
+
}
|
|
15780
|
+
function calendarDateOf(date) {
|
|
15781
|
+
if (Number.isNaN(date.getTime())) return null;
|
|
15782
|
+
const utcMidnight = date.getUTCHours() === 0 && date.getUTCMinutes() === 0 && date.getUTCSeconds() === 0 && date.getUTCMilliseconds() === 0;
|
|
15783
|
+
return utcMidnight ? { y: date.getUTCFullYear(), m: date.getUTCMonth() + 1, d: date.getUTCDate() } : { y: date.getFullYear(), m: date.getMonth() + 1, d: date.getDate() };
|
|
15784
|
+
}
|
|
15785
|
+
function ageInputFromStoredDob(stored) {
|
|
15786
|
+
return { y: stored?.dobYear ?? null, m: stored?.dobMonth ?? null, d: stored?.dobDay ?? null };
|
|
15787
|
+
}
|
|
15788
|
+
function normalizeDob(dobLike) {
|
|
15789
|
+
if (dobLike == null) return null;
|
|
15790
|
+
if (isDate(dobLike)) return calendarDateOf(dobLike);
|
|
15791
|
+
if (typeof dobLike === "object") {
|
|
15792
|
+
const m = toNullableMonth(dobLike.m);
|
|
15793
|
+
const d = toNullableDay(dobLike.d);
|
|
15794
|
+
const y = toNullableYear(dobLike.y);
|
|
15795
|
+
if (m == null && d == null && y == null) return null;
|
|
15796
|
+
return { m, d, y };
|
|
15797
|
+
}
|
|
15798
|
+
if (typeof dobLike === "string") {
|
|
15799
|
+
const s = dobLike.trim();
|
|
15800
|
+
if (!s) return null;
|
|
15801
|
+
const iso = /^(\d{4})-(\d{1,2})-(\d{1,2})/.exec(s);
|
|
15802
|
+
if (iso) {
|
|
15803
|
+
return {
|
|
15804
|
+
y: toNullableYear(iso[1]),
|
|
15805
|
+
m: toNullableMonth(iso[2]),
|
|
15806
|
+
d: toNullableDay(iso[3])
|
|
15807
|
+
};
|
|
15808
|
+
}
|
|
15809
|
+
const isoPartial = /^(\d{4})(?:-(\d{1,2}))?$/.exec(s);
|
|
15810
|
+
if (isoPartial) {
|
|
15811
|
+
const y = toNullableYear(isoPartial[1]);
|
|
15812
|
+
return y == null ? null : { y, m: toNullableMonth(isoPartial[2]), d: null };
|
|
15813
|
+
}
|
|
15814
|
+
const slash = /^(\d{0,2})\/(\d{0,2})\/(\d{0,4})$/.exec(s);
|
|
15815
|
+
if (slash) {
|
|
15816
|
+
const m = toNullableMonth(slash[1]);
|
|
15817
|
+
const d = toNullableDay(slash[2]);
|
|
15818
|
+
const y = toNullableYear(slash[3]);
|
|
15819
|
+
if (m == null && d == null && y == null) return null;
|
|
15820
|
+
return { m, d, y };
|
|
15821
|
+
}
|
|
15822
|
+
return null;
|
|
15823
|
+
}
|
|
15824
|
+
return null;
|
|
15825
|
+
}
|
|
15826
|
+
function ageFromDob(dob, today) {
|
|
15827
|
+
const parts = normalizeDob(dob);
|
|
15828
|
+
if (!parts || parts.y == null) return null;
|
|
15829
|
+
const t = isDate(today) ? calendarDateOf(today) : today;
|
|
15830
|
+
if (t == null || !Number.isInteger(t.y) || toNullableMonth(t.m) == null || toNullableDay(t.d) == null) {
|
|
15831
|
+
return null;
|
|
15832
|
+
}
|
|
15833
|
+
const todayY = t.y;
|
|
15834
|
+
const todayM = t.m;
|
|
15835
|
+
const todayD = t.d;
|
|
15836
|
+
if (parts.y < DOB_MIN_YEAR) return null;
|
|
15837
|
+
if (parts.y > todayY) return null;
|
|
15838
|
+
if (parts.y === todayY && parts.m != null) {
|
|
15839
|
+
if (parts.m > todayM) return null;
|
|
15840
|
+
if (parts.m === todayM && parts.d != null && parts.d > todayD) return null;
|
|
15841
|
+
}
|
|
15842
|
+
let birthdayPassed;
|
|
15843
|
+
if (parts.m == null) {
|
|
15844
|
+
birthdayPassed = false;
|
|
15845
|
+
} else if (parts.m < todayM) {
|
|
15846
|
+
birthdayPassed = true;
|
|
15847
|
+
} else if (parts.m > todayM) {
|
|
15848
|
+
birthdayPassed = false;
|
|
15849
|
+
} else {
|
|
15850
|
+
birthdayPassed = parts.d == null ? false : parts.d <= todayD;
|
|
15851
|
+
}
|
|
15852
|
+
return Math.max(0, todayY - parts.y - (birthdayPassed ? 0 : 1));
|
|
15853
|
+
}
|
|
15854
|
+
|
|
15752
15855
|
// src/generated/coreFunctionsEvaluable.ts
|
|
15753
15856
|
var CORE_FUNCTIONS_EVALUABLE_KEYS = [
|
|
15754
15857
|
"agency_info_manage",
|
|
@@ -69356,6 +69459,7 @@ var CVC_197_VALUES = selectableCodes(
|
|
|
69356
69459
|
DEFAULT_BOUND_STATE_LABELS,
|
|
69357
69460
|
DEFAULT_BOUND_STATE_VALUES,
|
|
69358
69461
|
DEFAULT_PARTICIPATION_ROLE_BY_CATEGORY,
|
|
69462
|
+
DOB_MIN_YEAR,
|
|
69359
69463
|
DaIncidentArchiveReasonKeys,
|
|
69360
69464
|
DaIncidentConfidenceKeys,
|
|
69361
69465
|
DaIncidentDayApproxKeys,
|
|
@@ -69676,6 +69780,8 @@ var CVC_197_VALUES = selectableCodes(
|
|
|
69676
69780
|
adminRolesSot,
|
|
69677
69781
|
administeringJurisdictionSot,
|
|
69678
69782
|
ageBinReportingSot,
|
|
69783
|
+
ageFromDob,
|
|
69784
|
+
ageInputFromStoredDob,
|
|
69679
69785
|
agencyOrgTypeSchemaDefinition,
|
|
69680
69786
|
announcementAudienceScopeSot,
|
|
69681
69787
|
announcementResponseTypeSot,
|
|
@@ -69694,6 +69800,7 @@ var CVC_197_VALUES = selectableCodes(
|
|
|
69694
69800
|
buildQuestionSchema,
|
|
69695
69801
|
buildScoringRuleSchema,
|
|
69696
69802
|
buildSectionSchema,
|
|
69803
|
+
calendarDateOf,
|
|
69697
69804
|
canonicalCoreIndicator,
|
|
69698
69805
|
canonicalIncidentParticipationRole,
|
|
69699
69806
|
canonicalServiceState,
|
|
@@ -69853,6 +69960,7 @@ var CVC_197_VALUES = selectableCodes(
|
|
|
69853
69960
|
nameTypeSot,
|
|
69854
69961
|
needsAssessmentChangeTypeSot,
|
|
69855
69962
|
needsResidentialAgainSot,
|
|
69963
|
+
normalizeDob,
|
|
69856
69964
|
normalizeServiceMechanismKeys,
|
|
69857
69965
|
normalizeServiceStampId,
|
|
69858
69966
|
normalizeServiceStamps,
|