Skip to content

Add ability to specify default FHIR server #576

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

nickclyde
Copy link
Member

@nickclyde nickclyde commented May 1, 2025

PULL REQUEST

Summary

Adds the ability to choose one FHIR server as the default.

Related Issue

Fixes #535
https://linear.app/skylight-cdc/issue/QUE-248/make-default-fhir-server-configurable

Copilot summary

This pull request introduces a "default server" feature for FHIR servers, allowing one server to be designated as the default. Key changes include database schema updates, backend service modifications, and frontend adjustments to support this new functionality.

Database Updates:

  • Added a default_server column to the fhir_servers table and enforced a unique constraint to ensure only one server can be marked as default at a time. (flyway/sql/V13_01__add_default_fhir_server.sql)

Backend Changes:

  • Updated the FhirServerConfigService class to handle the defaultServer property, including sorting servers to prioritize the default server and modifying SQL queries to include the new column. (src/app/backend/dbServices/fhir-servers.ts) [1] [2] [3]
  • Adjusted utility functions to handle the default_server field when inserting new FHIR server records. (src/app/backend/dbServices/util.ts) [1] [2]

Frontend Changes:

  • Added a checkbox in the FHIR server modal to set a server as default. (src/app/(pages)/fhirServers/page.tsx)
  • Updated the FHIR servers table to display a "DEFAULT" tag next to the default server and sort the list to show the default server first. (src/app/(pages)/fhirServers/page.tsx)
  • Modified the query page to automatically select the default server when fetching server names. (src/app/(pages)/query/page.tsx)

Code Cleanup:

  • Removed hardcoded default FHIR server references and associated constants. (src/app/shared/constants.ts, src/app/(pages)/query/components/searchForm/SearchForm.tsx) [1] [2]

These changes ensure that the default server feature is consistently applied across the application, enhancing usability and reducing manual configuration.

Screenshots

Screenshot 2025-05-01 at 2 04 37 PM Screenshot 2025-05-01 at 2 04 49 PM Screenshot 2025-05-01 at 2 04 59 PM

@codecov-commenter
Copy link

codecov-commenter commented May 1, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.14%. Comparing base (2129c24) to head (0d4ce13).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #576   +/-   ##
=======================================
  Coverage   66.13%   66.14%           
=======================================
  Files          99       99           
  Lines        4028     4029    +1     
  Branches      894      917   +23     
=======================================
+ Hits         2664     2665    +1     
  Misses       1354     1354           
  Partials       10       10           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

// Sort so that the default server is always first
configs.sort((a, b) =>
b.defaultServer === true ? 1 : a.defaultServer === true ? -1 : 0,
);
Copy link
Collaborator

@fzhao99 fzhao99 May 2, 2025

Choose a reason for hiding this comment

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

Noticing on dev startup that since the default isn't initialized any way outside of user input, that Public HAPI ends up being the default server on a fresh run of the app (ie without anyone marking a default) since it shows up first. We could just ask devs to mark Aidbox as default manually each time the start the app up fresh, but in self interest wondering if we could come up with something else 😅

Screen.Recording.2025-05-02.at.10.29.04.AM.mov

Can we think of a way between the way we're returning the servers here and the way we're setting the default on the frontend to still have Aidbox populate? Maybe by also alphabetizing the list as well?

Copy link
Collaborator

@fzhao99 fzhao99 left a comment

Choose a reason for hiding this comment

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

left one suggestion but otherwise lgtm!

Copy link
Collaborator

@robertandremitchell robertandremitchell left a comment

Choose a reason for hiding this comment

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

lgtm! same note as bob; initializing the FHIR server mostly makes sense. I kinda wonder if we want to have some way to set the default on the /query page, as well, but

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.

Make default FHIR server configurable
4 participants