## MedplumClient class 
The MedplumClient class provides a client for the Medplum FHIR server.

The client can be used in the browser, in a Node.js application, or in a Medplum Bot.

The client provides helpful methods for common operations such as: 
1. Authenticating  
2. Creating resources  
3. Reading resources  
4. Updating resources  
5. Deleting resources  
6. Searching  
7. Making GraphQL queries

The client can also be used to integrate with other FHIR servers. For an example, see the [Epic Connection Demo Bot](https://github.com/medplum/medplum/tree/main/examples/medplum-demo-bots/src/epic).

**Signature:**

```typescript
export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMap>
```

**Extends:** [TypedEventTarget](/content/docs/sdk/core.typedeventtarget) < [MedplumClientEventMap](/content/docs/sdk/core.medplumclienteventmap) >

## Example 1 
Here is a quick example of how to use the client:

```typescript
import { MedplumClient } from '@medplum/core';

const medplum = new MedplumClient();
```

## Example 2 
Create a `Patient`:

```typescript
const patient = await medplum.createResource({

resourceType: 'Patient',

name: [{

given: ['Alice'],

family: 'Smith'

}]

});
```

## Example 3 
Read a `Patient` by ID:

```typescript
const patient = await medplum.readResource('Patient', '123');

console.log(patient.name[0].given[0]);
```

## Example 4 
Search for a `Patient` by name:

```typescript
const bundle = await medplum.search('Patient', 'name=Alice');

console.log(bundle.total);
```

## Constructors

| Constructor | Modifiers | Description |
| --- | --- | --- |
| [(constructor)(options)](/content/docs/sdk/core.medplumclient._constructor_/index.html) |  | Constructs a new instance of the `MedplumClient` class |

## Properties

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [isInitialized](/content/docs/sdk/core.medplumclient.isinitialized) | `readonly` | boolean |  |
| [keyValue](/content/docs/sdk/core.medplumclient.keyvalue) | `readonly` | [MedplumKeyValueClient](/content/docs/sdk/core.medplumkeyvalueclient) | Returns the key value client. |
| [requestCache](/content/docs/sdk/core.medplumclient.requestcache) | `protected`<br>`readonly` | [LRUCache](/content/docs/sdk/core.lrucache) < [RequestCacheEntry](/content/docs/sdk/core.requestcacheentry) \\| undefined |  |

## Methods

| Method | Modifiers | Description |
| --- | --- | --- |
| [bulkExport(exportLevel, resourceTypes, since, options)](/content/docs/sdk/core.medplumclient.bulkexport) |  | Performs Bulk Data Export operation request flow. |
| [callCdsService(id, body, options)](/content/docs/sdk/core.medplumclient.callcdsservice) |  | Calls a CDS service by ID. |
| [clear()](/content/docs/sdk/core.medplumclient.clear) |  | Clears all auth state including local storage and session storage. |
| [clearActiveLogin()](/content/docs/sdk/core.medplumclient.clearactivelogin) |  | Clears the active login from local storage. Does not clear all local storage (such as other logins). |
| [createAttachment(createBinaryOptions, requestOptions)](/content/docs/sdk/core.medplumclient.createattachment) |  | Creates a FHIR `Attachment` with the provided data content. |
| [createResource(resource, options)](/content/docs/sdk/core.medplumclient.createresource) |  | Creates a new FHIR resource. |
| [deleteResource(resourceType, id, options)](/content/docs/sdk/core.medplumclient.deleteresource) |  | Deletes a FHIR resource by resource type and ID. |
| [search(resourceType, query, options)](/content/docs/sdk/core.medplumclient.search) |  | Sends a FHIR search request. |
| [updateResource(resource, options)](/content/docs/sdk/core.medplumclient.updateresource) |  | Updates a FHIR resource. |
| [graphql(query, operationName, variables, options)](/content/docs/sdk/core.medplumclient.graphql) |  | Executes a GraphQL query. |
