History Resource Instance
The FHIR history operation allows you to retrieve the change history for a specific resource instance. This is done using an HTTP GET request to the history endpoint for the resource.
- CLI
- TypeScript Client
- cURL
Retrieve the history of a Patient resource using the Haste Health CLI:
haste-health api history-instance Patient 12345 "_count=10"
This command retrieves the last 10 versions of the Patient resource with ID 12345.
You can also retrieve history without parameters:
haste-health api history-instance Patient 12345
Retrieve the history of a Patient resource using the TypeScript client:
import { AsynchronousClient } from '@haste-health/client';
import { R4 } from '@haste-health/fhir-types/versions';
// Assuming you have a configured client
const client: AsynchronousClient<{}> = /* ... */;
const history = await client.history_instance(
{},
R4,
'Patient',
'12345',
'_count=10'
);
console.log('Total versions:', history.total);
console.log('History entries:', history.entry);
Retrieve the history of a Patient resource using cURL:
curl -X GET "https://api.haste.health/w/[tenant]/[project]/api/v1/fhir/r4/Patient/12345/_history?_count=10" \
-H "Content-Type: application/fhir+json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Replace [tenant] with your tenant name and [project] with your project ID.
Error Handling
If the resource is not found, the server will respond with a 404 Not Found status code and include an OperationOutcome resource in the response body.
HTTP/1.1 404 Not Found
Content-Type: application/fhir+json
{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "error",
"code": "not-found",
"diagnostics": "Resource Patient/12345 not found"
}
]
}