Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
type: fix
issue: 4873
title: "Previously, if the fhirId in ResourceTable happened to be set to an empty string, the resourceId would be missing when trying to generate the full ID string. This has now been fixed."
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,9 @@ private DaoMethodOutcome doCreateForPostOrPut(RequestDetails theRequest, T theRe
String resourceIdBeforeStorage = theResource.getIdElement().getIdPart();
boolean resourceHadIdBeforeStorage = isNotBlank(resourceIdBeforeStorage);
boolean resourceIdWasServerAssigned = theResource.getUserData(JpaConstants.RESOURCE_ID_SERVER_ASSIGNED) == Boolean.TRUE;
entity.setFhirId(resourceIdBeforeStorage);
if (resourceHadIdBeforeStorage) {
entity.setFhirId(resourceIdBeforeStorage);
}

HookParams hookParams;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ public IIdType getIdType(FhirContext theContext) {
}

private void populateId(IIdType retVal) {
if (myFhirId != null) {
if (myFhirId != null && !myFhirId.isEmpty()) {
retVal.setValue(getResourceType() + '/' + myFhirId + '/' + Constants.PARAM_HISTORY + '/' + getVersion());
} else if (getTransientForcedId() != null) {
// Avoid a join query if possible
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
package ca.uhn.fhir.jpa.model.entity;

import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.primitive.IdDt;
import org.hl7.fhir.r4.model.Patient;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;

import javax.measure.quantity.Force;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.*;

public class ResourceTableTest {
Expand All @@ -16,5 +23,26 @@ public void testResourceLength() {
}
}

@ParameterizedTest
@CsvSource(value={
"123, 123, Patient/123/_history/1",
", 123, Patient/123/_history/1",
"null, 456, Patient/456/_history/1"
},nullValues={"null"})
public void testPopulateId(String theFhirId, String theForcedId, String theExpected) {
// Given
ResourceTable t = new ResourceTable();
t.setFhirId(theFhirId);
ForcedId forcedId = new ForcedId();
forcedId.setForcedId(theForcedId);
t.setForcedId(forcedId);
t.setResourceType(new Patient().getResourceType().name());
t.setVersion(1);

// When
IdDt actual = t.getIdDt();

// Then
assertTrue(actual.equals(theExpected));
}
}
2 changes: 1 addition & 1 deletion hapi-fhir-jpaserver-uhnfhirtest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>6.5.20-SNAPSHOT</version>
<version>6.5.21-SNAPSHOT</version>

<relativePath>../pom.xml</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion tests/hapi-fhir-base-test-jaxrsserver-kotlin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>6.5.20-SNAPSHOT</version>
<version>6.5.21-SNAPSHOT</version>

<relativePath>../../pom.xml</relativePath>
</parent>
Expand Down