Read Data
Introduction
Components for fetching FHIR data from the Commure FHIR API.
Both of the below components provide functionality to get data, but they support different styles of writing components.
Included Components
FhirDataQuery
: Component for reading FHIR datawithFhirDataQuery
: Higher-Order Component for getting an authenticated query function
Usage
For both of these components, be sure to wrap them in <CommureSmartApp/>
.
FhirDataQuery
Requires a queryString
as a prop
and one child that, given data on the query, returns a ReactNode
.
This component handles the logic around managing state for the query
and passes that state directly to the function you supply as a child.
When you need more direct control over how the flow around the query works,
prefer withFhirDataQuery
.
withFhirDataQuery
This component provides an asynchronous query
function as a prop to search for data.
This query
function takes in a string
to query for and an optional
object for more control over the query.
The typical way to use this component is to write a function that takes in this
query
function and uses it to render some data.
This component shines when you need direct control over the query that you issue.
If you just care about a simple query string and the data or errors you get back,
prefer FhirDataQuery
.
Troubleshooting
If you run into an error saying:
make sure that you have wrapped these components in a <CommureSmartApp/>
.
API Reference
FhirDataQuery
Prop Name | Required? | Type | Description |
---|---|---|---|
children | true | (state: State) => ReactNode | Function that will be rendered as children in the function-as-a-child pattern. |
queryString | true | string | Query string for Commure backend GET request |
renderWhileLoading | false | boolean | Render children while data is loading |
useCache | false | boolean | Whether to cache the result of this request. If enabled, result to the request will be cached until the window is closed. Subsequent requests won't make a network request. Useful for fetching data that is not expected to change, such as StructureDefinitions or SearchParameters. |