Stream: implementers
Topic: xml <-> json without storing
Sean McIlvenna (Sep 14 2017 at 18:38):
Do any servers support an operation to simply convert a resource from XML to JSON without storing it?
Sean McIlvenna (Sep 14 2017 at 18:38):
or vice versa?
Grahame Grieve (Sep 14 2017 at 18:39):
I don't think so, though it would be trivial
Michel Rutten (Sep 14 2017 at 18:39):
You could perform the conversion client side using the API?
Sean McIlvenna (Sep 14 2017 at 18:39):
would be useful
Sean McIlvenna (Sep 14 2017 at 18:39):
depends on if you're using a stack that has an API yet :)
Sean McIlvenna (Sep 14 2017 at 18:39):
(ex: javascript)
Grahame Grieve (Sep 14 2017 at 18:40):
POST [base]/[type]/$convert with Accept and Content-Type media types.. gets really interesting if the use version specific media types such as application/fhir.r3+xml (discussed for the first time yesterday)
Sean McIlvenna (Sep 14 2017 at 18:42):
ehhh
Sean McIlvenna (Sep 14 2017 at 18:42):
I don't know that I'd get too far into version specific media types
Sean McIlvenna (Sep 14 2017 at 18:42):
suppose that could be up to the server
Sean McIlvenna (Sep 14 2017 at 18:42):
on how far down that rabbit hole they want to support
Ewout Kramer (Sep 14 2017 at 19:28):
I just created #13888. Would that cover it?
Grahame Grieve (Sep 14 2017 at 19:29):
ok. live on test.fhir.org/r3/$convert - can convert formats (but not version conversion)
Christiaan Knaap (Sep 14 2017 at 19:30):
Discussions on SMART are too interesting to do this on Vonk during the session :-)
Ewout Kramer (Sep 14 2017 at 19:33):
ok. live on test.fhir.org/r3/$convert - can convert formats (but not version conversion)
Grahame - I think you're a bit too fast - $convert is too generic and you'll surely end up needing the same name for other kinds of conversions. My GF calls it $convert-format.
Ewout Kramer (Sep 14 2017 at 19:33):
[I am guess you can implement that change even quicker] ;-)
Sean McIlvenna (Sep 14 2017 at 20:31):
Tried to hit /$convert on your test server...
Sean McIlvenna (Sep 14 2017 at 20:32):
Gives errors.thought I would look at the OperationDefinnition, but I don't find fso-convert anywhere
Sean McIlvenna (Sep 14 2017 at 20:32):
nm, think I got it
Sean McIlvenna (Sep 14 2017 at 20:32):
but, fso-convert still isn't found on the server
Sean McIlvenna (Sep 14 2017 at 20:32):
fyi
Reuben Daniels (Sep 14 2017 at 20:36):
+1 for $convert-format
Grahame Grieve (Sep 14 2017 at 21:10):
hah who says it's too generic? I'm intending to see it used for more than just converting format
Grahame Grieve (Sep 14 2017 at 21:10):
not that I mind if we change the name
Grahame Grieve (Sep 14 2017 at 21:10):
@Sean McIlvenna what errors?
Ewout Kramer (Sep 14 2017 at 21:15):
hah who says it's too generic? I'm intending to see it used for more than just converting format
I think an operation should do 1 thing, and do that well. If we do all kinds of conversions (probably more involved than just the format), you'd run the risk that it gets implemented less since it will become more difficult to implement it.... CapabilityStatement has the power to express that you do or don't a function in its entirety, not whether you partially implement it... so I'd be cautious....
Vadim Peretokin (Sep 15 2017 at 06:54):
@Sean McIlvenna https://fhir-formats.github.io runs client-side in the browser
Vadim Peretokin (Sep 15 2017 at 06:55):
If there's interest I can clean it up into a library
Sean McIlvenna (Sep 17 2017 at 07:48):
@Vadim Peretokin , I can't seem to get it to work. I also don't see any downloads. Not sure I should rip off the code from the site, even if I could get it to work.
Grahame Grieve (Sep 19 2017 at 21:49):
well, how many transformations might there be?
Grahame Grieve (Sep 19 2017 at 21:49):
here's another kind:
Grahame Grieve (Sep 19 2017 at 21:49):
https://motorcycleguy.blogspot.com.au/2017/09/comparing-dynamically-generated.html
Grahame Grieve (Sep 19 2017 at 21:50):
that would be generally useful for implementers if that was implemented well
Grahame Grieve (Sep 19 2017 at 21:50):
another kind of transformation is trading between different coding systems, and codes on different elements
Ron Shapiro (Sep 20 2017 at 18:08):
The Qvera Interface Engine includes the ability to convert FHIR XML <-> FHIR JSON without storing the FHIR Resource on a FHIR server and without using any type of schema or schematron validation.
This is accomplished with a simple function call as follows:
var xmlMessage = qie.convertFHIRJSONtoXML(jsonMessage);
or to convert it the other way:
var jsonMessage = qie.convertFHIRXMLtoJSON(xmlMessage);
An example FHIR Patient Resource as JSON:
FHIR-JSON.png
converted to XML:
FHIR-XML.png
Since this conversion is done without schema or schematron validation or knowledge, you will notice the <!-- JSON array --> and <!-- JSON primitive --> XML comments included in the XML version of the FHIR Patient resource. These hints are added when converting from JSON to XML so that the interface engine knows to use JSON arrays and primitive values when converting back to JSON. This means that if you have an existing XML FHIR Resource, you will need to decorate it with the correct hints in order to be able to convert it to a valid JSON FHIR Resource. If you start with JSON, however, these are added for you.
The Qvera Interface Engine is an enterprise grade integration engine used by thousands of healthcare organizations to achieve interoperability success. Qvera offers a free version of the Qvera Interface Engine that can be used to solve low volume interfacing needs.
Vadim Peretokin (Sep 25 2017 at 06:50):
@Sean McIlvenna it's for STU3, maybe that is the problem?
Sean McIlvenna (Sep 25 2017 at 17:57):
@Ron Shapiro , this is good information. Thank you! In my case, I was trying to convert JSON to XML, but it wasn't working. I'll give it another try shortly.
Sean McIlvenna (Sep 25 2017 at 17:58):
@Vadim Peretokin , I assume you mean that the website is based on STU3... STU3 resources is what I was attempting to convert. Even tried with just an example resource from build.fhir.org. When I pasted the resource into the left, it did nothing to the right.
Sean McIlvenna (Sep 25 2017 at 17:59):
Although I may have just figured my problem out... I think I was pasting JSON on the left, not the right.
Sean McIlvenna (Sep 25 2017 at 17:59):
Will play with it more and see what I come up with
Richard Ettema (Sep 25 2017 at 21:26):
FYI - If anyone wants to try this on another server, I've implemented the $convert-format operation (experimental) in the WildFHIR server (http://wildfhir.aegis.net/fhir3-0-1). As this is purely experimental; i.e. no formal OperationDefinition yet, this is how it works:
Request: POST http://wildfhir.aegis.net/fhir3-0-1/$convert-format
Headers:
Accept [FHIR mime-type TO]
Content-Type [FHIR mime-type FROM]
Body:
[FHIR resource instance in FHIR mime-type FROM format]
Response:
Status HTTP1.1 200 OK
Headers:
Content-Type [FHIR mime-type TO]
Body:
[Converted FHIR resource instance in mime-type TO format]
If the conversion fails for any reason, the response will return a 4xx status code and an OperationOutcome.
Abbie Watson (Oct 10 2017 at 22:12):
Do any servers support an operation to simply convert a resource from XML to JSON without storing it?
If you're building in Node.js, the fhir
npm package supports these operations natively, with .jsonToXml()
and .xmlToJson()
functions.
https://www.npmjs.com/package/fhir
http://lantanagroup.github.io/FHIR.js/Fhir.html
Only issue with the above library is that the underlying library runs best on Mac/Linux, and one of it's dependencies (xml2js) needs a C compiler that's difficult to find on Windows.
Last updated: Apr 12 2022 at 19:14 UTC