Add nickname-aware patient name search#6170
Open
JasonWang-0401 wants to merge 1 commit into
Open
Conversation
Adds an opt-in nickname/alias layer to patient name search so that searching a common English given-name nickname matches a patient registered under the formal name and vice versa (e.g. "Bob" finds "Robert"). Soundex cannot connect these because a nickname is a social alias, not a phonetic variant. The change mirrors the existing analyzer pattern instead of adding a subsystem: - nicknames.txt: curated Solr-format synonym dictionary (given/middle names). - SearchAnalysis.NICKNAME_ANALYZER: new analyzer name constant. - LuceneConfig: registers nicknameAnalyzer (Whitespace + Classic + LowerCase + ASCIIFolding + SynonymGraphFilter over nicknames.txt + FlattenGraphFilter). - PersonName: two new index-time @FullTextField fields, givenNameNickname and middleNameNickname, queried with the plain EXACT analyzer. - OpenmrsConstants: new default-off boolean GlobalProperty patientSearch.matchMode.nickname, seeded as a core global property. - PersonQuery.getPersonNameQuery: adds the nickname fields to the query only when the toggle is enabled, composing with the existing match modes. Default-off and additive, so existing deployments are unaffected until an administrator enables it and rebuilds the search index. Adds two PatientDAOTest cases covering the enabled and disabled paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
jwnasambu
reviewed
Jun 7, 2026
Contributor
jwnasambu
left a comment
There was a problem hiding this comment.
@JasonWang-0401 Thanks for the PR! Could you please link the jira issue this PR addresses? This helps with traceability and project tracking.
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.



Description
Adds an opt-in nickname/alias layer to patient name search so that searching a common English given-name nickname matches a patient registered under the formal name and vice versa — e.g.
Bobfinds a patient stored asRobert. Soundex cannot connect these, because a nickname is a social alias, not a phonetic one (Soundex("Bob")=B100 vsSoundex("Robert")=R163).The change mirrors the existing Soundex analyzer pattern instead of adding a subsystem — one new analyzer, one new indexed field per relevant name, one runtime toggle, no schema change, no new service or DAO:
nicknames.txt— curated Solr-format synonym dictionary (given/middle names).SearchAnalysis— newNICKNAME_ANALYZERconstant.LuceneConfig— registersnicknameAnalyzer(Whitespace + Classic + LowerCase + ASCIIFolding +SynonymGraphFilterovernicknames.txt+FlattenGraphFilter).PersonName— two index-time@FullTextFields,givenNameNicknameandmiddleNameNickname, queried with the plainEXACTanalyzer (expansion happens only at index time).OpenmrsConstants— new default-off boolean GlobalPropertypatientSearch.matchMode.nickname, seeded as a core global property withBooleanDatatype.PersonQuery.getPersonNameQuery— adds the nickname fields to the query only when the toggle is enabled, composing with the existing match modes.Default-off and additive, so existing deployments are unaffected until an administrator enables it and rebuilds the search index.
Testing
Adds two
PatientDAOTestcases covering the enabled and disabled paths:getPatients_shouldMatchNicknameWhenNicknameSearchIsEnabled—Bobmatches a patient registered asRobert.getPatients_shouldNotMatchNicknameWhenNicknameSearchIsDisabled— with the toggle off (default),Bobdoes not matchRobert(regression guard).🤖 Generated with Claude Code