5.1.7 • Published 5 months ago

@iehr/core v5.1.7

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
5 months ago

iEHR JS Client Library

The iEHR JS Client Library is a pure TypeScript library for calling a FHIR server from the browser.

Key Features

  • FHIR validation and operations
  • FHIR client to create, read, update, delete, patch, and search
  • WebSockets for realtime communication
  • Evaluation of FhirPath
  • No external dependencies

Installation

Add as a dependency:

npm install @iehr/core

Basic Usage

Create a new IEHRClient:

import { IEHRClient } from '@iehr/core';

const iehr = new IEHRClient();

Create a IEHRClient with additional configuration options:

import { IEHRClient } from '@iehr/core';

const iehr = new IEHRClient({
  baseUrl: 'https://www.example.com/fhir/R4/ai/iehr/',
  clientId: 'MY_CLIENT_ID',
});

Authenticate with client credentials

const iehr = new IEHRClient();
await iehr.startClientLogin(MY_CLIENT_ID, MY_CLIENT_SECRET);

Authenticating with iEHR

If you are using iEHR as your FHIR server, you can use a direct sign-in API to authenticate email and password.

Before you begin

  1. Create a project in the iEHR App
  2. Enable Email/Password

After that, you can use the startLogin() method:

const loginResult = await iehr.startLogin({ email, password, remember });
const profile = await iehr.processCode(loginResult.code);
console.log(profile);

Authenticating with OAuth

Authenticate with a FHIR server via OAuth2 redirect:

iehr.signInWithRedirect().then((user) => console.log(user));

Search

Search for any resource using a FHIR search string:

search<K extends ResourceType>(
  resourceType: K,
  query?: URLSearchParams | string,
  options: RequestInit = {}
): ReadablePromise<Bundle<ExtractResource<K>>>

Example:

const bundle = await iehr.search('Patient', 'given=eve');
bundle.entry.forEach((entry) => console.log(entry.resource));

Create

Create resource:

createResource<T extends Resource>(resource: T): Promise<T>

Example:

iehr.createResource({
  resourceType: 'Observation',
  subject: {
    reference: 'Patient/123',
  },
  valueQuantity: {
    // ...
  },
  // ...
});

Read a resource

Read a resource by ID:

readResource<T extends Resource>(resourceType: string, id: string): Promise<T>

Example:

const patient = await iehr.readResource('Patient', '123');

Read resource history

Read resource history:

readHistory<T extends Resource>(resourceType: string, id: string): Promise<Bundle<T>>

Example:

const historyBundle = await iehr.readHistory('Patient', '123');

Read resource version

Read a specific version:

readVersion<T extends Resource>(resourceType: string, id: string, vid: string): Promise<T>

Example:

const version = await iehr.readVersion('Patient', '123', '456');

Update a resource

Update a resource:

updateResource<T extends Resource>(resource: T): Promise<T>

Example:

const result = await iehr.updateResource({
  resourceType: 'Patient',
  id: '123',
  name: [
    {
      family: 'Smith',
      given: ['John'],
    },
  ],
});
console.log(result.meta.versionId);

Delete a resource

Delete a resource:

deleteResource(resourceType: string, id: string): Promise<any>

Example:

await iehr.deleteResource('Patient', '123');

Patch a resource

Patch a resource:

patchResource<T extends Resource>(resourceType: string, id: string, operations: Operation[]): Promise<T>

Example:

const result = await iehr.patchResource('Patient', '123', [
  { op: 'replace', path: '/name/0/family', value: 'Smith' },
]);
console.log(result.meta.versionId);

GraphQL

Execute a GraphQL query:

graphql(query: string, options?: RequestInit): Promise<any>

Example:

const result = await graphql(`
  {
    PatientList(name: "Alice") {
      name {
        given
        family
      }
    }
  }
`);

About iEHR

iEHR is a FHIR®-native, AI-infused, API-first, interoperable EHR. iEHR makes it easy to build healthcare apps quickly with less code.

License

Apache 2.0.

Copyright © Medplum 2025 (HL7® FHIR® US)

Copyright © iEHR.ai 2025 (HL7® FHIR® International, AI & Data platform)

5.1.5

6 months ago

5.1.4

6 months ago

5.1.3

6 months ago

5.1.2

6 months ago

5.1.1

6 months ago

5.1.0

6 months ago

4.3.179

12 months ago

4.3.184

11 months ago

4.3.185

11 months ago

4.3.186

11 months ago

4.3.187

11 months ago

4.3.188

11 months ago

4.3.189

11 months ago

4.3.180

12 months ago

4.3.181

11 months ago

4.3.182

11 months ago

4.3.183

11 months ago

4.4.0

8 months ago

4.3.195

10 months ago

5.0.5

7 months ago

4.3.196

10 months ago

5.0.4

7 months ago

4.3.197

10 months ago

5.0.3

8 months ago

4.3.198

9 months ago

5.0.2

8 months ago

4.3.199

9 months ago

5.0.1

8 months ago

5.0.0

8 months ago

4.3.190

11 months ago

4.3.191

10 months ago

4.3.192

10 months ago

4.3.193

10 months ago

4.3.194

10 months ago

4.3.200

9 months ago

4.3.201

9 months ago

4.3.202

8 months ago

5.1.7

5 months ago

5.1.6

5 months ago

4.3.176

12 months ago

4.3.177

12 months ago

4.3.178

12 months ago

4.3.175

1 year ago

4.3.174

1 year ago

4.3.151

1 year ago

4.3.170

1 year ago

4.3.150

1 year ago

4.3.160

1 year ago

4.3.141

1 year ago

4.3.110

1 year ago

4.3.91

1 year ago

4.3.90

1 year ago

4.3.140

1 year ago

4.3.120

1 year ago

4.3.82

1 year ago

4.3.81

1 year ago

4.3.80

1 year ago

4.3.84

1 year ago

4.3.83

1 year ago

3.2.2

1 year ago

3.2.1

1 year ago

3.1.11

1 year ago

3.2.0

1 year ago

4.3.60

1 year ago

4.3.70

1 year ago

3.1.10

1 year ago

4.3.63

1 year ago

4.3.52

1 year ago

4.3.62

1 year ago

4.3.51

1 year ago

4.3.40

1 year ago

4.3.61

1 year ago

4.3.50

1 year ago

3.1.3

1 year ago

3.1.1

2 years ago

3.0.8

2 years ago

3.0.7

2 years ago

3.0.4

2 years ago