core.medplumclient.createresource | Medplum
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?: MedplumRequestOptions): Promise<WithId<T>>;
Parameters [](/content/docs/sdk/core.medplumclient.createresource#parameters "Direct link to Parameters"/index.html)
| Parameter | Type | Description |
|---|---|---|
| resource | T | The FHIR resource to create. |
| options | MedplumRequestOptions | (Optional) Optional fetch options. |
Returns:
Promise< WithId
The result of the create operation.
Example [](/content/docs/sdk/core.medplumclient.createresource#example "Direct link to Example"/index.html)
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.