This wiki has undergone a migration to Confluence found Here
<meta name="googlebot" content="noindex">

Difference between revisions of "Using the FHIR Validator to transform content"

From HL7Wiki
Jump to navigation Jump to search
Line 23: Line 23:
 
The source parameter can contain either:
 
The source parameter can contain either:
  
* a URL that returns the resource to validate (authentication is not supported)
+
* a URL that returns the content to transform (authentication is not supported)
 
* a filename (relative to the current directory, or absolute)
 
* a filename (relative to the current directory, or absolute)
* a directory that contains resources to validate (all files are validated if they are recognised as resources)
+
* a directory that contains a file to transform
 
* a pattern: a directory followed by a filename with an embedded asterisk.  E.g. foo*-examples.xml or someresource.*, etc
 
* a pattern: a directory followed by a filename with an embedded asterisk.  E.g. foo*-examples.xml or someresource.*, etc
  
Line 32: Line 32:
 
Exammple:
 
Exammple:
  
   java -jar org.hl7.fhir.validator.jar -transform /tmp/resource.json
+
   java -jar org.hl7.fhir.validator.jar -transform /tmp/resource.json (.. other parameters needed...)
  
 
or
 
or
  
   java -jar org.hl7.fhir.validator.jar -transform c:\temp\patient.xml
+
   java -jar org.hl7.fhir.validator.jar -transform c:\temp\patient.xml (.. other parameters needed...)
 +
 
 +
Note: the source does not need to be a FHIR resource - it needs to be whatever the transform reads from
  
 
= Choosing what to produce =
 
= Choosing what to produce =
 +
 +
The parameter -output must be provided, and is a file will be created to contain the output.
 +
 +
  java -jar org.hl7.fhir.validator.jar -transform c:\temp\patient.xml -output c:\temp\output.xml  (.. other parameters needed...)
  
 
= Specifying the map to start with =
 
= Specifying the map to start with =
 +
 +
A parameter -map must be specified that is canonical URI of the map to use.
 +
 +
  java -jar org.hl7.fhir.validator.jar -transform c:\temp\patient.xml -output c:\temp\output.xml -map http://acme.com/fhir/StructureMap/something  (.. other parameters needed...)
 +
 +
The map must already be loaded using the -ig parameter (see below)
  
 
= choosing where to save the log =
 
= choosing where to save the log =
 +
 +
The transform engine can produce a comprehensive log of the output from running the transform that is necessary when troubleshooting the transform process. By default, the transform engine writes the output to the console screen, but that can be redirected to a file using the -log parameter:
 +
 +
  java -jar org.hl7.fhir.validator.jar -transform c:\temp\patient.xml -log c:\temp\log.txt  (.. other parameters needed...)
  
 
= Specifying libraries =
 
= Specifying libraries =
  
The transform engine will need to load your mapping libraries, logical models, and the relevant FHIR version.
+
Before it can actually run the transform, and handle non-FHIR input and output, the transform engine will need to load the relevant mapping libraries, logical models, and the relevant FHIR version. All loading the of the input is done using the -ig parameter:
 +
 
 +
  java -jar org.hl7.fhir.validator.jar -transform c:\temp\patient.xml -output c:\temp\output.xml
 +
    -log c:\temp\log.txt -map http://acme.com/fhir/StructureMap/something 
 +
    -ig acme.fhir.formats -ig c:\temp\acme\maps
 +
 
 +
The -ig parameter can be one of the following:
 +
 
 +
* a package (e.g. acme.fhir.formats)
 +
* the canonical URL for an implementation guide containing content
 +
* a file name
 +
* a directory containing resources (*.xml. *.json, or *.map)
 +
 
 +
Note that there's no requirement for any order etc - all resources found from the specified -ig parameters are loaded into the transform engine cache. The transform engine uses StructureDefinitions, ValueSets, CodeSystems, ConceptMaps, and StructureMap resources, and ignores the rest.

Revision as of 22:19, 22 October 2018

This page describes how to use the validator to transform content from one format to another using the [FHIR Mapping Language]. To use the validator for validation, see Using the FHIR Validator

Running the validator

To use the validator, download the jar from http://build.fhir.org/downloads.html. Specifically, download the official FHIR validator at http://build.fhir.org/validator.zip Note that you always use the current validator from the build, irrespective of what transforms you are running.. You need a current version of java to run the validator:

 java -jar org.hl7.fhir.validator.jar -transform  [params]

The params control how the transfomration occurs, and are documented here.

In general, in order to perform the transform, you need to specify:

  • what to transform
  • the map to use to transform it
  • where to put the tranform

+ you need to tell the engine where to find all the relevant logical models, mapping libraries, etc.

Choosing what to transform

There must be at just one source param, which is not a named parameter. All other parameters are 'named parameters' - e.g. -name value. Any parameter preceded by a recognised name is interpreted as a source parameter

The source parameter can contain either:

  • a URL that returns the content to transform (authentication is not supported)
  • a filename (relative to the current directory, or absolute)
  • a directory that contains a file to transform
  • a pattern: a directory followed by a filename with an embedded asterisk. E.g. foo*-examples.xml or someresource.*, etc

In the case of a directory or a pattern, it is an error if there is more than one matching file.

Exammple:

 java -jar org.hl7.fhir.validator.jar -transform /tmp/resource.json  (.. other parameters needed...)

or

 java -jar org.hl7.fhir.validator.jar -transform c:\temp\patient.xml  (.. other parameters needed...)

Note: the source does not need to be a FHIR resource - it needs to be whatever the transform reads from

Choosing what to produce

The parameter -output must be provided, and is a file will be created to contain the output.

 java -jar org.hl7.fhir.validator.jar -transform c:\temp\patient.xml -output c:\temp\output.xml  (.. other parameters needed...)

Specifying the map to start with

A parameter -map must be specified that is canonical URI of the map to use.

 java -jar org.hl7.fhir.validator.jar -transform c:\temp\patient.xml -output c:\temp\output.xml -map http://acme.com/fhir/StructureMap/something  (.. other parameters needed...)

The map must already be loaded using the -ig parameter (see below)

choosing where to save the log

The transform engine can produce a comprehensive log of the output from running the transform that is necessary when troubleshooting the transform process. By default, the transform engine writes the output to the console screen, but that can be redirected to a file using the -log parameter:

 java -jar org.hl7.fhir.validator.jar -transform c:\temp\patient.xml -log c:\temp\log.txt  (.. other parameters needed...)

Specifying libraries

Before it can actually run the transform, and handle non-FHIR input and output, the transform engine will need to load the relevant mapping libraries, logical models, and the relevant FHIR version. All loading the of the input is done using the -ig parameter:

 java -jar org.hl7.fhir.validator.jar -transform c:\temp\patient.xml -output c:\temp\output.xml 
   -log c:\temp\log.txt -map http://acme.com/fhir/StructureMap/something  
   -ig acme.fhir.formats -ig c:\temp\acme\maps

The -ig parameter can be one of the following:

  • a package (e.g. acme.fhir.formats)
  • the canonical URL for an implementation guide containing content
  • a file name
  • a directory containing resources (*.xml. *.json, or *.map)

Note that there's no requirement for any order etc - all resources found from the specified -ig parameters are loaded into the transform engine cache. The transform engine uses StructureDefinitions, ValueSets, CodeSystems, ConceptMaps, and StructureMap resources, and ignores the rest.