Convert your FHIR JSON -> XML and back here. The CDA Book is sometimes listed for Kindle here and it is also SHIPPING from Amazon! See here for Errata.

Thursday, September 3, 2015

My FHIR JSON->XML Converter in JavaScript is now on GitHub

So, I've updated the FHIR Converter, fixed some bugs and posted it on GitHub for folks to play with. It is presently based on the DSTU 2 QA release and XML Schema.  You can try it out at my test page.

Usage is fairly straight-foward:
  1. First you create a new converter, specifying the indent level to use in the XML.
    var FHIR_JSONtoXML = new FHIRConverter(2); 
  2. Then you convert the FHIR JavaScript object
    var xml = FHIR_JSONtoXML.toXML(object); 

The toXML() member function will convert the object to an XML representation. It assumes that the object itself complies with the FHIR specification, and does not (yet) attempt to handle input implementation errors or validation.

I've tested it with the FHIR JSON Discharge Summary Example (since my main goal was to support FHIR to CDA conversion), but none done a lot of other testing.

Some things it doesn't yet handle (or which I haven't tested) are extensions and identifiers on primitive types.  Please log your bugs over on GitHub.  I'm not committing to keep this up in GitHub, but others might find it useful, and if the FHIR Core team thinks it is worthy of putting into the build, then I will volunteer to maintain it.  If that happens, I'll let you know.

   Keith


2 comments:

  1. Wow! This is a great post. Thanks for your wonderful article! I think this is valuable and useful to us.

    andrew fawce

    ReplyDelete
  2. Just added a note to the GitHub issue related to extensions support.

    Thinking about it, there may be a way to address my particular issue with the Conformance.Security section. Is there a way, perhaps updating the FHIRdefs model, to convert from JSON:

    "extension":[
    {
    "url":"register",
    "valueUri":"https://vml-catstools2.dhe.duke.edu:8443/duke-openid/register"
    },

    where the output XML would have the url piece as an attribute? Currently I don't even see the "url" piece as part of the output.

    Regards,
    Luiz

    ReplyDelete