FHIR Chat · Validate MedMij BgZ resources e.g. NL Patient · netherlands

Stream: netherlands

Topic: Validate MedMij BgZ resources e.g. NL Patient


view this post on Zulip Ted Vinke (Jan 21 2020 at 15:19):

I'm pretty new to the MedMij, Nictiz and FHIR standards and I'm trying to be able to get a grasp on coding systems, value sets and validating resources.

Consider I have a FHIR STU3 Patient.json(example "Irma Jongeneel-de Haas" from https://simplifier.net/nictizstu3-zib2017/patient-example-duplicate-12) which, after reading https://confluence.hl7.org/display/FHIR/Using+the+FHIR+Validator, am able to validate like this:

:boom: Default FHIR STU3 validation fails:

tvinke@localhost ~/projects/medmij (master) $ java -jar org.hl7.fhir.validator.jar Patient.json -version 3.0
FHIR Validation tool Version 4.1.21-SNAPSHOT (Git# 89592da490df). Built 2019-12-09T17:47:19.708+11:00 (43 days old)
Detected Java version: 1.8.0_121 from /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre on x86_64 (64bit). 3641MB available
Arguments: Patient.json -version 3.0
Directories: Current = /Users/tvinke/projects/medmij, Package Cache = /Users/tvinke/.fhir/packages
  .. FHIR Version 3.0, definitions from hl7.fhir.r3.core#3.0.2
  .. connect to tx server @ http://tx.fhir.org
    (v3.0.2)
  .. validate [Patient.json]
Success...validating Patient.json:  error:0 warn:3 info:1
  Information @ Patient.address[0].extension[0] (line 91, col18) : Unknown extension http://fhir.nl/fhir/StructureDefinition/nl-core-address-official
  Warning @ Patient.contact[0].relationship[0] (line 138, col18) : 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 = urn:oid:2.16.840.1.113883.2.4.3.11.22.472#1)
  Warning @ Patient.contact[0].relationship[1] (line 147, col18) : 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/v3/RoleCode#HUSB)
  Warning @ Patient.meta.profile[0] (line 1, col2) : StructureDefinition reference "http://fhir.nl/fhir/StructureDefinition/nl-core-patient" could not be resolved

Assumption: I've probably got all these errors because the JSON contains all Dutch-specific extensions right?

Since it's not just an international FHIR patient, I would like to validate it as valid "MedMij" patient.
Is a valid "MedMij" patient the same as a valid Nictiz https://simplifier.net/nictizstu3-zib2017/nl-core-patient ?

If so, how would I go about validating it according to nl-core-patient? I saw that the validator could be pointed to a profile. Unfortunately, the following fails.

:boom: Validating with -profile http://fhir.nl/fhir/StructureDefinition/nl-core-patient parameter fails:

tvinke@localhost ~/projects/medmij (master) $ java -jar org.hl7.fhir.validator.jar Patient.json -version 3.0 -profile http://fhir.nl/fhir/StructureDefinition/nl-core-patient
FHIR Validation tool Version 4.1.21-SNAPSHOT (Git# 89592da490df). Built 2019-12-09T17:47:19.708+11:00 (43 days old)
Detected Java version: 1.8.0_121 from /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre on x86_64 (64bit). 3641MB available
Arguments: Patient.json -version 3.0 -profile http://fhir.nl/fhir/StructureDefinition/nl-core-patient
Directories: Current = /Users/tvinke/projects/medmij, Package Cache = /Users/tvinke/.fhir/packages
  .. FHIR Version 3.0, definitions from hl7.fhir.r3.core#3.0.2
  .. connect to tx server @ http://tx.fhir.org
    (v3.0.2)
Fetch Profile from http://fhir.nl/fhir/StructureDefinition/nl-core-patient
Exception in thread "main" org.hl7.fhir.exceptions.FHIRException: unable to determine format
    at org.hl7.fhir.r5.formats.FormatUtilities.determineFormat(FormatUtilities.java:143)
    at org.hl7.fhir.r5.formats.FormatUtilities.determineFormat(FormatUtilities.java:131)
    at org.hl7.fhir.r5.validation.ValidationEngine.loadProfile(ValidationEngine.java:779)
    at org.hl7.fhir.r5.validation.Validator.main(Validator.java:630)

Ok, the validation wiki page talks about also specifying an "loading an implementation guide". Luckily I saw a "package" nictiz.fhir.nl.stu3.zib2017 is available on https://simplifier.net/packages/nictiz.fhir.nl.stu3.zib2017/1.3.3 so I tried additionally specifying that name with the -ig parameter -- but it fails:

:boom: Validating with -ig nictiz.fhir.nl.stu3.zib2017 -profile http://fhir.nl/fhir/StructureDefinition/nl-core-patient parameter fails:

tvinke@localhost ~/projects/medmij (master) $ java -jar org.hl7.fhir.validator.jar Patient.json -version 3.0 -ig nictiz.fhir.nl.stu3.zib2017 -profile http://fhir.nl/fhir/StructureDefinition/nl-core-patient
FHIR Validation tool Version 4.1.21-SNAPSHOT (Git# 89592da490df). Built 2019-12-09T17:47:19.708+11:00 (43 days old)
Detected Java version: 1.8.0_121 from /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre on x86_64 (64bit). 3641MB available
Arguments: Patient.json -version 3.0 -ig nictiz.fhir.nl.stu3.zib2017 -profile http://fhir.nl/fhir/StructureDefinition/nl-core-patient
Directories: Current = /Users/tvinke/projects/medmij, Package Cache = /Users/tvinke/.fhir/packages
  .. FHIR Version 3.0, definitions from hl7.fhir.r3.core#3.0.2
  .. connect to tx server @ http://tx.fhir.org
    (v3.0.2)
+  .. load IG from nictiz.fhir.nl.stu3.zib2017
Exception in thread "main" org.hl7.fhir.exceptions.FHIRException: Unable to resolve the package 'nictiz.fhir.nl.stu3.zib2017'
    at org.hl7.fhir.utilities.cache.PackageCacheManager.loadPackage(PackageCacheManager.java:605)
    at org.hl7.fhir.r5.validation.ValidationEngine.resolvePackage(ValidationEngine.java:694)
    at org.hl7.fhir.r5.validation.ValidationEngine.fetchByPackage(ValidationEngine.java:683)
    at org.hl7.fhir.r5.validation.ValidationEngine.loadIgSource(ValidationEngine.java:522)
    at org.hl7.fhir.r5.validation.ValidationEngine.loadIg(ValidationEngine.java:786)
    at org.hl7.fhir.r5.validation.Validator.main(Validator.java:567)

3rd strike. I saw on the validator page that the -ig parameter could also point to a directory!

Downloading profiles & value sets manually (as Henk-Jan Meijer did in "Validation of MedMij example") seems error-prone, so tried to download the entire package nictiz.fhir.nl.stu3.zib2017 with the instructions using NPM:

tvinke@localhost ~/projects/medmij (master) $ npm --registry https://packages.simplifier.net install nictiz.fhir.nl.stu3.zib2017@1.3.3
npm WARN saveError ENOENT: no such file or directory, open '/Users/tvinke/projects/medmij/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/Users/tvinke/projects/medmij/package.json'
npm WARN medmij No description
npm WARN medmij No repository field.
npm WARN medmij No README data
npm WARN medmij No license field.

+ nictiz.fhir.nl.stu3.zib2017@1.3.3
added 1 package from 1 contributor in 0.84s

(It's just that I happened to have NPM already on my Macbook, instead of this Torinox.)

Result, a directory in a node_modules with 500+ JSON files:

tvinke@localhost ~/projects/medmij (master) $ tree node_modules/
node_modules/
└── nictiz.fhir.nl.stu3.zib2017
    ├── AanvullendeGebruiksinstructie-2.16.840.1.113883.2.4.3.11.60.20.77.11.9--20160407000000.json
    ├── AanvullendeWensenCodelijst-2.16.840.1.113883.2.4.3.11.60.40.2.9.10.1--20171231000000.json
    ...
    ├── zib-Vaccination.json
    ├── zib-VaccinationRecommendation-OrderStatus.json
    └── zib-VaccinationRecommendation.json

1 directory, 548 files

:boom: Using the -ig node_modules/nictiz.fhir.nl.stu3.zib2017 -profile http://fhir.nl/fhir/StructureDefinition/nl-core-patient parameter pointing to the directory does seem to process its files ( :+1: ) but all kinds of errors about the files themselves it seems:

...
* load file: example-zib-NursingIntervention.json - ignored due to error: Unknown resource Procedure
* load file: medmij-bgz-fhir3-0-1-coverage-ts-02.json - ignored due to error: Unknown resource Coverage
  .. validate [Patient.json] against [http://fhir.nl/fhir/StructureDefinition/nl-core-patient]
Unable to generate snapshot for http://nictiz.nl/fhir/StructureDefinition/zib-InstructionsForUse: Error at path Dosage.dose[x]: Slice name must be 'doseQuantity' but is 'DoseQuantity'
Unable to generate snapshot for zib-AdministrationAgreement from MedicationDispense because Error at path Dosage.dose[x]: Slice name must be 'doseQuantity' but is 'DoseQuantity'
org.hl7.fhir.exceptions.FHIRException: Error at path Dosage.dose[x]: Slice name must be 'doseQuantity' but is 'DoseQuantity'
    at org.hl7.fhir.r5.conformance.ProfileUtilities.processPaths(ProfileUtilities.java:867)
    at org.hl7.fhir.r5.conformance.ProfileUtilities.generateSnapshot(ProfileUtilities.java:472)
    at org.hl7.fhir.r5.conformance.ProfileUtilities.processPaths(ProfileUtilities.java:700)
    at org.hl7.fhir.r5.conformance.ProfileUtilities.generateSnapshot(ProfileUtilities.java:472)
    at org.hl7.fhir.r5.context.SimpleWorkerContext.generateSnapshot(SimpleWorkerContext.java:616)
    at org.hl7.fhir.r5.context.SimpleWorkerContext.allStructures(SimpleWorkerContext.java:479)
    at org.hl7.fhir.r5.validation.ValidationEngine.prepare(ValidationEngine.java:1326)
    at org.hl7.fhir.r5.validation.Validator.main(Validator.java:652)
mismatch in paths: Observa...
...etc

So I gave up :-)
What would be the correct way to validate a Dutch patient from the command-line?

view this post on Zulip Mirjam Baltus (Jan 22 2020 at 17:10):

Hi @Ted Vinke, I've tried validating with our Torinox command line tool - see https://simplifier.net/downloads/torinox, and get a succes. Torinox is a dotnet core tool, which makes it run cross platform. It uses the validator of the official .NET API for HL7 FHIR. After you have installed the tool, and assuming you have the patient data in a file called patient.json, these are the steps to take:

$ fhir install nictiz.fhir.nl.stu3.zib2017
$ fhir push patient.json
$ fhir validate

view this post on Zulip Ted Vinke (Jan 23 2020 at 08:58):

Hi @Mirjam Baltus, thank you!

I sure hope some user of the Java validator will still be able to give some feedback on its usage. Seems more light-weight and more easy to run validation on any of our development systems since Java has been installed everywhere by default. :blush: but I will give Torinox definitely a try. :+1:

Do you perhaps know who created the Java validator so I can get in touch with the author?

view this post on Zulip Michael van der Zel (Jan 23 2020 at 12:07):

I think Grahame and/or on of the HAPI guys.
Anyhow. I noticed that passing the validation doesnot garantee a valid FHIR json. Especially with the StructureDefinitions and Extensions. I have not gotten my head around it yet.

view this post on Zulip Grahame Grieve (Jan 24 2020 at 06:37):

I'm still reconciling with the dutch medmij definitions. There's some underlying issues that we haven't sorted yet. If you think that validator isn't checking something, please tell me about it

view this post on Zulip Michael van der Zel (Jan 24 2020 at 08:34):

I will let you know the things I have found.

view this post on Zulip Grahame Grieve (Jan 24 2020 at 20:42):

@Alexander Henket I had a spare hour, so I looked at this again. The profile http://nictiz.nl/fhir/StructureDefinition/zib-BodyHeight allows Group in it's target list, but it's a constraint on http://nictiz.nl/fhir/StructureDefinition/zib-VitalSigns (via an intermediate step) which constrains observation.subject to http://fhir.nl/fhir/StructureDefinition/nl-core-patient. This error happens quite a bit

view this post on Zulip Alexander Henket (Jan 27 2020 at 08:19):

@Grahame Grieve Interesting you should call this an error. I thought that it was still under debate how you would interpret that in a multi-type, only one of them is named in a differential with a targetProfile.

  • You can use only this type with this targetProfile (or derived profile thereof). Other types are excluded
  • You must use this this type with this targetProfile (or derived profile thereof). Other types are not constrained.

Is the word out that the former is the correct interpretation? It means you will always need to leave all types in the differential if you want to apply a targetProfile to one of them.

I've filed the issue here: https://bits.nictiz.nl/browse/MM-894 - we are releasing updates on a monthly basis as long as they are backward compatible.

view this post on Zulip Alexander Henket (Jan 27 2020 at 08:44):

@Grahame Grieve Side note: running the java validator on the command line still yields String index out of range: -1

$ java -jar org.hl7.fhir.validator.jar -ig "../GitHub/Nictiz/Nictiz-STU3-Zib2017/Profiles - ZIB 2017" -version 3.0 -recurse -debug STU3-Java/instances/medmij-bgz-fhir3-0-1-labresult-ts-01.xml

FHIR Validation tool Version 4.1.53-SNAPSHOT (Git# ee6e0d90de9b). Built 2020-01-24T17:20:43.54+11:00 (3 days old)
Detected Java version: 1.8.0_121 from /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre on x86_64 (64bit). 3641MB available
Arguments: -ig "../GitHub/Nictiz/Nictiz-STU3-Zib2017/Profiles - ZIB 2017" -version 3.0 -recurse -debug STU3-Java/instances/medmij-bgz-fhir3-0-1-labresult-ts-01.xml
Directories: Current = /Users/ahenket/Development/FHIR, Package Cache = /Users/ahenket/.fhir/packages
  .. FHIR Version 3.0, definitions from hl7.fhir.r3.core#3.0.2
  .. connect to tx server @ http://tx.fhir.org
    (v3.0.2)
+  .. load IG from ../GitHub/Nictiz/Nictiz-STU3-Zib2017/Profiles - ZIB 2017
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -1
    at java.lang.String.substring(String.java:1967)
    at org.hl7.fhir.utilities.Utilities.path(Utilities.java:584)
    at org.hl7.fhir.r5.validation.ValidationEngine.loadIgSource(ValidationEngine.java:504)
    at org.hl7.fhir.r5.validation.ValidationEngine.loadIg(ValidationEngine.java:789)
    at org.hl7.fhir.r5.validation.Validator.main(Validator.java:572)

While running it in Eclipse yields results albeit that I don't understand them. Why does the latest generator give me 50-60 errors like this:

Unable to generate snapshot for zib-MedicationAgreement from MedicationRequest because Profile Zib MedicationAgreement (http://nictiz.nl/fhir/StructureDefinition/zib-MedicationAgreement). Error generating snapshot: Duplicate Element id MedicationRequest.extension:additionalInformation.value[x]:valueCodeableConcept
org.hl7.fhir.exceptions.DefinitionException: Profile Zib MedicationAgreement (http://nictiz.nl/fhir/StructureDefinition/zib-MedicationAgreement). Error generating snapshot: Duplicate Element id MedicationRequest.extension:additionalInformation.value[x]:valueCodeableConcept
    at org.hl7.fhir.r5.context.SimpleWorkerContext.generateSnapshot(SimpleWorkerContext.java:619)
    at org.hl7.fhir.r5.context.SimpleWorkerContext.allStructures(SimpleWorkerContext.java:479)
    at org.hl7.fhir.r5.validation.ValidationEngine.prepare(ValidationEngine.java:1326)
    at org.hl7.fhir.r5.validation.Validator.main(Validator.java:652)

This one above appears to concern a quite common thing we do which is to apply a binding to an extension in the calling profile instead of the extension itself.

view this post on Zulip Grahame Grieve (Jan 27 2020 at 09:22):

I'm still working through the errors as I have time. I don't know what's going on with that one yet.

view this post on Zulip Grahame Grieve (Jan 27 2020 at 09:23):

The definition for targetProfile says:

If any profiles are specified, then the content must conform to at least one of them

which means that this interpretation applies:

You can use only this type with this targetProfile (or derived profile thereof). Other types are excluded

And it must, really, else you can't exclude the other types


Last updated: Apr 12 2022 at 19:14 UTC