Skip to content

Conversation

@tessjaworski
Copy link

Fixes the issue where the "Add to existing individual" field did not display the autocomplete suggestions for individual IDs less than 3 characters.

The changes I made:

  • Updated makeAutocomplete() in src/main/webapp/javascript/core.js to accept a configurable minLength parameter.
  • Updated setIndivAutocomplete() in src/main/webapp/encounters/encounter.jsp to pass a minLength of 2 for the Individual ID field.

PR fixes #1126

Copy link
Contributor

@erinz2020 erinz2020 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @tessjaworski Thank you for working on this! I've done some testing and found that the issue extends beyond the JSP and JavaScript layers.

When a user types just one character, the autocomplete actually triggers an API request to SiteSearch. However, the Java backend has additional logic that restricts returning data based on certain conditions:

  1. In SiteSearch.java, there's a check that returns an empty array for terms with length < 2
  2. More interestingly, there's also a limit of 2000 results in MarkedIndividual.findByNames(). When a short search term matches too many individuals (e.g., searching "12" matched 2104 individuals), it returns an empty array with warning in the log.

    This explains why users might not see results even when typing 2 characters, not because the request wasn't made, but because the backend filtered them out. Would you mind taking a look at the Java side as well? Let me know your thoughts on the best approach here. Happy to help test any changes!

@goddesswarship
Copy link
Contributor

Hi @tessjaworski, just checking in to see if you have any questions about the feedback you received.

@JasonWildMe
Copy link
Collaborator

Closing. 10.9 rewrites the Encounter page in React, and this fix looks at the old encounter.jsp page.

@JasonWildMe JasonWildMe closed this Jan 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't add encounter to existing individual when ID is less than 3 characters

4 participants