Skip to main content

Create Resource

The FHIR create operation allows you to create a new resource of a specified type on the FHIR server. This is done using an HTTP POST request to the endpoint corresponding to the resource type.

Create a Patient resource using the Haste Health CLI:

haste-health api create --file patient.json

Where patient.json contains:

{
"resourceType": "Patient",
"name": [
{
"use": "official",
"family": "Doe",
"given": ["John"]
}
],
"gender": "male",
"birthDate": "1980-01-01"
}

Or pass the data inline:

echo '{
"resourceType": "Patient",
"name": [{"use": "official", "family": "Doe", "given": ["John"]}],
"gender": "male",
"birthDate": "1980-01-01"
}' | haste-health api create r4 --data -

Replace [tenant] with your tenant name and [project] with your project ID.

Error Handling

If there are any issues with the request (e.g., missing required fields, invalid data), the server will respond with an appropriate error status code (e.g., 400 Bad Request) and include an OperationOutcome resource in the response body detailing the errors.

HTTP/1.1 400 Bad Request Content-Type: application/fhir+json

{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "error",
"code": "invalid",
"diagnostics": "Missing required field: name"
}
]
}