hapifhir / org.hl7.fhir.core

Apache License 2.0
156 stars 158 forks source link

validator_cli confused about binding strength, causing unwarranted validation failures #1564

Closed DarthGizka closed 8 months ago

DarthGizka commented 8 months ago

It seems that somewhere between version 6.2.3 (OK) and 6.2.11 (b0rked) validator_cli started getting confused about binding strength in certain situations.

The attached example resource has the value "D" for Organization.address.country.code, which is in conformance with its profile that binds this extensibly to http://fhir.abda.de/eRezeptAbgabedaten/ValueSet/DAV-VS-ERP-DEUEV-Anlage-8. This binding overrides the preferred binding from the base profile (http://hl7.org/fhir/ValueSet/iso3166-1-2), but that is perfectly legit.

The country code "D" is accepted by validator_cli when validating generically (i.e. not specifying the IG for the profile in question) but 6.2.11 and 6.2.15 reject it as not conforming to ISO 3166 when doing profile-specific validation.

Generic validation:

FHIR Validation tool Version 6.2.15 (Git# 0bb2010409ad). Built 2024-01-30T11:13:28.136Z (11 days old)
  Java:   21.0.1 from C:\Program Files\Java\jdk-21 on amd64 (64bit). 16384MB available
  Params: -version R4 -best-practice ignore AD_Apotheke.xml
[...]

Success: 0 errors, 1 warnings, 1 notes
  Information @ Organization.meta.profile[0] (line 4, col104): Canonical URL 'http://fhir.abda.de/eRezeptAbgabedaten/StructureDefinition/DAV-PR-ERP-Apotheke|1.3' does not resolve
  Warning @ Organization.meta.profile[0] (line 1, col43): Profile reference 'http://fhir.abda.de/eRezeptAbgabedaten/StructureDefinition/DAV-PR-ERP-Apotheke|1.3' has not been checked because it could not be found, and fetching it resulted in the error org.hl7.fhir.r4.utils.client.EFhirClientException: Error reading Http Response from http://fhir.abda.de/eRezeptAbgabedaten: Error parsing JSON source: Unexpected char '<' in json stream at Line 3 (path=[null])

Correct profile-specific validation by version 6.2.3:

FHIR Validation tool Version 6.2.3 (Git# 7cb9286e3fa1). Built 2023-11-11T06:50:15.84Z (91 days old)
  Java:   21.0.1 from C:\Program Files\Java\jdk-21 on amd64 (64bit). 16384MB available
  Params: -version R4 -best-practice ignore AD_Apotheke.xml -ig de.abda.erezeptabgabedaten#1.3.2
[...]

Success: 0 errors, 0 warnings, 1 notes
  Information @ Organization.address[0].country (line 23, col23): The value provided ('D') is not in the value set 'Iso 3166 Part 1: 2 Letter Codes' (http://hl7.org/fhir/ValueSet/iso3166-1-2|4.0.1), and a code is recommended to come from this value set) (error message = The provided code 'urn:iso:std:iso:3166#D' was not found in the value set 'http://hl7.org/fhir/ValueSet/iso3166-1-2|4.0.1'; Unknown code 'D' in the CodeSystem 'urn:iso:std:iso:3166' version '2018' (from Tx-Server))

Incorrect rejection by 6.2.11 and 6.2.15:

FHIR Validation tool Version 6.2.15 (Git# 0bb2010409ad). Built 2024-01-30T11:13:28.136Z (11 days old)
  Java:   21.0.1 from C:\Program Files\Java\jdk-21 on amd64 (64bit). 16384MB available
  Params: -version R4 -best-practice ignore AD_Apotheke.xml -ig de.abda.erezeptabgabedaten#1.3.2
[...]

*FAILURE*: 1 errors, 0 warnings, 1 notes
  Error @ Organization.address[0].country.code (line 23, col23): Unknown code 'D' in the CodeSystem 'urn:iso:std:iso:3166' version '2018'
  Information @ Organization.address[0].country (line 23, col23): The value provided ('D') was not found in the value set 'Iso 3166 Part 1: 2 Letter Codes' (http://hl7.org/fhir/ValueSet/iso3166-1-2|4.0.1), and a code is recommended to come from this value set) (error message = The provided code 'urn:iso:std:iso:3166#D' was not found in the value set 'http://hl7.org/fhir/ValueSet/iso3166-1-2|4.0.1'; Unknown code 'D' in the CodeSystem 'urn:iso:std:iso:3166' version '2018')

Here are the profiles involved, from the R4 base definition to the most derived profile, and what each says about the binding of Address.country.code (profile URLs linked to the corresponding Simplifier pages for convenience):

The snapshot of the target profile does not contain any reference to urn:iso:std:iso:3166, let alone a required binding.

AD_Apotheke.xml.txt

grahamegrieve commented 8 months ago

it's not obvious what to do about this. From my point of view, a bug has been fixed, which is that the content wasn't being validated, and now it is. What's happening is that the http://fhir.de/StructureDefinition/address-de-basis is applying a binding to the address.country to ISO 3166. Because it's a preferred binding, there's no validation error associated with the value set. But putting the ValueSet binding on it implies that "D" is in the ISO 3166 code system, and so that is checked.

Further discussion here: https://chat.fhir.org/#narrow/stream/179177-conformance/topic/Preferred.20Bindings.20on.20Strings

grahamegrieve commented 8 months ago

no, this was a bug on tx.fhir.org. which will be fixed soon

DarthGizka commented 8 months ago

FWIW, the last validator_cli version with the old behaviour is 6.2.7; the new behaviour was introduced with version 6.2.8.