Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON parser does not parse extensions on absent primitives #3883

Open
daanjo3 opened this issue Aug 5, 2022 · 0 comments
Open

JSON parser does not parse extensions on absent primitives #3883

daanjo3 opened this issue Aug 5, 2022 · 0 comments

Comments

@daanjo3
Copy link

daanjo3 commented Aug 5, 2022

Describe the bug
The JSON parser in any HAPI FHIR version does not properly parse extensions on primitives that are absent.
As per the FHIR spec, when an extension is added to a primitive value, a field starting with _ is added to which the extension is added. While this is properly parsed in most scenario's, the field with (for instance) the name _line is currently omitted if there is no line field.

To Reproduce
This issue can be found in any HAPI FHIR version. Steps to illustrate this behavior on the HAPI FHIR test server are included below.

Steps to reproduce the behavior:

  1. Go to http://hapi.fhir.org/resource?serverId=home_r4&encoding=json&pretty=true&_summary=&resource=Patient or do the following steps on any other FHIR server.
  2. Post the following resource:
{
    "resourceType": "Patient",
    "address": [
        {
            "use": "home",
            "type": "both",
            "city": "Whiterun",
            "_line": [
                {
                    "extension": [
                        {
                            "url": "http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-streetName",
                            "valueString": "Examplestreet"
                        }
                    ]
                },
                {
                    "extension": [
                        {
                            "url": "http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-houseNumber",
                            "valueString": "42"
                        }
                    ]
                }
            ]
        }
    ]
}
  1. You'll see that the response is the following, and thus lacking the _line field which should be present:
{
    "resourceType": "Patient",
    "id": "acabfcd5-4518-4f3e-bbbd-87a5f7625e13",
    "meta": {
        "versionId": "1",
        "lastUpdated": "..."
    },
    "address": [
        {
            "use": "home",
            "type": "both",
            "city": "Whiterun"
        }
    ]
}

Expected behavior
The expected output would contain the _line field exactly as it was sent in the first place. It could be argued that the _line field should be omitted as the field it is extending is also omitted. However, according to the FHIR specs it is valid to only have a _line field without the line field itself.

Note: If the primitive has an id attribute or extension, but no value, only the property with the _ is rendered.
https://www.hl7.org/fhir/STU3/json.html#primitive

This issue applies to any primitive extension, Patient.line has been used as example to make it easier to write this out.

Environment

  • any HAPI FHIR Version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant