Validation of FHIR resource with custom schema and custom code system extension

273 views Asked by At

I am new to the FHIR world and I am trying to solve healthcare problems in my local region.

In my use case, I have following two requirements

  1. For Resource
  • I have to use most of the resources as it is from FHIR R4.

    ex - Encounter, MedicationRequest etc

  • I have to create a profile for some resources. (put some constraints on existing resource for my use case)

    ex - Observation

  • I have to create an extension for some resources. (add new property to resource for my use case)

    Ex - Patient

  1. For Code System
  • I have to use Snomed CT International.

  • I have to use couple of national extensions of snomed CT listed here (https://mlds.ihtsdotools.org/#/viewReleases#section-IN)

    ex - SnomedCT_IndiaAYUSHExtensionRF2_PRODUCTION_IN1000189_20220615T120000Z.zip etc

  • I have to create my own code system extension for local terminology.

Now I have confusion around how I can do the resource schema validation and code system or terminology validation as it includes my custom resource and my custom code system extension.

I was exploring the hapi-fhir library and I read about the FhirInstanceValidator for validation from the article (https://hapifhir.io/hapi-fhir/docs/validation/introduction.html). It says it can do validation of the official FHIR definition. What does it mean by official definition and can it be used for my use case where I have my custom resource and custom code system extension ?

I have also gone through the code examples from article (https://hapifhir.io/hapi-fhir/docs/validation/instance_validator.html). Particularly from 13.2.4Validating Using Packages. Can this be used for my validation purpose? It is not clear from this example what and how I need to supply so that It can do validation of custom schema and code system both.

Note -

  • I am not using hapi-fhir-jpa-server, I just want to use the hapi-fhir library for resource validation purposes.
  • I am not looking into Schema/Schematron Validation as it is advised by hapi-fhir that it's a legacy feature and might be deprecated with future releases.
1

There are 1 answers

4
Lloyd McKenzie On

If you define your profile, extensions, CodeSystem, and ValueSets in a FHIR IG and use the publication tooling to generate a package (and declare which edition of SNOMED you're drawing from as an IG parameter), then you can pass the reference to that package to the HAPI validator and the validator will check everything for you. Most terminology is checked with a terminology service, not schema, because you're using a combination of code + system to validate, and sometimes a collection of codings, only one of which must be valid. XML schema has no idea how to check something like that. XML schema also can't enforce most profile stuff, including extensions. So just create the relevant StructureDefinitions and other artifacts, package and publish as an IG, and the tooling will handle the validation.