@ecrvs/opencrvs-toolkit 1.8.1-rc.96537cc → 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,7 +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
- isGreaterThanOrEqualTo(value: number | string | FieldReference): JSONSchema;
125
+ isAbbreviation(): JSONSchema;
126
+ isIllDefined(causesOfDeathFields: FieldReference[], threshold: number): JSONSchema;
126
127
  /**
127
128
  * Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
128
129
  * @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
@@ -134,7 +135,7 @@ export declare function createFieldConditionals(fieldId: string): {
134
135
  isFalsy(): JSONSchema;
135
136
  isUndefined(): JSONSchema;
136
137
  inArray: (values: string[]) => JSONSchema;
137
- isValidEnglishName: () => JSONSchema;
138
+ isValidEnglishName: (isRequiredField?: boolean) => JSONSchema;
138
139
  isValidAdministrativeLeafLevel: () => JSONSchema;
139
140
  /**
140
141
  * Checks if the field value matches a given regular expression pattern.
@@ -168,7 +169,8 @@ export declare function createFieldConditionals(fieldId: string): {
168
169
  isLessThan: (value: number | FieldReference) => JSONSchema;
169
170
  isEqualTo(value: string | boolean | FieldReference): JSONSchema;
170
171
  isEqualToSumOf(val1: FieldReference, val2: FieldReference): JSONSchema;
171
- isGreaterThanOrEqualTo(value: number | string | FieldReference): JSONSchema;
172
+ isAbbreviation(): JSONSchema;
173
+ isIllDefined(causesOfDeathFields: FieldReference[], threshold: number): JSONSchema;
172
174
  /**
173
175
  * Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
174
176
  * @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
@@ -180,7 +182,7 @@ export declare function createFieldConditionals(fieldId: string): {
180
182
  isFalsy(): JSONSchema;
181
183
  isUndefined(): JSONSchema;
182
184
  inArray: (values: string[]) => JSONSchema;
183
- isValidEnglishName: () => JSONSchema;
185
+ isValidEnglishName: (isRequiredField?: boolean) => JSONSchema;
184
186
  isValidAdministrativeLeafLevel: () => JSONSchema;
185
187
  /**
186
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,13 +100,14 @@ export declare function field(fieldId: string, options?: {
100
100
  }, val2: {
101
101
  $$field: string;
102
102
  }): import("../conditionals/conditionals").JSONSchema;
103
- isGreaterThanOrEqualTo(value: number | string | {
103
+ isAbbreviation(): import("../conditionals/conditionals").JSONSchema;
104
+ isIllDefined(causesOfDeathFields: {
104
105
  $$field: string;
105
- }): import("../conditionals/conditionals").JSONSchema;
106
+ }[], threshold: number): import("../conditionals/conditionals").JSONSchema;
106
107
  isFalsy(): import("../conditionals/conditionals").JSONSchema;
107
108
  isUndefined(): import("../conditionals/conditionals").JSONSchema;
108
109
  inArray: (values: string[]) => import("../conditionals/conditionals").JSONSchema;
109
- isValidEnglishName: () => import("../conditionals/conditionals").JSONSchema;
110
+ isValidEnglishName: (isRequiredField?: boolean) => import("../conditionals/conditionals").JSONSchema;
110
111
  isValidAdministrativeLeafLevel: () => import("../conditionals/conditionals").JSONSchema;
111
112
  matches: (pattern: string) => import("../conditionals/conditionals").JSONSchema;
112
113
  isBetween: (min: number, max: number) => import("../conditionals/conditionals").JSONSchema;
@@ -149,13 +150,14 @@ export declare function field(fieldId: string, options?: {
149
150
  }, val2: {
150
151
  $$field: string;
151
152
  }): import("../conditionals/conditionals").JSONSchema;
152
- isGreaterThanOrEqualTo(value: number | string | {
153
+ isAbbreviation(): import("../conditionals/conditionals").JSONSchema;
154
+ isIllDefined(causesOfDeathFields: {
153
155
  $$field: string;
154
- }): import("../conditionals/conditionals").JSONSchema;
156
+ }[], threshold: number): import("../conditionals/conditionals").JSONSchema;
155
157
  isFalsy(): import("../conditionals/conditionals").JSONSchema;
156
158
  isUndefined(): import("../conditionals/conditionals").JSONSchema;
157
159
  inArray: (values: string[]) => import("../conditionals/conditionals").JSONSchema;
158
- isValidEnglishName: () => import("../conditionals/conditionals").JSONSchema;
160
+ isValidEnglishName: (isRequiredField?: boolean) => import("../conditionals/conditionals").JSONSchema;
159
161
  isValidAdministrativeLeafLevel: () => import("../conditionals/conditionals").JSONSchema;
160
162
  matches: (pattern: string) => import("../conditionals/conditionals").JSONSchema;
161
163
  isBetween: (min: number, max: number) => import("../conditionals/conditionals").JSONSchema;
@@ -366,35 +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
374
  });
375
375
  },
376
- isGreaterThanOrEqualTo(value) {
377
- const fieldSchema = { type: "number" };
378
- const properties = {};
379
- const required = [fieldId];
380
- if (typeof value === "number") {
381
- fieldSchema.minimum = value;
382
- } else {
383
- let refField = "";
384
- if (isFieldReference(value)) {
385
- refField = value.$$field;
386
- } else {
387
- refField = value;
388
- }
389
- fieldSchema.minimum = { $data: `/$form/${refField}` };
390
- properties[refField] = { type: "number" };
391
- required.push(refField);
392
- }
393
- properties[fieldId] = fieldSchema;
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
394
  return defineFormConditional({
395
395
  type: "object",
396
396
  properties,
397
- required
397
+ // required: fieldIds,
398
+ // Custom keyword or config (if used by your validator)
399
+ isIllDefined: {
400
+ fields: fieldIds,
401
+ threshold
402
+ }
398
403
  });
399
404
  },
400
405
  /**
@@ -460,12 +465,12 @@ function createFieldConditionals(fieldId) {
460
465
  },
461
466
  required: [fieldId]
462
467
  }),
463
- isValidEnglishName: () => defineFormConditional({
468
+ isValidEnglishName: (isRequiredField = true) => defineFormConditional({
464
469
  type: "object",
465
470
  properties: {
466
471
  [fieldId]: {
467
472
  type: "string",
468
- minLength: 1,
473
+ ...isRequiredField && { minLength: 1 },
469
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'.-]*)*$",
470
475
  description: "Name must contain only letters, numbers, and allowed special characters ('.-). No double spaces."
471
476
  }