Skip to main content

core.medplumclient.createresource

Home > @medplum/core > MedplumClient > createResource

MedplumClient.createResource() method

Creates a new FHIR resource.

The return value is the newly created resource, including the ID and meta.

Signature:

createResource<T extends Resource>(resource: T, options?: RequestInit): Promise<T>;

Parameters

ParameterTypeDescription
resourceTThe FHIR resource to create.
optionsRequestInit(Optional) Optional fetch options.

Returns:

Promise<T>

The result of the create operation.

Example

Example:

const result = await medplum.createResource({
resourceType: 'Patient',
name: [{
family: 'Smith',
given: ['John']
}]
});
console.log(result.id);

See the FHIR "create" operation for full details: https://www.hl7.org/fhir/http.html\#create