fhir-basics
FHIR Data Retrieval
Important: In this sandbox, run Python scripts with python (not python3). Use subprocess.run(["curl", "-sf", url], capture_output=True, text=True) for all FHIR HTTP calls — the requests library does NOT work through the sandbox proxy. Always parse the output with json.loads().
FHIR (Fast Healthcare Interoperability Resources) R4 is the standard API format mandated by the 21st Century Cures Act for US healthcare interoperability. ~70% of US hospitals expose FHIR R4 endpoints (ONC 2024). All queries use REST GET requests returning JSON Bundles.
Default FHIR Endpoint
Unless the user specifies a different FHIR server, always use: https://r4.smarthealthit.org
This is the SMART on FHIR public test server with synthetic (Synthea) patient data. No authentication required.
Query format for this server: Use bare codes without system URIs. Example: code=44054006 NOT code=http://snomed.info/sct|44054006. The test server does not support system-qualified code searches and will return empty results.
Authentication
- Public test servers (e.g.,
https://r4.smarthealthit.org): No authentication required. Synthetic data, real FHIR format. - Production hospital endpoints: Use SMART on FHIR OAuth2 flows. Requires a
client_id, redirect URI, and scope negotiation. Access tokens are passed asAuthorization: Bearer {token}headers.