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:
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
Usage is fairly straight-foward:
- First you create a new converter, specifying the indent level to use in the XML.
var FHIR_JSONtoXML = new FHIRConverter(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
Wow! This is a great post. Thanks for your wonderful article! I think this is valuable and useful to us.
ReplyDeleteandrew fawce
Just added a note to the GitHub issue related to extensions support.
ReplyDeleteThinking 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
Just added a note to the GitHub issue related to extensions support.
ReplyDeleteThinking 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
If you use one of the reference implementations, they can consume conformant XML and turn it into conformant JSON (or vice-versa)
Delete