Improve OpenCR patient matching rules for Haiti#4
Closed
mherman22 wants to merge 1 commit into
Closed
Conversation
The previous matching config had only 2 rules with strict exact-match
thresholds (jaro-winkler 1.0), which caused missed matches for:
- Patients with minor name typos ("Jean" vs "Jeen")
- Patients with swapped given/family names ("Jean Baptiste" vs "Baptiste Jean")
- Patients with birthdate entry errors (1985-03-15 vs 1985-03-51)
- Patients missing identifiers (no biometric, no national code)
- Patients with missing birthdates
New matching rules (evaluated in order, first match wins):
1. Biometric exact match — fingerprint (strongest identifier)
2. Code National exact match — national ID alone
3. Code National + full demographics — national ID confirmed by name/gender/DOB
4. iSantePlus ID + full demographics — facility ID confirmed by demographics
5. Exact demographics — name + gender + DOB (no identifier needed)
6. Swapped name detection — given↔family + gender + DOB
7. Fuzzy demographics — jaro-winkler 0.8 for names + DateDamerau 0.8 for DOB
8. Exact names + fuzzy birthdate — catches DOB typos with exact name
9. Code National + partial demographics — for patients with missing DOB
10. Phone + demographics — last resort for patients without identifiers
All rules use Haiti-specific identifier systems:
- http://isanteplus.org/openmrs/fhir2/6-biometrics-national-reference-code
- http://isanteplus.org/openmrs/fhir2/5-code-national
- http://isanteplus.org/openmrs/fhir2/3-isanteplus-id
Rules 5-10 use split thresholds:
- potentialMatchThreshold: 5 (flags for manual review)
- autoMatchThreshold: 6 (auto-links only when ALL fields match)
This prevents false auto-merges while still surfacing potential matches
for human review in the OpenCR dashboard.
Author
|
Merged into #3 (fix/pipeline-shr-integration). Closing this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the minimal 2-rule OpenCR matching configuration with a comprehensive 10-rule set adapted for Haiti's identifier systems. The previous config only matched on exact biometric codes or exact demographics (all fields at jaro-winkler threshold 1.0), which missed patients with minor data entry errors.
Problem
The existing matching rules were too strict:
In Haiti's context, where data is often entered by different clerks at different facilities with varying data quality, strict exact matching leads to duplicate patient records in the master patient index.
Solution
10 matching rules evaluated in order (first match wins):
Haiti-specific identifier systems used
http://isanteplus.org/openmrs/fhir2/6-biometrics-national-reference-code— M2Sys biometric fingerprinthttp://isanteplus.org/openmrs/fhir2/5-code-national— National identification codehttp://isanteplus.org/openmrs/fhir2/3-isanteplus-id— iSantePlus facility patient IDMatching algorithms
Auto-match vs potential match thresholds
Rules 5-10 use split thresholds to prevent false merges:
potentialMatchThreshold: 5— flags for manual review in OpenCR dashboardautoMatchThreshold: 6— auto-links only when ALL fields in the rule matchThis means fuzzy matches (rule 7) surface as potential matches for human review rather than being auto-merged, reducing the risk of incorrectly merging different patients.
Test plan