1. FHIR – Feel the Fire - Part 1
Jayant Singh
http://www.j4jayant.com
1
2. Feel the Fire
FHIR provides very good specification
http://www.hl7.org/implement/standards/fhir/
Hands on experience on any thing helps
understand it better.
Connect FHIR test servers and explore FHIR -
healthcare resources in RESTful environment.
2
3. Connect Test Servers
I will discuss two approaches to connect test
server
Fiddler
Write your own client (in C#)
I will connect Grahame's test server available at
http://hl7connect.healthintersections.com.au/svc/fhir/
3
4. Connect using Fiddler
Fiddler is simple tool which we will use to
compose requests to RESTful FHIR test servers
Download and install Fiddler from
http://www.fiddler2.com/fiddler2/
4
5. Conformance Resource - Request
First step - request a conformance resource to know how an
application or implementation supports FHIR.
OPTIONS
http://hl7connect.healthintersections.com.au/svc/fhir/
5
6. Conformance Resource - Response
Read the conformance carefully to understand supported FHIR
resources
6
7. Patient Resource Feed - Request
GET
http://hl7connect.healthintersections.com.au/svc/fhir/patient
In this request we have specified “Accept” Http header to specify
content type for this request as xml
7
8. Patient Resource Feed - Response
feed with collection of all the patient resources. Each patient
resource will be inside “entry” element.
Go through each element in this xml and understand it by
comparing with definition available in specification
8
9. Patient Resource - Request
GET
http://hl7connect.healthintersections.com.au/svc/fhir/patient/@1
In this request we have specified “Accept” Http header to specify
content type for this request as json
9
10. Patient Resource - Response
Patient Resource
Go through each element in this json and understand it by
comparing with definition available in specification
10
11. Bad Request
Try to query a resource which is not available
GET
http://hl7connect.healthintersections.com.au/svc/fhir/pati
ent/@1123
This will return HTTP 404 Not Found status code
11
12. Write a Client in C#
Writing your own client to query resources from
test server will help you understand the FHIR &
RESTful environment.
Sample code provided here is written in C# and
uses a library RestSharp to make RESTful
request/response.
12
13. Sample Code
//create a RestClient
var client = new RestClient();
//Assign base url of RESTFul Server
client.BaseUrl = txtUri.Text.Trim();
//HTTP method(GET/POST etc) to use for this request
Method method = (Method)Enum.Parse((typeof(Method)), cmbHttpOptions.Text);
//Create RestRequest
var request = new RestRequest(method);
//Add header "Accept" to request xml or json data format
if (cmbContentType.Text.Equals("xml"))
request.AddHeader("Accept", "application/xml");
else
request.AddHeader("Accept", "application/json");
//resource to query like patient, patient/@1, document etc.
request.Resource = txtResource.Text.Trim();
//Execute the request and get response
IRestResponse response = client.Execute(request);
//display the raw response header
txtResult.Text = "************Response Header***********n";
for (int i = 0; i < response.Headers.Count; i++)
txtResult.Text += response.Headers[i].Name + ": " + response.Headers[i].Value + "n";
txtResult.Text += "StatusCode: " + response.StatusCode + "n";
//display the raw response content
txtResult.Text += "nn************Raw Content**********n"; 13
txtResult.Text += response.Content;
16. Important
Try more resource URIs on your own to explore
other resources
http://hl7connect.healthintersections.com.au/sv
c/fhir/ lists all the supported resources and their
profiles
Note that these servers are testing servers. They
may be sporadically unavailable
16
17. Thank You
Jayant Singh
http://www.j4jayant.com
17