Stream: javascript
Topic: Profile(structure definition) validation in javascript
Radha Rajendran (Apr 22 2021 at 05:28):
Hi ..
I am implementing FHIR receiver in Node.js . I am using "FHIR schema" and "ajv npm" for validating JSON structure, Mandatory and data type .
For profiles i can find "Fhirpath.js" is the only option to validate FHIR expressions from elements.
I need to validate other Structure definition features like min, max, fixed, pattern, minValue, maxValue etc.
http://hl7.org/fhir/validation.html - In this link they mentioned schema will cover profile validation too.
So far i could not find how to validate profiles using schema.
Is there any other package available to validate profiles or we need to manually validate each elements available in structure definition ?
Paul Lynch (Apr 22 2021 at 20:35):
The FHIR Validator can validate against a profile. http://hl7.org/fhir/validation.html#jar
Radha Rajendran (Apr 23 2021 at 05:21):
is FHIR validator will support JSON format ? this is jar file . can i use it in Node.js ?
Morten Ernebjerg (Apr 23 2021 at 07:21):
The standard JAR validator supports both XML and JSON (reading the resources from files). You could thus, in theory, write the data you want to validate to file and trigger the JAR from node.js (using, it seems, the spawn()
method). However, it would probably be more elegant to set up a HAPI FHIR server, feed it the profiles you want to validate against, and then call the $validate endpoint via HTTP from node.js.
There is, AFAIK, no existing JS libs that will allow full validation based directly on StructureDefinition. There has been some discussion of generating JSON Schemata from StructureDefinition (though that cannot support all features of profiles) but again, I am not aware of any tools that actually do this.
Eric Prud'hommeaux (Apr 23 2021 at 07:27):
There are a couple implementations (python, js) of JSG (example), which is way less popular than JSON Schema, but more aimed at grammar-based validation.
I wouldn't be surprised if there were some practical use cases it covers (e.g. slicing) that it can support and JSON schema cannot.
Again, not popular, but if folks wanted to run with it, it could make a nice grammar for JSON validation.
Radha Rajendran (Apr 23 2021 at 11:29):
Thank you all
Radha Rajendran (Apr 23 2021 at 11:30):
one more doubt. other than $validate method, do i need validate the resource against profile when resource has meta->profile data ?
Oliver Egger (Apr 23 2021 at 11:35):
according to https://www.hl7.org/fhir/validation.html you don't need to do it, however I would check the implementation if it does it according to the rules listed.
Radha Rajendran (Apr 23 2021 at 11:42):
Okay..can we write our own profile validation program ?
Radha Rajendran (Apr 23 2021 at 11:46):
is JAR file will accept profile data (JSON) or it will support only published profiles ?
Morten Ernebjerg (Apr 23 2021 at 11:56):
This documentation page describes all the option for using the JAR validator, including how to load your own (local) profiles or entire published FHIR packages: https://confluence.hl7.org/display/FHIR/Using+the+FHIR+Validator
Radha Rajendran (Apr 23 2021 at 12:14):
okay thank you very much
Last updated: Apr 12 2022 at 19:14 UTC