FHIR Chat · Batch convert xml to json offline using Torinox · conformance

Stream: conformance

Topic: Batch convert xml to json offline using Torinox


view this post on Zulip Alexander Henket (Jan 21 2019 at 16:05):

The tool Torinox offers to convert between XML/JSON. The documentation does not offer any help, nor does the internal fhir -hdocumentation.

Any insights on how to do this? @Martijn Harthoorn?

view this post on Zulip Martijn Harthoorn (Jan 22 2019 at 09:44):

It's a two step.

view this post on Zulip Martijn Harthoorn (Jan 22 2019 at 09:44):

Step 1. Get some resources..

fhir read server Patient name='Chalmers'
or from disk:
fhir push *.xml

view this post on Zulip Martijn Harthoorn (Jan 22 2019 at 09:44):

Step 2. Save the resources
fhir save --all --json

view this post on Zulip Martijn Harthoorn (Jan 22 2019 at 09:45):

Optionally you can bundle them or split them first.

view this post on Zulip Martijn Harthoorn (Jan 22 2019 at 10:33):

Or save it as a zip instead of separate files.

view this post on Zulip Alexander Henket (Jan 22 2019 at 20:48):

That sounds like: upload to any fhir server and download as json? Or is that not what push/save does?

view this post on Zulip Stefan Lang (Jan 22 2019 at 22:40):

Torinox uses an internal stack here

view this post on Zulip Alexander Henket (Jan 23 2019 at 07:45):

$ fhir -info
There is no command that matches these parameters
Did you mean:
meta Info --help
$ dotnet tool update -g torinox
Tool 'torinox' was reinstalled with the latest stable version (version '0.8.1').
$ fhir push *.xml
There is no command that matches these parameters
Did you mean:
stack Push <pattern>
$ fhir Push *.xml
There is no command that matches these parameters
Did you mean:
stack Push <pattern>
$ fhir stack Push *.xml
There is no command that matches these parameters
Did you mean:
stack Push <pattern>

view this post on Zulip Alexander Henket (Jan 23 2019 at 07:51):

There's really a big gap between the documentation and what the tool actually accepts. For example fhir -info comes straight from Simplifier.

view this post on Zulip Alexander Henket (Jan 23 2019 at 07:55):

Even more basic I keep wondering why I install torinox and run fhir. Why is the command not called torinox?

view this post on Zulip Martijn Harthoorn (Jan 23 2019 at 13:02):

Alexander: it's weird that you get 0.8.1. The latest is 0.9.2
See here: https://www.nuget.org/packages/torinox

view this post on Zulip Martijn Harthoorn (Jan 23 2019 at 13:03):

Maybe you can get the latest by uninstall-reinstall :

dotnet tool uninstall -g torinox
dotnet tool install -g torinox

view this post on Zulip Martijn Harthoorn (Jan 23 2019 at 13:06):

The info on Simplifier is outdated (we'll have it fixed in the next release). We changed the parameter parser in Torinox to one that is inline with linux as well.
fhir -v | --version will show you the version.

view this post on Zulip Geert Berkers (Jan 23 2019 at 15:11):

Is it possible with torinox to only change the extension when you convert xml to json. Currently I get "Type-currentname--randomnumbers".json? Or do I have to rename all the saved files?

view this post on Zulip Alexander Henket (Jan 29 2019 at 07:53):

No dice. I run it on macOS:

$ dotnet tool uninstall -g torinox
Tool 'torinox' (version '0.8.1') was successfully uninstalled.
$ dotnet tool install -g torinox
You can invoke the tool using the following command: fhir
Tool 'torinox' (version '0.8.1') was successfully installed.

I tried this too as suggested on nuget.org:

$ dotnet tool install --global Torinox --version 0.9.2
error NU1102: Unable to find package torinox with version (>= 0.9.2)
error NU1102: - Found 29 version(s) in nuget.org [ Nearest version: 0.8.3-alpha3 ]
error NU1102: - Found 0 version(s) in /usr/local/share/dotnet/sdk/NuGetFallbackFolder
The tool package could not be restored.
Tool 'torinox' failed to install. This failure may have been caused by:

  • You are attempting to install a preview release and did not use the --version option to specify the version.
  • A package by this name was found, but it was not a .NET Core tool.
  • The required NuGet feed cannot be accessed, perhaps because of an Internet connection problem.
  • You mistyped the name of the tool.

view this post on Zulip Alexander Henket (Feb 06 2019 at 07:55):

@Martijn Harthoorn ?

view this post on Zulip Martijn Harthoorn (Feb 06 2019 at 10:12):

We have tried it here on Windows and on Macbook. And we don't have your issue. both the update, the install and the install - with-version-specified all go to version 0.9.2.

view this post on Zulip Martijn Harthoorn (Feb 06 2019 at 10:13):

Which version of dotnet do you have?
$ dotnet --version

view this post on Zulip Alexander Henket (Feb 07 2019 at 09:10):

I was running v2.1.402. I updated to v2.2.103 just now.
$ dotnet --version
2.2.103

view this post on Zulip Alexander Henket (Feb 07 2019 at 09:14):

$ dotnet tool install --global torinox --version 0.9.2
error NU1102: Unable to find package torinox with version (>= 0.9.2)
error NU1102: - Found 29 version(s) in nuget.org [ Nearest version: 0.8.3-alpha3 ]
error NU1102: - Found 0 version(s) in /usr/local/share/dotnet/sdk/NuGetFallbackFolder
The tool package could not be restored.
...

view this post on Zulip Alexander Henket (Feb 07 2019 at 09:32):

I've just also installed .Net Core on Windows and was able to install Torinox 0.9.2 there. Windows however is not where I do work, so that was only for analysis purposes

view this post on Zulip Alexander Henket (Feb 07 2019 at 09:36):

Found it:
$ dotnet tool install --no-cache --global torinox --version 0.9.2
You can invoke the tool using the following command: fhir
Tool 'torinox' (version '0.9.2') was successfully installed.

view this post on Zulip Martijn Harthoorn (Feb 07 2019 at 14:26):

good to hear. weird that it needs that setting though.

view this post on Zulip Brian Postlethwaite (Feb 11 2019 at 11:55):

I wonder where the other cache is that it was using.

view this post on Zulip Marc de Graauw (Apr 13 2020 at 15:08):

@Martijn Harthoorn would be good if Torinox documentation was updated - I found out how to xml->json here, the docs only mention Torinox offers "FHIR resource manipulation, using a stack" which is a bit dense. Nice tool, once figured out though.

view this post on Zulip Ward Weistra (Apr 14 2020 at 07:14):

Thanks @Marc de Graauw. I assume you did find the in-tool documentation with fhir --helpor fhir4 --help?

Mapping:
  parse           Parse mapping files.

Archive:
  zip             <zipname> (<pattern>) --xml --json --fmt <value> | Saves all stack entries to a zip file
  unzip           <path> (<format>) --disk | Extracts all resources from files in the zip on the stack. Use --disk to save files directly.

FHIR Client:
  read            <source> <record> | Reads a resource (type/id) from the given server. Example: Patient/1
  get             <url> | Does a FHIR http get on a URL
  search          <source> <record> (arguments...) | Searches for resources on the given server.
  post            <source> | Posts a resource to the given server
  put             <source> (<file>) | Updates a resource to the given server

Help:
  help            Shows help

Packages:
  versions        <pkgname> --raw | Lists all available versions of the package on the server
  cache           --location | Lists all globally installed packages
  semver          <pkgname> (<pkgversion>) | Tests if the specific version exists
  source          (<url>) --npm --insecure | Shows or sets the package server url.
  install         <package> (<version>) --here --file | Downloads and installs a package.
  remove          <pkgname> | Removes a package from the local context (package.json)
  pack            (<path>) | Creates a FHIR package from a folder
  contents        <filename> | Displays the contents from a package
  init            (<pkgname>) (<version>) | Generates a FHIR package manifest
  restore         Restores all packages referenced in this folders package file
  scope           Lists packages in scope for this folder context
  dependencies    Show direct package dependencies of current scope
  canonicals      (<pkgname>) (<version>) | Lists canonicals from resources in installed package.
  find            <value> | Searches for packages(s) by name or canonical

Resolving:
  resolve         <canonical> --anywhere | Resolves a canonical url to a resource and put's that on the stack
  doc             <canonical> | Brings you to the documentation page of the resource with that canonical

FHIR Servers:
  server list     Lists the configured server aliases
  server add      <name> <url> | Adds a server alias
  server delete   <name> | Deletes the given server alias

Simplifier:
  login           email=<value> password=<value> | (Re)authorizes you in Simplifier.net
  logout          Clears the credentials for Simplifier.net
  sync            <project> --up --down --verbose --folders | Synchronizes current folder with a simplifier project
  sync            <project> <folder> --down --clean --verbose --folders | Synchronizes a specific folder
  projects        --details | Shows your Simplifier.net projects
  license

Stack:
  push            <pattern> | Pushes matching files or server resources on the stack
  drop            Drops the top resource from the stack
  dup             Duplicates the top resource from the stack
  swap            Swaps the top 2 elements on the stack.
  show            (<path>) --xml --json --tree | Displays a resource tree from a file or the top of the stack
  stack           Lists the items on the stack
  save            (<filename>) --all --json --xml --fmt <value> | Saves resource(s) on stack to disk
  bundle          (<pattern>) | Takes all resources on the stack and puts them into a single bundle
  split           Splits the bundle on the top of the stack into separate resources
  peek            Displays the top item on the stack
  clear           Clears the stack
  filter          (args...) | Filter resources on the stack by type

Quality Assurance:
  validate        (<pattern>) --localsource <value> --terminologyserver <value> --verbose | Validates a FHIR resource
  snapshot        --verbose | Creates a snapshot from a StructureDefinition

It's quite complete, though admittedly very brief :slight_smile:

view this post on Zulip Marc de Graauw (Apr 14 2020 at 08:45):

Yes, saw that, but still only got it after this zulip thread. A basic walkthrough in https://simplifier.net/docs/torinox/home would help.

view this post on Zulip Martijn Harthoorn (Jun 19 2020 at 06:37):

@Marc de Graauw , something like this?
https://simplifier.net/docs/torinox/XmltoJsonandviceversa

view this post on Zulip Martijn Harthoorn (Jun 19 2020 at 06:37):

If you have more suggestions, i'll try to add them.

view this post on Zulip Marc de Graauw (Jun 19 2020 at 07:45):

:+1:


Last updated: Apr 12 2022 at 19:14 UTC