onc-healthit / onc-certification-g10-test-kit

ONC Certification (g)(10) Standardized API Tests
Apache License 2.0
34 stars 11 forks source link

Inferno Validator throwing error 'If a code for the unit is present, the system SHALL also be present' when using _code #442

Closed jj027509 closed 1 year ago

jj027509 commented 1 year ago

Resource: Observation Scenario: When DARing code using DAR extension on _code for Observation.valueQuantity, Inferno validator is still showing an error stating System shall also be present.

Input into validator:

{
    "resourceType": "Observation",
    "id": "L-196186655",
    "meta": {
        "versionId": "1",
        "lastUpdated": "2017-02-15T20:48:54.000Z"
    },
    "text": {
        "status": "generated",
        "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p><b>Observation</b></p><p><b>Patient Id</b>: 12457981</p><p><b>Status</b>: Final</p><p><b>Categories</b>: Laboratory</p><p><b>Code</b>: BUN</p><p><b>Result</b>: 40</p><p><b>Interpretation</b>: N/A</p><p><b>Effective Date</b>: Feb 15, 2017  2:48 P.M. CST</p></div>"
    },
    "identifier": [
        {
            "system": "https://fhir.cerner.com/ceuuid",
            "value": "CE87caf4b7-9397-4667-9897-702218017c9e-196186655-2017021520485500"
        }
    ],
    "basedOn": [
        {
            "reference": "ServiceRequest/294925759"
        }
    ],
    "status": "final",
    "category": [
        {
            "coding": [
                {
                    "system": "http://terminology.hl7.org/CodeSystem/observation-category",
                    "code": "laboratory",
                    "display": "Laboratory",
                    "userSelected": false
                }
            ],
            "text": "Laboratory"
        }
    ],
    "code": {
        "coding": [
            {
                "system": "https://fhir.cerner.com/dacc6494-e336-45ad-8729-b789ff8663c6/codeSet/72",
                "code": "20136460",
                "display": "BUN",
                "userSelected": true
            },
            {
                "system": "http://loinc.org",
                "code": "3094-0",
                "userSelected": false
            }
        ],
        "text": "BUN"
    },
    "subject": {
        "reference": "Patient/12457981"
    },
    "encounter": {
        "reference": "Encounter/97697407"
    },
    "effectiveDateTime": "2017-02-15T20:48:00.000Z",
    "issued": "2017-02-15T20:48:53.000Z",
    "performer": [
        {
            "extension": [
                {
                    "valueCodeableConcept": {
                        "coding": [
                            {
                                "system": "http://terminology.hl7.org/CodeSystem/v3-ParticipationType",
                                "code": "LA",
                                "display": "legal authenticator"
                            }
                        ],
                        "text": "legal authenticator"
                    },
                    "url": "http://hl7.org/fhir/StructureDefinition/event-performerFunction"
                },
                {
                    "valueCodeableConcept": {
                        "coding": [
                            {
                                "system": "http://terminology.hl7.org/CodeSystem/v3-ParticipationType",
                                "code": "PPRF",
                                "display": "primary performer"
                            }
                        ],
                        "text": "primary performer"
                    },
                    "url": "http://hl7.org/fhir/StructureDefinition/event-performerFunction"
                }
            ],
            "reference": "Practitioner/11638288"
        },
        {
            "extension": [
                {
                    "valueCodeableConcept": {
                        "coding": [
                            {
                                "system": "http://terminology.hl7.org/CodeSystem/v2-0912",
                                "code": "OP",
                                "display": "Ordering Provider"
                            }
                        ],
                        "text": "Ordering Provider"
                    },
                    "url": "http://hl7.org/fhir/StructureDefinition/event-performerFunction"
                }
            ],
            "reference": "Practitioner/4122622"
        }
    ],
    "valueQuantity": {
        "value": 40,
        "_code": {
            "extension": [{
               "url": "http://hl7.org/fhir/StructureDefinition/data-absent-reason",
               "valueCode": "unknown"
               }]
        }
    }
}

Validation error received: image

Since we are using _code and not code, this is an unexpected error.

yunwwang commented 1 year ago

The FHIRPath expression for qty-3 is code.empty() or system.exists() _code element adds an extension to the code element, so that code.empty() is false. In such case, system.exists() must be true or the invariant fails Removing the _code element passes this invariant.