Skip to content

WEB-4545 fix: Prioritize SMART context clinic selection - #1960

Merged
krystophv merged 1 commit into
release-1.97.0from
WEB-4545-smart-editable.2
Jun 24, 2026
Merged

WEB-4545 fix: Prioritize SMART context clinic selection#1960
krystophv merged 1 commit into
release-1.97.0from
WEB-4545-smart-editable.2

Conversation

@krystophv

Copy link
Copy Markdown
Member

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:

  • Updated getFetchers in patientdata.js to 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.
  • Passed smartOnFhirData through mapStateToProps to ensure context information is available for clinic selection.

Component updates:

  • Added a selectClinic callback to SmartOnFhir and 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:

  • Added and expanded unit tests in patientdata.test.js to 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.
  • Added new tests in smartonfhir.test.js to cover scenarios where the context clinic is selected, not selected due to lack of access, not provided, or patient lookup fails.

Copilot AI review requested due to automatic review settings June 22, 2026 22:04
@krystophv
krystophv requested a review from henry-tp June 22, 2026 22:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.getFetchers to prefer the SMART context clinicId (when applicable) when selecting a clinic among multiple memberships, with a fallback to the first matching clinic.
  • Extended mapStateToProps in patientdata.js to pass smartOnFhirData into fetcher selection logic.
  • Updated SmartOnFhir to 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.

@krystophv

Copy link
Copy Markdown
Member Author

/deploy int

@tidebot

tidebot commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

krystophv updated values.yaml file in external

@tidebot

tidebot commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

krystophv updated flux policies file in external

@tidebot

tidebot commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

krystophv deployed blip WEB-4545-smart-editable.2 branch to external namespace

@krystophv
krystophv merged commit 33e705c into release-1.97.0 Jun 24, 2026
3 checks passed
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.

4 participants