<aside> 💡 In this page we will learn how to delete resource in a FHIR server.

</aside>

The create uses HTTP DELETE call to the URL base URL/resource typ/id where id is the ID of an existing resource on the FHIR server that we want to delete. This operation is a logical delete, which means that the resource is marked as deleted, and will no longer appear in search. Furthermore, the previous versions of the resource are not really deleted. In fact, a delete operation is saved as an update or new version of the resource where it is now tagged as deleted. Finally, the resource that was deleted can be un-delete by updating the resource again.

For the example, we will be deleting the resource of the Patient with ID 15152 that was created in the create example and was updated in the update example.

The following shows how to perform the read operation using CURL:

Request

Method:

DELETE

Address:

<http://172.104.170.172:8080/sila-fhirserver/fhir/Patient/15152>

Response

<aside> 💡 This should be the expected return value when the DELETE call is made

</aside>

Output:

* TCP_NODELAY set
* Connected to 172.104.170.172 (172.104.170.172) port 8080 (#0)
> DELETE /sila-fhirserver/fhir/Patient/15152 HTTP/1.1
> Host: 172.104.170.172:8080
> User-Agent: curl/7.64.1
> Accept: */*
> 
< HTTP/1.1 200 OK
< Date: Tue, 12 May 2020 07:55:20 GMT
< X-Powered-By: HAPI FHIR 3.7.0 REST Server (FHIR Server; FHIR 3.0.1/DSTU3)
< ETag: W/"3"
< Content-Location: <http://172.104.170.172:8080/sila-fhirserver/fhir/Patient/15152/_history/3>
< Last-Modified: Tue, 12 May 2020 07:29:12 GMT
< Content-Type: application/fhir+json;charset=utf-8
< Transfer-Encoding: chunked
< Server: Jetty(9.4.8.v20180619)
< 
{
  "resourceType": "OperationOutcome",
  "text": {
    "status": "generated",
    "div": "<div xmlns=\\"<http://www.w3.org/1999/xhtml\\>"><h1>Operation Outcome</h1><table border=\\"0\\"><tr><td style=\\"font-weight: bold;\\">INFORMATION</td><td>[]</td><td><pre>Successfully deleted 1 resource(s) in 46ms</pre></td>\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\n\\t\\t\\t</tr>\\n\\t\\t</table>\\n\\t</div>"
  },
  "issue": [
    {
      "severity": "information",
      "code": "informational",
      "diagnostics": "Successfully deleted 1 resource(s) in 46ms"
    }
  ]
* Connection #0 to host 172.104.170.172 left intact
}* Closing connection 0

Command using CURL:

curl -v -X DELETE [<http://172.104.170.172:8080/sila-fhirserver/fhir/Patient/15152>](<http://172.104.170.172:8080/sila-fhirserver/fhir/Patient/15152>)