open-index/open-npm huggingface dataset:
npm package: @medplum/agent
Description: Medplum Agent
Author: Medplum
Latest version: 5.1.7

# Medplum Agent

On-prem agent for device connectivity.

## Building

Published releases are built using Github Actions. See the [build-agent workflow](../../.github/workflows/build-agent.yml) for details.

The following tools are used to build the agent:

- [Node.js](https://nodejs.org/en/)
- [Node.js Single Executable Applications](https://nodejs.org/docs/latest/api/single-executable-applications.html) to build the `.exe` file
- [NSIS](https://nsis.sourceforge.io/) to build the installer
- [Shawl](https://github.com/mtkennerly/shawl) for the Microsoft Windows service wrapper
- [Azure Trusted Signing](https://azure.microsoft.com/en-us/products/trusted-signing) to sign the executable files

### Authentication and Signing

The build process uses [OpenID Connect (OIDC)](https://www.microsoft.com/security/business/security-101/what-is-openid-connect-oidc) to authenticate with Azure Trusted Signing. This provides secure, secret-free authentication using federated credentials.

#### Required GitHub Secrets

**For Azure OIDC Authentication:**
- `AZURE_TENANT_ID` - Azure Active Directory tenant ID
- `AZURE_CLIENT_ID` - Azure application client ID (from service principal with federated credentials)
- `AZURE_SUBSCRIPTION_ID` - Azure subscription ID

**For GPG Signing:**
- `MEDPLUM_RELEASE_GPG_KEY` - The private GPG key (imported before signing)
- `MEDPLUM_RELEASE_GPG_KEY_ID` - GPG key identifier
- `MEDPLUM_RELEASE_GPG_PASSPHRASE` - GPG key passphrase

#### Setup Instructions

To configure OIDC authentication for Azure Trusted Signing:

1. Create a Microsoft Entra application and service principal
2. Add federated credentials for GitHub Actions
3. Assign the **Trusted Signing Certificate Profile Signer** role to your service principal
4. Configure the required GitHub secrets

For detailed setup instructions, see [Authenticating with OpenID Connect](https://github.com/Azure/trusted-signing-action/blob/main/docs/OIDC.md).

#### References

- [Azure Trusted Signing Action](https://github.com/Azure/trusted-signing-action)
- [Azure Trusted Signing with OIDC](https://github.com/Azure/trusted-signing-action/blob/main/docs/OIDC.md)
- [Azure Trusted Signing Documentation](https://learn.microsoft.com/azure/trusted-signing/)
- [Shawl](https://github.com/mtkennerly/shawl)
- [NSIS](https://nsis.sourceforge.io/)

## Docker Image

Build and run the docker image

```bash
docker build -t medplum-agent:latest \
  --build-arg GIT_SHA=$(git log -1 --format=format:%H) \
  --build-arg MEDPLUM_VERSION=3.0.3 .
```

```bash
docker run --rm \
  -e MEDPLUM_BASE_URL="" \
  -e MEDPLUM_CLIENT_ID="" \
  -e MEDPLUM_CLIENT_SECRET="" \
  -e MEDPLUM_AGENT_ID="" \
  medplum-agent:latest
```

Optionally set the `MEDPLUM_LOG_LEVEL` environment variable

```bash
  -e MEDPLUM_LOG_LEVEL="DEBUG"
```
npm package: @medplum/app
Description: Medplum App
Author: Medplum
Latest version: 5.1.7

# Medplum App

This is the code for [https://app.medplum.com](https://app.medplum.com)

## Deployment

Medplum publishes the app package with placeholders for configuration settings. You can use the Medplum CLI to deploy the app, which will automatically replace the placeholders with your settings.

For example:

```bash
# Deploy the latest version of the app to your Medplum AWS environment named "staging"
medplum aws deploy-app staging
```

## Config Settings

When deploying from the Medplum CLI, config settings are loaded from the corresponding JSON config file.

When building and running the app from source, config settings are loaded from environment variables or the `.env` file.

| Name                       | Description                                                                                | Required |
| -------------------------- | ------------------------------------------------------------------------------------------ | -------- |
| `MEDPLUM_BASE_URL`         | The base URL of the API server for all API calls. For example, "https://api.medplum.com/". | yes      |
| `MEDPLUM_CLIENT_ID`        | Optional Medplum client application ID.                                                    | no       |
| `GOOGLE_CLIENT_ID`         | Optional Google client application ID for Google Auth.                                     | no       |
| `RECAPTCHA_SITE_KEY`       | Optional reCAPTCHA site key for reCAPTCHA user verification.                               | no       |
| `MEDPLUM_REGISTER_ENABLED` | Optional flag to enable or disable open registration for new projects.                     | no       |

## Developing

Dev server:

```bash
npm run dev
```

Production build:

```bash
npm run build
```

For more information, refer to the [Developer Instructions](https://www.medplum.com/docs/contributing/run-the-stack).
npm package: @medplum/bot-layer
Description: Medplum Bot Lambda Layer
Author: Medplum
Latest version: 5.1.7

# Medplum Bot Layer

Medplum bots can run in [AWS Lambdas](https://aws.amazon.com/lambda/). When running in lambdas, bots can use [AWS Lambda Layers](https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html) for pre-built dependencies and configuration.

This package defines the packages in the default AWS Lambda Layer.

Current packages:

- [`@medplum/core`](https://www.npmjs.com/package/@medplum/core)
- [`fast-xml-parser`](https://www.npmjs.com/package/fast-xml-parser)
- [`form-data`](https://www.npmjs.com/package/form-data)
- [`jose`](https://www.npmjs.com/package/jose)
- [`jszip`](https://www.npmjs.com/package/jszip)
- [`node-fetch`](https://www.npmjs.com/package/node-fetch)
- [`pdfmake`](https://www.npmjs.com/package/pdfmake)
- [`ssh2`](https://www.npmjs.com/package/ssh2)
- [`ssh2-sftp-client`](https://www.npmjs.com/package/ssh2-sftp-client)
- [`twilio`](https://www.npmjs.com/package/twilio)

## Usage

To use the Medplum Bot Layer in your own Bot packages, add `@medplum/bot-layer` as a dependency:

```bash
npm i @medplum/bot-layer
```

## Deployment

For more details on how to build and use, refer to `/scripts/deploy-bot-layer.sh`.

## References

- [Deploy Node.js Lambda functions with .zip file archives](https://docs.aws.amazon.com/lambda/latest/dg/nodejs-package.html)
- [Creating and sharing Lambda layers](https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html)
- [Using layers with your Lambda function](https://docs.aws.amazon.com/lambda/latest/dg/invocation-layers.html)
- [AWS CLI publish-layer-version](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lambda/publish-layer-version.html)
- [Lambda layers node_modules](https://stackoverflow.com/questions/53788753/lambda-layers-node-modules)
npm package: @medplum/cdk
Description: Medplum CDK Infra as Code
Author: Medplum
Latest version: 5.1.7

# Medplum Infra

CDK scripts to setup the full stack:

- S3 + CloudFront for static site
- VPC for private network
- Fargate for backend server
- Aurora RDS for database

![diagram](./medplum_stack.png)

### Install

Medplum uses [npm workspaces](https://docs.npmjs.com/cli/v8/using-npm/workspaces) for a monorepo configuration.

See [Developer Setup](https://www.medplum.com/docs/contributing) for cloning the repository and installing dependencies.

### Deploy

First, create a configuration file.

Next, it is strongly recommended to `diff` changes before deploying.

```bash
npx cdk diff -c config=my-config.json
```

```bash
npx cdk deploy -c config=my-config.json
```

### Destroy

```
npx cdk destroy
```

### Front End

Based on: https://github.com/aws-samples/aws-cdk-examples/tree/master/typescript/static-site

Creates:

- S3 Bucket
- CloudFront distribution
- SSL Certificate
- Route 53 Entries

### Back End

Based on: Based on: https://github.com/aws-samples/http-api-aws-fargate-cdk/blob/master/cdk/singleAccount/lib/fargate-vpclink-stack.ts

Creates:

- VPC
- Security Groups
- Fargate Task and Service
- CloudWatch Log Groups
- Load Balancer
- SSL Certificate
- Route 53 Entries

### Storage

Based on:

The CloudFront distribution requires a public key for signature verification.

Generate a 2048 bit RSA key:

```sh
openssl genrsa -des3 -out private.pem 2048
```

Export the public key to a file:

```sh
openssl rsa -in private.pem -outform PEM -pubout -out public.pem
```

Open the `public.pem` file and ensure that it starts with `-----BEGIN PUBLIC KEY-----`. This is how you know that this file is the public key of the pair and not a private key.

Add the public key to the CDK infrastructure configuration.

Add the private key to the server configuration settings (JSON, AWS Parameter Store, etc).
npm package: @medplum/cli
Description: Medplum Command Line Interface
Author: Medplum
Latest version: 5.1.7

# Medplum Command Line Interface

The Medplum CLI (Command Line Interface) is a set of command line tools to quickly deploy Medplum web applications and Medplum bots.

## Installation

Add globally:

```bash
npm install --global @medplum/cli
```

Or add as a package dependency:

```bash
npm install @medplum/cli
```

## Usage

See <https://www.medplum.com/docs/cli> for usage.

## About Medplum

Medplum is a healthcare platform that helps you quickly develop high-quality compliant applications. Medplum includes a FHIR server, React component library, and developer app.

## License

[Apache 2.0](../../LICENSE.txt)
npm package: @medplum/definitions
Description: Medplum Data Definitions
Author: Medplum
Latest version: 5.1.7

# Medplum Data Definitions

This package contains raw data definitions for a number of healthcare standards.

## Installation

Add as a dependency:

```bash
npm install @medplum/definitions
```

## About Medplum

Medplum is a healthcare platform that helps you quickly develop high-quality compliant applications. Medplum includes a FHIR server, React component library, and developer app.

## License

[Apache 2.0](../../LICENSE.txt)
npm package: @medplum/fhir-router
Description: Medplum FHIR Router
Author: Medplum
Latest version: 5.1.7

# Medplum FHIR Router

Provides a FHIR URL router. Standard CRUD operations map to a standard `FhirRepository` interface. FHIR operations registered separately.

## About Medplum

Medplum is a healthcare platform that helps you quickly develop high-quality compliant applications. Medplum includes a FHIR server, React component library, and developer app.

## License

[Apache 2.0](../../LICENSE.txt)
npm package: @medplum/fhirpath
Description: Medplum FHIRPath Library
Author: Medplum
Latest version: 0.9.6

# Medplum FHIRPath Library

The Medplum FHIRPath Library is a pure TypeScript library for evaluating [FHIRPath](https://hl7.org/fhirpath/) expressions.

## Installation

Add as a dependency:

```bash
npm install @medplum/fhirpath
```

## Basic Usage

```ts
import { Patient } from '@medplum/fhirtypes';
import { evalFhirPath } from '@medplum/fhirpath';

const patient: Patient = {
  resourceType: 'Patient',
  name: [
    {
      given: ['John'],
      family: 'Doe',
    },
  ],
  birthDate: '1980-01-01',
};

console.log(evalFhirPath('birthDate', patient));
```

## About Medplum

Medplum is a healthcare platform that helps you quickly develop high-quality compliant applications. Medplum includes a FHIR server, React component library, and developer app.

## License

Apache 2.0. Copyright &copy; Medplum 2022
npm package: @medplum/fhirtypes
Description: Medplum FHIR Type Definitions
Author: Medplum
Latest version: 5.1.7

# Medplum FHIR Type Definitions

This library contains [TypeScript](https://www.typescriptlang.org/) type definitions for all [R4 types](https://hl7.org/fhir/R4/valueset-resource-types.html).

## Installation

Add as a dependency:

```bash
npm install --save-dev @medplum/fhirtypes
```

## Basic Usage

Consider the following untyped code:

```ts
const myPatient = {
  resourceType: 'Patient',
  name: 'George Washington',
};
```

Keen observers will note that `Patient.name` should not be a string. Instead, it should be an array of `HumanName` objects.

Let's add the type definition and see what happens:

```ts
import { Patient } from '@medplum/fhirtypes';

const myPatient: Patient = {
  resourceType: 'Patient',
  name: 'George Washington',
};
```

Now "name" is a compile error. Developer tools with TypeScript support should provide feedback. For example, VS Code adds red squigglies and a helpful error message:

![Medplum fhirtypes screenshot](https://user-images.githubusercontent.com/749094/146444130-ac3a2c5d-3a9a-429d-8db3-5581986c05dc.png)

And now you will receive typeahead support:

![Medplum fhirtypes typeahead](https://user-images.githubusercontent.com/749094/146444465-974f6a3e-f655-4212-893b-fad14b1c4386.png)

So we can build a well-formed example:

```ts
import { Patient } from '@medplum/fhirtypes';

const myPatient: Patient = {
  resourceType: 'Patient',
  name: [
    {
      given: ['George'],
      family: 'Washington',
    },
  ],
};
```

## About Medplum

Medplum is a healthcare platform that helps you quickly develop high-quality compliant applications. Medplum includes a FHIR server, React component library, and developer app.

## License

[Apache 2.0](../../LICENSE.txt)
npm package: @medplum/health-gorilla
Description: Medplum Health Gorilla SDK
Author: Medplum
Latest version: 3.2.9

# Medplum Health Gorilla SDK

The Medplum Health Gorilla SDK provides helpers and utilities for working with the [Health Gorilla](https://www.healthgorilla.com/) FHIR API.

## About Medplum

Medplum is a healthcare platform that helps you quickly develop high-quality compliant applications. Medplum includes a FHIR server, React component library, and developer app.

## License

Apache 2.0. Copyright &copy; Medplum 2024
npm package: @medplum/hl7
Description: Medplum HL7 Utilities
Author: Medplum
Latest version: 5.1.7

# Medplum HL7

Server and client.

## Character Encoding

List of iconv-lite character encodings

See: https://github.com/ashtuchkin/iconv-lite/wiki/Supported-Encodings

## License

[Apache 2.0](../../LICENSE.txt)
npm package: @medplum/mock
Description: Medplum Mock Client
Author: Medplum
Latest version: 5.1.7

# Medplum Mock Library

Provides the `MockClient` class and a large number of mocked endpoints and resources.

For example:

- `GET fhir/R4/Patient/123` returns Homer Simpson
- `GET fhir/R4/Practitioner/123` returns Dr. Alice Smith
- `GET fhir/R4/Organization/123` returns Test Organization

## Installation

Add as a dependency:

```bash
npm install @medplum/mock
```

Note the following peer dependencies:

- [@medplum/core](https://www.npmjs.com/package/@medplum/core)
- [@medplum/fhir-router](https://www.npmjs.com/package/@medplum/fhir-router)
- If you want to use JSONPatch:
  - [rfc6902](https://www.npmjs.com/package/rfc6902)
- If you want to use GraphQL:
  - [graphql](https://www.npmjs.com/package/graphql)
  - [dataloader](https://www.npmjs.com/package/dataloader)

## Usage

Create a new mock client:

```ts
const client = new MockClient();
```

Read a `Patient` resource:

```ts
const patient = await client.readResource('Patient', '123');
```

`MockClient` is API compatible with `MedplumClient` in [@medplum/core](https://www.npmjs.com/package/@medplum/core). Please refer to `MedplumClient` for full documentation on client capabilities.

## About Medplum

Medplum is a healthcare platform that helps you quickly develop high-quality compliant applications. Medplum includes a FHIR server, React component library, and developer app.

## License

[Apache 2.0](../../LICENSE.txt)
npm package: @medplum/react
Description: Medplum React Component Library
Author: Medplum
Latest version: 5.1.7

# Medplum React Component Library

The Medplum React Component Library provides many helpful components to quickly build your healthcare web app.

The Medplum SDK can be used with any compliant FHIR server. However, some advanced features are only available when paired with a Medplum server.

Check out a live demo: <https://storybook.medplum.com/>

## Installation

Add as a dependency:

```
npm install @medplum/react
```

Note the following peer dependencies:

- [@medplum/core](https://www.npmjs.com/package/@medplum/core)
- [react](https://www.npmjs.com/package/react)
- [react-dom](https://www.npmjs.com/package/react-dom)

Note the following optional peer dependencies:

- [@emotion/react](https://www.npmjs.com/package/@emotion/react)
- [@mantine/core](https://www.npmjs.com/package/@mantine/core)
- [@mantine/hooks](https://www.npmjs.com/package/@mantine/hooks)
- [@mantine/notifications](https://www.npmjs.com/package/@mantine/notifications)

## Basic Usage

```tsx
import { MedplumClient } from '@medplum/core';
import { MedplumProvider } from '@medplum/react';

const medplum = new MedplumClient();

export function App() {
  return (
    <MedplumProvider medplum={medplum}>
      <MyPage1 />
      <MyPage2 />
      <Etc />
    </MedplumProvider>
  );
}
```

For more details on how to setup `MedplumClient`, refer to the docs for [`medplum`](https://www.npmjs.com/package/medplum).

## Sign In

```tsx
export function SignInPage() {
  const auth = useMedplumContext();
  return (
    <Document>
      {auth.user ? (
        <div>
          <pre>User: {JSON.stringify(auth.user)}</pre>
          <Button onClick={() => auth.medplum.signOut().then(() => alert('Signed out!'))}>Sign out</Button>
        </div>
      ) : (
        <SignInForm onSuccess={() => alert('Signed in!')} />
      )}
    </Document>
  );
}
```

## Chat

```tsx
export function ChatPage() {
  return (
    <Document>
      <ChatControl criteria="Communication?encounter=123" {...args} />
    </Document>
  );
}
```

## About Medplum

Medplum is a healthcare platform that helps you quickly develop high-quality compliant applications. Medplum includes a FHIR server, React component library, and developer app.

## License

[Apache 2.0](../../LICENSE.txt)
npm package: @medplum/ui
Description: Medplum React Component Library
Author: Medplum
Latest version: 0.9.6

# Medplum React Component Library

The Medplum React Component Library provides many helpful components to quickly build your healthcare web app.

The Medplum SDK can be used with any compliant FHIR server. However, some advanced features are only available when paired with a Medplum server.

Check out a live demo: [https://docs.medplum.com/storybook/index.html](https://docs.medplum.com/storybook/index.html)

## Key Features

- SmartText - Detect clinical concepts, tag with SNOMED and ICD codes
- Chat - FHIR-based chat with real time push events
- Data Table - For a FHIR search, show the results as a live table
- SSE for server side push
- Evaluation of [FhirPath](https://hl7.org/fhirpath/N1/index.html)
- No external dependencies

## Installation

Add as a dependency:

```
npm install @medplum/ui
```

Note the following peer dependencies:
- [@medplum/core](https://www.npmjs.com/package/@medplum/core)
- [@medplum/fhirpath](https://www.npmjs.com/package/@medplum/fhirpath)
- [react](https://www.npmjs.com/package/react)
- [react-dom](https://www.npmjs.com/package/react-dom)
- [react-router-dom](https://www.npmjs.com/package/react-router-dom)

## Basic Usage

```tsx
import { MedplumClient } from '@medplum/core';
import { MedplumProvider } from '@medplum/ui';

const medplum = new MedplumClient();

export function App() {
  return (
    <MedplumProvider medplum={medplum}>
      <MyPage1 />
      <MyPage2 />
      <Etc />
    </MedplumProvider>
  );
}
```

For more details on how to setup `MedplumClient`, refer to the docs for [`medplum`](https://www.npmjs.com/package/medplum).

## Sign In

```tsx
export function SignInPage() {
  const auth = useMedplumContext();
  return (
    <Document>
      {auth.user ? (
        <div>
          <pre>User: {JSON.stringify(auth.user)}</pre>
          <Button onClick={() => auth.medplum.signOut().then(() => alert('Signed out!'))}>Sign out</Button>
        </div>
      ) : (
        <SignInForm onSuccess={() => alert('Signed in!')} />
      )}
    </Document>
  );
}
```

## Chat

```tsx
export function ChatPage() {
  return (
    <Document>
      <ChatControl criteria="Communication?encounter=123" {...args} />
    </Document>
  );
}
```

## About Medplum

Medplum is a healthcare platform that helps you quickly develop high-quality compliant applications. Medplum includes a FHIR server, React component library, and developer app.

## License

Apache 2.0. Copyright &copy; Medplum 2022