GraphQL

Following my post yesterday, someone who shall remain nameless (you know who you are Brian) suggested that it would also be good to be able to make GraphQL queries from clinFHIR. I know even less about GraphQL than I did about FHIRPath, but as Grahame has an implementation on his server, it was a reasonably straightforward matter to put a simple UI in so you can experiment with that against a Patient resource. (GraphQL can do a lot more than that, but this is a start).

The specification for the FHIR version of GraphQL is available here (be warned, it’s very early in the process).

If you select Grahames R3 server as the data server, then select a patient in the Patient Viewer of clinFHIR, you’ll see a new tab as shown in the screenshot below.

Screen Shot 2017-08-17 at 10.53.46 am

You can enter a GraphQL query that makes sense against the current patient, and then run it to see the results (or an error) displayed below the query.

One of the neatest things is that way you can easily resolve references across resources. You can do this using plain REST and FHIRPath as well, but GraphQL seems to be a good choice when you are after only a subset of the data – The REST option in general returns whole resources, and FHIRPath is (I think) more for describing paths and references rather than wholesale data extraction.

Oh, and here’s a more interesting example where we pull in details from a referenced resource (the managingOrganization)

Screen Shot 2017-08-17 at 11.17.00 am

One thing to be quite clear about is that GraphQL does not return resources (even though it may look like it). It allows you to pull out the bits you a want and assemble a completely custom response.

I have to say that implementing GraphQL does look like quite an exciting addition to the FHIR family – especially in collecting information across resources, and it will be interesting where it ends up.  I’ll try to enhance the support in clinFHIR (as a client of course) and if you are implementing it on a server using the FHIR interface (with CORS enabled) , than let me know and I’ll add your server to the list of supported servers.

About David Hay
I'm an independent contractor working with a number of Organizations in the health IT space. I'm an HL7 Fellow, Chair Emeritus of HL7 New Zealand and a co-chair of the FHIR Management Group. I have a keen interest in health IT, especially health interoperability with HL7 and the FHIR standard. I'm the author of a FHIR training and design tool - clinFHIR - which is sponsored by InterSystems Ltd.

Leave a Reply

%d