Write Data


Component for mutating FHIR data using the Commure FHIR API. This is a Higher-Order Component that passes a mutate function as a prop to the component you supply it.


Make sure to wrap your app in <CommureSmartApp /> to get access to the data.


Use this when you want to POST, PUT, or PATCH a resource.

import React, { useState, useEffect } from "react";
import { FhirMethod, withFhirDataMutate, FhirDataMutateConsumer } from "@commure/components-data";
import { Resource, Bundle } from "@commure/fhir-types/r4/types";
interface AnyResource extends Resource {
[key: string]: any;
const MyComponent = (props: FhirDataMutateConsumer) => {
const { mutate } = props;
const [outcome, setBundle] = useState<Bundle | undefined>(undefined);
useEffect(() => {
query: "Patient",
body: {
resourceType: "Patient",
name: [{ given: ["joe"] }],
gender: "female"
} as AnyResource,
method: FhirMethod.POST
.then((response: Response) => response.clone().json())
.then(data => setBundle(data));
}, [mutate]);
return <div>Outcome: {JSON.stringify(outcome)}</div>;
export default withFhirDataMutate(MyComponent);


If you run into an error saying:

No FhirClientProvider found in component tree

make sure that you have wrapped this component (or your app) in a <CommureSmartApp />.

Note that we only support JSON patches right now, though the FHIR Spec supports XML and FHIRPath patches.

Related Reading

Commure FHIR API
Read data