FHIR Chat · Conditional Create Issue/Bug? · hapi

Stream: hapi

Topic: Conditional Create Issue/Bug?


view this post on Zulip Brian Reinhold (May 12 2021 at 12:56):

I have an identifier in an Observation resource that looks as follows:

                "identifier": [
                    {
                        "value": "B4E782FFFF4B4A10-VL-testing-Ren-urn:oid:2.2.2.333-150364-41.34-6048-20210427133226.444+0800"
                    }
                ]

The search on this identifier works fine. However, when I have a Conditional Create in a transaction bundle

            "request": {
                "method": "POST",
                "url": "Observation",
                "ifNoneExist": "identifier=B4E782FFFF4B4A10-VL-testing-Ren-urn:oid:2.2.2.333-150364-41.34-6048-20210427133226.444+0800"
            }

It does not work and now I have multiple resources with identical content loaded on the server.

However, if my resource has a 'system' entry as well as a 'value' entry, then the conditional create works. Am I doing something wrong?

Just in case the problem is due to the lack of a system field I added one to the identifier, gave it a constant value, and added that to the conditional create so it mirrored the Device case. It still failed to work.

view this post on Zulip Brian Reinhold (May 14 2021 at 11:36):

Turns out (thanks James Agnew) that my identifier has a '+' sign in it which is okay but when used in the URL of the 'ifNoneExist' field, the '+' sign needs to be escaped. I did not know this but there are two ways to escape a 'space' in a URL, the common %20 but also a '+' sign. Since I did not escape the plus sign, HAPI FHIR decoded the URL and the '+' sign became a 'space'. Thus the conditional create did not find such an identifier.

The solution was to escape the '+' sign (%2B).


Last updated: Apr 12 2022 at 19:14 UTC