Model Context Protocol (MCP) finally gives AI models a way to access the business data needed to make them really useful at work. CData MCP Servers have the depth and performance to make sure AI has access to all of the answers.
Try them now for free →How to pipe FHIR Data to CSV in PowerShell
Use standard PowerShell cmdlets to access FHIR tables.
The CData Cmdlets Module for FHIR is a standard PowerShell module offering straightforward integration with FHIR. Below, you will find examples of using our FHIR Cmdlets with native PowerShell cmdlets.
Creating a Connection to Your FHIR Data
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.
Sample Service Base URLs
- Generic: http://my_fhir_server/r4b/
- Azure: https://MY_AZURE_FHIR.azurehealthcareapis.com/
- AWS: https://healthlake.REGION.amazonaws.com/datastore/DATASTORE_ID/r4/
- Google: https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/
Generic FHIR Instances
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.
$conn = Connect-FHIR -URL "$URL" -ConnectionType "$ConnectionType" -ContentType "$ContentType" -AuthScheme "$AuthScheme"
Selecting Data
Follow the steps below to retrieve data from the Patient table and pipe the result into to a CSV file:
Select-FHIR -Connection $conn -Table Patient | Select -Property * -ExcludeProperty Connection,Table,Columns | Export-Csv -Path c:\myPatientData.csv -NoTypeInformation
You will notice that we piped the results from Select-FHIR into a Select-Object cmdlet and excluded some properties before piping them into an Export-Csv cmdlet. We do this because the CData Cmdlets append Connection, Table, and Columns information onto each "row" in the result set, and we do not necessarily want that information in our CSV file.
The Connection, Table, and Columns are appended to the results in order to facilitate piping results from one of the CData Cmdlets directly into another one.