@ecrvs/opencrvs-toolkit 1.9.0-rc.4dc2d92 → 1.9.0-rc.64705da
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.
|
@@ -133,7 +133,7 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
133
133
|
isLessThan(value: number | FieldReference): JSONSchema;
|
|
134
134
|
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
135
135
|
isEqualToSumOf(val1: FieldReference, val2: FieldReference): JSONSchema;
|
|
136
|
-
isValidDeceasedAge(dobField: FieldReference, dodField: FieldReference, todField: FieldReference, format: "years" | "months" | "days" | "hours"): JSONSchema;
|
|
136
|
+
isValidDeceasedAge(dobField: FieldReference, dodField: FieldReference, todField: FieldReference, format: "years" | "months" | "days" | "hours" | "minutes"): JSONSchema;
|
|
137
137
|
isAbbreviation(): JSONSchema;
|
|
138
138
|
isIllDefined(causesOfDeathFields: FieldReference[], threshold: number): JSONSchema;
|
|
139
139
|
/**
|
|
@@ -192,7 +192,7 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
192
192
|
isLessThan(value: number | FieldReference): JSONSchema;
|
|
193
193
|
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
194
194
|
isEqualToSumOf(val1: FieldReference, val2: FieldReference): JSONSchema;
|
|
195
|
-
isValidDeceasedAge(dobField: FieldReference, dodField: FieldReference, todField: FieldReference, format: "years" | "months" | "days" | "hours"): JSONSchema;
|
|
195
|
+
isValidDeceasedAge(dobField: FieldReference, dodField: FieldReference, todField: FieldReference, format: "years" | "months" | "days" | "hours" | "minutes"): JSONSchema;
|
|
196
196
|
isAbbreviation(): JSONSchema;
|
|
197
197
|
isIllDefined(causesOfDeathFields: FieldReference[], threshold: number): JSONSchema;
|
|
198
198
|
/**
|
|
@@ -265,7 +265,7 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
265
265
|
isLessThan(value: number | FieldReference): JSONSchema;
|
|
266
266
|
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
267
267
|
isEqualToSumOf(val1: FieldReference, val2: FieldReference): JSONSchema;
|
|
268
|
-
isValidDeceasedAge(dobField: FieldReference, dodField: FieldReference, todField: FieldReference, format: "years" | "months" | "days" | "hours"): JSONSchema;
|
|
268
|
+
isValidDeceasedAge(dobField: FieldReference, dodField: FieldReference, todField: FieldReference, format: "years" | "months" | "days" | "hours" | "minutes"): JSONSchema;
|
|
269
269
|
isAbbreviation(): JSONSchema;
|
|
270
270
|
isIllDefined(causesOfDeathFields: FieldReference[], threshold: number): JSONSchema;
|
|
271
271
|
/**
|
|
@@ -333,7 +333,7 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
333
333
|
isLessThan(value: number | FieldReference): JSONSchema;
|
|
334
334
|
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
335
335
|
isEqualToSumOf(val1: FieldReference, val2: FieldReference): JSONSchema;
|
|
336
|
-
isValidDeceasedAge(dobField: FieldReference, dodField: FieldReference, todField: FieldReference, format: "years" | "months" | "days" | "hours"): JSONSchema;
|
|
336
|
+
isValidDeceasedAge(dobField: FieldReference, dodField: FieldReference, todField: FieldReference, format: "years" | "months" | "days" | "hours" | "minutes"): JSONSchema;
|
|
337
337
|
isAbbreviation(): JSONSchema;
|
|
338
338
|
isIllDefined(causesOfDeathFields: FieldReference[], threshold: number): JSONSchema;
|
|
339
339
|
/**
|
|
@@ -400,7 +400,7 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
400
400
|
isLessThan(value: number | FieldReference): JSONSchema;
|
|
401
401
|
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
402
402
|
isEqualToSumOf(val1: FieldReference, val2: FieldReference): JSONSchema;
|
|
403
|
-
isValidDeceasedAge(dobField: FieldReference, dodField: FieldReference, todField: FieldReference, format: "years" | "months" | "days" | "hours"): JSONSchema;
|
|
403
|
+
isValidDeceasedAge(dobField: FieldReference, dodField: FieldReference, todField: FieldReference, format: "years" | "months" | "days" | "hours" | "minutes"): JSONSchema;
|
|
404
404
|
isAbbreviation(): JSONSchema;
|
|
405
405
|
isIllDefined(causesOfDeathFields: FieldReference[], threshold: number): JSONSchema;
|
|
406
406
|
/**
|
|
@@ -457,7 +457,7 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
457
457
|
isLessThan(value: number | FieldReference): JSONSchema;
|
|
458
458
|
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
459
459
|
isEqualToSumOf(val1: FieldReference, val2: FieldReference): JSONSchema;
|
|
460
|
-
isValidDeceasedAge(dobField: FieldReference, dodField: FieldReference, todField: FieldReference, format: "years" | "months" | "days" | "hours"): JSONSchema;
|
|
460
|
+
isValidDeceasedAge(dobField: FieldReference, dodField: FieldReference, todField: FieldReference, format: "years" | "months" | "days" | "hours" | "minutes"): JSONSchema;
|
|
461
461
|
isAbbreviation(): JSONSchema;
|
|
462
462
|
isIllDefined(causesOfDeathFields: FieldReference[], threshold: number): JSONSchema;
|
|
463
463
|
/**
|
|
@@ -531,7 +531,7 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
531
531
|
isLessThan(value: number | FieldReference): JSONSchema;
|
|
532
532
|
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
533
533
|
isEqualToSumOf(val1: FieldReference, val2: FieldReference): JSONSchema;
|
|
534
|
-
isValidDeceasedAge(dobField: FieldReference, dodField: FieldReference, todField: FieldReference, format: "years" | "months" | "days" | "hours"): JSONSchema;
|
|
534
|
+
isValidDeceasedAge(dobField: FieldReference, dodField: FieldReference, todField: FieldReference, format: "years" | "months" | "days" | "hours" | "minutes"): JSONSchema;
|
|
535
535
|
isAbbreviation(): JSONSchema;
|
|
536
536
|
isIllDefined(causesOfDeathFields: FieldReference[], threshold: number): JSONSchema;
|
|
537
537
|
/**
|
|
@@ -590,7 +590,7 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
590
590
|
isLessThan(value: number | FieldReference): JSONSchema;
|
|
591
591
|
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
592
592
|
isEqualToSumOf(val1: FieldReference, val2: FieldReference): JSONSchema;
|
|
593
|
-
isValidDeceasedAge(dobField: FieldReference, dodField: FieldReference, todField: FieldReference, format: "years" | "months" | "days" | "hours"): JSONSchema;
|
|
593
|
+
isValidDeceasedAge(dobField: FieldReference, dodField: FieldReference, todField: FieldReference, format: "years" | "months" | "days" | "hours" | "minutes"): JSONSchema;
|
|
594
594
|
isAbbreviation(): JSONSchema;
|
|
595
595
|
isIllDefined(causesOfDeathFields: FieldReference[], threshold: number): JSONSchema;
|
|
596
596
|
/**
|
|
@@ -664,7 +664,7 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
664
664
|
isLessThan(value: number | FieldReference): JSONSchema;
|
|
665
665
|
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
666
666
|
isEqualToSumOf(val1: FieldReference, val2: FieldReference): JSONSchema;
|
|
667
|
-
isValidDeceasedAge(dobField: FieldReference, dodField: FieldReference, todField: FieldReference, format: "years" | "months" | "days" | "hours"): JSONSchema;
|
|
667
|
+
isValidDeceasedAge(dobField: FieldReference, dodField: FieldReference, todField: FieldReference, format: "years" | "months" | "days" | "hours" | "minutes"): JSONSchema;
|
|
668
668
|
isAbbreviation(): JSONSchema;
|
|
669
669
|
isIllDefined(causesOfDeathFields: FieldReference[], threshold: number): JSONSchema;
|
|
670
670
|
/**
|
|
@@ -723,7 +723,7 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
723
723
|
isLessThan(value: number | FieldReference): JSONSchema;
|
|
724
724
|
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
725
725
|
isEqualToSumOf(val1: FieldReference, val2: FieldReference): JSONSchema;
|
|
726
|
-
isValidDeceasedAge(dobField: FieldReference, dodField: FieldReference, todField: FieldReference, format: "years" | "months" | "days" | "hours"): JSONSchema;
|
|
726
|
+
isValidDeceasedAge(dobField: FieldReference, dodField: FieldReference, todField: FieldReference, format: "years" | "months" | "days" | "hours" | "minutes"): JSONSchema;
|
|
727
727
|
isAbbreviation(): JSONSchema;
|
|
728
728
|
isIllDefined(causesOfDeathFields: FieldReference[], threshold: number): JSONSchema;
|
|
729
729
|
/**
|
|
@@ -780,7 +780,7 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
780
780
|
isLessThan(value: number | FieldReference): JSONSchema;
|
|
781
781
|
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
782
782
|
isEqualToSumOf(val1: FieldReference, val2: FieldReference): JSONSchema;
|
|
783
|
-
isValidDeceasedAge(dobField: FieldReference, dodField: FieldReference, todField: FieldReference, format: "years" | "months" | "days" | "hours"): JSONSchema;
|
|
783
|
+
isValidDeceasedAge(dobField: FieldReference, dodField: FieldReference, todField: FieldReference, format: "years" | "months" | "days" | "hours" | "minutes"): JSONSchema;
|
|
784
784
|
isAbbreviation(): JSONSchema;
|
|
785
785
|
isIllDefined(causesOfDeathFields: FieldReference[], threshold: number): JSONSchema;
|
|
786
786
|
/**
|
|
@@ -123,7 +123,7 @@ export declare function field(fieldId: string, options?: {
|
|
|
123
123
|
}, todField: {
|
|
124
124
|
$$field: string;
|
|
125
125
|
$$subfield: string[];
|
|
126
|
-
}, format: "years" | "months" | "days" | "hours"): import("../conditionals/conditionals").JSONSchema;
|
|
126
|
+
}, format: "years" | "months" | "days" | "hours" | "minutes"): import("../conditionals/conditionals").JSONSchema;
|
|
127
127
|
isAbbreviation(): import("../conditionals/conditionals").JSONSchema;
|
|
128
128
|
isIllDefined(causesOfDeathFields: {
|
|
129
129
|
$$field: string;
|
|
@@ -193,7 +193,7 @@ export declare function field(fieldId: string, options?: {
|
|
|
193
193
|
}, todField: {
|
|
194
194
|
$$field: string;
|
|
195
195
|
$$subfield: string[];
|
|
196
|
-
}, format: "years" | "months" | "days" | "hours"): import("../conditionals/conditionals").JSONSchema;
|
|
196
|
+
}, format: "years" | "months" | "days" | "hours" | "minutes"): import("../conditionals/conditionals").JSONSchema;
|
|
197
197
|
isAbbreviation(): import("../conditionals/conditionals").JSONSchema;
|
|
198
198
|
isIllDefined(causesOfDeathFields: {
|
|
199
199
|
$$field: string;
|
|
@@ -271,7 +271,7 @@ export declare function field(fieldId: string, options?: {
|
|
|
271
271
|
}, todField: {
|
|
272
272
|
$$field: string;
|
|
273
273
|
$$subfield: string[];
|
|
274
|
-
}, format: "years" | "months" | "days" | "hours"): import("../conditionals/conditionals").JSONSchema;
|
|
274
|
+
}, format: "years" | "months" | "days" | "hours" | "minutes"): import("../conditionals/conditionals").JSONSchema;
|
|
275
275
|
isAbbreviation(): import("../conditionals/conditionals").JSONSchema;
|
|
276
276
|
isIllDefined(causesOfDeathFields: {
|
|
277
277
|
$$field: string;
|
|
@@ -347,7 +347,7 @@ export declare function field(fieldId: string, options?: {
|
|
|
347
347
|
}, todField: {
|
|
348
348
|
$$field: string;
|
|
349
349
|
$$subfield: string[];
|
|
350
|
-
}, format: "years" | "months" | "days" | "hours"): import("../conditionals/conditionals").JSONSchema;
|
|
350
|
+
}, format: "years" | "months" | "days" | "hours" | "minutes"): import("../conditionals/conditionals").JSONSchema;
|
|
351
351
|
isAbbreviation(): import("../conditionals/conditionals").JSONSchema;
|
|
352
352
|
isIllDefined(causesOfDeathFields: {
|
|
353
353
|
$$field: string;
|
|
@@ -422,7 +422,7 @@ export declare function field(fieldId: string, options?: {
|
|
|
422
422
|
}, todField: {
|
|
423
423
|
$$field: string;
|
|
424
424
|
$$subfield: string[];
|
|
425
|
-
}, format: "years" | "months" | "days" | "hours"): import("../conditionals/conditionals").JSONSchema;
|
|
425
|
+
}, format: "years" | "months" | "days" | "hours" | "minutes"): import("../conditionals/conditionals").JSONSchema;
|
|
426
426
|
isAbbreviation(): import("../conditionals/conditionals").JSONSchema;
|
|
427
427
|
isIllDefined(causesOfDeathFields: {
|
|
428
428
|
$$field: string;
|
|
@@ -490,7 +490,7 @@ export declare function field(fieldId: string, options?: {
|
|
|
490
490
|
}, todField: {
|
|
491
491
|
$$field: string;
|
|
492
492
|
$$subfield: string[];
|
|
493
|
-
}, format: "years" | "months" | "days" | "hours"): import("../conditionals/conditionals").JSONSchema;
|
|
493
|
+
}, format: "years" | "months" | "days" | "hours" | "minutes"): import("../conditionals/conditionals").JSONSchema;
|
|
494
494
|
isAbbreviation(): import("../conditionals/conditionals").JSONSchema;
|
|
495
495
|
isIllDefined(causesOfDeathFields: {
|
|
496
496
|
$$field: string;
|
|
@@ -569,7 +569,7 @@ export declare function field(fieldId: string, options?: {
|
|
|
569
569
|
}, todField: {
|
|
570
570
|
$$field: string;
|
|
571
571
|
$$subfield: string[];
|
|
572
|
-
}, format: "years" | "months" | "days" | "hours"): import("../conditionals/conditionals").JSONSchema;
|
|
572
|
+
}, format: "years" | "months" | "days" | "hours" | "minutes"): import("../conditionals/conditionals").JSONSchema;
|
|
573
573
|
isAbbreviation(): import("../conditionals/conditionals").JSONSchema;
|
|
574
574
|
isIllDefined(causesOfDeathFields: {
|
|
575
575
|
$$field: string;
|
|
@@ -639,7 +639,7 @@ export declare function field(fieldId: string, options?: {
|
|
|
639
639
|
}, todField: {
|
|
640
640
|
$$field: string;
|
|
641
641
|
$$subfield: string[];
|
|
642
|
-
}, format: "years" | "months" | "days" | "hours"): import("../conditionals/conditionals").JSONSchema;
|
|
642
|
+
}, format: "years" | "months" | "days" | "hours" | "minutes"): import("../conditionals/conditionals").JSONSchema;
|
|
643
643
|
isAbbreviation(): import("../conditionals/conditionals").JSONSchema;
|
|
644
644
|
isIllDefined(causesOfDeathFields: {
|
|
645
645
|
$$field: string;
|
|
@@ -718,7 +718,7 @@ export declare function field(fieldId: string, options?: {
|
|
|
718
718
|
}, todField: {
|
|
719
719
|
$$field: string;
|
|
720
720
|
$$subfield: string[];
|
|
721
|
-
}, format: "years" | "months" | "days" | "hours"): import("../conditionals/conditionals").JSONSchema;
|
|
721
|
+
}, format: "years" | "months" | "days" | "hours" | "minutes"): import("../conditionals/conditionals").JSONSchema;
|
|
722
722
|
isAbbreviation(): import("../conditionals/conditionals").JSONSchema;
|
|
723
723
|
isIllDefined(causesOfDeathFields: {
|
|
724
724
|
$$field: string;
|
|
@@ -788,7 +788,7 @@ export declare function field(fieldId: string, options?: {
|
|
|
788
788
|
}, todField: {
|
|
789
789
|
$$field: string;
|
|
790
790
|
$$subfield: string[];
|
|
791
|
-
}, format: "years" | "months" | "days" | "hours"): import("../conditionals/conditionals").JSONSchema;
|
|
791
|
+
}, format: "years" | "months" | "days" | "hours" | "minutes"): import("../conditionals/conditionals").JSONSchema;
|
|
792
792
|
isAbbreviation(): import("../conditionals/conditionals").JSONSchema;
|
|
793
793
|
isIllDefined(causesOfDeathFields: {
|
|
794
794
|
$$field: string;
|
|
@@ -856,7 +856,7 @@ export declare function field(fieldId: string, options?: {
|
|
|
856
856
|
}, todField: {
|
|
857
857
|
$$field: string;
|
|
858
858
|
$$subfield: string[];
|
|
859
|
-
}, format: "years" | "months" | "days" | "hours"): import("../conditionals/conditionals").JSONSchema;
|
|
859
|
+
}, format: "years" | "months" | "days" | "hours" | "minutes"): import("../conditionals/conditionals").JSONSchema;
|
|
860
860
|
isAbbreviation(): import("../conditionals/conditionals").JSONSchema;
|
|
861
861
|
isIllDefined(causesOfDeathFields: {
|
|
862
862
|
$$field: string;
|
package/dist/events/index.js
CHANGED
|
@@ -4413,6 +4413,7 @@ var isValidDateFormat = (date) => {
|
|
|
4413
4413
|
};
|
|
4414
4414
|
var MS_PER_DAY = 1e3 * 60 * 60 * 24;
|
|
4415
4415
|
var MS_PER_HOUR = 1e3 * 60 * 60;
|
|
4416
|
+
var MS_PER_MINUTE = 1e3 * 60;
|
|
4416
4417
|
function getAgeOfDeceased(dateOfBirth, dateOfDeath, format3 = "years") {
|
|
4417
4418
|
if (dateOfDeath < dateOfBirth) {
|
|
4418
4419
|
return 0;
|
|
@@ -4434,9 +4435,14 @@ function getAgeOfDeceased(dateOfBirth, dateOfDeath, format3 = "years") {
|
|
|
4434
4435
|
const diffTime2 = dateOfDeath.getTime() - dateOfBirth.getTime();
|
|
4435
4436
|
return Math.floor(diffTime2 / MS_PER_DAY);
|
|
4436
4437
|
}
|
|
4438
|
+
if (format3 === "hours") {
|
|
4439
|
+
const diffTime2 = dateOfDeath.getTime() - dateOfBirth.getTime();
|
|
4440
|
+
const remainingMs2 = diffTime2 - MS_PER_DAY;
|
|
4441
|
+
return remainingMs2 < 0 ? Math.floor(diffTime2 / MS_PER_HOUR) : Math.floor(remainingMs2 / MS_PER_HOUR);
|
|
4442
|
+
}
|
|
4437
4443
|
const diffTime = dateOfDeath.getTime() - dateOfBirth.getTime();
|
|
4438
4444
|
const remainingMs = diffTime - MS_PER_DAY;
|
|
4439
|
-
return remainingMs < 0 ? Math.floor(diffTime /
|
|
4445
|
+
return remainingMs < 0 ? Math.floor(diffTime / MS_PER_MINUTE) : Math.floor(remainingMs / MS_PER_MINUTE);
|
|
4440
4446
|
}
|
|
4441
4447
|
ajv.addKeyword({
|
|
4442
4448
|
keyword: "isValidAgeOfDeceased",
|
|
@@ -4451,20 +4457,19 @@ ajv.addKeyword({
|
|
|
4451
4457
|
deathTimeField,
|
|
4452
4458
|
format: format3
|
|
4453
4459
|
} = schema;
|
|
4454
|
-
console.log(schema);
|
|
4455
4460
|
const dob = data?.[dateOfBirthField];
|
|
4456
4461
|
const dod = data?.[deathDateField];
|
|
4457
4462
|
const tod = data?.[deathTimeField];
|
|
4458
4463
|
const ageValue = data?.[ageField];
|
|
4459
|
-
|
|
4460
|
-
if (!ageValue || !isValidDateFormat(dob) || !isValidDateFormat(dod)) {
|
|
4464
|
+
if (!ageValue || !isValidDateFormat(dob) || !isValidDateFormat(dod) || !dod || !dob) {
|
|
4461
4465
|
return true;
|
|
4462
4466
|
}
|
|
4463
4467
|
const dateOfBirth = /* @__PURE__ */ new Date(`${dob}T00:00:00+00:00`);
|
|
4464
4468
|
const dateOfDeath = tod ? /* @__PURE__ */ new Date(`${dod}T${tod}:00+00:00`) : /* @__PURE__ */ new Date(`${dod}T00:00:00+00:00`);
|
|
4465
4469
|
const deceasedAge = getAgeOfDeceased(dateOfBirth, dateOfDeath, format3);
|
|
4470
|
+
console.log(dob, dod, tod, ageValue, deceasedAge);
|
|
4466
4471
|
const sameDay = dateOfBirth.toISOString().slice(0, 10) === dateOfDeath.toISOString().slice(0, 10);
|
|
4467
|
-
return Number(ageValue) === deceasedAge && !(format3 === "hours" && !sameDay) || format3 === "days" && deceasedAge - Number(ageValue) === 1 || format3 === "hours" && !sameDay && deceasedAge < Number(ageValue);
|
|
4472
|
+
return Number(ageValue) === deceasedAge && !(format3 === "hours" && !sameDay) && !(format3 === "minutes" && !sameDay) || format3 === "days" && deceasedAge - Number(ageValue) === 1 || format3 === "hours" && !sameDay && deceasedAge < Number(ageValue) || format3 === "hours" && sameDay && !tod || format3 === "minutes" && !sameDay && deceasedAge < Number(ageValue) || format3 === "minutes" && sameDay && !tod;
|
|
4468
4473
|
}
|
|
4469
4474
|
});
|
|
4470
4475
|
ajv.addKeyword({
|
|
@@ -3652,6 +3652,7 @@ var isValidDateFormat = (date) => {
|
|
|
3652
3652
|
};
|
|
3653
3653
|
var MS_PER_DAY = 1e3 * 60 * 60 * 24;
|
|
3654
3654
|
var MS_PER_HOUR = 1e3 * 60 * 60;
|
|
3655
|
+
var MS_PER_MINUTE = 1e3 * 60;
|
|
3655
3656
|
function getAgeOfDeceased(dateOfBirth, dateOfDeath, format3 = "years") {
|
|
3656
3657
|
if (dateOfDeath < dateOfBirth) {
|
|
3657
3658
|
return 0;
|
|
@@ -3673,9 +3674,14 @@ function getAgeOfDeceased(dateOfBirth, dateOfDeath, format3 = "years") {
|
|
|
3673
3674
|
const diffTime2 = dateOfDeath.getTime() - dateOfBirth.getTime();
|
|
3674
3675
|
return Math.floor(diffTime2 / MS_PER_DAY);
|
|
3675
3676
|
}
|
|
3677
|
+
if (format3 === "hours") {
|
|
3678
|
+
const diffTime2 = dateOfDeath.getTime() - dateOfBirth.getTime();
|
|
3679
|
+
const remainingMs2 = diffTime2 - MS_PER_DAY;
|
|
3680
|
+
return remainingMs2 < 0 ? Math.floor(diffTime2 / MS_PER_HOUR) : Math.floor(remainingMs2 / MS_PER_HOUR);
|
|
3681
|
+
}
|
|
3676
3682
|
const diffTime = dateOfDeath.getTime() - dateOfBirth.getTime();
|
|
3677
3683
|
const remainingMs = diffTime - MS_PER_DAY;
|
|
3678
|
-
return remainingMs < 0 ? Math.floor(diffTime /
|
|
3684
|
+
return remainingMs < 0 ? Math.floor(diffTime / MS_PER_MINUTE) : Math.floor(remainingMs / MS_PER_MINUTE);
|
|
3679
3685
|
}
|
|
3680
3686
|
ajv.addKeyword({
|
|
3681
3687
|
keyword: "isValidAgeOfDeceased",
|
|
@@ -3690,20 +3696,19 @@ ajv.addKeyword({
|
|
|
3690
3696
|
deathTimeField,
|
|
3691
3697
|
format: format3
|
|
3692
3698
|
} = schema;
|
|
3693
|
-
console.log(schema);
|
|
3694
3699
|
const dob = data?.[dateOfBirthField];
|
|
3695
3700
|
const dod = data?.[deathDateField];
|
|
3696
3701
|
const tod = data?.[deathTimeField];
|
|
3697
3702
|
const ageValue = data?.[ageField];
|
|
3698
|
-
|
|
3699
|
-
if (!ageValue || !isValidDateFormat(dob) || !isValidDateFormat(dod)) {
|
|
3703
|
+
if (!ageValue || !isValidDateFormat(dob) || !isValidDateFormat(dod) || !dod || !dob) {
|
|
3700
3704
|
return true;
|
|
3701
3705
|
}
|
|
3702
3706
|
const dateOfBirth = /* @__PURE__ */ new Date(`${dob}T00:00:00+00:00`);
|
|
3703
3707
|
const dateOfDeath = tod ? /* @__PURE__ */ new Date(`${dod}T${tod}:00+00:00`) : /* @__PURE__ */ new Date(`${dod}T00:00:00+00:00`);
|
|
3704
3708
|
const deceasedAge = getAgeOfDeceased(dateOfBirth, dateOfDeath, format3);
|
|
3709
|
+
console.log(dob, dod, tod, ageValue, deceasedAge);
|
|
3705
3710
|
const sameDay = dateOfBirth.toISOString().slice(0, 10) === dateOfDeath.toISOString().slice(0, 10);
|
|
3706
|
-
return Number(ageValue) === deceasedAge && !(format3 === "hours" && !sameDay) || format3 === "days" && deceasedAge - Number(ageValue) === 1 || format3 === "hours" && !sameDay && deceasedAge < Number(ageValue);
|
|
3711
|
+
return Number(ageValue) === deceasedAge && !(format3 === "hours" && !sameDay) && !(format3 === "minutes" && !sameDay) || format3 === "days" && deceasedAge - Number(ageValue) === 1 || format3 === "hours" && !sameDay && deceasedAge < Number(ageValue) || format3 === "hours" && sameDay && !tod || format3 === "minutes" && !sameDay && deceasedAge < Number(ageValue) || format3 === "minutes" && sameDay && !tod;
|
|
3707
3712
|
}
|
|
3708
3713
|
});
|
|
3709
3714
|
ajv.addKeyword({
|