If your using FHIR resources to represent your healthcare models, you may run into some issues when building a Node.JS application to work with your FHIR models.
FHIR has had a great deal of focus on accessing individual resources (such as a single patient, or a single encounter) but little-to-no focus on combining multiple resources into a full document. This has been a big focus of my company. We have been working on ways to create a full document out of these individual resources.
One aspect that we have established, is that in order to represent a full document model, you have to use an ATOM feed. ATOM feeds are best represented in XML, for sure. Additionally, it is much easier to transform XML into other types of documents, as opposed to transform a JSON model to an entirely separate model. So, our need for using FHIR in XML is pretty high.
However, we really like the Node.JS, Angular.JS and Twitter Bootstrap technology stack, and would like to make use of FHIR in JSON as much as possible, and then later conver the JSON to XML when we need to send the data, or transform it to something else (like CDA – Clinical Document Architecture).
The second issue is that it does not expose a method of serializing the JSON models to XML and then back to JSON again. Here, I have discovered is more of a limitation with JS in general. There are plenty of libraries for converting JSON to XML and then other libraries for converting XML to JSON. However, these separate libraries use different methods of representing XML in JSON, so there is a major limitation on round-trip JSON to XML, and back to JSON; you get different (or entirely broken) results.
To solve this issue, I have stumbled on an xml.com article that contains a custom set of functions for converting JSON to XML and XML to JSON that use the same syntax. It doesn’t appear that these libraries have been placed into an official npm or mongoose package, so you have to include them manually in your JS project. But, with a little work, round-trip JSON<->XML is possible. I have created a JSFiddle example to demonstrate this successful round-trip conversion: http://jsfiddle.net/kbcb/4DS4P/4/