FHIR Chat · bundle conditional patch alternative solution · hapi

Stream: hapi

Topic: bundle conditional patch alternative solution


view this post on Zulip Nath (Jul 22 2020 at 17:44):

Hello Implementers,
Hapi jpa R4 release inside a bundle txn, conditional patch is not working. Can you please kindly suggest a workaround ?. One possible solution I am thinking is that instead of patch, read the resource again, apply the changed fields on the read resource, apply bundle PUT with setIfMatch (conditional version). Is this ok ofcourse this has a penalty of reading the resource. Are there any other alternatives ?. Can you please kindly suggest.
thanks for your kind help.
(apologies raised this in #implementers forum earlier and got redirected here).

view this post on Zulip Jens Villadsen (Jul 22 2020 at 19:08):

Can you provide a small test that prooves it?

view this post on Zulip Nath (Jul 22 2020 at 23:25):

thanks @Jens Villadsen . I have created a simple testcase here. I created in R5 but the issue is in R4 also.
go to this link http://hapi.fhir.org/transaction and choose R5 server,

{
"resourceType": "Bundle",
"type": "transaction",
"total": 1,
"entry": [
{
"fullUrl": "Patient/107",
"resource": {
"resourceType": "Binary",
"contentType": "application/json-patch+json",
"data": "WyB7ICJvcCI6InJlcGxhY2UiLCAicGF0aCI6Ii9iaXJ0aERhdGUiLCAidmFsdWUiOiIxOTMzLTAxLTAxIiB9IF0="
},
"request": {
"method": "PATCH",
"url": "Patient/107",
"ifMatch": "4"
}
}
]
}

Note: data field is basically in base64 form of this
[ { "op":"replace", "path":"/birthDate", "value":"1933-01-01" } ]

you get an error message like this
Warning!
Error: HTTP 400 Bad Request: Invalid match URL[4] - URL has no search parameters
HTTP 400 Bad Request
Response Headers
x-request-id: DQKWFTclsCMJoOH5
date: Wed, 22 Jul 2020 23:22:32 GMT
server: nginx/1.14.0 (Ubuntu)
transfer-encoding: chunked
x-powered-by: HAPI FHIR 5.1.0-SNAPSHOT REST Server (FHIR Server; FHIR 4.4.0/R5)
connection: keep-alive
content-type: application/fhir+json;charset=utf-8
{
"resourceType": "OperationOutcome",
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><h1>Operation Outcome</h1><table border=\"0\"><tr><td style=\"font-weight: bold;\">ERROR</td><td>[]</td><td><pre>Invalid match URL[4] - URL has no search parameters</pre></td>\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t</tr>\n\t\t</table>\n\t</div>"
},
"issue": [ {
"severity": "error",
"code": "processing",
"diagnostics": "Invalid match URL[4] - URL has no search parameters"
} ]
}

Remove "ifMatch" : "4" and run it , it will update correctly.


Last updated: Apr 12 2022 at 19:14 UTC