hapifhir/org.hl7.fhir.validator-wrapper

Validation is inconsistent for a resource with us-core-ethnicity extension

dotasek opened this issue · 1 comments

Originally posted in Zulip:

I'm submitting a simple Patient resource to validator.fhir.org and getting inconsistent results.
The resource is found below. When I first paste this into the Code field, and click on Validate I get this error message:

Error Line: 8
The extension http://hl7.org/fhir/us/core/StructureDefinition/us-core-race is unknown, and not allowed here.
Maybe I'm missing something, it seems like the extension should work okay.

When I click on Validate again, there are no errors, warnings, etc.

If I try to validate using the command line validator, I get the same error, although running it twice doesn't change the result.

Patient Resource

{
    "resourceType": "Patient",
    "text": {
        "status": "extensions",
        "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">some text<\/div>"
    },
    "extension": [
        {
            "extension": [
                {
                    "url": "ombCategory",
                    "valueCoding": {
                        "system": "http://terminology.hl7.org/CodeSystem/v3-NullFlavor",
                        "code": "UNK",
                        "display": "unknown"
                    }
                },
                {
                    "url": "text",
                    "valueString": "unknown"
                }
            ],
            "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-race"
        },
        {
            "extension": [
                {
                    "url": "ombCategory",
                    "valueCoding": {
                        "system": "http://terminology.hl7.org/CodeSystem/v3-NullFlavor",
                        "code": "UNK",
                        "display": "unknown"
                    }
                },
                {
                    "url": "text",
                    "valueString": "unknown"
                }
            ],
            "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity"
        }
    ],
    "name": [
        {
            "family": "Everyperson",
            "given": ["Jane"]
        }
    ],
    "gender": "female",
    "birthDate": "1974-12-25",
    "address": [
        {
            "line": ["123 Main St"],
            "city": "Minneapolis",
            "state": "MN",
            "postalCode": "55401",
            "country": "USA"
        }
    ]
}

Output from CLI run:

$ java -jar validator_cli.jar Patient.json -version 4.0.1
FHIR Validation tool Version 5.6.75 (Git# a285132f5b46). Built 2022-10-28T11:57:44.269Z (5 days old)
Java: 11.0.14.1 from /Library/Java/JavaVirtualMachines/temurin-11.jdk/Contents/Home on x86_64 (64bit). 4096MB available
Paths: Current = /Users/bmilius/Documents/src/ms-validation, Package Cache = /Users/bmilius/.fhir/packages
Params: Patient.json -version 4.0.1
Jurisdiction: No Jurisdiction
Loading
Load FHIR v4.0 from hl7.fhir.r4.core#4.0.1 Load hl7.terminology.r4#4.0.0 - 4164 resources (00:06.796)
- 7383 resources (00:00.001)
Load hl7.terminology#4.0.0 - 4164 resources (00:00.760)
Load R5 Extensions - 86 resources (00:07.779)
Terminology server http://tx.fhir.org/ - Version 2.0.14 (00:01.061)
Get set... go (00:00.004)
Validating
Validate Patient.json
Validate Patient against http://hl7.org/fhir/StructureDefinition/Patient..........20........ Load hl7.terminology.r4#3.1.0 - 4117 resources (00:01.813)
Load hl7.fhir.uv.bulkdata#2.0.0 - 6 resources (00:00.007)
Load hl7.fhir.uv.smart-app-launch#2.0.0 - 0 resources (00:00.004)
Load us.nlm.vsac#0.7.0 - 12403 resources (00:02.818)
Load hl7.fhir.r4.examples#4.0.1 - 4582 resources (00:08.963)
Load hl7.fhir.uv.sdc#3.0.0 - 137 resources (00:00.018)
Load hl7.fhir.us.core#5.0.1 - 192 resources (00:00.038)
..40..........60..........80.........|
00:01.336
Done. Times: Loading: 00:16.838, validation: 00:14.999. Memory = 380Mb

FAILURE: 1 errors, 0 warnings, 0 notes
Error @ Patient.extension[0] (line 8, col10): The extension http://hl7.org/fhir/us/core/StructureDefinition/us-core-race is unknown, and not allowed here

I'm also getting the same result with an even simpler Patient resource that only has race extension:

{
    "resourceType": "Patient",
    "extension": [
        {
            "extension": [
                {
                    "url": "ombCategory",
                    "valueCoding": {
                        "system": "http://terminology.hl7.org/CodeSystem/v3-NullFlavor",
                        "code": "UNK",
                        "display": "unknown"
                    }
                },
                {
                    "url": "text",
                    "valueString": "unknown"
                }
            ],
            "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-race"
        }
    ]
}

If I have a Patient resource that just has the us-core-ethnicity extension, I get a similar error on the first try, but no errors when I click on Validate again.

{
    "resourceType": "Patient",
     "extension": [
        {
            "extension": [
                {
                    "url": "ombCategory",
                    "valueCoding": {
                        "system": "http://terminology.hl7.org/CodeSystem/v3-NullFlavor",
                        "code": "UNK",
                        "display": "unknown"
                    }
                },
                {
                    "url": "text",
                    "valueString": "unknown"
                }
            ],
            "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity"
        }
    ]
}

This is still happening in the current release.