Creating Data
Data is created in FHIR by using the create operation, which is performed by sending a POST request to the server.
Medplum also provides the createResource method on the MedplumClient which implements the create operation. When creating a resource, you do not need to provide an id, as it will be assigned by the server.
Example: Creating a Practitioner
- Typescript
- CLI
- cURL
const practitioner: Practitioner = await medplum.createResource({
resourceType: 'Practitioner',
name: [{ family: 'Smith', given: ['Alice'], prefix: ['Dr.'] }],
});
medplum post Practitioner '{"resourceType":"Practitioner","name":[{"family":"Smith","given":["Alice"],"prefix":["Dr."]}]}'
curl -X POST 'https://api.medplum.com/fhir/R4/Practitioner' \
-H 'authorization: Bearer $ACCESS_TOKEN' \
-H 'content-type: application/fhir+json' \
-d {"resourceType":"Practitioner","name":[{"family":"Smith","given":["Alice"],"prefix":["Dr."]}]}