Test script for running ShEx validation against FHIR Example instances
- python 3 -- this has been tested with python 3.5.0
- node.js -- JavaScript engine for shex.js
- shex.js -- ShEx validation REST server
-
Download the FHIR STU3 Distribution:
There are a number of ways to accomplish this including:
- Use the hcls-fhir-rdf
download_fhir_spec
utility --
> download_fhir_spec -u http://hl7.org/fhir/2016Sep/
- Download and unzip the FHIR specification
- Build a local image using the FHIR Build Process. Once the
publish.sh
orpublish.bat
script has been run, the final specification will be in the "publish" directory
- Use the hcls-fhir-rdf
download_fhir_spec
utility --
-
Start the shex.js server as a separate thread:
> git clone https://github.com/caCDE-QA/shex.js > cd shex.js > npm update -g shex-test > node --no-deprecation ./bin/validate -S http://localhost:4290/validate --regex-module nfax-val-1err --duplicate-shape ignore Visit http://localhost:4290/ in browser. Test with a supplied schema and data: curl -i http://localhost:4290/validate -F "schema=@test/cli/1dotOr2dot.shex" -F "shape=http://a.example/S1" -F "data=@test/cli/p2p3.ttl" -F "node=x" or preload the schema and just supply the data: bin/validate -x test/cli/1dotOr2dot.shex -s http://a.example/S1 -S http://localhost:4290/validate and pass only the data parameters: curl -i http://localhost:4290/validate -F "data=@test/cli/p2p3.ttl" -F "node=x" Note that shape and node can be relative or prefixed URLs. Press CTRL+C to stop...
The latest version of
node
issues a deprecation warning about calling an asynchronous function without a callback. This is the reason for the--no-deprecation
tag in the invocation above. -
Clone or download FHIRShExTest and install:
> https://github.com/caCDE-QA/FHIRShExTest.git > cd FHIRShExTest > virtualenv venv -p python3 > . FHIRShExTest/bin/activate (venv) > python setup.py
-
Copy the local changes to the ShEx specifications to the publish directory
(venv) > cp changes/* <FHIR specification directory>
-
Run the FHIRShExTest script:
(venv) > python src/FHIRShExTest -id <FHIR specification directory> -od data --nosuccesslog /Users/mrf7578/Development/fhirstu3/stu3-ballot/publish/claim-example-vision-glasses.ttl /Users/mrf7578/Development/fhirstu3/stu3-ballot/publish/claim.shex MissingProperty http://www.w3.org/1999/02/22-rdf-syntax-ns#type JsonObj(property='http://www.w3.org/1999/02/22-rdf-syntax-ns#type', type='MissingProperty', valueExpr=JsonObj(type='NodeConstraint', values=['http://hl7.org/fhir/MedicationOrder'])) /Users/mrf7578/Development/fhirstu3/stu3-ballot/publish/claimresponse-example.ttl /Users/mrf7578/Development/fhirstu3/stu3-ballot/publish/claimresponse.shex MissingProperty http://www.w3.org/1999/02/22-rdf-syntax-ns#type JsonObj(property='http://www.w3.org/1999/02/22-rdf-syntax-ns#type', type='MissingProperty', valueExpr=JsonObj(type='NodeConstraint', values=['http://hl7.org/fhir/Claim'])) ... /Users/mrf7578/Development/fhirstu3/stu3-ballot/publish/rim.ttl Not a FHIR resource instance Total=499 Successful=480 Not a FHIR resource: 57 Missing ShEx file: 0 On skip list: 0 Failed validation: 19 Invalid RDF: 12 (venv) >
The Invalid RDF counts above are due to an rdflib error. We are awaiting an alternative resolution from the rdflib authors -- the solution is targeted for the rdflib 4.2.2 milestone. Once this change has been installed, the output should match:
Total=511 Successful=492
Not a FHIR resource: 57
Missing ShEx file: 0
On skip list: 0
Failed validation: 19
Invalid RDF: 0