HL7®, FHIR® and the flame Design mark are the registered trademarks of Health Level Seven International and are used with permission.
Amsterdam, 14-16 November | @HL7 @FirelyTeam | #fhirdevdays18 | www.fhirdevdays.com
Validating FHIR data
Ewout Kramer
© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.
Goal....
Take away some of the “black magic” of FHIR validation
We can use a tool to create profiles, but what happens under the hood?
Will show StructureDefinition + validation tools
2
© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.
Validation inputs
3
Conformance Resources
StructureDefinition
ValueSet
CodeSystemValidator
Packages
• HL7 International (“core”)
• National
• Your own
Results
OperationOutcome
© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.
ElementDefinition
Whever a tool reads or writes profiles, it reads StructureDefinitions, itself collections of ElementDefinitions
Most important parts: path (the dotted part expressing hierarchy: “Patient.identifier.use”) short/definition min/max (cardinality) fixed/pattern typeRef (base data type of element) binding (fhirpath) invariants4
© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.
Pet project for this session
5
DocumentBundleSD on Bundle
DocumentCompositionSD on Composition
WeightHeightObservationSD on Observation
SectionTitlesValueSet
WeightQuantitySD on Quantity
HeightQuantitySD on Quantity
constrain document sections (“slicing”)
constrain Quantity.value[x]
© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.
WeightQuantity
6
value: 1..1, between 0 and 200comparator: 0..0unit: unchangedsystem: 1..1, fixed to ‘http://unitsofmeasure.org’code: 1..1, fixed to ‘kg’
© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.
Forge XML
7
© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.
Pet project for this session
8
DocumentBundleSD on Bundle
DocumentCompositionSD on Composition
WeightHeightObservationSD on Observation
SectionTitlesValueSet
WeightQuantitySD on Quantity
HeightQuantitySD on Quantity
constrain document sections (“slicing”)
constrain Quantity.value[x]
Determines possible section codes
√ √
© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.
WeightHeightObservation
9
value: 1..1, string OR Quantity
If Quantity, either:WeightQuantity orHeightQuantity
Note: We are using a canonical reference to point to WeightQuantity and HeightQuantity.
© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.
Forge XML
10
How is that canonical reference resolved??
© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.
Try it out in a validator!
Try remove ‘status’ (core: 1..1) Try valueBoolean Change a unit (Quantity.code) to ‘kgs’
Why multiple errors? Try looking at the informational message!
11
© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.
Pet project for this session
12
DocumentBundleSD on Bundle
DocumentCompositionSD on Composition
WeightHeightObservationSD on Observation
SectionTitlesValueSet
WeightQuantitySD on Quantity
HeightQuantitySD on Quantity
constrain document sections (“slicing”)
constrain Quantity.value[x]
Determines possible section codes
√ √
√
© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.
DocumentComposition – Easy bits
13
type: a CodeableConcept with at least one LOINC code 18842-5. May optionally specify other elements like text, version, display...
subject: limit to type Patient
author: limit to type Practitioner
© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.
Forge XML
14
© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.
Pattern...the unloved feature
15
Can even make this ‘*’!
© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.
Try it out in a validator!
Make a reference to another type for Composition.subject Composition.type:
Add another coding. Add <text> element. Take the first coding, add a <version> element. Take the first coding, change the code.
16
© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.
DocumentComposition - Slicing
17
For all sections (1..*)
title: 1..1, max. 20 characters longcode: 1..1, Must come from ValueSet
“SectionTitles”emptyReason: 0..0entry: Must be Observationssection: 0..0 (no subsections)
For sections where code = 8716-3 (1..1)vitalSignscode: 1..1, 8716-3entry: Must be a WeightHeightObservation
For sections where code = 10154-3 (0..1)chiefComplaintscode: 1..1, 10154-3
Other sections are allowed, no additional rules apply.
© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.
Forge XML
18
© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.
Forge XML
19
© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.
Try it out in a validator!
Many any section.title > 20 Duplicate the vital signs section give the first duplicate a section.code of
<system value="http://loinc.org"/><code value="8716-3"/>
Change the slice’s <ordered> to “true”
20
© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.
FhirPath integration
In the slice intro add:
21
© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.
Pet project for this session
22
DocumentBundleSD on Bundle
DocumentCompositionSD on Composition
WeightHeightObservationSD on Observation
SectionTitlesValueSet
WeightQuantitySD on Quantity
HeightQuantitySD on Quantity
constrain document sections (“slicing”)
constrain Quantity.value[x]
Determines possible section codes
√ √
√
√
© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.
Other validation tools
Java validator: https://www.hl7.org/fhir/validation.html
.NET Core cross-platform (“Torinox”): https://simplifier.net/downloads/torinox
In your Simplifier projects, integrated Validation: https://simplifier.net/validate
23
© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.
Questions?
24
© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.
Play along...
Example data, StructureDefinitions & Validator (Windows) can be found at:
https://github.com/ewoutkramer/Furore.Fhir.ValidationDemo/releases
Includes and executable + examples shown in this tutorial.
25
© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.
Extensions and StructureDefs
Extensions are defined using StructureDefinitions In fact, they are constraints on the Extension datatype!
26
Fix this URL to the extension’s url
Limit to just “Boolean” [1..1]
Don’t allow nested extensions
© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.
27
© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.
Validation inputs
28
Conformance Resources
StructureDefinition
ValueSet
CodeSystemValidator
Validator-libraries
Java• JAR• Stand-alone cmdline• Integrated in HAPI• Touchstone
Delphi• Notepad++• Grahame’s server
.NET• NuGet package• Torinox (cmdline)• Simplifier• Windows-tool
Packages
• HL7 International (“core”)
• National
• Your own
Results
OperationOutcome
© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.
Validation inputs
29
Conformance Resources
StructureDefinition
ValueSet
CodeSystemValidator
Validator-libraries
Java• JAR• Stand-alone cmdline• Integrated in HAPI• Touchstone
Delphi• Notepad++• Grahame’s server
.NET• NuGet package• Torinox (cmdline)• Simplifier• Windows-tool
Packages
• HL7 International (“core”)
• National
• Your own
Results
OperationOutcome