meta.versionId Incremented After Update Operation With No Changes (DSTU 3) (#4349)

* Tests for R4 (passing) and DSTU3 (failing)

* Fix

Co-authored-by: nathaniel.doef <nathaniel.doef@smilecdr.com>
This commit is contained in:
Nathan Doef 2022-12-08 23:26:49 -05:00 committed by GitHub
parent b8760cc022
commit d639a2a86d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 1 deletions

View File

@ -0,0 +1,6 @@
---
type: fix
issue: 4348
jira: SMILE-5651
title: "Previously, if a DSTU3 Resource was updated and no changes were made, the `meta.versionId` value was
incremented incorrectly. This has been fixed."

View File

@ -705,7 +705,10 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> extends BaseStora
}
}
}
boolean allExtensionsRemoved = extensions.isEmpty();
if(allExtensionsRemoved){
hasExtensions = false;
}
}
}

View File

@ -4576,6 +4576,22 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
}
}
@Test
public void testUpdateResourceAfterReadOperationAndNoChangesShouldNotChangeVersion(){
// Create Patient
Patient patient = new Patient();
patient = (Patient) myClient.create().resource(patient).execute().getResource();
assertEquals(1, patient.getIdElement().getVersionIdPartAsLong());
// Read Patient
patient = (Patient) myClient.read().resource("Patient").withId(patient.getIdElement()).execute();
assertEquals(1, patient.getIdElement().getVersionIdPartAsLong());
// Update Patient with no changes
patient = (Patient) myClient.update().resource(patient).execute().getResource();
assertEquals(1, patient.getIdElement().getVersionIdPartAsLong());
}
@Test
public void testValidateBadInputViaGet() throws IOException {

View File

@ -762,6 +762,22 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
}
@Test
public void testUpdateResourceAfterReadOperationAndNoChangesShouldNotChangeVersion(){
// Create Patient
Patient patient = new Patient();
patient = (Patient) myClient.create().resource(patient).execute().getResource();
assertEquals(1, patient.getIdElement().getVersionIdPartAsLong());
// Read Patient
patient = (Patient) myClient.read().resource("Patient").withId(patient.getIdElement()).execute();
assertEquals(1, patient.getIdElement().getVersionIdPartAsLong());
// Update Patient with no changes
patient = (Patient) myClient.update().resource(patient).execute().getResource();
assertEquals(1, patient.getIdElement().getVersionIdPartAsLong());
}
@Test
public void testCreateWithNoBody() throws IOException {