FHIR Chat · Must id of a FHIR code StructureDefinition equal its name? · conformance

Stream: conformance

Topic: Must id of a FHIR code StructureDefinition equal its name?


view this post on Zulip Michael Lawley (Jul 26 2018 at 04:51):

In the Java reference implementation, ParserBase.java contains the following:

if (name.equals(sd.getIdElement().getIdPart())) {

in the method getDefinition

This means that, for example, the StructureDefinition for StructureDefinitionitself MUST have the id of StructureDefinition which violates the principle that servers get to choose id values.

Are there rules / assumptions elsewhere in the spec that require this constraint?

view this post on Zulip Grahame Grieve (Jul 26 2018 at 04:52):

I'm not finding this method

view this post on Zulip Grahame Grieve (Jul 26 2018 at 04:56):

oh that ParserBase.

view this post on Zulip Grahame Grieve (Jul 26 2018 at 04:57):

well... no, there is no rules in the spec. But this particular code is expected to run straight off the hl7.fhir.core package

view this post on Zulip Michael Lawley (Jul 26 2018 at 04:58):

It gets called via the validation module and breaks when the SD's are pulled from our server

view this post on Zulip Grahame Grieve (Jul 26 2018 at 05:00):

hmm why? that's odd.... what's it actually broken on?

view this post on Zulip Michael Lawley (Jul 26 2018 at 05:03):

We supply an implementation of IValidationSupport which has the method fetchStructureDefinition. This gets called for the URI http://hl7.org/fhir/StructureDefinition/StructureDefinition and we return our instance but with an id != "StructureDefinition". It looks like this gets serialised as XML and then parsed back as elements as some kind of STU3 -> R4 transformation ?

view this post on Zulip Grahame Grieve (Jul 26 2018 at 05:04):

yeah but so? the code should be depending on the canonical URL - which is immediately before hand. there's a few special circumstances where it falls through to the ode you've asked about, but they should not apply for you

view this post on Zulip Michael Lawley (Jul 26 2018 at 05:07):

This is the code I'm seeing in implementations/java/org.hl7.fhir.dstu3/src/org/hl7/fhir/dstu3/elementmodel/ParserBase.java:

protected StructureDefinition getDefinition(int line, int col, String ns, String name) throws FHIRFormatError {
    if (ns == null) {
      logError(line, col, name, IssueType.STRUCTURE, "This cannot be parsed as a FHIR object (no namespace)", IssueSeverity.FATAL);
      return null;
    }
    if (name == null) {
      logError(line, col, name, IssueType.STRUCTURE, "This cannot be parsed as a FHIR object (no name)", IssueSeverity.FATAL);
      return null;
    }
    for (StructureDefinition sd : context.allStructures()) {
      if (name.equals(sd.getIdElement().getIdPart())) {
       // ...

The only paths that will avoid this are if ns or name are null

view this post on Zulip Grahame Grieve (Jul 26 2018 at 05:08):

3? you can't run the R3 version of that code. I should really delete it... only the R4 validator is supported

view this post on Zulip Michael Lawley (Jul 26 2018 at 05:11):

I'm not calling it directly, but the r4 is similar:

protected StructureDefinition getDefinition(int line, int col, String ns, String name) throws FHIRFormatError {
    if (ns == null) {
      logError(line, col, name, IssueType.STRUCTURE, "This cannot be parsed as a FHIR object (no namespace)", IssueSeverity.FATAL);
      return null;
    }
    if (name == null) {
      logError(line, col, name, IssueType.STRUCTURE, "This cannot be parsed as a FHIR object (no name)", IssueSeverity.FATAL);
      return null;
    }
    for (StructureDefinition sd : context.allStructures()) {
            if (name.equals(sd.getIdElement().getIdPart()) && !sd.getUrl().startsWith("http://hl7.org/fhir/StructureDefinition/de-")) {

view this post on Zulip Grahame Grieve (Jul 26 2018 at 05:12):

my copy:

    protected StructureDefinition getDefinition(int line, int col, String name) throws FHIRFormatError {
    if (name == null) {
      logError(line, col, name, IssueType.STRUCTURE, "This cannot be parsed as a FHIR object (no name)", IssueSeverity.FATAL);
      return null;
    }
    // first pass: only look at base definitions
      for (StructureDefinition sd : context.allStructures()) {
        if (sd.getUrl().equals("http://hl7.org/fhir/StructureDefinition/"+name)) {
          return sd;
        }
      }
    for (StructureDefinition sd : context.allStructures()) {
      if (name.equals(sd.getIdElement().getIdPart())) {
        return sd;
      }
    }
      logError(line, col, name, IssueType.STRUCTURE, "This does not appear to be a FHIR resource (unknown name '"+name+"')", IssueSeverity.FATAL);
      return null;
  }

view this post on Zulip Grahame Grieve (Jul 26 2018 at 05:13):

I made that change a long time ago. what version are you running?

view this post on Zulip Michael Lawley (Jul 26 2018 at 05:15):

It would be the "copy" that is in HAPI 3.4.0

view this post on Zulip Grahame Grieve (Jul 26 2018 at 05:15):

hmm. you should chat to James about how old that is

view this post on Zulip Michael Lawley (Jul 26 2018 at 05:17):

But I've just done a git pull and see no difference - wait, that's a different method

view this post on Zulip Michael Lawley (Jul 26 2018 at 05:17):

Your version has no ns parameter

view this post on Zulip Michael Lawley (Jul 26 2018 at 05:20):

XmlParser(ParserBase).getDefinition(int, int, String, String) line: 88
XmlParser.parse(Element) line: 150
XmlParser.parse(Document) line: 142

view this post on Zulip Grahame Grieve (Jul 26 2018 at 05:27):

ok, well, I just committed a fix that seems to work....

view this post on Zulip Grahame Grieve (Jul 26 2018 at 05:27):

or not... thought of one more test to do

view this post on Zulip Michael Lawley (Jul 26 2018 at 05:27):

Many thanks!


Last updated: Apr 12 2022 at 19:14 UTC