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.

import React from "react";
import { FhirDataQuery } from "@commure/components-data";
const Practitioner = () => (
<FhirDataQuery queryString="Practitioner">
{(bundle, error, loading) => {
if (loading) {
return "Loading...";
}
if (error) {
return "Error loading data!";
}
const practitioners: Practitioner[] = (bundle as Bundle).entry!.map(
value => value.resource as Practitioner
);
return `Found ${practitioners.length} Practitioners!`;
}}
</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

Build A New Application

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:

curl 'https://api-TENANT_ID.staging.developer.commure.com/api/v1/r4/Practitioner' \
-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.