Repository navigation
Add company code autocomplete with organisation suggestions - #644
Merged
Merged
Conversation
twill742
approved these changes
Nov 20, 2026
twill742
left a comment
Contributor
There was a problem hiding this comment.
All looks good. Only note I have is that it may be worth adding a TODO to restrict the endpoint to only return results that are of the same record type (Vaccine or Medicine) as being currently populated (still scoped to the organisation obvs). We only really need to add this when we build out vaccines, but I don't want to forget
SmithR-IS
force-pushed
the
feature/company-code-autocomplete
branch
from
November 20, 2026 15:21
49cca2e to
65f9c4e
Compare
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.
Company code autocomplete
Summary
Adds type-ahead suggestions to the Company code field. As a user types, it suggests the company codes already used on their organisation's records. Any value can still be entered.
Backend
GET /records/organisations/{organisationId}/company-codes?search=&limit=. It returns the distinct company codes that contain the search text, ignoring case:GetOrganisationRecords(403 or 404).searchis at most 200 characters andlimitis between 1 and 20, otherwise the endpoint returns a 400ValidationProblemDetails.RecordPageDtonow includesorganisationId, so dynamic form pages can look up suggestions for the organisation.RecordProductDetail.CompanyCodeis annotated withDisplay = "autocomplete:company-codes". The display hint names where the suggestions come from, so the frontend doesn't depend on question IDs. The format is documented onFormFieldAttribute.2026.11.20.1, with an updated fingerprint.Frontend
Autocompletecomponent that follows the WAI-ARIA 1.2 combobox pattern (list autocomplete):/portal/components/autocomplete.TextQuestion. A newFormPageContextgives questions the organisation ID. The hint is mapped to its source inlib/dynamic-form/suggestionSources.ts.Screenshots / Evidence
Tests:
RecordServiceCompanyCodeTestscovers matching, ranking, duplicates, wildcard escaping,discarded records, the latest revision, the limit, not allowed and not found.
RecordControllerTestscovers 200, the values passed to the service, 403, 404 and 400 validation. - Frontend:Autocomplete.test.tsxcovers ARIA attributes, keyboard use, mouse selection, debounceand cancelling, leaving the field mid-request, failures and errors.
FormPage.test.tsxandCreateMedicineRecordForm.test.tsxcover choosing a suggestion, free text, the required rule, and falling back to a plain input.Risks and follow-up
ILIKE '%…%'query hano index or SQLLIMIT. This is fine at current volumes, since each record has one code. Iforganisations grow large, the starts-with ranking and a cap could move into SQL.
autocomplete:<source>. A bareautocomplete, or an unknown source, gives a plain input.suggestionSourcesuses a plainobject lookup, so a hint naming a built-in key (for exampleautocomplete:constructor) would breakthe field. Only the backend sets the hint, so the risk is low. A small follow-up could add an
Object.hasOwncheck.organisationIdonRecordPageDtoor theautocomplete:<source>hint (documentation/form-generation/high-level-design.md). Also,RecordPageQuestionDto.Displaystill only givescomboboxas its example.Checklist