FHIR Chat · Using the FHIR Validator against a Profile · conformance

Stream: conformance

Topic: Using the FHIR Validator against a Profile


view this post on Zulip Håkan MacLean (Nov 25 2020 at 08:40):

So I'm trying to validate an example JSON against a Profile but I just can't get it to work. Starting to suspect it could be something with the Profile. All I'm doing is this:
java -jar validator_cli.jar rx.json -profile https://fhir.simplifier.net/SwedishNationalMedicationList/StructureDefinition/dcae1550-a48a-4d44-a431-73c47c9dd075

Where the URL above gives me a JSON with a StructureDefinition and rx.json contains a file with:

    "versionId": "1",
    "profile": [
      "http://electronichealth.se/fhir/StructureDefinition/NLLMedicationRequest"
    ]
  }

And it seems like NLLMedicationRequest defined in the StructureDefinition above. The error is:

Validate rx.jsonException in thread "main" java.lang.Error: Unable to resolve profile https://fhir.simplifier.net/SwedishNationalMedicationList/StructureDefinition/dcae1550-a48a-4d44-a431-73c47c9dd075

Have I misunderstood something?

view this post on Zulip Oliver Egger (Nov 25 2020 at 08:55):

where is your profile? with the -profile parameter you specify against which profile you want to validate (canonical url)

view this post on Zulip Oliver Egger (Nov 25 2020 at 08:57):

with the -ig parameter you can specify the profiles, however the link you listed above does not return currently the resource

view this post on Zulip Oliver Egger (Nov 25 2020 at 08:57):

see docu also here for the parameters: https://confluence.hl7.org/display/FHIR/Using+the+FHIR+Validator

view this post on Zulip Grahame Grieve (Nov 25 2020 at 08:58):

the link you listed above does not return currently the resource

That's the key

view this post on Zulip Grahame Grieve (Nov 25 2020 at 08:59):

if it actually comes from somewhere else, you need to tell the publisher where to find it using an -ig parameter

view this post on Zulip Håkan MacLean (Nov 25 2020 at 10:26):

I apologise for my previous confusing post. I tried having the url in both -ig and -profile and pasted the wrong one. So I have also tried
java -jar validator_cli.jar rx.json -profile http://electronichealth.se/fhir/StructureDefinition/NLLMedicationRequest -ig https://fhir.simplifier.net/SwedishNationalMedicationList/StructureDefinition/dcae1550-a48a-4d44-a431-73c47c9dd075

With the same error about not being to resolve the profile. When I curl https://fhir.simplifier.net/SwedishNationalMedicationList/StructureDefinition/dcae1550-a48a-4d44-a431-73c47c9dd075 I get back a StructureDefinition, containing a definition of http://electronichealth.se/fhir/StructureDefinition/NLLMedicationRequest, which indicates to me it should work?

I just now tried downloading the StructureDefinition to a file and use it locally, like the documentation suggests:
java -jar validator_cli.jar rx.json -profile http://electronichealth.se/fhir/StructureDefinition/NLLMedicationRequest -ig ./nllmedicationrequest.json

And now I seem to be getting closer, but I receive the following error:
Error @ MedicationRequest (line 1, col2) : StructureDefinition has no snapshot - validation is against the snapshot, so it must be provided

Is there something fundamental I have misunderstood?
I'm just trying to test against the Swedish Government MedicationRequestProfile. Its canonical URL is http://electronichealth.se/fhir/StructureDefinition/NLLMedicationRequest, which if I've understood things correct means there is no actual information to download at this url, it's just a name. The content of the actual profile is in a StructureDefinition, that is available here: https://fhir.simplifier.net/SwedishNationalMedicationList/StructureDefinition/dcae1550-a48a-4d44-a431-73c47c9dd075. I thought this would be like the most basic thing in the world to test when learning FHIR, but there must be something I've misunderstood :)

view this post on Zulip Oliver Egger (Nov 25 2020 at 10:53):

  1. the address you provide (https://fhir.simplifier.net/SwedishNationalMedicationList/StructureDefinition/dcae1550-a48a-4d44-a431-73c47c9dd075.) does not allow myself to download the structuredefinition

view this post on Zulip Oliver Egger (Nov 25 2020 at 10:56):

  1. you need a StructureDefintion with a snapshot, you can download a version from that with simplifier with Download, Download snapshots as ...

view this post on Zulip Grahame Grieve (Nov 25 2020 at 10:56):

StructureDefinition has no snapshot - validation is against the snapshot, so it must be provided

weird.... that definitely should not happen. It's absolutely an unexpected bug. I'll investigate tomorrow.

view this post on Zulip Grahame Grieve (Nov 25 2020 at 10:56):

the validator generates it's own snapshot.

view this post on Zulip Håkan MacLean (Nov 25 2020 at 11:08):

Oliver Egger said:

  1. you need a StructureDefintion with a snapshot, you can download a version from that with simplifier with Download, Download snapshots as ...

So I tried downloading the json with a snapshot (thanks for the tip!). Then when I run:

java -jar validator_cli.jar rx_small.json -profile http://electronichealth.se/fhir/StructureDefinition/NLLMedicationRequest -ig ./NLLMedicationRequest.json

I get an exception:
Validating
Profiles: [http://electronichealth.se/fhir/StructureDefinition/NLLMedicationRequest]
Validate rx_small.jsonException in thread "main" java.lang.Error: Not done yet
at org.hl7.fhir.validation.cli.services.StandAloneValidatorFetcher.fetch(StandAloneValidatorFetcher.java:41)
at org.hl7.fhir.validation.ValidationEngine.fetch(ValidationEngine.java:1864)
at org.hl7.fhir.validation.instance.InstanceValidator.checkReference(InstanceValidator.java:2458)

This is my super simple MedicationRequest:

{
  "resourceType": "MedicationRequest",
  "meta": {
    "versionId": "1",
    "profile": [
      "http://electronichealth.se/fhir/StructureDefinition/NLLMedicationRequest"
    ]
  },
  "status": "active",
  "intent": "plan",
  "subject": {
    "reference": "Patient/21e495cf-aab6-482e-b630-cdd87b437cab"
  },
  "authoredOn": "2020-11-11T10:58:14.768528",
  "requester": {
    "reference": "#1505724e-2d13-4790-ab25-e9ae2fa8d272"
  }

view this post on Zulip Grahame Grieve (Nov 25 2020 at 20:15):

@Håkan MacLean Not one of your references to the profile you're working with resolve for me. I consistently get "this site can't be reached" for the electronichealth.se and https://fhir.simplifier.net references, though simplifier.net etc do resolve for me

view this post on Zulip Håkan MacLean (Nov 25 2020 at 22:20):

@Grahame Grieve The electronichealth.se urls are the Canonical urls, so they are not expected to be resolved, right? The link to simplifier.net is the one I got from here: https://simplifier.net/swedishnationalmedicationlist/nllmedicationrequest and then clicking on the API-link. It doesn't resolve in my browser, but works when I use curl.

But if I reverse the question: How should I go about validating a simple FHIR MedicationRequest.json file that I have created (shown above) against the profile described here: https://simplifier.net/swedishnationalmedicationlist? I have tried both pointing the validator to the url mentioned above and to downloading the resources in different ways locally, but it always fails. Is there perhaps something wrong with the profile? N.B. I haven't created the profile, it's the official profile from the Swedish government.

view this post on Zulip Lloyd McKenzie (Nov 25 2020 at 23:14):

If you want to point to a profile by URL with the validator, it must resolve or must be defined in an IG .tgz package you refer to with -ig. You can't reference an ImplementationGuide resource, you must refer to an ig package (and that package must contain the profile or must refer to a package that exists in the package registry that has the profile)

view this post on Zulip Kevin Mayfield (Nov 26 2020 at 07:48):

If it helps. For the English Medication profiles we have this page https://simplifier.net/guide/NHSDigitalSpine/TestingandValidation
Which has a number of examples for validation resources using a simplifier IG.
The Digital Medicine IG section refers to England NHS Meds.

view this post on Zulip Grahame Grieve (Nov 26 2020 at 20:13):

ok I had time to look at this.

Not done yet

Is caused by a bug in the validator. No use having 100s of tests if your deployed version has a bug not in the tests. Fix will be released some time today

view this post on Zulip Grahame Grieve (Nov 26 2020 at 22:03):

@Mirjam Baltus more generally, this is something that is pretty obscure to simplifier.net users - the canonical doesn't resolve. The validator will try to resolve it (and do so much more coherently from next release) but even if it can resolved, it'll be slower and more trouble prone than asking the validator to get the package. So I think that simplifier should document this somewhere where users will find it

view this post on Zulip Grahame Grieve (Nov 26 2020 at 22:07):

btw, @Håkan MacLean the reason it failed with not done yet is actually a bug related to the contained reference, nothing to do with the profile

view this post on Zulip Grahame Grieve (Nov 26 2020 at 22:09):

fyi https://github.com/FHIR/fhir-test-cases/commit/972f06b6dd4c97778b501031bdb2585ebab56313 if interested

view this post on Zulip Ward Weistra (Nov 30 2020 at 10:30):

Grahame Grieve said:

Mirjam Baltus more generally, this is something that is pretty obscure to simplifier.net users - the canonical doesn't resolve. The validator will try to resolve it (and do so much more coherently from next release) but even if it can resolved, it'll be slower and more trouble prone than asking the validator to get the package. So I think that simplifier should document this somewhere where users will find it

Thanks for the suggestion. The suggestion is to better document how a Simplifier.net user can use the Java validator to validate against their Simplifier.net project, right? (Indeed, publishing a FHIR package would be my answer. Unless the Java validator also has the option to be pointed to a FHIR server to get the resources from)

@Håkan MacLean I'm sure you've already seen simplifier.net/validate and the validation options when you'd upload that example JSON to your project, right?

view this post on Zulip Grahame Grieve (Nov 30 2020 at 10:32):

Unless the Java validator also has the option to be pointed to a FHIR server to get the resources from)

well, it does, but that's not a terribly practical thing right now, since it downloads profiles at their URL.. doesn't work for a the whole package. Unless we do something about that

view this post on Zulip Grahame Grieve (Nov 30 2020 at 10:34):

Indeed, publishing a FHIR package would be my answer.

So, for a random user, is it published? What's the package name? is that visible from the web page for the profile?

view this post on Zulip Ward Weistra (Dec 01 2020 at 07:59):

@Grahame Grieve

view this post on Zulip Grahame Grieve (Dec 01 2020 at 10:10):

But a user can make a package from the project at any time

I presume that is a simplifier admin kind of user, not any person in the world?

view this post on Zulip Grahame Grieve (Dec 01 2020 at 10:11):

if an authorised user has created a package, will any other person in the world know that this has happened?

view this post on Zulip Ward Weistra (Dec 01 2020 at 11:40):

Grahame Grieve said:

I presume that is a simplifier admin kind of user, not any person in the world?

Anyone person in the world can create a free Simplifier.net account and one public development project.
Any project member with admin rights on the project can create a new (version of a) package from it.

Grahame Grieve: if an authorised user has created a package, will any other person in the world know that this has happened?

There is no notification system for newly created packages, but users can then find the new package (version) on the package page on Simplifier.net, registry.fhir.org or via the package API.

view this post on Zulip Grahame Grieve (Dec 01 2020 at 11:41):

so I think it would be appropriate for a random user to see on the page what package a profile is in, and whether it's been released. Otherwise they are in a world of confusion

view this post on Zulip Ward Weistra (Dec 01 2020 at 11:47):

Ah, like that: Show on the page for a resource in a project (like this ACME patient) that it has been published in a package (link to this package). Yes, that's something we will start to do!

We're still working through the major shift of projects being the entry point for consumers to packages being that. Our path on that will roughly be:

  • Improve Simplifier.net search to also search in packages and likely in packages by default
  • Make package pages prettier (all the smarts currently projects already have, like easier search in its resources)
  • Steer consumers from projects to packages, where available

Last updated: Apr 12 2022 at 19:14 UTC