mirror of
https://github.com/hapifhir/hapi-fhir.git
synced 2025-02-16 09:55:09 +00:00
3668 fhir patch operation returning 500 when patching in a transaction with a resource query in property request.url (#3675)
* Initial test exerting the issue. * Providing fix and changelog * Providing fix and changelog * Providing a searchUrl or matchUrl based on the requestUrl. * Providing fix and changelog * Modification on test * Modification on test Co-authored-by: peartree <etienne.poirier@smilecdr.com> Co-authored-by: qingyixia <cherry.xia@smilecdr.com>
This commit is contained in:
parent
2c580dfa2f
commit
05cb6c241c
@ -0,0 +1,4 @@
|
||||
---
|
||||
type: fix
|
||||
issue: 3668
|
||||
title: "Fhir patch operation returning 500 when patching in a transaction with a resource query in property request.url."
|
@ -110,6 +110,38 @@ public class PatchProviderR4Test extends BaseResourceProviderR4Test {
|
||||
assertEquals(false, newPt.getActive());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFhirPatch_TransactionWithSearchParameter() throws Exception {
|
||||
String methodName = "testFhirPatch_Transaction";
|
||||
IIdType pid1;
|
||||
{
|
||||
Patient patient = new Patient();
|
||||
patient.setActive(true);
|
||||
patient.addIdentifier().setSystem("urn:system").setValue("0");
|
||||
patient.addName().setFamily(methodName).addGiven("Joe");
|
||||
pid1 = myClient.create().resource(patient).execute().getId().toUnqualifiedVersionless();
|
||||
}
|
||||
Parameters patch = new Parameters();
|
||||
Parameters.ParametersParameterComponent operation = patch.addParameter();
|
||||
operation.setName("operation");
|
||||
operation.addPart().setName("type").setValue(new CodeType("replace"));
|
||||
operation.addPart().setName("path").setValue(new CodeType("Patient.active"));
|
||||
operation.addPart().setName("value").setValue(new BooleanType(false));
|
||||
|
||||
Bundle input = new Bundle();
|
||||
input.setType(Bundle.BundleType.TRANSACTION);
|
||||
input.addEntry()
|
||||
.setFullUrl(pid1.getValue())
|
||||
.setResource(patch)
|
||||
.getRequest().setUrl(String.format("Patient?name=%s", methodName))
|
||||
.setMethod(Bundle.HTTPVerb.PATCH);
|
||||
|
||||
myClient.transaction().withBundle(input).execute();
|
||||
|
||||
Patient newPt = myClient.read().resource(Patient.class).withId(pid1.getIdPart()).execute();
|
||||
assertEquals("2", newPt.getIdElement().getVersionIdPart());
|
||||
assertEquals(false, newPt.getActive());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPatchAddArray() throws IOException {
|
||||
|
@ -133,6 +133,7 @@ import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static ca.uhn.fhir.util.StringUtil.toUtf8String;
|
||||
import static java.util.Objects.isNull;
|
||||
import static org.apache.commons.lang3.StringUtils.defaultString;
|
||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
@ -1079,7 +1080,10 @@ public abstract class BaseTransactionProcessor {
|
||||
|
||||
IFhirResourceDao<? extends IBaseResource> dao = toDao(parts, verb, url);
|
||||
IIdType patchId = myContext.getVersion().newIdType().setValue(parts.getResourceId());
|
||||
DaoMethodOutcome outcome = dao.patch(patchId, matchUrl, patchType, patchBody, patchBodyParameters, theRequest);
|
||||
|
||||
String conditionalUrl = isNull(patchId.getIdPart()) ? url : matchUrl;
|
||||
|
||||
DaoMethodOutcome outcome = dao.patch(patchId, conditionalUrl, patchType, patchBody, patchBodyParameters, theRequest);
|
||||
setConditionalUrlToBeValidatedLater(conditionalUrlToIdMap, matchUrl, outcome.getId());
|
||||
updatedEntities.add(outcome.getEntity());
|
||||
if (outcome.getResource() != null) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user