For the complete documentation index, see llms.txt. This page is also available as Markdown.

Deduplication

Deduplication rules are built with the field, and, or, and not functions from @opencrvs/toolkit/events/deduplication. These are separate from the conditionals module — they produce ClauseInput objects (not JSONSchema) and are evaluated by the search index.


field (deduplication)

Builds a field matcher for use in a deduplication rule.

Signature

import { field } from '@opencrvs/toolkit/events/deduplication'

field(fieldId: string): {
  fuzzyMatches(options?: FuzzyMatcherOptions): ClauseInput
  strictMatches(options?: StrictMatcherOptions): ClauseInput
  dateRangeMatches(options: DateRangeMatcherOptions): ClauseInput
}

Parameters

Parameter
Type
Description

fieldId

string

The form field ID to match against (e.g. 'child.name').

.fuzzyMatches(options?)

Fuzzy text match — tolerates minor spelling differences.

Option
Type
Default
Description

fuzziness

string | number

'AUTO:4,7'

Edit distance: ≤3 chars → 0 edits, 4–6 → 1 edit, ≥7 → 2 edits.

boost

number

1

Scoring weight multiplier.

matchAgainst

string

Match this field's value against a different field ID instead.

.strictMatches(options?)

Exact value match.

Option
Type
Default
Description

value

string

Constant value both records must share. Omit to match any identical value.

boost

number

1

Scoring weight multiplier.

matchAgainst

string

Compare against a different field ID.

.dateRangeMatches(options)

Date proximity match — records within ±days of each other score as potential duplicates.

Option
Type
Required
Description

days

number

Yes

Half-width of the match window in days.

pivot

number

No

Day distance at which the relevance score is halved. Defaults to ⌊(days * 2) / 3⌋.

boost

number

No

Scoring weight multiplier (default 1).

matchAgainst

string

No

When set, matches this field against matchAgainst instead of against itself; useful for cross-field age/dob matching.

Example 1 — match births with similar child names and nearby dates

Example 2 — match only when an ID document is identical (or not provided)


and (deduplication)

All clauses must match for the pair to be considered a duplicate.

Signature

Example 1 — full birth deduplication rule

Example 2 — death deduplication


or (deduplication)

At least one clause must match.

Signature

Example 1 — cross-field age/dob matching

Example 2 — multiple duplicate detection strategies


not (deduplication)

Inverts a deduplication clause.

Signature

Example 1 — skip ID check when ID types differ

Example 2 — exclude records marked as authenticated

Last updated