Validation.jar failing to handle structuredefinition that is a differential

I am utilizing the validation.jar (org.hl7.fhir.validator.jar) in an attempt to validate against a differential custom structurdefinition… via the following

 java  -jar org.hl7.fhir.validator.jar patient-example.xml -defn validation-min.xml.zip -profile MyPatient.structuredefinition.xml

And I wind up with an IndexOutOfBoundException: Index:0 Size:0, at InstanceValidator.java:2186)

The custom StructureDefinition looks like:

<?xml version="1.0" encoding="utf-8"?>
<StructureDefinition xmlns="http://hl7.org/fhir">
  <meta>
   <lastUpdated value="2017-01-23T14:15:06.425-05:00" />
  </meta>
 <name value="MyPatient" />
 <status value="draft" />
 <date value="2017-01-23T14:12:46.7975804-05:00" />
 <kind value="resource" />
 <constrainedType value="Patient" />
 <abstract value="false" />
  <base value="http://hl7.org/fhir/StructureDefinition/Patient" />
 <differential>
   <element>
     <path value="Patient" />
   </element>
   <element>
     <path value="Patient.gender" />
     <min value="1" />
   </element>
 </differential>
</StructureDefinition>

If I run the program against he default values, it properly runs:

java -jar org.hl7.fhir.validator.jar patient-example.xml -defn validation-min.xml.zip -profile http://hl7.org/fhir/StructureDefinition/daf-patient

If I save a version of my structural definition including a snapshop, and differential and pass that in, the validation works, but only against the snapshot, it completely ignores the differential definition that is in the file… So I can modify the snapshop and get the validation I want, but I don’t get it from the differential.

I don’t understand why the differential only structuredefinition is not working… and throws the error… I assume it is some sort of parsing error, but have no idea what… and I am further confused why when I pass in a full structuredefinition with snapshot and differential, that the differential is completely ignored.

Can someone offer some help? I really would like to utilize differentials, but unless I can figure this out the only option I have is to take snapshots of the base and tweak them to validate what I want to validate which is very bad form to say the least.

Try using the most recent version of the validator - which can be found here:
http://build.fhir.org/validator.zip

You shouldn’t need to specify -defn anymore.

If the problem still exists, please raise this issue in a change request (link at the bottom of every page in the FHIR spec) and attach your sample instance and profile.

Lloyd,

Looks like there is something wrong with the latest build, looks like it looks for the validator pack at buid.fhir.org which doesn’t exist instead of build.fhir.org

Yup, that was broken. Fix committed. It should be available in the next 30-60 minutes.

That seems to be better… but I am getting an odd error stating the namespace referenced in the

But I am still having an issue… it seems like its not liking my patient-exmample xml’s XMLNS setting or something as the error is bombing at the end of the first line of my patient-example xml which is :

 <Patient xmlns="http://hl7.org/fhir">

My testdiff.xml structuraldefinition is also set to the “hl7.org/fhir” namespace

<StructureDefinition xmlns="http://hl7.org/fhir">

So, I assume this is some sort of namespace or other setting thing, that is not correct, but I am not sure what.

java -Djava.ext.dirs=. -jar org.hl7.fhir.validator.jar patient-example.xml -profile testdiff.xml
… load FHIR from
… connect to tx server @
(vnull-null)
… validate
Terminology server: Check for supported code systems for http://hl7.org/fhir/patient-contact-relationship
FAILURE validating patient-example.xml: error:1 warn:2 info:0
Error @ Patient (line 1, col38) : StructureDefinition reference “testdiff.xml” could not be resolved

I attempted to change the -profile value to a fully qualified URI since using filename just seemed to throw the same error even if I just fully made up a filename (file that doesn’t exist on the disk…

So changing -profile to be -profile file:///users/myaccount/fhir/validation/mystructdef.xml

and set the URL value inside the structuraldefinition as well… and I wind up with

(vnull-null)

… validate
Exception in thread “main” java.lang.Error: org.hl7.fhir.exceptions.FHIRException: fetching org.hl7.fhir.dstu3.model.StructureDefinition not done yet for URI ‘file:///Users/pecks2/Downloads/validator3/MyPatient.xml’
at org.hl7.fhir.dstu3.context.SimpleWorkerContext.fetchResource(SimpleWorkerContext.java:361)
at org.hl7.fhir.dstu3.validation.InstanceValidator$ResourceProfiles.addProfile(InstanceValidator.java:224)
at org.hl7.fhir.dstu3.validation.InstanceValidator$ResourceProfiles.addProfiles(InstanceValidator.java:220)
at org.hl7.fhir.dstu3.validation.InstanceValidator.validateResource(InstanceValidator.java:3353)
at org.hl7.fhir.dstu3.validation.InstanceValidator.validate(InstanceValidator.java:512)
at org.hl7.fhir.dstu3.validation.InstanceValidator.validate(InstanceValidator.java:362)
at org.hl7.fhir.dstu3.validation.ValidationEngine.validate(ValidationEngine.java:473)
at org.hl7.fhir.dstu3.validation.ValidationEngine.validate(ValidationEngine.java:401)
at org.hl7.fhir.dstu3.validation.Validator.main(Validator.java:248)
Caused by: org.hl7.fhir.exceptions.FHIRException: fetching org.hl7.fhir.dstu3.model.StructureDefinition not done yet for URI ‘file:///Users/pecks2/Downloads/validator3/MyPatient.xml’
at org.hl7.fhir.dstu3.context.SimpleWorkerContext.fetchResourceWithException(SimpleWorkerContext.java:408)
at org.hl7.fhir.dstu3.context.SimpleWorkerContext.fetchResource(SimpleWorkerContext.java:359)
… 8 more

I am beyond perplexed, has anyone ever successfully validated against a custom structure definition that is a differential?

Since defining the file as a full URI (FILE://) seemed to throw all sorts of errors, and the raw file just being passed doesn’t seem to get picked up, I put the file onto an actual web server on my machine… but that too just results in the same error, as if I just passed in the filename:

 $ java -Djava.ext.dirs=. -jar org.hl7.fhir.validator.jar patient-example.xml  -profile http://localhost/MyPatient.xml
  .. load FHIR from http://build.fhir.org/
  .. connect to tx server @ http://fhir3.healthintersections.com.au/open
    (vnull-null)
  .. validate
Terminology server: Check for supported code systems for http://hl7.org/fhir/patient-contact-relationship
*FAILURE* validating patient-example.xml:  error:1 warn:2 info:0
  Error @ Patient (line 1, col38) : StructureDefinition reference "http://localhost/MyPatient.xml" could not be resolved
  Warning @ Patient.contact.relationship (line 121, col19) : None of the codes provided are in the value set     http://hl7.org/fhir/ValueSet/v2-0131 (http://hl7.org/fhir/ValueSet/v2-0131, and a code should come from this value set unless it has no suitable code) (codes = http://hl7.org/fhir/patient-contact-relationship#partner)
  Warning @ Patient.contact.relationship.coding (line 122, col15) : Unknown Code System http://hl7.org/fhir/patient-contact-relationship

Just passing in the local filename:

$ java -Djava.ext.dirs=. -jar org.hl7.fhir.validator.jar patient-example.xml  -profile MyPatient.xml
  .. load FHIR from http://build.fhir.org/
  .. connect to tx server @ http://fhir3.healthintersections.com.au/open
   (vnull-null)
 .. validate
Terminology server: Check for supported code systems for http://hl7.org/fhir/patient-contact-relationship
*FAILURE* validating patient-example.xml:  error:1 warn:2 info:0
  Error @ Patient (line 1, col38) : StructureDefinition reference "MyPatient.xml" could not be resolved
  Warning @ Patient.contact.relationship (line 121, col19) : None of the codes provided are in the value set    http://hl7.org/fhir/ValueSet/v2-0131 (http://hl7.org/fhir/ValueSet/v2-0131, and a code should come from this value set unless it has no suitable code) (codes = http://hl7.org/fhir/patient-contact-relationship#partner)
  Warning @ Patient.contact.relationship.coding (line 122, col15) : Unknown Code System http://hl7.org/fhir/patient-contact-relationship

Where is the change request link? I do not see it.

“Propose a change” - bottom of each page in the spec.