Stream: conformance
Topic: validator bug
Jens Villadsen (Jun 16 2020 at 08:02):
The validator has a bug when loading parameters it seems:
jvi@Jenss-MacBook-Pro-2 Downloads % file params.json
params.json: JSON data
jvi@Jenss-MacBook-Pro-2 Downloads % java -jar org.hl7.fhir.validator.jar -source params.json -ig https://docs.ehealth.sundhed.dk/latest/ig/package.tgz
FHIR Validation tool Version 5.0.7-SNAPSHOT (Git# 6bc790d98b04). Built 2020-06-07T08:35:37.25+10:00 (9 days old)
Detected Java version: 11.0.7 from /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home on x86_64 (64bit). 4096MB available
Arguments: -source params.json -ig https://docs.ehealth.sundhed.dk/latest/ig/package.tgz
Directories: Current = /Users/jvi/Downloads, Package Cache = /Users/jvi/.fhir/packages
.. FHIR Version current, definitions from hl7.fhir.r5.core#current
.. connect to tx server @ http://tx.fhir.org
(vcurrent)
+ .. load IG from https://docs.ehealth.sundhed.dk/latest/ig/package.tgz
.. validate [-source, params.json]
Exception in thread "main" java.io.IOException: File -source does not exist
at org.hl7.fhir.validation.ValidationEngine.handleSource(ValidationEngine.java:1071)
at org.hl7.fhir.validation.ValidationEngine.handleSources(ValidationEngine.java:1046)
at org.hl7.fhir.validation.ValidationEngine.validate(ValidationEngine.java:1006)
at org.hl7.fhir.validation.cli.services.ValidationService.validateSources(ValidationService.java:54)
at org.hl7.fhir.validation.Validator.main(Validator.java:202)
jvi@Jenss-MacBook-Pro-2 Downloads % code params.json
contents of the params.json:
{
"resourceType": "Parameters",
"parameter": [
{
"name": "resource",
"resource": {
"resourceType": "Communication",
"meta": {
"profile": [
"http://ehealth.sundhed.dk/fhir/StructureDefinition/ehealth-message"
]
},
"extension": [
{
"url": "http://ehealth.sundhed.dk/fhir/StructureDefinition/ehealth-communication-recipientCareTeam",
"valueReference": {
"reference": "https://inttest.ehealth.sundhed.dk/organization/fhir/CareTeam/50"
}
},
{
"url": "http://ehealth.sundhed.dk/fhir/StructureDefinition/ehealth-restriction-category",
"valueCodeableConcept": {
"coding": [
{
"system": "http://ehealth.sundhed.dk/cs/restriction-category",
"code": "None"
}
]
}
}
],
"partOf": [
{
"reference": "http://careplan.fut.trifork.com/CarePlan/42"
}
],
"status": "preparation",
"category": [
{
"coding": [
{
"system": "http://ehealth.sundhed.dk/cs/message-category",
"code": "message"
}
],
"text": "Besked"
}
],
"medium": [
{
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/v3-ParticipationMode",
"code": "WRITTEN"
}
],
"text": "WRITTEN"
}
],
"sender": {
"reference": "http://inttest.ehealth.sundhed.dk/trifork-fhir-server/Patient/100"
},
"reasonCode": [
{
"coding": [
{
"system": "http://ehealth.sundhed.dk/cs/task-category",
"code": "MissingMeasurementResolving"
}
]
}
],
"payload": [
{
"contentString": "Hello world"
}
]
}
}
]
}
Grahame Grieve (Jun 16 2020 at 10:51):
@Mark Iantorno can you look at this one
Mark Iantorno (Jun 16 2020 at 13:48):
on it
Mark Iantorno (Jun 16 2020 at 14:00):
I can 100% replicate it
Mark Iantorno (Jun 16 2020 at 14:02):
Alright, so I can get this to work by taking out the -source argument. For some reason the validator is reading in -source as the file name, and not the file name itself.
Mark Iantorno (Jun 16 2020 at 14:03):
if you run java -jar <path_to_the_jar> <path_to_your_file> -ig https://docs.ehealth.sundhed.dk/latest/ig/package.tgz
Mark Iantorno (Jun 16 2020 at 14:03):
it works and produces the proper output
Mark Iantorno (Jun 16 2020 at 14:03):
java -jar org.hl7.fhir.validation.cli/target/org.hl7.fhir.validation.cli-5.0.7-SNAPSHOT.jar org.hl7.fhir.validation.cli/target/params.json -ig https://docs.ehealth.sundhed.dk/latest/ig/package.tgz
FHIR Validation tool Version 5.0.7-SNAPSHOT (Git# 1f0419b82255). Built 2020-06-11T17:02:55.58-04:00 (4 days old)
Detected Java version: 1.8.0_202 from /home/mark/.sdkman/candidates/java/8.0.202-zulu/jre on amd64 (64bit). 7136MB available
Arguments: org.hl7.fhir.validation.cli/target/params.json -ig https://docs.ehealth.sundhed.dk/latest/ig/package.tgz
Directories: Current = /home/mark/Documents/Projects/FHIR/org.hl7.fhir.core, Package Cache = /home/mark/.fhir/packages
.. FHIR Version current, definitions from hl7.fhir.r5.core#current
.. connect to tx server @ http://tx.fhir.org
(vcurrent)
+ .. load IG from https://docs.ehealth.sundhed.dk/latest/ig/package.tgz
.. validate [org.hl7.fhir.validation.cli/target/params.json]
*FAILURE* validating org.hl7.fhir.validation.cli/target/params.json: error:5 warn:1 info:1
Error @ Parameters.parameter[0].resource (line 63, col24) : Unrecognised property '@reasonCode'
Error @ Parameters.parameter[0].resource.ofType(Communication).payload[0] (line 74, col12) : Profile http://ehealth.sundhed.dk/fhir/StructureDefinition/ehealth-message, Element 'Parameters.parameter[0].resource.ofType(Communication).payload[0].content[x]': minimum required = 1, but only found 0
Error @ Parameters.parameter[0].resource.ofType(Communication).payload[0] (line 74, col12) : Profile http://ehealth.sundhed.dk/fhir/StructureDefinition/ehealth-message, Element 'Parameters.parameter[0].resource.ofType(Communication).payload[0].content[x][contentString]': minimum required = 1, but only found 0
Error @ Parameters.parameter[0].resource.ofType(Communication).payload[0] (line 74, col12) : Profile http://hl7.org/fhir/StructureDefinition/Communication, Element 'Parameters.parameter[0].resource.ofType(Communication).payload[0].content[x]': minimum required = 1, but only found 0
Error @ Parameters.parameter[0].resource.payload[0] (line 76, col12) : Unrecognised property '@contentString'
Information @ Parameters.parameter[0].resource.ofType(Communication).medium[0] (line 50, col12) : This element does not match any known slice defined in the profile http://ehealth.sundhed.dk/fhir/StructureDefinition/ehealth-message
Warning @ Parameters.parameter[0].resource.ofType(Communication).medium[0] (line 50, col12) : ValueSet http://hl7.org/fhir/ValueSet/v3-ParticipationMode not found by validator
Mark Iantorno (Jun 16 2020 at 14:04):
So, use that as a workaround for now, but I'll look at why the -source arg is messing everything up right now
Mark Iantorno (Jun 16 2020 at 14:54):
@Jens Villadsen So, it's actually working as intended.
Mark Iantorno (Jun 16 2020 at 14:54):
If you look at the documentation here: https://confluence.hl7.org/display/FHIR/Using+the+FHIR+Validator
Mark Iantorno (Jun 16 2020 at 14:55):
There is no -source
tag
Mark Iantorno (Jun 16 2020 at 14:55):
you just list the input files as parameters, without any identifier
Mark Iantorno (Jun 16 2020 at 14:56):
When you included the -source
param, it caused the cli to search for a file named "-source", that's why you got the java.io.IOException: File -source does not exist
exception
Mark Iantorno (Jun 16 2020 at 14:56):
Just don't include the -source flag and you're golden
Mark Iantorno (Jun 16 2020 at 14:57):
Please let me know if you have any other questions.
Jens Villadsen (Jun 16 2020 at 15:07):
Right, copy that, thx
Jens Villadsen (Jun 16 2020 at 15:07):
Makes sense
Jens Villadsen (Jun 16 2020 at 15:08):
Guess I've been around docker too much lately and got used to tagging my arguments
Jens Villadsen (Jun 16 2020 at 15:09):
Maybe this is a feature request instead then
Jens Villadsen (Jun 16 2020 at 15:09):
Most cli tools (at least on *nix) tags their inputs
Mark Iantorno (Jun 16 2020 at 15:54):
:ok:
Mark Iantorno (Jun 16 2020 at 15:54):
Let me know if you have any other issues
Grahame Grieve (Jun 16 2020 at 17:30):
@Mark Iantorno maybe if we can't find a file and the name we can't find looks like a parameter that we don't recognise, we can be smart in the error message
Mark Iantorno (Jun 16 2020 at 17:31):
so filter for if the 'filename' starts with '-'
Mark Iantorno (Jun 16 2020 at 17:32):
I'll add a more verbose output for now, one that actually says what's going on outside of a stack trace
Grahame Grieve (Jun 16 2020 at 17:32):
y. not in how things work, but in the error message - something like 'no file -source, and it's not a parameter we recognise'
Mark Iantorno (Jun 16 2020 at 17:38):
okay, adding it now
Mark Iantorno (Jun 16 2020 at 18:09):
@Grahame Grieve how is this for a more verbose output:
Mark Iantorno (Jun 16 2020 at 18:09):
Directories: Current = /home/mark/Documents/Projects/FHIR/org.hl7.fhir.core, Package Cache = /home/mark/.fhir/packages
.. FHIR Version current, definitions from hl7.fhir.r5.core#current
.. connect to tx server @ http://tx.fhir.org
(vcurrent)
+ .. load IG from https://docs.ehealth.sundhed.dk/latest/ig/package.tgz
.. validate [-source, org.hl7.fhir.validation.cli/target/params.json]
**********
* The file name you passed in, "-source", doesn't exist on the local filesystem.
* Please verify that this is valid file location.
**********
Exception in thread "main" java.io.IOException: File -source does not exist
at org.hl7.fhir.validation.ValidationEngine.handleSource(ValidationEngine.java:1076)
at org.hl7.fhir.validation.ValidationEngine.handleSources(ValidationEngine.java:1048)
at org.hl7.fhir.validation.ValidationEngine.validate(ValidationEngine.java:1008)
at org.hl7.fhir.validation.cli.services.ValidationService.validateSources(ValidationService.java:54)
at org.hl7.fhir.validation.Validator.main(Validator.java:202)
Grahame Grieve (Jun 16 2020 at 18:11):
that works for me
Mark Iantorno (Jun 16 2020 at 18:11):
ok i'll throw up a quick PR
Mark Iantorno (Jun 16 2020 at 18:12):
Should work on both cli and non cli implementations, I use both System.condole().prinf, and System.out.println depending on where it's run from
Jens Villadsen (Jun 23 2020 at 09:44):
ok - another thing @Mark Iantorno :
java -jar org.hl7.fhir.validator.jar ./comm.json -ig ~/gitlab/implementationguide/resources/
FHIR Validation tool Version 5.0.7-SNAPSHOT (Git# 6bc790d98b04). Built 2020-06-07T08:35:37.25+10:00 (16 days old)
Detected Java version: 11.0.7 from /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home on x86_64 (64bit). 4096MB available
Arguments: ./comm.json -ig /Users/jvi/gitlab/implementationguide/resources/
Directories: Current = /Users/jvi/Downloads, Package Cache = /Users/jvi/.fhir/packages
.. FHIR Version current, definitions from hl7.fhir.r5.core#current
.. connect to tx server @ http://tx.fhir.org
(vcurrent)
+ .. load IG from /Users/jvi/gitlab/implementationguide/resources/
Exception in thread "main" java.io.FileNotFoundException: /Users/jvi/gitlab/implementationguide/resources/structuredefinition (Is a directory)
at java.base/java.io.FileInputStream.open0(Native Method)
at java.base/java.io.FileInputStream.open(FileInputStream.java:219)
at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157)
at org.hl7.fhir.utilities.TextFile.fileToBytes(TextFile.java:199)
at org.hl7.fhir.validation.ValidationEngine.checkIsResource(ValidationEngine.java:709)
at org.hl7.fhir.validation.ValidationEngine.scanDirectory(ValidationEngine.java:558)
at org.hl7.fhir.validation.ValidationEngine.loadIgSource(ValidationEngine.java:464)
at org.hl7.fhir.validation.ValidationEngine.loadIg(ValidationEngine.java:742)
at org.hl7.fhir.validation.cli.services.ValidationService.getValidator(ValidationService.java:185)
at org.hl7.fhir.validation.Validator.main(Validator.java:175)
Whats the problem here? The doc says:
-ig [package|file|folder|url]: an IG or profile definition to load. Can be
the URL of an implementation guide or a package ([id]-[ver]) for
a built implementation guide or a local folder that contains a
set of conformance resources.
No default value. This parameter can appear any number of times
I thought I just passed a folder containing the conformance resources of an IG - but apparently not?
Jens Villadsen (Jun 23 2020 at 09:51):
wait ... seems like a bug on my side ...
Grahame Grieve (Jun 23 2020 at 11:44):
what happens if you drop the trailing slash?
Jens Villadsen (Jun 23 2020 at 12:21):
The contents of the IG was not generated ... Apparently this is the kind of error the validator throws if it cannot find any conformance resources. You can reproduce it by pointing it to any other folder. @Mark Iantorno - feature request: make it cough up a bit differently, please ;)
Jens Villadsen (Jun 23 2020 at 12:23):
I've found another bug. Take a look at the following:
java -jar org.hl7.fhir.validator.jar ./comm.xml -ig https://docs.ehealth.sundhed.dk/latest/ig/package.tgz
FHIR Validation tool Version 5.0.7-SNAPSHOT (Git# 6bc790d98b04). Built 2020-06-07T08:35:37.25+10:00 (16 days old)
Detected Java version: 11.0.7 from /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home on x86_64 (64bit). 4096MB available
Arguments: ./comm.xml -ig https://docs.ehealth.sundhed.dk/latest/ig/package.tgz
Directories: Current = /Users/jvi/Downloads, Package Cache = /Users/jvi/.fhir/packages
.. FHIR Version current, definitions from hl7.fhir.r5.core#current
.. connect to tx server @ http://tx.fhir.org
(vcurrent)
+ .. load IG from https://docs.ehealth.sundhed.dk/latest/ig/package.tgz
.. validate [./comm.xml]
Validation Infrastructure fail validating ./comm.xml: Unable to find type string for element contentString with path Communication.payload.content[x]
Exception in thread "main" org.hl7.fhir.exceptions.FHIRException: Unable to find type string for element contentString with path Communication.payload.content[x]
at org.hl7.fhir.r5.elementmodel.Property.getChildProperties(Property.java:334)
at org.hl7.fhir.r5.elementmodel.XmlParser.parseChildren(XmlParser.java:258)
at org.hl7.fhir.r5.elementmodel.XmlParser.parseChildren(XmlParser.java:369)
at org.hl7.fhir.r5.elementmodel.XmlParser.parseChildren(XmlParser.java:369)
at org.hl7.fhir.r5.elementmodel.XmlParser.parse(XmlParser.java:199)
at org.hl7.fhir.r5.elementmodel.XmlParser.parse(XmlParser.java:183)
at org.hl7.fhir.r5.elementmodel.XmlParser.parse(XmlParser.java:153)
at org.hl7.fhir.validation.instance.InstanceValidator.validate(InstanceValidator.java:514)
at org.hl7.fhir.validation.ValidationEngine.validate(ValidationEngine.java:1107)
at org.hl7.fhir.validation.ValidationEngine.validate(ValidationEngine.java:1014)
at org.hl7.fhir.validation.cli.services.ValidationService.validateSources(ValidationService.java:54)
at org.hl7.fhir.validation.Validator.main(Validator.java:202)
jvi@Jenss-MacBook-Pro-2 Downloads % java -jar org.hl7.fhir.validator.jar ./comm.json -ig https://docs.ehealth.sundhed.dk/latest/ig/package.tgz
FHIR Validation tool Version 5.0.7-SNAPSHOT (Git# 6bc790d98b04). Built 2020-06-07T08:35:37.25+10:00 (16 days old)
Detected Java version: 11.0.7 from /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home on x86_64 (64bit). 4096MB available
Arguments: ./comm.json -ig https://docs.ehealth.sundhed.dk/latest/ig/package.tgz
Directories: Current = /Users/jvi/Downloads, Package Cache = /Users/jvi/.fhir/packages
.. FHIR Version current, definitions from hl7.fhir.r5.core#current
.. connect to tx server @ http://tx.fhir.org
(vcurrent)
+ .. load IG from https://docs.ehealth.sundhed.dk/latest/ig/package.tgz
.. validate [./comm.json]
*FAILURE* validating ./comm.json: error:5 warn:1 info:1
Error @ Communication (line 58, col17) : Unrecognised property '@reasonCode'
Error @ Communication.payload[0] (line 69, col4) : Profile http://ehealth.sundhed.dk/fhir/StructureDefinition/ehealth-message, Element 'Communication.payload[0].content[x]': minimum required = 1, but only found 0
Error @ Communication.payload[0] (line 69, col4) : Profile http://ehealth.sundhed.dk/fhir/StructureDefinition/ehealth-message, Element 'Communication.payload[0].content[x][contentString]': minimum required = 1, but only found 0
Error @ Communication.payload[0] (line 69, col4) : Profile http://hl7.org/fhir/StructureDefinition/Communication, Element 'Communication.payload[0].content[x]': minimum required = 1, but only found 0
Error @ Communication.payload[0] (line 71, col4) : Unrecognised property '@contentString'
Information @ Communication.medium[0] (line 45, col4) : This element does not match any known slice defined in the profile http://ehealth.sundhed.dk/fhir/StructureDefinition/ehealth-message
Warning @ Communication.medium[0] (line 45, col4) : ValueSet http://hl7.org/fhir/ValueSet/v3-ParticipationMode not found by validator
Jens Villadsen (Jun 23 2020 at 12:25):
(@Grahame Grieve I'm working on providing you with the test case we talked about last week)
Jens Villadsen (Jun 23 2020 at 12:28):
1) It seems like there's a bug somewhere. The attached files should be equal to each other - its just different formats, but the XML version seems to be a problem for the validator
2) I don't understand what the problem is in the use of payload in the resource. The profile narrows down payload to be of type string content- that's it. Why the validator chokes is a mystery to me
Mark Iantorno (Jun 23 2020 at 13:25):
Alright, I'll take a look into this today. I'm just working on another task first.
Jens Villadsen (Jun 23 2020 at 16:47):
And btw - its not directly related to the profile as far as I can tell
Jens Villadsen (Jun 24 2020 at 11:44):
@Grahame Grieve ..... hmmmm ... looks like your work when you prepared for r5: https://github.com/hapifhir/org.hl7.fhir.core/blame/344d778a87d446f36717c9f895a854eec762fbb6/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/Property.java#L334
Jens Villadsen (Jun 24 2020 at 20:23):
@Mark Iantorno have you had the chance to have a look?
Mark Iantorno (Jun 24 2020 at 20:38):
Sorry I have not. I will do this tomorrow. I am just finishing up another task.
Jens Villadsen (Jun 24 2020 at 20:51):
@Grahame Grieve as far as I can see, the test case 'slicing-types-by-string' should cover it - but simply running the following:
java -jar org.hl7.fhir.validator.jar comm.json
FHIR Validation tool Version 5.0.7-SNAPSHOT (Git# 6bc790d98b04). Built 2020-06-07T08:35:37.25+10:00 (17 days old)
Detected Java version: 11.0.7 from /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home on x86_64 (64bit). 4096MB available
Arguments: comm.json
Directories: Current = /Users/jkv/Downloads, Package Cache = /Users/jkv/.fhir/packages
.. FHIR Version current, definitions from hl7.fhir.r5.core#current
.. connect to tx server @ http://tx.fhir.org
(vcurrent)
.. validate [comm.json]
*FAILURE* validating comm.json: error:4 warn:0 info:0
Error @ Communication.payload[0] (line 4, col5) : Profile http://hl7.org/fhir/StructureDefinition/Communication, Element 'Communication.payload[0].content[x]': minimum required = 1, but only found 0
Error @ Communication.payload[0] (line 6, col5) : Unrecognised property '@contentString'
Error @ Communication.payload[1].content.ofType(Attachment) (line 10, col4) : Attachments have data and/or url, or else must have either contentType and/oor language
Error @ Communication.payload[2].content.ofType(Attachment) (line 15, col4) : Attachments have data and/or url, or else must have either contentType and/oor language
- with contents of the file 'comm.json' (copied from the test case):
{
"resourceType": "Communication",
"payload": [
{
"contentString": "test"
},
{
"contentAttachment": {
"title": "some title"
}
},
{
"contentAttachment": {
"title": "some other title"
}
}
],
"status": "in-progress"
}
gives an error on the payload: ' Error @ Communication.payload[0] (line 6, col5) : Unrecognised property '@contentString''
Grahame Grieve (Jun 24 2020 at 22:53):
well, it is unrecognised content. That's because you didn't tell the validator what version it is, and it defaults to R5. contentString is not valid in R5 but is valid in R3. So -version 3.0 @Jens Villadsen
Jens Villadsen (Jun 25 2020 at 06:23):
Jens Villadsen (Jun 25 2020 at 06:26):
@Grahame Grieve that part makes sense - however that does not explain why it fails when I point it to an IG that is based on STU3. Shouldn't that be setting the FHIR version?
Jens Villadsen (Jun 25 2020 at 06:28):
I mean, its errorprone if you can pass an IG that is bound to one version and then you explicitly can throw another version at the validator.
Grahame Grieve (Jun 25 2020 at 06:45):
it is error prone and fixing it is on my wish list but it's a total redesign
Jens Villadsen (Jun 25 2020 at 06:46):
because you need to reverse the order for getting the version?
Grahame Grieve (Jun 25 2020 at 06:47):
right. the very first thing is setting the version. I'd have to totally redesign the entire validator and hapi context framework to load the version late
Jens Villadsen (Jun 25 2020 at 06:49):
because fetching the IG (if specified) it not fetched up front?
Grahame Grieve (Jun 25 2020 at 06:49):
you can specify multiple IGs and validate against multiple versions. There's lots of great things about the way it works now. You just can't default to the IG version if only one is specified
Jens Villadsen (Jun 25 2020 at 06:50):
its a feature that you can specify multiple IG's that are allowed to differ in the FHIR version?
Grahame Grieve (Jun 25 2020 at 06:51):
yes indeed it is though it's not a feature that's good for beginners.
Jens Villadsen (Jun 25 2020 at 07:12):
right - I can certainly see the benefit of verifying whether a given resource is allowed across multiple IG's. However shouldn't one make suchs users aware with eg. an explicit 'versionVariance' parameter? It could provide users with a false hope of conformance or are there already output that explains that a given resource is actually verified against multiple versions?
Grahame Grieve (Jun 25 2020 at 07:32):
I'm not defending the current user experience
Last updated: Apr 12 2022 at 19:14 UTC