How can you tell if a FHIR server is active?
By “active” I mean available for queries and ready to return data.
First, what’s the context here? Why would you need to know if a FHIR server is active?
Let’s say you have an app that displays Appointment or DiagnosticReport data.
A users logs in at the beginning of the day. Everything looks good. Then they click a button that triggers a call to the FHIR server and an error message appears.
If the server is down, this is unlikely to be an OperationOutcome. It’ll be an API gateway error, a NotFound error of some kind, or a wall of HTML — familiar to anyone who uses the HAPI test server.
It would be a better user experience to notify the user when they log in that the server is down.
I haven’t found a simple or elegant way of doing this.
Possible solutions:
- Make a call to load the CapabilityStatement
Not accurate. For many server providers the “metadata” endpoint is accessible even when the server is down. - Make a call to access some resources: /Patient
Not accurate. Maybe you don’t have access to the Patient endpoint without specific parameters. Is the server really down? - Run a permitted query: /Patient?custom-parameter=User123
This will work. If a valid query you’re allowed to run fails you know the server is down or in difficulty.
But running a search query on a production FHIR server purely to see if the server is running is bad practice. You’re accessing potentially sensitive data for no valid reason. And you’re leaving a trail — AuditEvent and other logs are written to.
The only solution I see is to build a custom endpoint or operation.
- $is-server-active
- The operation makes a direct query to the FHIR server, bypassing any logs
- The operation returns a meaningful status to the user
- The users never encounters live data
This is a real-world problem I’ve encountered many times.
If you’ve found a more elegant solution I’d love to hear about it.
---