hapifhir / org.hl7.fhir.core

Apache License 2.0
156 stars 157 forks source link

Bug: erroneous error `This element has a Binding but the types to do not make this kind of constraint relevant` #908

Closed david-simons closed 2 years ago

david-simons commented 2 years ago

This commit last week introduced the following issues for us (fhirVersion 3.0.2, latest HL7 Validator 5.6.56) https://github.com/hapifhir/org.hl7.fhir.core/commit/2f6dfa62cabf9252be4275b9c22c4f461060dbff @grahamegrieve

I suspect a number of Resource types are missing, incl.

that need a has-binding, max-length, etc. characteristic, which they do not get erroneously as a plain Resource .

FHIR Validation tool Version 5.6.56 (Git# 51199251e858). Built 2022-08-26T21:14:55.137Z (4 days old)
    Java:   1.8.0_345 from /__w/_tool/jdk/8.0.345/x64/jre on amd64 (64bit). 1712MB available
    Paths:  Current = /__w/FHIR/FHIR, Package Cache = /root/.fhir/packages
    Params: -version 3.0.2 -ig profiles-folder

image

grahamegrieve commented 2 years ago

what types do those elements have?

david-simons commented 2 years ago

Element[4] in the above snippet, is a Device.identifier.type having a binding, for example - if that's what you're asking? Element[5] is a Device.identifier.value, with a a maxLength.

However, i also see the error on Observation.code, Contract.status, etc. for all Resource types listed in the Issue above.

    <element id="Device.identifier:instrumentNumber.type">
      <path value="Device.identifier.type" />
      <patternCodeableConcept>
        <coding>
          <system value="https://www.fhir.philips.com/3.0/CodeSystem/common/dataType/identifier-v1/ExtendedIdentifierTypeCodeSystem" />
          <code value="INO" />
        </coding>
      </patternCodeableConcept>
      <binding>
        <strength value="extensible" />
        <valueSetReference>
          <reference value="https://www.fhir.philips.com/3.0/ValueSet/common/core/deviceManagement-v1/operations/DeviceIdentifierTypesValueSet" />
        </valueSetReference>
      </binding>
    </element>

    <element id="Device.identifier:instrumentNumber.value">
      <path value="Device.identifier.value" />
      <maxLength value="100" />
    </element>
david-simons commented 2 years ago

Tested using a HL7Validator version older = 5.6.33 instead of latest = 5.6.56 - this is not giving these issues....

grahamegrieve commented 2 years ago

Fixed next time I commit and release

david-simons commented 2 years ago

Thanks for your help! For completeness - between 5.6.33 and 5.6.57 (including fix for #908) - the following error+warnings still showing for us:

image

 <element id="ImagingStudy.series.extension:dsSeriesAvailabilityStatus">
      <path value="ImagingStudy.series.extension" />
      <sliceName value="dsSeriesAvailabilityStatus" />
      <definition value="Can be Available, Processing or Unavailable." />
      <max value="1" />
      <type>
        <code value="Extension" />
        <profile value="https://.../DsSeriesAvailabilityStatusExtension" />
      </type>
      <binding>
        <strength value="required" />
        <description value="DICOMStore ImagingStudy.dsSeriesAvailabilityStatus" />
        <valueSetUri value="https://.../DsSeriesAvailabilityStatusValueSet" />
      </binding>
    </element>
  </differential>

And I actually think the remaining error is actually relevant here, I'll moved the code-binding down into the extension (along type=code - which indeed resolves that last error.

PS: The Binding http://hl7.org/fhir/ValueSet/ucum-vitals-common could not be expanded is a separate issue popped up after 5.6.33

grahamegrieve commented 2 years ago

Oh. missed that. it is legal, though mainly for legacy reasons.