Get Resource

Pre-Built Gets

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:

Example: Retrieve basic information

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.


Examples

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

Resource Type: Practitioner

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

Resource Type: Patient

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

Resource Type: Encounter

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

References

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