Skip to content

Commit c97567c

Browse files
authored
Transaction processing improvements (#6874)
* Add junk ine * Add extension for placeholder ID * Cleanup * Header * Cleanup * Spotless * Better logging * Fix transaction conditional URL prefetch on non-token params * Drop a check * Adjust query counts * Improve performance * Single token optimized * Test fixes * About to try to ensure we prefetch resource bodies for conditional create * Test fixes * Some test fixes * Test fixes * Test fixes * Test fixes * Work on tests * Test fix * Spotless * Add docs * Add test * Add grouping * Spotless * Add size option to CMD * Adjust consumer * Cleanup * Work on bulk import * Spotless * More work * Add logging * More diagnostics * add logs * Cleanup * Fix premature finishing of bulk import command * Add changelogs * Test cleanup * Test fixes * Fix tests * Test fix * Spotless * Cleanup * Resolve conflicts * Clean up * Add to transaction response parser * TransactionUtil parsing improvements * Work on tests * Test fix * Test fixes * Spotless * Bug fix * Build tweak * Test cleanup * Add some test logging * Bump to trigger CI * Try to address intermittent * Address review comments * Version bump * License header
1 parent ec773ed commit c97567c

File tree

107 files changed

+778
-274
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+778
-274
lines changed

hapi-deployable-pom/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>ca.uhn.hapi.fhir</groupId>
77
<artifactId>hapi-fhir</artifactId>
8-
<version>8.3.2-SNAPSHOT</version>
8+
<version>8.3.3-SNAPSHOT</version>
99

1010
<relativePath>../pom.xml</relativePath>
1111
</parent>

hapi-fhir-android/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>ca.uhn.hapi.fhir</groupId>
77
<artifactId>hapi-deployable-pom</artifactId>
8-
<version>8.3.2-SNAPSHOT</version>
8+
<version>8.3.3-SNAPSHOT</version>
99

1010
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
1111
</parent>

hapi-fhir-base/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>ca.uhn.hapi.fhir</groupId>
77
<artifactId>hapi-deployable-pom</artifactId>
8-
<version>8.3.2-SNAPSHOT</version>
8+
<version>8.3.3-SNAPSHOT</version>
99

1010
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
1111
</parent>

hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/StorageResponseCodeEnum.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public enum StorageResponseCodeEnum implements ICodingEnum {
5151
SUCCESSFUL_CONDITIONAL_PATCH_NO_CHANGE(
5252
"Conditional patch succeeded: No changes were detected so no action was taken."),
5353
AUTOMATICALLY_CREATED_PLACEHOLDER_RESOURCE("Automatically created placeholder resource."),
54+
FAILURE("Failed to process resource."),
5455
;
5556

5657
public static final String SYSTEM = "https://hapifhir.io/fhir/CodeSystem/hapi-fhir-storage-response-code";

hapi-fhir-base/src/main/java/ca/uhn/fhir/util/HapiExtensions.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,13 @@ public class HapiExtensions {
194194
public static final String EXTENSION_SEARCHPARAM_CUSTOM_TARGET_RESOURCE =
195195
"http://hl7.org/fhir/tools/CustomTargetResource";
196196

197+
/**
198+
* When an OperationOutcome returned by the JPA server includes a declaration that a placeholder
199+
* reference was automatically created, this extension indicates the ID of the placeholder.
200+
*/
201+
public static final String EXTENSION_PLACEHOLDER_ID =
202+
"http://hapifhir.io/fhir/StructureDefinition/oo-placeholder-id";
203+
197204
/**
198205
* When a resource is replacing another resource, this extension can be added
199206
* to include a reference to the resource that is being replaced.

hapi-fhir-base/src/main/java/ca/uhn/fhir/util/IoUtils.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,21 @@
22

33
/*-
44
* #%L
5-
* Smile CDR - CDR
5+
* HAPI FHIR - Core Library
66
* %%
7-
* Copyright (C) 2016 - 2025 Smile CDR, Inc.
7+
* Copyright (C) 2014 - 2025 Smile CDR, Inc.
88
* %%
9-
* All rights reserved.
9+
* Licensed under the Apache License, Version 2.0 (the "License");
10+
* you may not use this file except in compliance with the License.
11+
* You may obtain a copy of the License at
12+
*
13+
* http://www.apache.org/licenses/LICENSE-2.0
14+
*
15+
* Unless required by applicable law or agreed to in writing, software
16+
* distributed under the License is distributed on an "AS IS" BASIS,
17+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
* See the License for the specific language governing permissions and
19+
* limitations under the License.
1020
* #L%
1121
*/
1222

hapi-fhir-base/src/main/java/ca/uhn/fhir/util/MetaUtil.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ public static String cleanProvenanceSourceUriOrEmpty(String theProvenanceSourceU
5353
return StringUtils.substringBefore(sanitizedProvenance, "#");
5454
}
5555

56+
/**
57+
* @since 8.2.0
58+
*/
59+
public static String getSource(FhirContext theContext, IBaseResource theResource) {
60+
return getSource(theContext, theResource.getMeta());
61+
}
62+
5663
public static String getSource(FhirContext theContext, IBaseMetaType theMeta) {
5764
if (theContext.getVersion().getVersion().isEqualOrNewerThan(FhirVersionEnum.R4)) {
5865
return getSourceR4Plus(theContext, theMeta);

hapi-fhir-base/src/main/java/ca/uhn/fhir/util/OperationOutcomeUtil.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,28 +47,30 @@ public class OperationOutcomeUtil {
4747

4848
/**
4949
* Add an issue to an OperationOutcome
50-
* @param theCtx The fhir context
50+
*
51+
* @param theCtx The fhir context
5152
* @param theOperationOutcome The OO resource to add to
5253
* @param theSeverity The severity (fatal | error | warning | information)
53-
* @param theDetails The details string
54+
* @param theDiagnostics The diagnostics string (this was called "details" in FHIR DSTU2 but was renamed to diagnostics in DSTU3)
5455
* @param theCode
5556
* @return Returns the newly added issue
5657
*/
5758
public static IBase addIssue(
5859
FhirContext theCtx,
5960
IBaseOperationOutcome theOperationOutcome,
6061
String theSeverity,
61-
String theDetails,
62+
String theDiagnostics,
6263
String theLocation,
6364
String theCode) {
64-
return addIssue(theCtx, theOperationOutcome, theSeverity, theDetails, theLocation, theCode, null, null, null);
65+
return addIssue(
66+
theCtx, theOperationOutcome, theSeverity, theDiagnostics, theLocation, theCode, null, null, null);
6567
}
6668

6769
public static IBase addIssue(
6870
FhirContext theCtx,
6971
IBaseOperationOutcome theOperationOutcome,
7072
String theSeverity,
71-
String theDetails,
73+
String theDiagnostics,
7274
String theLocation,
7375
String theCode,
7476
@Nullable String theDetailSystem,
@@ -79,7 +81,7 @@ public static IBase addIssue(
7981
theCtx,
8082
issue,
8183
theSeverity,
82-
theDetails,
84+
theDiagnostics,
8385
theLocation,
8486
theCode,
8587
theDetailSystem,
@@ -101,7 +103,7 @@ private static IBase createIssue(FhirContext theCtx, IBaseResource theOutcome) {
101103

102104
/**
103105
* @deprecated Use {@link #getFirstIssueDiagnostics(FhirContext, IBaseOperationOutcome)} instead. This
104-
* method has always been misnamed for historical reasons.
106+
* method has always been misnamed for historical reasons.
105107
*/
106108
@Deprecated(forRemoval = true, since = "8.2.0")
107109
public static String getFirstIssueDetails(FhirContext theCtx, IBaseOperationOutcome theOutcome) {
@@ -199,7 +201,7 @@ private static void populateDetails(
199201
FhirContext theCtx,
200202
IBase theIssue,
201203
String theSeverity,
202-
String theDetails,
204+
String theDiagnostics,
203205
String theLocation,
204206
String theCode,
205207
String theDetailSystem,
@@ -225,7 +227,7 @@ private static void populateDetails(
225227
severityChild.getMutator().addValue(theIssue, severityElem);
226228

227229
IPrimitiveType<?> string = (IPrimitiveType<?>) stringDef.newInstance();
228-
string.setValueAsString(theDetails);
230+
string.setValueAsString(theDiagnostics);
229231
diagnosticsChild.getMutator().setValue(theIssue, string);
230232

231233
addLocationToIssue(theCtx, theIssue, theLocation);

hapi-fhir-base/src/main/java/ca/uhn/fhir/util/StopWatch.java

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,34 @@ public String toString() {
282282
}
283283

284284
/**
285-
* Format a throughput number (output does not include units)
285+
* Format a throughput number (output does not include units) into
286+
* a number suitable for logging.
287+
* <p>
288+
* This method tries to use a suitable amount of precision for logging.
289+
* For numbers above 1000 it includes no decimal.
290+
* For numbers between 100 and 1000 it includes one decimal.
291+
* For numbers below 100 it includes two decimals.
292+
* </p>
286293
*/
287294
public static String formatThroughput(double throughput) {
288-
return new DecimalFormat("0.0").format(throughput);
295+
return formatDouble(throughput);
296+
}
297+
298+
/**
299+
* This method tries to use a suitable amount of precision for logging.
300+
* For numbers above 1000 it includes no decimal.
301+
* For numbers between 100 and 1000 it includes one decimal.
302+
* For numbers below 100 it includes two decimals.
303+
*/
304+
static String formatDouble(double theDouble) {
305+
double abs = Math.abs(theDouble);
306+
if (abs > 1000) {
307+
return Long.toString(Math.round(theDouble));
308+
}
309+
if (abs > 100) {
310+
return Double.toString(Math.round(theDouble * 10.0) / 10.0);
311+
}
312+
return Double.toString(Math.round(theDouble * 100.0) / 100.0);
289313
}
290314

291315
/**

hapi-fhir-base/src/test/java/ca/uhn/fhir/util/StopWatchTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import org.apache.commons.lang3.time.DateUtils;
44
import org.junit.jupiter.api.AfterEach;
55
import org.junit.jupiter.api.Test;
6+
import org.junit.jupiter.params.ParameterizedTest;
7+
import org.junit.jupiter.params.provider.CsvSource;
68

79
import java.util.Date;
810
import java.util.concurrent.TimeUnit;
@@ -288,4 +290,20 @@ public void testAppendRightAlignedNumber() {
288290
assertEquals("PFX0000000100", b.toString());
289291
}
290292

293+
@ParameterizedTest
294+
@CsvSource({
295+
"0 , 0.0 ",
296+
"1.2345 , 1.23 ",
297+
"-1.2345 , -1.23 ",
298+
"99.88888 , 99.89 ",
299+
"-99.88888 , -99.89 ",
300+
"101.88888 , 101.9 ",
301+
"-101.88888 , -101.9 ",
302+
"1001.88888 , 1002 ",
303+
"-1001.88888 , -1002 ",
304+
})
305+
public void testFormatDouble(double theInput, String theExpected) {
306+
assertEquals(theExpected, StopWatch.formatDouble(theInput));
307+
}
308+
291309
}

0 commit comments

Comments
 (0)