@ecrvs/opencrvs-toolkit 1.8.1-rc.9775e4e → 1.8.1-rc.a2d23b7

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.
@@ -0,0 +1,5 @@
1
+ export declare const medicalAbbreviations: {
2
+ code: string;
3
+ label: string;
4
+ }[];
5
+ //# sourceMappingURL=abbreviation.d.ts.map
@@ -122,6 +122,8 @@ export declare function createFieldConditionals(fieldId: string): {
122
122
  isLessThan: (value: number | FieldReference) => JSONSchema;
123
123
  isEqualTo(value: string | boolean | FieldReference): JSONSchema;
124
124
  isEqualToSumOf(val1: FieldReference, val2: FieldReference): JSONSchema;
125
+ isAbbreviation(): JSONSchema;
126
+ isIllDefined(causesOfDeathFields: FieldReference[], threshold: number): JSONSchema;
125
127
  /**
126
128
  * Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
127
129
  * @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
@@ -133,7 +135,7 @@ export declare function createFieldConditionals(fieldId: string): {
133
135
  isFalsy(): JSONSchema;
134
136
  isUndefined(): JSONSchema;
135
137
  inArray: (values: string[]) => JSONSchema;
136
- isValidEnglishName: () => JSONSchema;
138
+ isValidEnglishName: (isRequiredField?: boolean) => JSONSchema;
137
139
  isValidAdministrativeLeafLevel: () => JSONSchema;
138
140
  /**
139
141
  * Checks if the field value matches a given regular expression pattern.
@@ -167,6 +169,8 @@ export declare function createFieldConditionals(fieldId: string): {
167
169
  isLessThan: (value: number | FieldReference) => JSONSchema;
168
170
  isEqualTo(value: string | boolean | FieldReference): JSONSchema;
169
171
  isEqualToSumOf(val1: FieldReference, val2: FieldReference): JSONSchema;
172
+ isAbbreviation(): JSONSchema;
173
+ isIllDefined(causesOfDeathFields: FieldReference[], threshold: number): JSONSchema;
170
174
  /**
171
175
  * Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
172
176
  * @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
@@ -178,7 +182,7 @@ export declare function createFieldConditionals(fieldId: string): {
178
182
  isFalsy(): JSONSchema;
179
183
  isUndefined(): JSONSchema;
180
184
  inArray: (values: string[]) => JSONSchema;
181
- isValidEnglishName: () => JSONSchema;
185
+ isValidEnglishName: (isRequiredField?: boolean) => JSONSchema;
182
186
  isValidAdministrativeLeafLevel: () => JSONSchema;
183
187
  /**
184
188
  * Checks if the field value matches a given regular expression pattern.
@@ -0,0 +1,2 @@
1
+ export declare const illDefinedConditions: string[];
2
+ //# sourceMappingURL=ill-defined.d.ts.map
@@ -100,10 +100,14 @@ export declare function field(fieldId: string, options?: {
100
100
  }, val2: {
101
101
  $$field: string;
102
102
  }): import("../conditionals/conditionals").JSONSchema;
103
+ isAbbreviation(): import("../conditionals/conditionals").JSONSchema;
104
+ isIllDefined(causesOfDeathFields: {
105
+ $$field: string;
106
+ }[], threshold: number): import("../conditionals/conditionals").JSONSchema;
103
107
  isFalsy(): import("../conditionals/conditionals").JSONSchema;
104
108
  isUndefined(): import("../conditionals/conditionals").JSONSchema;
105
109
  inArray: (values: string[]) => import("../conditionals/conditionals").JSONSchema;
106
- isValidEnglishName: () => import("../conditionals/conditionals").JSONSchema;
110
+ isValidEnglishName: (isRequiredField?: boolean) => import("../conditionals/conditionals").JSONSchema;
107
111
  isValidAdministrativeLeafLevel: () => import("../conditionals/conditionals").JSONSchema;
108
112
  matches: (pattern: string) => import("../conditionals/conditionals").JSONSchema;
109
113
  isBetween: (min: number, max: number) => import("../conditionals/conditionals").JSONSchema;
@@ -146,10 +150,14 @@ export declare function field(fieldId: string, options?: {
146
150
  }, val2: {
147
151
  $$field: string;
148
152
  }): import("../conditionals/conditionals").JSONSchema;
153
+ isAbbreviation(): import("../conditionals/conditionals").JSONSchema;
154
+ isIllDefined(causesOfDeathFields: {
155
+ $$field: string;
156
+ }[], threshold: number): import("../conditionals/conditionals").JSONSchema;
149
157
  isFalsy(): import("../conditionals/conditionals").JSONSchema;
150
158
  isUndefined(): import("../conditionals/conditionals").JSONSchema;
151
159
  inArray: (values: string[]) => import("../conditionals/conditionals").JSONSchema;
152
- isValidEnglishName: () => import("../conditionals/conditionals").JSONSchema;
160
+ isValidEnglishName: (isRequiredField?: boolean) => import("../conditionals/conditionals").JSONSchema;
153
161
  isValidAdministrativeLeafLevel: () => import("../conditionals/conditionals").JSONSchema;
154
162
  matches: (pattern: string) => import("../conditionals/conditionals").JSONSchema;
155
163
  isBetween: (min: number, max: number) => import("../conditionals/conditionals").JSONSchema;
@@ -366,11 +366,40 @@ function createFieldConditionals(fieldId) {
366
366
  [field2Id]: { type: "number" }
367
367
  },
368
368
  required: [fieldId, field1Id, field2Id],
369
- sumOf: [
370
- { $data: `/$form/${fieldId}` },
371
- { $data: `/$form/${field1Id}` },
372
- { $data: `/$form/${field2Id}` }
373
- ]
369
+ sumOf: {
370
+ sum: fieldId,
371
+ field1: field1Id,
372
+ field2: field2Id
373
+ }
374
+ });
375
+ },
376
+ isAbbreviation() {
377
+ return defineFormConditional({
378
+ type: "object",
379
+ properties: {
380
+ [fieldId]: { type: "string", isAbbreviation: true }
381
+ },
382
+ required: [fieldId]
383
+ });
384
+ },
385
+ isIllDefined(causesOfDeathFields, threshold) {
386
+ const fieldIds = causesOfDeathFields.map((field) => field.$$field);
387
+ const properties = fieldIds.reduce(
388
+ (acc, field) => {
389
+ acc[field] = { type: "string" };
390
+ return acc;
391
+ },
392
+ {}
393
+ );
394
+ return defineFormConditional({
395
+ type: "object",
396
+ properties,
397
+ // required: fieldIds,
398
+ // Custom keyword or config (if used by your validator)
399
+ isIllDefined: {
400
+ fields: fieldIds,
401
+ threshold
402
+ }
374
403
  });
375
404
  },
376
405
  /**
@@ -436,12 +465,12 @@ function createFieldConditionals(fieldId) {
436
465
  },
437
466
  required: [fieldId]
438
467
  }),
439
- isValidEnglishName: () => defineFormConditional({
468
+ isValidEnglishName: (isRequiredField = true) => defineFormConditional({
440
469
  type: "object",
441
470
  properties: {
442
471
  [fieldId]: {
443
472
  type: "string",
444
- minLength: 1,
473
+ ...isRequiredField && { minLength: 1 },
445
474
  pattern: "^[\\p{Script=Latin}0-9'.-]*(\\([\\p{Script=Latin}0-9'.-]+\\))?[\\p{Script=Latin}0-9'.-]*( [\\p{Script=Latin}0-9'.-]*(\\([\\p{Script=Latin}0-9'.-]+\\))?[\\p{Script=Latin}0-9'.-]*)*$",
446
475
  description: "Name must contain only letters, numbers, and allowed special characters ('.-). No double spaces."
447
476
  }