npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@iehr/core

v4.3.184

Published

iEHR TS/JS Library

Downloads

1,029

Readme

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 healthcare platform that helps you quickly develop high-quality compliant applications. iEHR includes a FHIR server, React component library, and developer app.

License

Apache 2.0.