FHIR
Power BI is a powerful business intelligence tool for data analysis, visualization, and reporting. It is widely used in many industries for its ability to connect to various data sources and transform them into meaningful insights. One of the most popular data sources in the healthcare industry is the Fast Healthcare Interoperability Resources (FHIR) standard. In this article, we will explore how to use Power Query M language code to connect to the FHIR data source from inside Power BI.
What is FHIR?
FHIR is a standard for exchanging electronic healthcare information, developed by the Health Level Seven International (HL7) organization. It is designed to enable interoperability between different healthcare systems, such as electronic health records (EHRs), health information exchanges (HIEs), and patient portals. FHIR uses modern web technologies, such as RESTful APIs and JSON formats, to make it easier to access and exchange healthcare data.
Connecting to the FHIR data source
To connect to the FHIR data source from inside Power BI, we need to use the Power Query editor, which is a data transformation and query language tool. Power Query supports various data sources, including web-based sources such as APIs and web pages. In this case, we will be using the FHIR REST API to retrieve patient data.
Step 1: Open Power BI and create a new report
First, open Power BI and create a new report. Click on the “Get Data” button on the Home tab and select “Web” from the drop-down menu.
Step 2: Enter the FHIR REST API URL
Enter the FHIR REST API URL in the “URL” field. The FHIR API URL typically follows this format:
https://yourFHIRserver.com/FHIR/baseDstu2/Patient
Replace “yourFHIRserver.com” with the URL of your FHIR server. Change “Dstu2” to the version of FHIR your server supports, if needed. “Patient” is the resource type we are requesting, but you can change this to other resource types such as “Observation” or “Condition” depending on your needs.
Step 3: Choose the type of data you want to retrieve
Next, choose the type of data you want to retrieve from the FHIR server. Click on the “OK” button to preview the data and select the fields you want to import.
Step 4: Transform the data with Power Query M language code
Once you have imported the data, you can use the Power Query editor to transform the data into a format that is suitable for your analysis. Power Query has a powerful language called M that allows you to perform various data transformations, such as filtering, grouping, and pivoting. Here’s an example of M language code that filters the patient data by gender:
let
Source = Json.Document(Web.Contents(“https://yourFHIRserver.com/FHIR/baseDstu2/Patient”)),
#”Converted to Table” = Record.ToTable(Source),
#”Expanded Value” = Table.ExpandRecordColumn(#”Converted to Table”, “Value”, {“gender”}, {“gender”}),
#”Filtered Rows” = Table.SelectRows(#”Expanded Value”, each ([gender] = “female”))
in
#”Filtered Rows”
This code retrieves the patient data from the FHIR API, converts it into a table format, expands the “gender” column, and filters the rows where the gender is female.
Conclusion
In conclusion, Power BI is a powerful tool for analyzing and visualizing healthcare data, and the FHIR standard is a popular data source in the healthcare industry. By using the Power Query M language code, we can easily connect to the FHIR REST API and transform the data into a format that is suitable for our analysis. With this knowledge, you can explore other FHIR resources and perform more complex data transformations using the M language code.