The FHIR RESTful API is described as a set of operations, including: Search, Create, Read/VRead, Delete, Update. The following categories of operations would be demonstrated with some examples.
After the base URL of https://evalfhir.directmdemail.com/fhir/baseDstu3/
, resource type can be appended as parameter to specify the type of
resource needing to be operated on. https://evalfhir.directmdemail.com/fhir/baseDstu3/Patient
, for example, indicating the resource being operated on
is a Patient
resource.
HL7 Consolidated CDA (Clinical Document Architecture), abbreviated as CCDA, is a type of template standard for electronic clinical documents. This RESTful API supports several requests to acquire the CCDA document related with a patient.
Get all data in CCDA:
GET https://evalfhir.directmdemail.com/fhir/baseDstu3/CCDA/{patientId}
Get all data of a specific date in CCDA:
GET https://evalfhir.directmdemail.com/fhir/baseDstu3/CCDA/{patientId}?date=yyyy-mm-dd
Get all data in a date range in CCDA:
GET https://evalfhir.directmdemail.com/fhir/baseDstu3/CCDA/{patientId}?dateFrom=yyyy-mm-dd&dateTo=yyyy-mm-dd
The following example shows how to search resources, the result would be a bundle gathering a set of resources as the result. The searching parameter
varies from resource to resource, most elements under resources can be used as parameter.
This request utilized GET
method and an example base URL of https://evalfhir.directmdemail.com/fhir/baseDstu3/Patient
.
It also resembles ?family=Newman
as its searching parameter.
The general searching criteria and format could be found here: https://www.hl7.org/fhir/search.html
GET https://evalfhir.directmdemail.com/fhir/baseDstu3/Patient?family=Newman
Here is the Example result:
{
"resourceType": "Bundle",
"id": "9c5bf8f1-e75a-4e96-b634-a704ccef8f5c",
"meta": {
"lastUpdated": "2017-12-13T15:08:12.382-06:00"
},
"type": "searchset",
"total": 1,
"link": [
{
"relation": "self",
"url": "https://evalfhir.directmdemail.com/fhir/baseDstu3/Patient?family=Newman"
}
],
"entry": [
{
"fullUrl": "https://evalfhir.directmdemail.com/fhir/baseDstu3/Patient/1",
"resource": {
"resourceType": "Patient",
"id": "1",
"meta": {
"versionId": "1",
"lastUpdated": "2017-12-13T14:15:01.000-06:00"
},
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><div class=\"hapiHeaderText\">Alice Jones <b>NEWMAN </b></div><table class=\"hapiPropertyTable\"><tbody><tr><td>Address</td><td><span>1357, Amber Dr </span><br/><span>Beaverton </span><span>OR </span></td></tr><tr><td>Date of birth</td><td><span>01 May 1970</span></td></tr></tbody></table></div>"
},
"extension": [
{
"url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-race",
"valueCodeableConcept": {
"coding": [
{
"system": "2.16.840.1.113883.6.238",
"code": "2106-3",
"display": "White"
}
]
}
},
{
"url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-race",
"valueCodeableConcept": {
"coding": [
{
"system": "2.16.840.1.113883.6.238",
"code": "2108-9",
"display": "White European"
}
]
}
},
{
"url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity",
"valueCodeableConcept": {
"coding": [
{
"system": "2.16.840.1.113883.6.238",
"code": "2186-5",
"display": "Not Hispanic or Latino"
}
]
}
}
],
"name": [
{
"use": "usual",
"family": "Newman",
"given": [
"Alice",
"Jones"
]
},
{
"use": "old",
"family": "Newman",
"given": [
"Alicia"
],
"period": {
"start": "1970-05-01T00:00:00-04:00"
}
}
],
"telecom": [
{
"system": "phone",
"value": "+1-(555)777-1234",
"use": "mobile"
},
{
"system": "phone",
"value": "+1-(555)723-1544",
"use": "home"
}
],
"gender": "female",
"birthDate": "1970-05-01",
"address": [
{
"use": "home",
"type": "physical",
"line": [
"1357, Amber Dr"
],
"city": "Beaverton",
"state": "OR",
"postalCode": "97006"
}
],
"communication": [
{
"language": {
"coding": [
{
"system": "2.16.840.1.113883.4.642.3.891",
"code": "en",
"display": "English"
}
]
},
"preferred": true
}
],
"managingOrganization": {
"reference": "Organization/2"
}
},
"search": {
"mode": "match"
}
}
]
}
The following example shows how to create resources, and add the corresponding resource to the data warehouse if this operation is successful.
This request utilized POST
method and an example base URL of https://evalfhir.directmdemail.com/fhir/baseDstu3/Patient
.
It does not require a parameter to proceed. But the resource should be contained in the body of POST
operation.
An OperationOutcome
resource would be returned indicating the status of this operation.
POST https://evalfhir.directmdemail.com/fhir/baseDstu3/Patient
The contained body content would be in JSON format like following:
{
"resourceType": "Patient",
"id": "2",
"meta": {
"versionId": "1",
"lastUpdated": "2017-11-21T11:01:20.049-05:00"
},
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><div class=\"hapiHeaderText\">Alice Jones <b>NEWMAN </b></div><table class=\"hapiPropertyTable\"><tbody><tr><td>Address</td><td><span>1357, Amber Dr </span><br/><span>Beaverton </span><span>OR </span></td></tr><tr><td>Date of birth</td><td><span>01 May 1970</span></td></tr></tbody></table></div>"
},
"extension": [{
"url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-race",
"valueCodeableConcept": {
"coding": [{
"system": "2.16.840.1.113883.6.238",
"code": "2106-3",
"display": "White"
}]
}
},
{
"url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-race",
"valueCodeableConcept": {
"coding": [{
"system": "2.16.840.1.113883.6.238",
"code": "2108-9",
"display": "White European"
}]
}
},
{
"url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity",
"valueCodeableConcept": {
"coding": [{
"system": "2.16.840.1.113883.6.238",
"code": "2186-5",
"display": "Not Hispanic or Latino"
}]
}
}
],
"name": [{
"use": "usual",
"family": "Newman",
"given": [
"Alice",
"Jones"
]
},
{
"use": "old",
"family": "Newman",
"given": [
"Alicia"
],
"period": {
"start": "1970-05-01T00:00:00-04:00"
}
}
],
"telecom": [{
"system": "phone",
"value": "+1-(555)777-1234",
"use": "mobile"
},
{
"system": "phone",
"value": "+1-(555)723-1544",
"use": "home"
}
],
"gender": "female",
"birthDate": "1970-05-01",
"address": [{
"use": "home",
"type": "physical",
"line": [
"1357, Amber Dr"
],
"city": "Beaverton",
"state": "OR",
"postalCode": "97006"
}],
"communication": [{
"language": {
"coding": [{
"system": "2.16.840.1.113883.4.642.3.891",
"code": "en",
"display": "English"
}]
},
"preferred": true
}],
"managingOrganization": {
"reference": "Organization/2"
}
}
The operation outcome is shown as following:
{
"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 created resource "Patient/102/_history/1" in 1,490ms</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 created resource \"Patient/102/_history/1\" in 1,490ms"
}
]
}
The following example shows how to access resources using read operation. This operation would return a resource JSON object if it is successful.
This request is using GET
operation with an example base URL of https://evalfhir.directmdemail.com/fhir/baseDstu3/Patient/1
.
The last part of the base URL is a single parameter representing the ID of the specific resource. In this case, the read operation is able to retrieve the resource by its ID.
GET https://evalfhir.directmdemail.com/fhir/baseDstu3/Patient/1
The result would be:
{
"resourceType": "Patient",
"id": "1",
"meta": {
"versionId": "1",
"lastUpdated": "2017-12-13T14:15:01.000-06:00"
},
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><div class=\"hapiHeaderText\">Alice Jones <b>NEWMAN </b></div><table class=\"hapiPropertyTable\"><tbody><tr><td>Address</td><td><span>1357, Amber Dr </span><br/><span>Beaverton </span><span>OR </span></td></tr><tr><td>Date of birth</td><td><span>01 May 1970</span></td></tr></tbody></table></div>"
},
"extension": [
{
"url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-race",
"valueCodeableConcept": {
"coding": [
{
"system": "2.16.840.1.113883.6.238",
"code": "2106-3",
"display": "White"
}
]
}
},
{
"url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-race",
"valueCodeableConcept": {
"coding": [
{
"system": "2.16.840.1.113883.6.238",
"code": "2108-9",
"display": "White European"
}
]
}
},
{
"url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity",
"valueCodeableConcept": {
"coding": [
{
"system": "2.16.840.1.113883.6.238",
"code": "2186-5",
"display": "Not Hispanic or Latino"
}
]
}
}
],
"name": [
{
"use": "usual",
"family": "Newman",
"given": [
"Alice",
"Jones"
]
},
{
"use": "old",
"family": "Newman",
"given": [
"Alicia"
],
"period": {
"start": "1970-05-01T00:00:00-04:00"
}
}
],
"telecom": [
{
"system": "phone",
"value": "+1-(555)777-1234",
"use": "mobile"
},
{
"system": "phone",
"value": "+1-(555)723-1544",
"use": "home"
}
],
"gender": "female",
"birthDate": "1970-05-01",
"address": [
{
"use": "home",
"type": "physical",
"line": [
"1357, Amber Dr"
],
"city": "Beaverton",
"state": "OR",
"postalCode": "97006"
}
],
"communication": [
{
"language": {
"coding": [
{
"system": "2.16.840.1.113883.4.642.3.891",
"code": "en",
"display": "English"
}
]
},
"preferred": true
}
],
"managingOrganization": {
"reference": "Organization/2"
}
}
For operations concerning specific data category, the request format may vary. For example, in order to get the immunization resources for a patient with ID 102. The following two requests are both valid. Please note, the later request is actually adapting searching operation, whereas the first request is a reading operation.
GET https://evalfhir.directmdemail.com/fhir/baseDstu3/Patient/102/Immunization
GET https://evalfhir.directmdemail.com/fhir/baseDstu3/Immunization?patient=102
The following example shows how to delete resources using delete operation. This operation would return a resource JSON object if it is successful.
This request is adapting DELETE
operation with an example base URL of https://evalfhir.directmdemail.com/fhir/baseDstu3/Patient/102
.
The last part of the base URL is a single parameter representing the ID of the specific resource. In this case, the delete operation is able to delete the resource by its ID.
The output would be an OperationOutcome
resource.
DELETE https://evalfhir.directmdemail.com/fhir/baseDstu3/Patient/102
The result would be:
{
"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 38ms</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 38ms"
}
]
}