![]() |
VOOZH | about |
The CData ODBC Drivers can be used in any environment that supports loading an ODBC Driver. In this tutorial we will explore using the CData ODBC Driver for FHIR from within PyCharm. Included are steps for adding the CData ODBC Driver as a data source, as well as basic PyCharm code to query the data source and display results.
To begin, this tutorial will assume that you have already installed the CData ODBC Driver for FHIR as well as PyCharm.
Follow the steps below to add the pyodbc module to your project.
You can now connect with an ODBC connection string or a DSN. See the Getting Started section in the CData driver documentation for a guide to creating a DSN on your OS.
Set URL to the Service Base URL of the FHIR server. This is the address where the resources are defined in the FHIR server you would like to connect to. Set ConnectionType to a supported connection type. Set ContentType to the format of your documents. Set AuthScheme based on the authentication requirements for your FHIR server.
Generic, Azure-based, AWS-based, and Google-based FHIR server implementations are supported.
The product supports connections to custom instances of FHIR. Authentication to custom FHIR servers is handled via OAuth (read more about OAuth in the Help documentation. Before you can connect to custom FHIR instances, you must set ConnectionType to Generic.
Below is the syntax for a DSN:
[CData FHIR Source] Driver = CData ODBC Driver for FHIR Description = My Description URL = http://test.fhir.org/r4b/ ConnectionType = Generic ContentType = JSON AuthScheme = None
Instantiate a Cursor and use the execute method of the Cursor class to execute any SQL statement.
import pyodbc
cnxn = pyodbc.connect('DRIVER={CData ODBC Driver for FHIR};URL = http://test.fhir.org/r4b/;ConnectionType = Generic;ContentType = JSON;AuthScheme = None;')
cursor = cnxn.cursor()
cursor.execute("SELECT Id, [name-use] FROM Patient WHERE [address-city] = 'New York'")
rows = cursor.fetchall()
for row in rows:
print(row.Id, row.[name-use])
After connecting to FHIR in PyCharm using the CData ODBC Driver, you will be able to build Python apps with access to FHIR data as if it were a standard database. If you have any questions, comments, or feedback regarding this tutorial, please contact us at [email protected].
Download a free trial of the FHIR ODBC Driver to get started:
Download NowLearn more:
👁 FHIR IconThe FHIR ODBC Driver is a powerful tool that allows you to connect with live data from FHIR, directly from any applications that support ODBC connectivity.
Access FHIR data like you would a database - read, write, and update FHIR 0, etc. through a standard ODBC Driver interface.