Stream: implementers
Topic: FHIR Validation Tool
Vivek Kumar Yadav (Nov 08 2019 at 04:38):
I was working with the FHIR validation jar file org.hl7.fhir.validator, and I have got some doubts :
1). I need to validate , STU2 , DSTU3 and R4 , where can I get a stable jar which will validate all these versions .
2). What are the valid parameters which I need to pass in the -version argument of the jar file , in the documentation the valid values are given as 1.0,1.4 and 3.0 , but I need to validate R4 as well , so is 4.0 a valid value for the version argument .
3). There is -out argument to convert the output of the validation into OperationOutcome , but it comes in xml format , is there a way to convert it into json without using a explicit parser .
4). At times the validation takes a lot of time to connect to the tx server , there is -ig argument tag which can be used to give the path of locally saved implementation guides , is this a correct approach , I mean is there a way to automatically sync my local ig repo with remote one .
Grahame Grieve (Nov 08 2019 at 04:45):
- the same jar for all versions
- 4.0 is a valid argument. where is it that this was not documented?
- if you nominate a -output parameter than ends with .json, you'll get json format
4a. yes, it connects to the terminology server. Should only take 1-2 secs. If you want to batch it up in a server, or process etc, you should either use org.hl7.fhir.r5.validation.NativeHostServices or a full HAPI framework
4b. -ig with just the package id is the best way, and the package will be cached locally if you do
Lloyd McKenzie (Nov 08 2019 at 04:45):
https://fhir.github.io/latest-ig-publisher/org.hl7.fhir.validator.jar is always the current one and you should use
sreenivasagopalan ananthakrishna (Nov 08 2019 at 20:03):
Hi folks, I would like to validate an STU3 resource, what is the possible values for -ig
or -defn
params ? I tried passing -ig hl7.fhir.core#3.0.2
as param and end up getting the following error: Fatal @ Task (line 1, col2) : This does not appear to be a FHIR resource (unknown name 'Task')
. While debugging this code through intellij, I found that the code is not able to pick up structure definitions. Is there anything I am missing here ? The resource I am validating is actually a valid resource, with resourceType
property set to Task
sreenivasagopalan ananthakrishna (Nov 08 2019 at 20:04):
btw, I am using the latest version of the official validator jar downloaded form the FHIR website.
Vivek Kumar Yadav (Nov 09 2019 at 10:55):
https://fhir.github.io/latest-ig-publisher/org.hl7.fhir.validator.jar is always the current one and you should use
Thanks for your response .
Vivek Kumar Yadav (Nov 09 2019 at 10:55):
- the same jar for all versions
- 4.0 is a valid argument. where is it that this was not documented?
- if you nominate a -output parameter than ends with .json, you'll get json format
4a. yes, it connects to the terminology server. Should only take 1-2 secs. If you want to batch it up in a server, or process etc, you should either use org.hl7.fhir.r5.validation.NativeHostServices or a full HAPI framework
4b. -ig with just the package id is the best way, and the package will be cached locally if you do
Thanks for your response .
Grahame Grieve (Nov 09 2019 at 21:11):
@sreenivasagopalan ananthakrishna - oops I mixed fixing something up when we reorganised the packages. Will be fixed next release (within 24 hours). In the meantime, use the -version parameter
I updated the documentation here: https://confluence.hl7.org/display/FHIR/Using+the+FHIR+Validator
sreenivasagopalan ananthakrishna (Nov 11 2019 at 23:16):
sreenivasagopalan ananthakrishna - oops I mixed fixing something up when we reorganised the packages. Will be fixed next release (within 24 hours). In the meantime, use the -version parameter
I updated the documentation here: https://confluence.hl7.org/display/FHIR/Using+the+FHIR+Validator
Thanks will check it out!
sreenivasagopalan ananthakrishna (Nov 15 2019 at 16:51):
sreenivasagopalan ananthakrishna - oops I mixed fixing something up when we reorganised the packages. Will be fixed next release (within 24 hours). In the meantime, use the -version parameter
I updated the documentation here: https://confluence.hl7.org/display/FHIR/Using+the+FHIR+Validator
@Grahame Grieve I am back on this task of validating custom profiles. My observation is that the Validation tool is not able to validate even examples bundled as part of the definition files. For example:
11:44 $ java -jar org.hl7.fhir.validator.jar task-example.json -version 3.2.0 FHIR Validator Build ?? Arguments: task-example.json -version 3.2.0 .. connect to tx server @ http://tx.fhir.org .. definitions from hl7.fhir.core#3.2.0 (v3.2.0-null) .. validate [task-example.json] *FAILURE* validating task-example.json: error:1 warn:0 info:0 Fatal @ Task (line 1, col2) : This does not appear to be a FHIR resource (unknown name 'Task')
I have tried both version 3.0.2 and 3.2.0. Both are giving same issue. WIth version 3.0.2, the definition files are not even downloaded in the cache. All I see is a package.json which refers to other resources. I do see a reference to StructureDefinition-Taskjson
as part of the 3.2.0 cache, but the file extension seems to be incorrect in the downloaded package, Is it supposed to be `StructureDefinition-Task.json
instead ?
✔ ~/.fhir/packages/hl7.fhir.core#3.2.0/package 11:52 $ ls StructureDefinition-task-* StructureDefinition-task-candidateListjson StructureDefinition-task-replacesjson
I renamed StructureDefinition-Taskjson
to StructureDefinition-Task.json
, but now I get this following error:
11:45 $ java -jar org.hl7.fhir.validator.jar task-example.json -version 3.2.0 FHIR Validator Build ?? Arguments: task-example.json -version 3.2.0 .. connect to tx server @ http://tx.fhir.org .. definitions from hl7.fhir.core#3.2.0 Error loading StructureDefinition-Task.json: Unknown FHIRVersion code '3.2.0' Exception in thread "main" org.hl7.fhir.exceptions.FHIRException: Error loading StructureDefinition-Task.json: Unknown FHIRVersion code '3.2.0' at org.hl7.fhir.r4.context.SimpleWorkerContext.fromDefinitions(SimpleWorkerContext.java:197) at org.hl7.fhir.r4.validation.ValidationEngine.loadDefinitions(ValidationEngine.java:300) at org.hl7.fhir.r4.validation.ValidationEngine.loadInitialDefinitions(ValidationEngine.java:262) at org.hl7.fhir.r4.validation.ValidationEngine.<init>(ValidationEngine.java:287) at org.hl7.fhir.r4.validation.Validator.main(Validator.java:347) Caused by: java.lang.IllegalArgumentException: Unknown FHIRVersion code '3.2.0' at org.hl7.fhir.r4.model.Enumerations$FHIRVersionEnumFactory.fromCode(Enumerations.java:10202) at org.hl7.fhir.r4.model.Enumerations$FHIRVersionEnumFactory.fromCode(Enumerations.java:1) at org.hl7.fhir.r4.formats.JsonParser.parseEnumeration(JsonParser.java:104) at org.hl7.fhir.r4.formats.JsonParser.parseStructureDefinitionProperties(JsonParser.java:23559) at org.hl7.fhir.r4.formats.JsonParser.parseStructureDefinition(JsonParser.java:23478) at org.hl7.fhir.r4.formats.JsonParser.parseResource(JsonParser.java:27655) at org.hl7.fhir.r4.formats.JsonParserBase.parse(JsonParserBase.java:92) at org.hl7.fhir.r4.context.SimpleWorkerContext.loadFromFileJson(SimpleWorkerContext.java:257) at org.hl7.fhir.r4.context.SimpleWorkerContext.loadDefinitionItem(SimpleWorkerContext.java:206) at org.hl7.fhir.r4.context.SimpleWorkerContext.fromDefinitions(SimpleWorkerContext.java:194)
Is it possible to get definition files for 3.0.2
if 3.2.0
is not supported?
Michael Lawley (Nov 16 2019 at 07:56):
-version
specifies the FHIR spec version. There is no FHIR 3.2.0, only 3.0.0, 3.0.1, and 3.0.2 in the 3.x series
So, 3.0.2 is the correct latest version to use.
Out of interest, are you able to use 3.0.1?
Grahame Grieve (Nov 16 2019 at 15:25):
the validator supports stated versions 3.0, 3.0.0, 3.0.1, and 3.0.2. It all works for me. 3.2.0 won't work.
sreenivasagopalan ananthakrishna (Nov 19 2019 at 23:14):
the validator supports stated versions 3.0, 3.0.0, 3.0.1, and 3.0.2. It all works for me. 3.2.0 won't work.
@Grahame Grieve @Michael Lawley thanks for the reply! can you please provide the exact command and definition file link for version 3.0.2
. It doesn't seem to work for me as the definition files are not getting fetched. Here is what I have in the cache folder:
$ ls ~/.fhir/packages/hl7.fhir.core#3.0.2/package/ package.json
Grahame Grieve (Nov 20 2019 at 04:48):
the package hl7.fhir.core#3.0.2 is empty - it just expresses dependency on the other packages for R3. But this should not be a factor for you. All of the ways of invoking the validator documented here https://confluence.hl7.org/display/FHIR/Using+the+FHIR+Validator work for me. If they don't for you, post your parameters, and the output from the validator
Last updated: Apr 12 2022 at 19:14 UTC