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

</aside>

The create uses HTTP POST call to the URL base URL/resource type . The POST call should have a content-type which should indicate the file type of the payload. Common content-type are fhir+xml and fhir+json

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

Request Details

Method:

POST

Address:

<http://172.104.170.172:8080/fhir/Patient/>

Headers:

Content-type: application/fhir+json

Request (JSON):

{
  "resourceType": "Patient",
  "identifier": [ { "system": "Philhealth ID", "value": "12345" } ],
  "name": [ {
      "family": "dela Cruses",
      "given": [ "Jose", "Juan" ]
  } ],
  "gender": "male",
  "birthDate": "2020-01-01"
}

Response

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

</aside>

Output:

TCP_NODELAY set
* Connected to 172.104.170.172 (172.104.170.172) port 8080 (#0)
> POST /sila-fhirserver/fhir/Patient/ HTTP/1.1
> Host: 172.104.170.172:8080
> User-Agent: curl/7.55.1
> Accept: */*
> Content-Type:application/fhir+json
> Content-Length: 224
>
* upload completely sent off: 224 out of 224 bytes
< HTTP/1.1 201 Created
< Date: Fri, 08 May 2020 14:56:32 GMT
< X-Powered-By: HAPI FHIR 3.7.0 REST Server (FHIR Server; FHIR 3.0.1/DSTU3)
< ETag: W/"1"
< Content-Location: <http://172.104.170.172:8080/sila-fhirserver/fhir/Patient/15152/_history/1>
< Last-Modified: Fri, 08 May 2020 14:56:32 GMT
< Location: <http://172.104.170.172:8080/sila-fhirserver/fhir/Patient/15152/_history/1>
< Content-Type: application/fhir+json;charset=utf-8
< Transfer-Encoding: chunked
< Server: Jetty(9.4.8.v20180619)
<
{
  "resourceType": "Patient",
  "id": "15152",
  "meta": {
    "versionId": "1",
    "lastUpdated": "2020-05-08T14:56:32.092+00:00"
  },
  "text": {
    "status": "generated",
    "div": "<div xmlns=\\"<http://www.w3.org/1999/xhtml\\>"><div class=\\"hapiHeaderText\\">Jose Juan <b>DELA CRUZ </b></div><table class=\\"hapiPropertyTable\\"><tbody><tr><td>Identifier</td><td>12345</td></tr><tr><td>Date of birth</td><td><span>01 January 2020</span></td></tr></tbody></table></div>"
  },
  "identifier": [
    {
      "system": "Philhealth ID",
      "value": "12345"
    }
  ],
  "name": [
    {
      "family": "dela Cruz",
      "given": [
        "Jose",
        "Juan"
      ]
    }
  ],
  "gender": "male",
  "birthDate": "2020-01-01"
}* Connection #0 to host 172.104.170.172 left intact