Repository navigation
Grey out custom id subject DOB and sex if already filled, let admins see default group ids - #1591
Merged
joshunrau merged 13 commits intoOct 1, 2026
Conversation
…y has one in session form
david-roper
force-pushed
the
grey-custom-session-info
branch
from
September 30, 2026 20:46
9304a2d to
96d43cb
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.
Summary
Two improvements to the Custom Identifier field on the Start Session page.
1. Admins with no group now see custom ID suggestions
An admin who belongs to no group has no current group, so the custom ID combobox used to skip the lookup and list nothing.
When there is no current group, the form now scopes a custom ID to the default group (
root$<id>). The combobox now suggests exactly those subjects: every subject whose ID carries theroot$scope and that was identified by a custom ID rather than personal information.GET /v1/subjects/default-group/custom-ids@RouteAccess({ action: 'read', subject: 'Subject' }), the same as the per-group custom-ID route.accessibleQuery, so an admin sees every such subject and a group manager sees only those in their own groups.GET /v1/subjects/:idroute can't catch it.groupIds. A later session, upload or assignment in a group adds that group to the subject but leaves itsroot$ID unchanged. Matching on "no groups" would hide those subjects, even though they are exactly the ones the form resolves to.startsWithinto an unescaped regex, so the$inroot$acts as an end anchor and matches nothing. The query uses a lexical range instead (gte: 'root$', lt: 'root%'), through a smallidsWithPrefixhelper.IDENTIFIED_BY_CUSTOM_IDclause, used by both the per-group and default-group lookups.useSubjectCustomIdsQuerycalls the new endpoint when there is no current group, instead of returning[]without a request.2. Existing subjects' date of birth and sex are filled in and locked
When the custom ID picked or typed matches an existing subject, the form fills in the date of birth and sex that subject already records, and disables those fields. This shows the clinician they don't need to enter them again.
useSubjectDemographicsLookuphook calls the existingGET /v1/subjects/:id, which is already permission-scoped.nulland raises no error notification.dateOfBirthandsexare parsed, through a new$SubjectDemographicsschema inpackages/schemas.root$), so the details shown belong to the subject the session will actually use.Changes
apps/api/src/subjects/subjects.controller.ts,subjects.service.tspackages/schemas/src/subject/subject.ts($SubjectDemographics)apps/web/src/hooks/useSubjectCustomIdsQuery.ts,apps/web/src/hooks/useSubjectDemographicsLookup.ts(new),apps/web/src/components/StartSessionForm/StartSessionForm.tsxapps/api/src/subjects/__tests__/subjects.service.spec.ts,apps/web/src/hooks/__tests__/useSubjectCustomIdsQuery.test.ts,apps/web/src/hooks/__tests__/useSubjectDemographicsLookup.test.ts(new),apps/web/src/__tests__/start-session-form.test.tsxtesting/src/specs/start-session.spec.ts,testing/src/pages/_app/session/start-session.page.ts,testing/src/support/api-client.tsTest notes
StartSessionPagegainsdateOfBirthField,sexFieldandsexTriggerlocators.sexTriggeris the visible dropdown. The element namedsubjectSexis Radix's hidden native<select>, which is never disabled, so it can't be used for enabled/disabled checks.fillSessionDetailsis split sofillSessionTiming()can fill the session type and date on its own.start-session-form.test.tsxnow renders inside aQueryClientProviderwithaxiosmocked.Test plan
pnpm lintpasses forapi,web,schemasandtestingweb,schemasandapi(1050 tests), plus the API integration suitestart-session.spec.tsanddatahub.spec.tspass in Chromium (33 tests)pnpm test:e2e. Locally, a 12-worker run hits the API rate limiter (429 Too Many Requests), unrelated to this change. CI runs one worker.root$subject, and check that its date of birth and sex are filled in and greyed out. Then type a new ID and check they clear and unlock.🤖 Generated with Claude Code
Closes Issue #1588
Closes Issue #1584