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?: MedplumRequestOptions): Promise<T>;
Parameters
Parameter | Type | Description |
---|---|---|
resource | T | The FHIR resource to create. |
options | (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