WEB-4545 fix: Prioritize SMART context clinic selection - #1960
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves clinic-context selection for clinicians launching via SMART-on-FHIR/EHR by prioritizing the SMART context clinic when determining the clinic to use for a patient who belongs to multiple clinics, ensuring entitlements and patient context align with the EHR launch.
Changes:
- Updated
PatientData.getFetchersto prefer the SMART contextclinicId(when applicable) when selecting a clinic among multiple memberships, with a fallback to the first matching clinic. - Extended
mapStateToPropsinpatientdata.jsto passsmartOnFhirDatainto fetcher selection logic. - Updated
SmartOnFhirto switch the clinician’s selected clinic to the SMART context clinic only after patient lookup succeeds, and added/expanded unit tests for these behaviors.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
app/pages/patientdata/patientdata.js |
Prefer SMART context clinic during clinic auto-selection; plumb smartOnFhirData via mapStateToProps. |
app/pages/smartonfhir/smartonfhir.js |
Defer clinic switching until after successful patient lookup to avoid leaving clinicians in the wrong workspace on failure. |
test/unit/pages/patientdata.test.js |
Added unit tests validating SMART-context clinic preference and fallback behavior in getFetchers. |
__tests__/unit/app/pages/smartonfhir/smartonfhir.test.js |
Added unit tests covering clinic selection behavior across access/no-access/no-context and lookup-failure scenarios. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
henry-tp
approved these changes
Jun 22, 2026
Member
Author
|
/deploy int |
Collaborator
|
krystophv updated values.yaml file in external |
Collaborator
|
krystophv updated flux policies file in external |
Collaborator
|
krystophv deployed blip WEB-4545-smart-editable.2 branch to external namespace |
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.
This pull request enhances how the application selects a clinic context when a clinician accesses patient data via a SMART-on-FHIR/EHR session, especially when the patient belongs to multiple clinics. The updates ensure that, when possible, the clinic chosen matches the one from which the EHR session was launched, improving consistency for entitlements and patient context. The changes also add comprehensive unit tests to cover these scenarios and improve test coverage for edge cases.
Key changes include:
Clinic selection logic improvements:
getFetchersinpatientdata.jsto prefer the SMART-on-FHIR/EHR context clinic when selecting a clinic for a patient who belongs to multiple clinics, falling back to the first available clinic if the context clinic is not applicable.smartOnFhirDatathroughmapStateToPropsto ensure context information is available for clinic selection.Component updates:
selectCliniccallback toSmartOnFhirand updated the logic to only switch the clinician’s selected clinic to the SMART context clinic after patient lookup succeeds, preventing context mismatches in case of lookup failure. [1] [2]Testing and coverage:
patientdata.test.jsto verify that the SMART-on-FHIR context clinic is selected when appropriate, and that the fallback logic works as intended when the context clinic is not available.smartonfhir.test.jsto cover scenarios where the context clinic is selected, not selected due to lack of access, not provided, or patient lookup fails.