@ecrvs/opencrvs-toolkit 1.9.12-rc.62ef478 → 1.9.12-rc.a54282a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/events/index.js +11 -5
- package/dist/notification/index.js +11 -5
- package/package.json +1 -1
package/dist/events/index.js
CHANGED
|
@@ -4616,7 +4616,9 @@ ajv.addKeyword({
|
|
|
4616
4616
|
});
|
|
4617
4617
|
var datePattern = /^\d{4}-\d{1,2}-\d{1,2}$/;
|
|
4618
4618
|
var isValidDateFormat = (date) => {
|
|
4619
|
-
if (!datePattern.test(date))
|
|
4619
|
+
if (!datePattern.test(date)) {
|
|
4620
|
+
return false;
|
|
4621
|
+
}
|
|
4620
4622
|
const d = new Date(date);
|
|
4621
4623
|
return !isNaN(d.getTime());
|
|
4622
4624
|
};
|
|
@@ -4631,13 +4633,17 @@ function getAgeOfDeceased(dateOfBirth, dateOfDeath, format3 = "years") {
|
|
|
4631
4633
|
let age = dateOfDeath.getFullYear() - dateOfBirth.getFullYear();
|
|
4632
4634
|
const monthDiff = dateOfDeath.getMonth() - dateOfBirth.getMonth();
|
|
4633
4635
|
const dayDiff = dateOfDeath.getDate() - dateOfBirth.getDate();
|
|
4634
|
-
if (monthDiff < 0 || monthDiff === 0 && dayDiff < 0)
|
|
4636
|
+
if (monthDiff < 0 || monthDiff === 0 && dayDiff < 0) {
|
|
4637
|
+
age--;
|
|
4638
|
+
}
|
|
4635
4639
|
return age;
|
|
4636
4640
|
}
|
|
4637
4641
|
if (format3 === "months") {
|
|
4638
4642
|
let months = (dateOfDeath.getFullYear() - dateOfBirth.getFullYear()) * 12;
|
|
4639
4643
|
months += dateOfDeath.getMonth() - dateOfBirth.getMonth();
|
|
4640
|
-
if (dateOfDeath.getDate() < dateOfBirth.getDate())
|
|
4644
|
+
if (dateOfDeath.getDate() < dateOfBirth.getDate()) {
|
|
4645
|
+
months--;
|
|
4646
|
+
}
|
|
4641
4647
|
return months;
|
|
4642
4648
|
}
|
|
4643
4649
|
if (format3 === "days") {
|
|
@@ -4670,14 +4676,14 @@ ajv.addKeyword({
|
|
|
4670
4676
|
const dod = data?.[deathDateField];
|
|
4671
4677
|
const tod = data?.[deathTimeField];
|
|
4672
4678
|
const ageValue = data?.[ageField];
|
|
4673
|
-
if (!ageValue || !isValidDateFormat(dob) || !isValidDateFormat(dod)
|
|
4679
|
+
if (!ageValue || !isValidDateFormat(dob) || !isValidDateFormat(dod)) {
|
|
4674
4680
|
return true;
|
|
4675
4681
|
}
|
|
4676
4682
|
const dateOfBirth = /* @__PURE__ */ new Date(`${dob}T00:00:00+00:00`);
|
|
4677
4683
|
const dateOfDeath = tod ? /* @__PURE__ */ new Date(`${dod}T${tod}:00+00:00`) : /* @__PURE__ */ new Date(`${dod}T00:00:00+00:00`);
|
|
4678
4684
|
const deceasedAge = getAgeOfDeceased(dateOfBirth, dateOfDeath, format3);
|
|
4679
4685
|
const sameDay = dateOfBirth.toISOString().slice(0, 10) === dateOfDeath.toISOString().slice(0, 10);
|
|
4680
|
-
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;
|
|
4686
|
+
return Number(ageValue) === deceasedAge && !(format3 === "hours" && !sameDay) && !(format3 === "minutes" && !sameDay) || format3 === "days" && !tod && deceasedAge - Number(ageValue) === 1 || format3 === "hours" && !sameDay && deceasedAge < Number(ageValue) || format3 === "hours" && sameDay && (!tod || Number(ageValue) <= deceasedAge) || format3 === "minutes" && !sameDay && deceasedAge < Number(ageValue) || format3 === "minutes" && sameDay && (!tod || Number(ageValue) <= deceasedAge);
|
|
4681
4687
|
}
|
|
4682
4688
|
});
|
|
4683
4689
|
ajv.addKeyword({
|
|
@@ -3806,7 +3806,9 @@ ajv.addKeyword({
|
|
|
3806
3806
|
});
|
|
3807
3807
|
var datePattern = /^\d{4}-\d{1,2}-\d{1,2}$/;
|
|
3808
3808
|
var isValidDateFormat = (date) => {
|
|
3809
|
-
if (!datePattern.test(date))
|
|
3809
|
+
if (!datePattern.test(date)) {
|
|
3810
|
+
return false;
|
|
3811
|
+
}
|
|
3810
3812
|
const d = new Date(date);
|
|
3811
3813
|
return !isNaN(d.getTime());
|
|
3812
3814
|
};
|
|
@@ -3821,13 +3823,17 @@ function getAgeOfDeceased(dateOfBirth, dateOfDeath, format3 = "years") {
|
|
|
3821
3823
|
let age = dateOfDeath.getFullYear() - dateOfBirth.getFullYear();
|
|
3822
3824
|
const monthDiff = dateOfDeath.getMonth() - dateOfBirth.getMonth();
|
|
3823
3825
|
const dayDiff = dateOfDeath.getDate() - dateOfBirth.getDate();
|
|
3824
|
-
if (monthDiff < 0 || monthDiff === 0 && dayDiff < 0)
|
|
3826
|
+
if (monthDiff < 0 || monthDiff === 0 && dayDiff < 0) {
|
|
3827
|
+
age--;
|
|
3828
|
+
}
|
|
3825
3829
|
return age;
|
|
3826
3830
|
}
|
|
3827
3831
|
if (format3 === "months") {
|
|
3828
3832
|
let months = (dateOfDeath.getFullYear() - dateOfBirth.getFullYear()) * 12;
|
|
3829
3833
|
months += dateOfDeath.getMonth() - dateOfBirth.getMonth();
|
|
3830
|
-
if (dateOfDeath.getDate() < dateOfBirth.getDate())
|
|
3834
|
+
if (dateOfDeath.getDate() < dateOfBirth.getDate()) {
|
|
3835
|
+
months--;
|
|
3836
|
+
}
|
|
3831
3837
|
return months;
|
|
3832
3838
|
}
|
|
3833
3839
|
if (format3 === "days") {
|
|
@@ -3860,14 +3866,14 @@ ajv.addKeyword({
|
|
|
3860
3866
|
const dod = data?.[deathDateField];
|
|
3861
3867
|
const tod = data?.[deathTimeField];
|
|
3862
3868
|
const ageValue = data?.[ageField];
|
|
3863
|
-
if (!ageValue || !isValidDateFormat(dob) || !isValidDateFormat(dod)
|
|
3869
|
+
if (!ageValue || !isValidDateFormat(dob) || !isValidDateFormat(dod)) {
|
|
3864
3870
|
return true;
|
|
3865
3871
|
}
|
|
3866
3872
|
const dateOfBirth = /* @__PURE__ */ new Date(`${dob}T00:00:00+00:00`);
|
|
3867
3873
|
const dateOfDeath = tod ? /* @__PURE__ */ new Date(`${dod}T${tod}:00+00:00`) : /* @__PURE__ */ new Date(`${dod}T00:00:00+00:00`);
|
|
3868
3874
|
const deceasedAge = getAgeOfDeceased(dateOfBirth, dateOfDeath, format3);
|
|
3869
3875
|
const sameDay = dateOfBirth.toISOString().slice(0, 10) === dateOfDeath.toISOString().slice(0, 10);
|
|
3870
|
-
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;
|
|
3876
|
+
return Number(ageValue) === deceasedAge && !(format3 === "hours" && !sameDay) && !(format3 === "minutes" && !sameDay) || format3 === "days" && !tod && deceasedAge - Number(ageValue) === 1 || format3 === "hours" && !sameDay && deceasedAge < Number(ageValue) || format3 === "hours" && sameDay && (!tod || Number(ageValue) <= deceasedAge) || format3 === "minutes" && !sameDay && deceasedAge < Number(ageValue) || format3 === "minutes" && sameDay && (!tod || Number(ageValue) <= deceasedAge);
|
|
3871
3877
|
}
|
|
3872
3878
|
});
|
|
3873
3879
|
ajv.addKeyword({
|