Getting Resources

An understanding of how to use the SMART Client is required before reading this section.

Practitioner, Patient, and Encounter

Once you’ve successfully authenticated and created a SMART Client post-smartlaunch, you are now able to easily retrieve some basic information with our pre-built functions. See the following example using React:

import { useState } from "react";
import * as R4 from "fhir/r4";
import { BaseClient} from "@topologyhealth/smarterfhir";

const [user, setUser] = useState<R4.Practitioner | undefined>(undefined);
const [patient, setPatient] = useState<R4.Patient | undefined>(undefined);
const [encounter, setEncounter] = useState<R4.Encounter | undefined>(undefined)

async function handleEMRClientCreateSuccess(myClient: BaseClient) {
    setUser(await myClient.getPractitionerRead())
    setPatient(await myClient.getPatientRead())
    setEncounter(await myClient.getEncounterRead())

These getRead() functions return a corresponding result in FHIR R4 format, typed using the FHIR R4 Typescript Library which faithfully reflects a mapping of the HL7 specifications into a well-defined typescript interface.


Here are some barebones examples of what some of these objects could look like:

const somePractitioner: R4.Practitioner = {
    resourceType: 'Practitioner',
    name: [
            use: 'usual',
            given: ['Roger'],
            family: 'Pepper',
            prefix: ['Dr.']

const somePatient: R4.Patient = {
    resourceType: 'Patient',
    name: [
            use: 'usual',
            given: ['Demo'],
            family: 'Patient',
            prefix: ['Mr.']

const encounter: R4.Encounter = {
    resourceType: 'Encounter',
    period: {
        start: '2011-10-05T14:48:00.000Z',
        end: '2011-10-05T15:15:00.000Z'
    class: {},
    status: 'arrived'


See the Github Repo for R4 types for more information about the structure of each of these Resource types