This topic contains 0 replies, has 1 voice, and was last updated by  Rolly 4 years, 2 months ago.

Connecting to FHIR Patient using RESTful Web Services

  • One of the new and exciting standards emerging from HL7 is Fast Healthcare Interoperable Resource AKA FHIR. The main emphasis is to simplify the exchange of health information with a lightweight implementation framework that will bring smiles to implementers. It certainly put a smile on my face as I put this example together using Iguana 🙂

    Before beginning I would like to give a shout out to Grahame Grieve for kindly providing a publicly available FHIR test server that was used in this example. More information about Grahame’s FHIR server can be found here.

    We use XML as the payload for this example, however JSON is also supported.

    The example below is fairly simple; get a Patient resource, search Patient resources and add a Patient resource.

    To start, I defined a variable (Patient149XMLURL) pointing to a known fictitious patient named Henry Glover (id 149). By using net.http.get function I was able to pull Henry Glover’s info as illustrated below:

    -- The main function is the first function called from Iguana.
    -- The Data argument will contain the message to be processed.
    require 'node'
    require 'patientFHIR'
    Patient149XMLURL = ''
    AllPatientsXMLURL = ''
    CreatePatientXMLURL = ''
    function main(Data)
       local msg, name = hl7.parse({vmd = 'demo.vmd', data = Data})   
       -- read an individual patient in XML format from FHIR server
       -- reference
       local R,C,H = net.http.get{url=Patient149XMLURL, live=true}
       print (C,R,H)

    Searching Patient resources is done by adding search keyword after the resource URL. FHIR defines a resource bundle as the return type.

     -- read all patient records in XML format from FHIR server
       -- reference
       R,C,H = net.http.get{url=AllPatientsXMLURL, live=true}
       print (C,R,H)

    Finally, I added a patient resource by using and passing in patient XML data that was created in a separate module, patientFHIR.

    -- create a new patient in FHIR server
       -- reference
       local P = patientFHIR.InsertTemplate()
       P = mapPatientData(P,msg,name)
       R,C,H ={url=CreatePatientXMLURL, live=true,
       print (C,R,H) -- code 201 (c=201) is a successful insert
    function mapPatientData(Xml,Msg,Name)
       if Name=='ADT' then
       return Xml

    Module for creating XML containing patient info:

    function patientFHIR.InsertTemplate()
       return xml.parse
       {data = [[
    ]] } end function node.S(ANode) return tostring(ANode) end

    Well, that's it for today, but stay tuned as I'll be posting a JSON example shortly.


You must be logged in to reply to this topic.