Reading Data

In this tutorial we will cover some of the ways to access data in the Commure Platform.

React Data Access

To access data from a React application, the simplest solution is to use the Commure <FhirDataQuery/> React component, or the associated <withFhirDataQuery/> higher-order component.

1import React from "react";
2import { FhirDataQuery } from "@commure/components-data";
3import { Practitioner, Bundle } from "@commure/fhir-types/r4/types";
5const PractitionerCount = () => (
6 <FhirDataQuery queryString="Practitioner">
7 {({ loading, error, data }) => {
8 if (loading) {
9 return "Loading...";
10 }
11 if (error) {
12 return "Error loading data!";
13 }
14 const practitioners: Practitioner[] = (data as Bundle).entry!.map(
15 (value) => value.resource as Practitioner
16 );
17 return `Found ${practitioners.length} Practitioners!`;
18 }}
19 </FhirDataQuery>

In order for the <FhirDataQuery/> component to work correctly, it must have the <CommureSmartApp/> component as an ancestor in the component tree.

Related Reading

Getting Started

Non-React Data Access

It is also possible to access data in the Commure Platform without using React. The Commure FHIR API can be queried directly using the programming language of your choice, the curl command, or a REST client like Postman.

For example, the same data retrieved in the React example above can be accessed using the following curl command:

1curl '' \
2 -H 'Authorization: Bearer ACCESS_TOKEN'

You'll need to replace TENANT_ID with your actual Commure tenant ID, which you find in the top right menu in the console. The ACCESS_TOKEN should be replaced with the value obtained after authentication.