Delete Data
You can delete any of your FHIR® resources or versions from the 1up FHIR Server _history
endpoint.
Delete a Single Resource
To delete a single resource, use the following command. It will delete only an individual resource. Past version histories will remain to help apps ensure HIPAA compliance and proper backups. After a resource is deleted, a GET request to the same endpoint will indicate it is no longer available with a 410 GONE status code, according to the FHIR specification.
curl -XDELETE 'https://api.1up.health/dstu2/Patient/{patientId}' \
-H 'Authorization: Bearer access_token'
Delete the Version History for a Resource
Deleting version history is a capability outside the FHIR specification, but is provided for customers to allow for their specific requirements. Once a resource AND its history are deleted, the information is not recoverable. Deleting a resource's version history will permanently delete the resource's version history. When the resource's version history is deleted AND the resource is deleted, then reading the resource explicitly by its id will return a 404 NOT FOUND status code as though the resource had never existed
To delete a FHIR resource's version history use the following command. Each individual version history item must be deleted explicitly using this command.
curl -XDELETE 'https://api.1up.health/dstu2/Patient/{patientId}/_history/{versionId}' \
-H 'Authorization: Bearer access_token'
After a resource has been deleted it will no longer be returned in search requests. For an explicit read request of the deleted resource by it's id, an OperationOutcome will be returned with status code 410, indicating that the resource has been deleted. The previous state of the resource will still be available through a versioned read of its history
Examples — Create & Delete a Resource
The following examples show how to create a patient resource, show the resource you created, and delete the same patient resource and resources history.
curl -XPOST 'https://api.1up.health/dstu2/Patient' \
-H 'Authorization: Bearer access_token' \
-H 'Content-Type: application/json' \
-d '{"resourceType": "Patient"}'
{
"resourceType":"Bundle",
"type":"searchset",
"total":1,
"entry":[{
"fullUrl":"https://api.1up.health/dstu2/Patient/7hocu3823ze1",
"search":{
"mode":"match"
},
"resource":{
"resourceType":"Patient",
"meta":{
"lastUpdated":"2019-09-19T17:28:37.449Z",
"versionId":"9000000000000"
},
"id":"7hocu3823ze1”
}
}]
}
curl -X DELETE 'https://api.1up.health/dstu2/Patient/7hocu3823ze1' \
-H 'Authorization: Bearer access_token'
{
"resourceType":"Bundle",
"type":"searchset",
"total":1,
"entry":[{
"fullUrl":"https://api.1up.health/dstu2/Patient/hwpvwsp7gsl",
"search":{
"mode":"match"
},
"resource":{
"resourceType":"OperationOutcome",
"id":"hwpvwsp7gsl",
"issue":[{
"severity":"information",
"code":"value",
"details":{
"text":"this resource with id 7hocu3823ze1 and version 9000000000001 has been deleted"
}
}]
}
}]
}
curl -X GET https://api.1up.health/dstu2/Patient/7hocu3823ze1/_history \
-H 'Authorization: Bearer access_token'
{
"resourceType":"Bundle",
"type":"searchset",
"total":2,
"entry":[{
"fullUrl":"https://api.1up.health/dstu2/Patient/7hocu3823ze1",
"search":{
"mode":"match"
},
"resource":{
"resourceType":"Patient",
"meta":{
"lastUpdated":"2019-09-19T17:28:37.449Z",
"versionId":"9000000000000"},
"id":"7hocu3823ze1"
}
},{
"fullUrl":"https://api.1up.health/dstu2/Patient/g6ek4r0tpsj",
"search":{
"mode":"match"
},
"resource":{
"resourceType":"OperationOutcome",
"id":"g6ek4r0tpsj",
"issue":[{
"severity":"information",
"code":"value",
"details":{
"text":"this resource with id 7hocu3823ze1 and version 9000000000001 has been deleted"
}
}]
}
}]
}
curl -X DELETE 'https://api.1up.health/dstu2/Patient/7hocu3823ze1/_history/9000000000000' \
-H 'Authorization: Bearer access_token'
curl -X GET https://api.1up.health/dstu2/Patient/7hocu3823ze1/_history \
-H 'Authorization: Bearer access_token'
{
"resourceType":"Bundle",
"type":"searchset",
"total":2,
"entry":[{
"fullUrl":"https://api.1up.health/dstu2/Patient/gmdu2j0571m",
"search":{
"mode":"match"
},
"resource":{
"resourceType":"OperationOutcome",
"id":"gmdu2j0571m",
"issue":[{
"severity":"information",
"code":"value",
"details":{
"text":"this resource with id 7hocu3823ze1 and version 9000000000000 has been deleted"
}
}]
}
},{
"fullUrl":"https://api.1up.health/dstu2/Patient/ie8df27mz3",
"search":{
"mode":"match"
},
"resource":{
"resourceType":"OperationOutcome",
"id":"ie8df27mz3",
"issue":[{
"severity":"information",
"code":"value",
"details":{
"text":"this resource with id 7hocu3823ze1 and version 9000000000001 has been deleted"
}
}]
}
}]
}