@ecrvs/opencrvs-toolkit 1.9.0-rc.a4498ac → 1.9.0-rc.b385861
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/commons/conditionals/conditionals.d.ts +11 -0
- package/dist/commons/conditionals/validate.d.ts +1 -0
- package/dist/commons/events/DeduplicationConfig.d.ts +2 -2
- package/dist/commons/events/field.d.ts +110 -0
- package/dist/conditionals/index.js +24 -3
- package/dist/events/index.js +100 -8
- package/dist/notification/index.js +99 -8
- package/package.json +1 -1
|
@@ -133,6 +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
137
|
isAbbreviation(): JSONSchema;
|
|
137
138
|
isIllDefined(causesOfDeathFields: FieldReference[], threshold: number): JSONSchema;
|
|
138
139
|
/**
|
|
@@ -191,6 +192,7 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
191
192
|
isLessThan(value: number | FieldReference): JSONSchema;
|
|
192
193
|
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
193
194
|
isEqualToSumOf(val1: FieldReference, val2: FieldReference): JSONSchema;
|
|
195
|
+
isValidDeceasedAge(dobField: FieldReference, dodField: FieldReference, todField: FieldReference, format: "years" | "months" | "days" | "hours"): JSONSchema;
|
|
194
196
|
isAbbreviation(): JSONSchema;
|
|
195
197
|
isIllDefined(causesOfDeathFields: FieldReference[], threshold: number): JSONSchema;
|
|
196
198
|
/**
|
|
@@ -263,6 +265,7 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
263
265
|
isLessThan(value: number | FieldReference): JSONSchema;
|
|
264
266
|
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
265
267
|
isEqualToSumOf(val1: FieldReference, val2: FieldReference): JSONSchema;
|
|
268
|
+
isValidDeceasedAge(dobField: FieldReference, dodField: FieldReference, todField: FieldReference, format: "years" | "months" | "days" | "hours"): JSONSchema;
|
|
266
269
|
isAbbreviation(): JSONSchema;
|
|
267
270
|
isIllDefined(causesOfDeathFields: FieldReference[], threshold: number): JSONSchema;
|
|
268
271
|
/**
|
|
@@ -330,6 +333,7 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
330
333
|
isLessThan(value: number | FieldReference): JSONSchema;
|
|
331
334
|
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
332
335
|
isEqualToSumOf(val1: FieldReference, val2: FieldReference): JSONSchema;
|
|
336
|
+
isValidDeceasedAge(dobField: FieldReference, dodField: FieldReference, todField: FieldReference, format: "years" | "months" | "days" | "hours"): JSONSchema;
|
|
333
337
|
isAbbreviation(): JSONSchema;
|
|
334
338
|
isIllDefined(causesOfDeathFields: FieldReference[], threshold: number): JSONSchema;
|
|
335
339
|
/**
|
|
@@ -396,6 +400,7 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
396
400
|
isLessThan(value: number | FieldReference): JSONSchema;
|
|
397
401
|
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
398
402
|
isEqualToSumOf(val1: FieldReference, val2: FieldReference): JSONSchema;
|
|
403
|
+
isValidDeceasedAge(dobField: FieldReference, dodField: FieldReference, todField: FieldReference, format: "years" | "months" | "days" | "hours"): JSONSchema;
|
|
399
404
|
isAbbreviation(): JSONSchema;
|
|
400
405
|
isIllDefined(causesOfDeathFields: FieldReference[], threshold: number): JSONSchema;
|
|
401
406
|
/**
|
|
@@ -452,6 +457,7 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
452
457
|
isLessThan(value: number | FieldReference): JSONSchema;
|
|
453
458
|
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
454
459
|
isEqualToSumOf(val1: FieldReference, val2: FieldReference): JSONSchema;
|
|
460
|
+
isValidDeceasedAge(dobField: FieldReference, dodField: FieldReference, todField: FieldReference, format: "years" | "months" | "days" | "hours"): JSONSchema;
|
|
455
461
|
isAbbreviation(): JSONSchema;
|
|
456
462
|
isIllDefined(causesOfDeathFields: FieldReference[], threshold: number): JSONSchema;
|
|
457
463
|
/**
|
|
@@ -525,6 +531,7 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
525
531
|
isLessThan(value: number | FieldReference): JSONSchema;
|
|
526
532
|
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
527
533
|
isEqualToSumOf(val1: FieldReference, val2: FieldReference): JSONSchema;
|
|
534
|
+
isValidDeceasedAge(dobField: FieldReference, dodField: FieldReference, todField: FieldReference, format: "years" | "months" | "days" | "hours"): JSONSchema;
|
|
528
535
|
isAbbreviation(): JSONSchema;
|
|
529
536
|
isIllDefined(causesOfDeathFields: FieldReference[], threshold: number): JSONSchema;
|
|
530
537
|
/**
|
|
@@ -583,6 +590,7 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
583
590
|
isLessThan(value: number | FieldReference): JSONSchema;
|
|
584
591
|
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
585
592
|
isEqualToSumOf(val1: FieldReference, val2: FieldReference): JSONSchema;
|
|
593
|
+
isValidDeceasedAge(dobField: FieldReference, dodField: FieldReference, todField: FieldReference, format: "years" | "months" | "days" | "hours"): JSONSchema;
|
|
586
594
|
isAbbreviation(): JSONSchema;
|
|
587
595
|
isIllDefined(causesOfDeathFields: FieldReference[], threshold: number): JSONSchema;
|
|
588
596
|
/**
|
|
@@ -656,6 +664,7 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
656
664
|
isLessThan(value: number | FieldReference): JSONSchema;
|
|
657
665
|
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
658
666
|
isEqualToSumOf(val1: FieldReference, val2: FieldReference): JSONSchema;
|
|
667
|
+
isValidDeceasedAge(dobField: FieldReference, dodField: FieldReference, todField: FieldReference, format: "years" | "months" | "days" | "hours"): JSONSchema;
|
|
659
668
|
isAbbreviation(): JSONSchema;
|
|
660
669
|
isIllDefined(causesOfDeathFields: FieldReference[], threshold: number): JSONSchema;
|
|
661
670
|
/**
|
|
@@ -714,6 +723,7 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
714
723
|
isLessThan(value: number | FieldReference): JSONSchema;
|
|
715
724
|
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
716
725
|
isEqualToSumOf(val1: FieldReference, val2: FieldReference): JSONSchema;
|
|
726
|
+
isValidDeceasedAge(dobField: FieldReference, dodField: FieldReference, todField: FieldReference, format: "years" | "months" | "days" | "hours"): JSONSchema;
|
|
717
727
|
isAbbreviation(): JSONSchema;
|
|
718
728
|
isIllDefined(causesOfDeathFields: FieldReference[], threshold: number): JSONSchema;
|
|
719
729
|
/**
|
|
@@ -770,6 +780,7 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
770
780
|
isLessThan(value: number | FieldReference): JSONSchema;
|
|
771
781
|
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
772
782
|
isEqualToSumOf(val1: FieldReference, val2: FieldReference): JSONSchema;
|
|
783
|
+
isValidDeceasedAge(dobField: FieldReference, dodField: FieldReference, todField: FieldReference, format: "years" | "months" | "days" | "hours"): JSONSchema;
|
|
773
784
|
isAbbreviation(): JSONSchema;
|
|
774
785
|
isIllDefined(causesOfDeathFields: FieldReference[], threshold: number): JSONSchema;
|
|
775
786
|
/**
|
|
@@ -7,6 +7,7 @@ import { TranslationConfig } from '../events/TranslationConfig';
|
|
|
7
7
|
import { ITokenPayload } from '../authentication';
|
|
8
8
|
import { UUID } from '../uuid';
|
|
9
9
|
import { ActionType } from '../client';
|
|
10
|
+
export declare const isValidDateFormat: (date: string) => boolean;
|
|
10
11
|
export declare function validate(schema: JSONSchema, data: ConditionalParameters): boolean;
|
|
11
12
|
export declare function validateValue(schema: JSONSchema, data: unknown): boolean;
|
|
12
13
|
export declare function isOnline(): boolean;
|
|
@@ -120,8 +120,8 @@ declare const DateRangeMatcher: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
120
120
|
days: z.ZodNumber;
|
|
121
121
|
boost: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
122
122
|
}, "strip", z.ZodTypeAny, {
|
|
123
|
-
boost: number;
|
|
124
123
|
days: number;
|
|
124
|
+
boost: number;
|
|
125
125
|
pivot?: number | undefined;
|
|
126
126
|
}, {
|
|
127
127
|
days: number;
|
|
@@ -131,8 +131,8 @@ declare const DateRangeMatcher: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
131
131
|
}>, "strip", z.ZodTypeAny, {
|
|
132
132
|
type: "dateRange";
|
|
133
133
|
options: {
|
|
134
|
-
boost: number;
|
|
135
134
|
days: number;
|
|
135
|
+
boost: number;
|
|
136
136
|
pivot?: number | undefined;
|
|
137
137
|
};
|
|
138
138
|
fieldId: string;
|
|
@@ -114,6 +114,16 @@ export declare function field(fieldId: string, options?: {
|
|
|
114
114
|
$$field: string;
|
|
115
115
|
$$subfield: string[];
|
|
116
116
|
}): import("../conditionals/conditionals").JSONSchema;
|
|
117
|
+
isValidDeceasedAge(dobField: {
|
|
118
|
+
$$field: string;
|
|
119
|
+
$$subfield: string[];
|
|
120
|
+
}, dodField: {
|
|
121
|
+
$$field: string;
|
|
122
|
+
$$subfield: string[];
|
|
123
|
+
}, todField: {
|
|
124
|
+
$$field: string;
|
|
125
|
+
$$subfield: string[];
|
|
126
|
+
}, format: "years" | "months" | "days" | "hours"): import("../conditionals/conditionals").JSONSchema;
|
|
117
127
|
isAbbreviation(): import("../conditionals/conditionals").JSONSchema;
|
|
118
128
|
isIllDefined(causesOfDeathFields: {
|
|
119
129
|
$$field: string;
|
|
@@ -174,6 +184,16 @@ export declare function field(fieldId: string, options?: {
|
|
|
174
184
|
$$field: string;
|
|
175
185
|
$$subfield: string[];
|
|
176
186
|
}): import("../conditionals/conditionals").JSONSchema;
|
|
187
|
+
isValidDeceasedAge(dobField: {
|
|
188
|
+
$$field: string;
|
|
189
|
+
$$subfield: string[];
|
|
190
|
+
}, dodField: {
|
|
191
|
+
$$field: string;
|
|
192
|
+
$$subfield: string[];
|
|
193
|
+
}, todField: {
|
|
194
|
+
$$field: string;
|
|
195
|
+
$$subfield: string[];
|
|
196
|
+
}, format: "years" | "months" | "days" | "hours"): import("../conditionals/conditionals").JSONSchema;
|
|
177
197
|
isAbbreviation(): import("../conditionals/conditionals").JSONSchema;
|
|
178
198
|
isIllDefined(causesOfDeathFields: {
|
|
179
199
|
$$field: string;
|
|
@@ -242,6 +262,16 @@ export declare function field(fieldId: string, options?: {
|
|
|
242
262
|
$$field: string;
|
|
243
263
|
$$subfield: string[];
|
|
244
264
|
}): import("../conditionals/conditionals").JSONSchema;
|
|
265
|
+
isValidDeceasedAge(dobField: {
|
|
266
|
+
$$field: string;
|
|
267
|
+
$$subfield: string[];
|
|
268
|
+
}, dodField: {
|
|
269
|
+
$$field: string;
|
|
270
|
+
$$subfield: string[];
|
|
271
|
+
}, todField: {
|
|
272
|
+
$$field: string;
|
|
273
|
+
$$subfield: string[];
|
|
274
|
+
}, format: "years" | "months" | "days" | "hours"): import("../conditionals/conditionals").JSONSchema;
|
|
245
275
|
isAbbreviation(): import("../conditionals/conditionals").JSONSchema;
|
|
246
276
|
isIllDefined(causesOfDeathFields: {
|
|
247
277
|
$$field: string;
|
|
@@ -308,6 +338,16 @@ export declare function field(fieldId: string, options?: {
|
|
|
308
338
|
$$field: string;
|
|
309
339
|
$$subfield: string[];
|
|
310
340
|
}): import("../conditionals/conditionals").JSONSchema;
|
|
341
|
+
isValidDeceasedAge(dobField: {
|
|
342
|
+
$$field: string;
|
|
343
|
+
$$subfield: string[];
|
|
344
|
+
}, dodField: {
|
|
345
|
+
$$field: string;
|
|
346
|
+
$$subfield: string[];
|
|
347
|
+
}, todField: {
|
|
348
|
+
$$field: string;
|
|
349
|
+
$$subfield: string[];
|
|
350
|
+
}, format: "years" | "months" | "days" | "hours"): import("../conditionals/conditionals").JSONSchema;
|
|
311
351
|
isAbbreviation(): import("../conditionals/conditionals").JSONSchema;
|
|
312
352
|
isIllDefined(causesOfDeathFields: {
|
|
313
353
|
$$field: string;
|
|
@@ -373,6 +413,16 @@ export declare function field(fieldId: string, options?: {
|
|
|
373
413
|
$$field: string;
|
|
374
414
|
$$subfield: string[];
|
|
375
415
|
}): import("../conditionals/conditionals").JSONSchema;
|
|
416
|
+
isValidDeceasedAge(dobField: {
|
|
417
|
+
$$field: string;
|
|
418
|
+
$$subfield: string[];
|
|
419
|
+
}, dodField: {
|
|
420
|
+
$$field: string;
|
|
421
|
+
$$subfield: string[];
|
|
422
|
+
}, todField: {
|
|
423
|
+
$$field: string;
|
|
424
|
+
$$subfield: string[];
|
|
425
|
+
}, format: "years" | "months" | "days" | "hours"): import("../conditionals/conditionals").JSONSchema;
|
|
376
426
|
isAbbreviation(): import("../conditionals/conditionals").JSONSchema;
|
|
377
427
|
isIllDefined(causesOfDeathFields: {
|
|
378
428
|
$$field: string;
|
|
@@ -431,6 +481,16 @@ export declare function field(fieldId: string, options?: {
|
|
|
431
481
|
$$field: string;
|
|
432
482
|
$$subfield: string[];
|
|
433
483
|
}): import("../conditionals/conditionals").JSONSchema;
|
|
484
|
+
isValidDeceasedAge(dobField: {
|
|
485
|
+
$$field: string;
|
|
486
|
+
$$subfield: string[];
|
|
487
|
+
}, dodField: {
|
|
488
|
+
$$field: string;
|
|
489
|
+
$$subfield: string[];
|
|
490
|
+
}, todField: {
|
|
491
|
+
$$field: string;
|
|
492
|
+
$$subfield: string[];
|
|
493
|
+
}, format: "years" | "months" | "days" | "hours"): import("../conditionals/conditionals").JSONSchema;
|
|
434
494
|
isAbbreviation(): import("../conditionals/conditionals").JSONSchema;
|
|
435
495
|
isIllDefined(causesOfDeathFields: {
|
|
436
496
|
$$field: string;
|
|
@@ -500,6 +560,16 @@ export declare function field(fieldId: string, options?: {
|
|
|
500
560
|
$$field: string;
|
|
501
561
|
$$subfield: string[];
|
|
502
562
|
}): import("../conditionals/conditionals").JSONSchema;
|
|
563
|
+
isValidDeceasedAge(dobField: {
|
|
564
|
+
$$field: string;
|
|
565
|
+
$$subfield: string[];
|
|
566
|
+
}, dodField: {
|
|
567
|
+
$$field: string;
|
|
568
|
+
$$subfield: string[];
|
|
569
|
+
}, todField: {
|
|
570
|
+
$$field: string;
|
|
571
|
+
$$subfield: string[];
|
|
572
|
+
}, format: "years" | "months" | "days" | "hours"): import("../conditionals/conditionals").JSONSchema;
|
|
503
573
|
isAbbreviation(): import("../conditionals/conditionals").JSONSchema;
|
|
504
574
|
isIllDefined(causesOfDeathFields: {
|
|
505
575
|
$$field: string;
|
|
@@ -560,6 +630,16 @@ export declare function field(fieldId: string, options?: {
|
|
|
560
630
|
$$field: string;
|
|
561
631
|
$$subfield: string[];
|
|
562
632
|
}): import("../conditionals/conditionals").JSONSchema;
|
|
633
|
+
isValidDeceasedAge(dobField: {
|
|
634
|
+
$$field: string;
|
|
635
|
+
$$subfield: string[];
|
|
636
|
+
}, dodField: {
|
|
637
|
+
$$field: string;
|
|
638
|
+
$$subfield: string[];
|
|
639
|
+
}, todField: {
|
|
640
|
+
$$field: string;
|
|
641
|
+
$$subfield: string[];
|
|
642
|
+
}, format: "years" | "months" | "days" | "hours"): import("../conditionals/conditionals").JSONSchema;
|
|
563
643
|
isAbbreviation(): import("../conditionals/conditionals").JSONSchema;
|
|
564
644
|
isIllDefined(causesOfDeathFields: {
|
|
565
645
|
$$field: string;
|
|
@@ -629,6 +709,16 @@ export declare function field(fieldId: string, options?: {
|
|
|
629
709
|
$$field: string;
|
|
630
710
|
$$subfield: string[];
|
|
631
711
|
}): import("../conditionals/conditionals").JSONSchema;
|
|
712
|
+
isValidDeceasedAge(dobField: {
|
|
713
|
+
$$field: string;
|
|
714
|
+
$$subfield: string[];
|
|
715
|
+
}, dodField: {
|
|
716
|
+
$$field: string;
|
|
717
|
+
$$subfield: string[];
|
|
718
|
+
}, todField: {
|
|
719
|
+
$$field: string;
|
|
720
|
+
$$subfield: string[];
|
|
721
|
+
}, format: "years" | "months" | "days" | "hours"): import("../conditionals/conditionals").JSONSchema;
|
|
632
722
|
isAbbreviation(): import("../conditionals/conditionals").JSONSchema;
|
|
633
723
|
isIllDefined(causesOfDeathFields: {
|
|
634
724
|
$$field: string;
|
|
@@ -689,6 +779,16 @@ export declare function field(fieldId: string, options?: {
|
|
|
689
779
|
$$field: string;
|
|
690
780
|
$$subfield: string[];
|
|
691
781
|
}): import("../conditionals/conditionals").JSONSchema;
|
|
782
|
+
isValidDeceasedAge(dobField: {
|
|
783
|
+
$$field: string;
|
|
784
|
+
$$subfield: string[];
|
|
785
|
+
}, dodField: {
|
|
786
|
+
$$field: string;
|
|
787
|
+
$$subfield: string[];
|
|
788
|
+
}, todField: {
|
|
789
|
+
$$field: string;
|
|
790
|
+
$$subfield: string[];
|
|
791
|
+
}, format: "years" | "months" | "days" | "hours"): import("../conditionals/conditionals").JSONSchema;
|
|
692
792
|
isAbbreviation(): import("../conditionals/conditionals").JSONSchema;
|
|
693
793
|
isIllDefined(causesOfDeathFields: {
|
|
694
794
|
$$field: string;
|
|
@@ -747,6 +847,16 @@ export declare function field(fieldId: string, options?: {
|
|
|
747
847
|
$$field: string;
|
|
748
848
|
$$subfield: string[];
|
|
749
849
|
}): import("../conditionals/conditionals").JSONSchema;
|
|
850
|
+
isValidDeceasedAge(dobField: {
|
|
851
|
+
$$field: string;
|
|
852
|
+
$$subfield: string[];
|
|
853
|
+
}, dodField: {
|
|
854
|
+
$$field: string;
|
|
855
|
+
$$subfield: string[];
|
|
856
|
+
}, todField: {
|
|
857
|
+
$$field: string;
|
|
858
|
+
$$subfield: string[];
|
|
859
|
+
}, format: "years" | "months" | "days" | "hours"): import("../conditionals/conditionals").JSONSchema;
|
|
750
860
|
isAbbreviation(): import("../conditionals/conditionals").JSONSchema;
|
|
751
861
|
isIllDefined(causesOfDeathFields: {
|
|
752
862
|
$$field: string;
|
|
@@ -437,18 +437,39 @@ function createFieldConditionals(fieldId) {
|
|
|
437
437
|
return defineFormConditional({
|
|
438
438
|
type: "object",
|
|
439
439
|
properties: {
|
|
440
|
-
[
|
|
440
|
+
[this.$$field]: { type: "number" },
|
|
441
441
|
[field1Id]: { type: "number" },
|
|
442
442
|
[field2Id]: { type: "number" }
|
|
443
443
|
},
|
|
444
|
-
required: [
|
|
444
|
+
required: [this.$$field, field1Id, field2Id],
|
|
445
445
|
sumOf: {
|
|
446
|
-
sum:
|
|
446
|
+
sum: this.$$field,
|
|
447
447
|
field1: field1Id,
|
|
448
448
|
field2: field2Id
|
|
449
449
|
}
|
|
450
450
|
});
|
|
451
451
|
},
|
|
452
|
+
isValidDeceasedAge(dobField, dodField, todField, format) {
|
|
453
|
+
const dobFieldId = dobField.$$field;
|
|
454
|
+
const dodFieldId = dodField.$$field;
|
|
455
|
+
const todFieldId = todField.$$field;
|
|
456
|
+
return defineFormConditional({
|
|
457
|
+
type: "object",
|
|
458
|
+
properties: {
|
|
459
|
+
[this.$$field]: { type: "string" },
|
|
460
|
+
[dobFieldId]: { type: "string" },
|
|
461
|
+
[dodFieldId]: { type: "string" },
|
|
462
|
+
[todFieldId]: { type: "string" }
|
|
463
|
+
},
|
|
464
|
+
isValidAgeOfDeceased: {
|
|
465
|
+
ageField: this.$$field,
|
|
466
|
+
dateOfBirthField: dobFieldId,
|
|
467
|
+
deathDateField: dodFieldId,
|
|
468
|
+
deathTimeField: todFieldId,
|
|
469
|
+
format
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
},
|
|
452
473
|
isAbbreviation() {
|
|
453
474
|
return defineFormConditional({
|
|
454
475
|
type: "object",
|
package/dist/events/index.js
CHANGED
|
@@ -349,6 +349,7 @@ __export(events_exports, {
|
|
|
349
349
|
isTextFieldType: () => isTextFieldType,
|
|
350
350
|
isTimeFieldType: () => isTimeFieldType,
|
|
351
351
|
isUndeclaredDraft: () => isUndeclaredDraft,
|
|
352
|
+
isValidDateFormat: () => isValidDateFormat,
|
|
352
353
|
isVerificationPage: () => isVerificationPage,
|
|
353
354
|
isVerificationStatusType: () => isVerificationStatusType,
|
|
354
355
|
isWriteAction: () => isWriteAction,
|
|
@@ -4404,6 +4405,66 @@ ajv.addKeyword({
|
|
|
4404
4405
|
return locations.some((location) => location.id === locationIdInput);
|
|
4405
4406
|
}
|
|
4406
4407
|
});
|
|
4408
|
+
var datePattern = /^\d{4}-\d{1,2}-\d{1,2}$/;
|
|
4409
|
+
var isValidDateFormat = (date) => {
|
|
4410
|
+
if (!datePattern.test(date)) return false;
|
|
4411
|
+
const d = new Date(date);
|
|
4412
|
+
return !isNaN(d.getTime());
|
|
4413
|
+
};
|
|
4414
|
+
var MS_PER_DAY = 1e3 * 60 * 60 * 24;
|
|
4415
|
+
var MS_PER_HOUR = 1e3 * 60 * 60;
|
|
4416
|
+
function getAgeOfDeceased(dateOfBirth, dateOfDeath, format3 = "years") {
|
|
4417
|
+
if (dateOfDeath < dateOfBirth) {
|
|
4418
|
+
return 0;
|
|
4419
|
+
}
|
|
4420
|
+
if (format3 === "years") {
|
|
4421
|
+
let age = dateOfDeath.getFullYear() - dateOfBirth.getFullYear();
|
|
4422
|
+
const monthDiff = dateOfDeath.getMonth() - dateOfBirth.getMonth();
|
|
4423
|
+
const dayDiff = dateOfDeath.getDate() - dateOfBirth.getDate();
|
|
4424
|
+
if (monthDiff < 0 || monthDiff === 0 && dayDiff < 0) age--;
|
|
4425
|
+
return age;
|
|
4426
|
+
}
|
|
4427
|
+
if (format3 === "months") {
|
|
4428
|
+
let months = (dateOfDeath.getFullYear() - dateOfBirth.getFullYear()) * 12;
|
|
4429
|
+
months += dateOfDeath.getMonth() - dateOfBirth.getMonth();
|
|
4430
|
+
if (dateOfDeath.getDate() < dateOfBirth.getDate()) months--;
|
|
4431
|
+
return months;
|
|
4432
|
+
}
|
|
4433
|
+
if (format3 === "days") {
|
|
4434
|
+
const diffTime2 = dateOfDeath.getTime() - dateOfBirth.getTime();
|
|
4435
|
+
return Math.floor(diffTime2 / MS_PER_DAY);
|
|
4436
|
+
}
|
|
4437
|
+
const diffTime = dateOfDeath.getTime() - dateOfBirth.getTime();
|
|
4438
|
+
const remainingMs = diffTime - MS_PER_DAY;
|
|
4439
|
+
return remainingMs < 0 ? Math.floor(diffTime / MS_PER_HOUR) : Math.floor(remainingMs / MS_PER_HOUR);
|
|
4440
|
+
}
|
|
4441
|
+
ajv.addKeyword({
|
|
4442
|
+
keyword: "isValidAgeOfDeceased",
|
|
4443
|
+
type: "object",
|
|
4444
|
+
schemaType: "object",
|
|
4445
|
+
errors: true,
|
|
4446
|
+
validate(schema, data) {
|
|
4447
|
+
const {
|
|
4448
|
+
ageField,
|
|
4449
|
+
dateOfBirthField,
|
|
4450
|
+
deathDateField,
|
|
4451
|
+
deathTimeField,
|
|
4452
|
+
format: format3
|
|
4453
|
+
} = schema;
|
|
4454
|
+
const dob = data?.[dateOfBirthField];
|
|
4455
|
+
const dod = data?.[deathDateField];
|
|
4456
|
+
const tod = data?.[deathTimeField];
|
|
4457
|
+
const ageValue = data?.[ageField];
|
|
4458
|
+
if (!ageValue || !isValidDateFormat(dob) || !isValidDateFormat(dod)) {
|
|
4459
|
+
return true;
|
|
4460
|
+
}
|
|
4461
|
+
const dateOfBirth = /* @__PURE__ */ new Date(`${dob}T00:00:00+00:00`);
|
|
4462
|
+
const dateOfDeath = tod ? /* @__PURE__ */ new Date(`${dod}T${tod}:00+00:00`) : /* @__PURE__ */ new Date(`${dod}T00:00:00+00:00`);
|
|
4463
|
+
const deceasedAge = getAgeOfDeceased(dateOfBirth, dateOfDeath, format3);
|
|
4464
|
+
const sameDay = dateOfBirth.toISOString().slice(0, 10) === dateOfDeath.toISOString().slice(0, 10);
|
|
4465
|
+
return Number(ageValue) === deceasedAge && !(format3 === "hours" && !sameDay) || format3 === "days" && deceasedAge - Number(ageValue) === 1 || format3 === "hours" && !sameDay && deceasedAge < Number(ageValue);
|
|
4466
|
+
}
|
|
4467
|
+
});
|
|
4407
4468
|
ajv.addKeyword({
|
|
4408
4469
|
keyword: "sumOf",
|
|
4409
4470
|
type: "object",
|
|
@@ -4427,7 +4488,9 @@ ajv.addKeyword({
|
|
|
4427
4488
|
schemaType: "boolean",
|
|
4428
4489
|
errors: true,
|
|
4429
4490
|
validate(schema, data) {
|
|
4430
|
-
if (!schema)
|
|
4491
|
+
if (!schema) {
|
|
4492
|
+
return true;
|
|
4493
|
+
}
|
|
4431
4494
|
if (typeof data !== "string") {
|
|
4432
4495
|
return true;
|
|
4433
4496
|
}
|
|
@@ -4448,11 +4511,15 @@ ajv.addKeyword({
|
|
|
4448
4511
|
errors: true,
|
|
4449
4512
|
validate(schema, data) {
|
|
4450
4513
|
const { fields, threshold } = schema;
|
|
4451
|
-
if (!data || typeof data !== "object")
|
|
4514
|
+
if (!data || typeof data !== "object") {
|
|
4515
|
+
return true;
|
|
4516
|
+
}
|
|
4452
4517
|
const causesOfDeath = fields.flatMap(
|
|
4453
4518
|
(field3) => (data?.[field3] || "").split(",").map((v) => v.trim()).filter(Boolean)
|
|
4454
4519
|
).filter((val, index, self) => self.indexOf(val) === index);
|
|
4455
|
-
if (causesOfDeath.length === 0)
|
|
4520
|
+
if (causesOfDeath.length === 0) {
|
|
4521
|
+
return true;
|
|
4522
|
+
}
|
|
4456
4523
|
let hasNonIllDefined = false;
|
|
4457
4524
|
for (const term of causesOfDeath) {
|
|
4458
4525
|
const results = fuzzySearch(term, illDefinedConditions, threshold).filter(
|
|
@@ -4791,7 +4858,9 @@ function fuzzySearch(query, list, threshold, limit = 3) {
|
|
|
4791
4858
|
const normalize = (str) => str.toLowerCase().replace(/[^\w\s]/g, "").trim();
|
|
4792
4859
|
const tokenize = (str) => normalize(str).split(/\s+/).filter((w) => w.length >= 3);
|
|
4793
4860
|
const queryWords = tokenize(query);
|
|
4794
|
-
if (queryWords.length === 0)
|
|
4861
|
+
if (queryWords.length === 0) {
|
|
4862
|
+
return [];
|
|
4863
|
+
}
|
|
4795
4864
|
const results = [];
|
|
4796
4865
|
for (const item of list) {
|
|
4797
4866
|
const itemWords = tokenize(item);
|
|
@@ -4807,7 +4876,9 @@ function fuzzySearch(query, list, threshold, limit = 3) {
|
|
|
4807
4876
|
for (const iWord of itemWords) {
|
|
4808
4877
|
const dist = levenshtein(qWord, iWord);
|
|
4809
4878
|
const normDist = dist / Math.max(qWord.length, iWord.length);
|
|
4810
|
-
if (normDist < bestScore)
|
|
4879
|
+
if (normDist < bestScore) {
|
|
4880
|
+
bestScore = normDist;
|
|
4881
|
+
}
|
|
4811
4882
|
}
|
|
4812
4883
|
if (bestScore !== Infinity) {
|
|
4813
4884
|
const weight = COMMON_WORDS.has(qWord) ? 0.5 : 1;
|
|
@@ -5623,18 +5694,39 @@ function createFieldConditionals(fieldId) {
|
|
|
5623
5694
|
return defineFormConditional({
|
|
5624
5695
|
type: "object",
|
|
5625
5696
|
properties: {
|
|
5626
|
-
[
|
|
5697
|
+
[this.$$field]: { type: "number" },
|
|
5627
5698
|
[field1Id]: { type: "number" },
|
|
5628
5699
|
[field2Id]: { type: "number" }
|
|
5629
5700
|
},
|
|
5630
|
-
required: [
|
|
5701
|
+
required: [this.$$field, field1Id, field2Id],
|
|
5631
5702
|
sumOf: {
|
|
5632
|
-
sum:
|
|
5703
|
+
sum: this.$$field,
|
|
5633
5704
|
field1: field1Id,
|
|
5634
5705
|
field2: field2Id
|
|
5635
5706
|
}
|
|
5636
5707
|
});
|
|
5637
5708
|
},
|
|
5709
|
+
isValidDeceasedAge(dobField, dodField, todField, format3) {
|
|
5710
|
+
const dobFieldId = dobField.$$field;
|
|
5711
|
+
const dodFieldId = dodField.$$field;
|
|
5712
|
+
const todFieldId = todField.$$field;
|
|
5713
|
+
return defineFormConditional({
|
|
5714
|
+
type: "object",
|
|
5715
|
+
properties: {
|
|
5716
|
+
[this.$$field]: { type: "string" },
|
|
5717
|
+
[dobFieldId]: { type: "string" },
|
|
5718
|
+
[dodFieldId]: { type: "string" },
|
|
5719
|
+
[todFieldId]: { type: "string" }
|
|
5720
|
+
},
|
|
5721
|
+
isValidAgeOfDeceased: {
|
|
5722
|
+
ageField: this.$$field,
|
|
5723
|
+
dateOfBirthField: dobFieldId,
|
|
5724
|
+
deathDateField: dodFieldId,
|
|
5725
|
+
deathTimeField: todFieldId,
|
|
5726
|
+
format: format3
|
|
5727
|
+
}
|
|
5728
|
+
});
|
|
5729
|
+
},
|
|
5638
5730
|
isAbbreviation() {
|
|
5639
5731
|
return defineFormConditional({
|
|
5640
5732
|
type: "object",
|
|
@@ -3644,6 +3644,66 @@ ajv.addKeyword({
|
|
|
3644
3644
|
return locations.some((location) => location.id === locationIdInput);
|
|
3645
3645
|
}
|
|
3646
3646
|
});
|
|
3647
|
+
var datePattern = /^\d{4}-\d{1,2}-\d{1,2}$/;
|
|
3648
|
+
var isValidDateFormat = (date) => {
|
|
3649
|
+
if (!datePattern.test(date)) return false;
|
|
3650
|
+
const d = new Date(date);
|
|
3651
|
+
return !isNaN(d.getTime());
|
|
3652
|
+
};
|
|
3653
|
+
var MS_PER_DAY = 1e3 * 60 * 60 * 24;
|
|
3654
|
+
var MS_PER_HOUR = 1e3 * 60 * 60;
|
|
3655
|
+
function getAgeOfDeceased(dateOfBirth, dateOfDeath, format3 = "years") {
|
|
3656
|
+
if (dateOfDeath < dateOfBirth) {
|
|
3657
|
+
return 0;
|
|
3658
|
+
}
|
|
3659
|
+
if (format3 === "years") {
|
|
3660
|
+
let age = dateOfDeath.getFullYear() - dateOfBirth.getFullYear();
|
|
3661
|
+
const monthDiff = dateOfDeath.getMonth() - dateOfBirth.getMonth();
|
|
3662
|
+
const dayDiff = dateOfDeath.getDate() - dateOfBirth.getDate();
|
|
3663
|
+
if (monthDiff < 0 || monthDiff === 0 && dayDiff < 0) age--;
|
|
3664
|
+
return age;
|
|
3665
|
+
}
|
|
3666
|
+
if (format3 === "months") {
|
|
3667
|
+
let months = (dateOfDeath.getFullYear() - dateOfBirth.getFullYear()) * 12;
|
|
3668
|
+
months += dateOfDeath.getMonth() - dateOfBirth.getMonth();
|
|
3669
|
+
if (dateOfDeath.getDate() < dateOfBirth.getDate()) months--;
|
|
3670
|
+
return months;
|
|
3671
|
+
}
|
|
3672
|
+
if (format3 === "days") {
|
|
3673
|
+
const diffTime2 = dateOfDeath.getTime() - dateOfBirth.getTime();
|
|
3674
|
+
return Math.floor(diffTime2 / MS_PER_DAY);
|
|
3675
|
+
}
|
|
3676
|
+
const diffTime = dateOfDeath.getTime() - dateOfBirth.getTime();
|
|
3677
|
+
const remainingMs = diffTime - MS_PER_DAY;
|
|
3678
|
+
return remainingMs < 0 ? Math.floor(diffTime / MS_PER_HOUR) : Math.floor(remainingMs / MS_PER_HOUR);
|
|
3679
|
+
}
|
|
3680
|
+
ajv.addKeyword({
|
|
3681
|
+
keyword: "isValidAgeOfDeceased",
|
|
3682
|
+
type: "object",
|
|
3683
|
+
schemaType: "object",
|
|
3684
|
+
errors: true,
|
|
3685
|
+
validate(schema, data) {
|
|
3686
|
+
const {
|
|
3687
|
+
ageField,
|
|
3688
|
+
dateOfBirthField,
|
|
3689
|
+
deathDateField,
|
|
3690
|
+
deathTimeField,
|
|
3691
|
+
format: format3
|
|
3692
|
+
} = schema;
|
|
3693
|
+
const dob = data?.[dateOfBirthField];
|
|
3694
|
+
const dod = data?.[deathDateField];
|
|
3695
|
+
const tod = data?.[deathTimeField];
|
|
3696
|
+
const ageValue = data?.[ageField];
|
|
3697
|
+
if (!ageValue || !isValidDateFormat(dob) || !isValidDateFormat(dod)) {
|
|
3698
|
+
return true;
|
|
3699
|
+
}
|
|
3700
|
+
const dateOfBirth = /* @__PURE__ */ new Date(`${dob}T00:00:00+00:00`);
|
|
3701
|
+
const dateOfDeath = tod ? /* @__PURE__ */ new Date(`${dod}T${tod}:00+00:00`) : /* @__PURE__ */ new Date(`${dod}T00:00:00+00:00`);
|
|
3702
|
+
const deceasedAge = getAgeOfDeceased(dateOfBirth, dateOfDeath, format3);
|
|
3703
|
+
const sameDay = dateOfBirth.toISOString().slice(0, 10) === dateOfDeath.toISOString().slice(0, 10);
|
|
3704
|
+
return Number(ageValue) === deceasedAge && !(format3 === "hours" && !sameDay) || format3 === "days" && deceasedAge - Number(ageValue) === 1 || format3 === "hours" && !sameDay && deceasedAge < Number(ageValue);
|
|
3705
|
+
}
|
|
3706
|
+
});
|
|
3647
3707
|
ajv.addKeyword({
|
|
3648
3708
|
keyword: "sumOf",
|
|
3649
3709
|
type: "object",
|
|
@@ -3667,7 +3727,9 @@ ajv.addKeyword({
|
|
|
3667
3727
|
schemaType: "boolean",
|
|
3668
3728
|
errors: true,
|
|
3669
3729
|
validate(schema, data) {
|
|
3670
|
-
if (!schema)
|
|
3730
|
+
if (!schema) {
|
|
3731
|
+
return true;
|
|
3732
|
+
}
|
|
3671
3733
|
if (typeof data !== "string") {
|
|
3672
3734
|
return true;
|
|
3673
3735
|
}
|
|
@@ -3688,11 +3750,15 @@ ajv.addKeyword({
|
|
|
3688
3750
|
errors: true,
|
|
3689
3751
|
validate(schema, data) {
|
|
3690
3752
|
const { fields, threshold } = schema;
|
|
3691
|
-
if (!data || typeof data !== "object")
|
|
3753
|
+
if (!data || typeof data !== "object") {
|
|
3754
|
+
return true;
|
|
3755
|
+
}
|
|
3692
3756
|
const causesOfDeath = fields.flatMap(
|
|
3693
3757
|
(field3) => (data?.[field3] || "").split(",").map((v) => v.trim()).filter(Boolean)
|
|
3694
3758
|
).filter((val, index, self) => self.indexOf(val) === index);
|
|
3695
|
-
if (causesOfDeath.length === 0)
|
|
3759
|
+
if (causesOfDeath.length === 0) {
|
|
3760
|
+
return true;
|
|
3761
|
+
}
|
|
3696
3762
|
let hasNonIllDefined = false;
|
|
3697
3763
|
for (const term of causesOfDeath) {
|
|
3698
3764
|
const results = fuzzySearch(term, illDefinedConditions, threshold).filter(
|
|
@@ -3742,7 +3808,9 @@ function fuzzySearch(query, list, threshold, limit = 3) {
|
|
|
3742
3808
|
const normalize = (str) => str.toLowerCase().replace(/[^\w\s]/g, "").trim();
|
|
3743
3809
|
const tokenize = (str) => normalize(str).split(/\s+/).filter((w) => w.length >= 3);
|
|
3744
3810
|
const queryWords = tokenize(query);
|
|
3745
|
-
if (queryWords.length === 0)
|
|
3811
|
+
if (queryWords.length === 0) {
|
|
3812
|
+
return [];
|
|
3813
|
+
}
|
|
3746
3814
|
const results = [];
|
|
3747
3815
|
for (const item of list) {
|
|
3748
3816
|
const itemWords = tokenize(item);
|
|
@@ -3758,7 +3826,9 @@ function fuzzySearch(query, list, threshold, limit = 3) {
|
|
|
3758
3826
|
for (const iWord of itemWords) {
|
|
3759
3827
|
const dist = levenshtein(qWord, iWord);
|
|
3760
3828
|
const normDist = dist / Math.max(qWord.length, iWord.length);
|
|
3761
|
-
if (normDist < bestScore)
|
|
3829
|
+
if (normDist < bestScore) {
|
|
3830
|
+
bestScore = normDist;
|
|
3831
|
+
}
|
|
3762
3832
|
}
|
|
3763
3833
|
if (bestScore !== Infinity) {
|
|
3764
3834
|
const weight = COMMON_WORDS.has(qWord) ? 0.5 : 1;
|
|
@@ -4267,18 +4337,39 @@ function createFieldConditionals(fieldId) {
|
|
|
4267
4337
|
return defineFormConditional({
|
|
4268
4338
|
type: "object",
|
|
4269
4339
|
properties: {
|
|
4270
|
-
[
|
|
4340
|
+
[this.$$field]: { type: "number" },
|
|
4271
4341
|
[field1Id]: { type: "number" },
|
|
4272
4342
|
[field2Id]: { type: "number" }
|
|
4273
4343
|
},
|
|
4274
|
-
required: [
|
|
4344
|
+
required: [this.$$field, field1Id, field2Id],
|
|
4275
4345
|
sumOf: {
|
|
4276
|
-
sum:
|
|
4346
|
+
sum: this.$$field,
|
|
4277
4347
|
field1: field1Id,
|
|
4278
4348
|
field2: field2Id
|
|
4279
4349
|
}
|
|
4280
4350
|
});
|
|
4281
4351
|
},
|
|
4352
|
+
isValidDeceasedAge(dobField, dodField, todField, format3) {
|
|
4353
|
+
const dobFieldId = dobField.$$field;
|
|
4354
|
+
const dodFieldId = dodField.$$field;
|
|
4355
|
+
const todFieldId = todField.$$field;
|
|
4356
|
+
return defineFormConditional({
|
|
4357
|
+
type: "object",
|
|
4358
|
+
properties: {
|
|
4359
|
+
[this.$$field]: { type: "string" },
|
|
4360
|
+
[dobFieldId]: { type: "string" },
|
|
4361
|
+
[dodFieldId]: { type: "string" },
|
|
4362
|
+
[todFieldId]: { type: "string" }
|
|
4363
|
+
},
|
|
4364
|
+
isValidAgeOfDeceased: {
|
|
4365
|
+
ageField: this.$$field,
|
|
4366
|
+
dateOfBirthField: dobFieldId,
|
|
4367
|
+
deathDateField: dodFieldId,
|
|
4368
|
+
deathTimeField: todFieldId,
|
|
4369
|
+
format: format3
|
|
4370
|
+
}
|
|
4371
|
+
});
|
|
4372
|
+
},
|
|
4282
4373
|
isAbbreviation() {
|
|
4283
4374
|
return defineFormConditional({
|
|
4284
4375
|
type: "object",
|