mirror of
https://github.com/hapifhir/hapi-fhir.git
synced 2025-02-16 18:05:19 +00:00
Resolve 5452-mdm-query-link-returns-scientific-notation-in-linkcreated-and-linkupdated (#5453)
* set the scale to 0 when transforming double to BigDecimal * - set negative scale to 0 when transforming double to BigDecimal - added test
This commit is contained in:
parent
9dace159b4
commit
41d9abf6ac
@ -403,8 +403,15 @@ public class ParametersUtil {
|
|||||||
public static void addPartDecimal(FhirContext theContext, IBase theParameter, String theName, Double theValue) {
|
public static void addPartDecimal(FhirContext theContext, IBase theParameter, String theName, Double theValue) {
|
||||||
IPrimitiveType<BigDecimal> value = (IPrimitiveType<BigDecimal>)
|
IPrimitiveType<BigDecimal> value = (IPrimitiveType<BigDecimal>)
|
||||||
theContext.getElementDefinition("decimal").newInstance();
|
theContext.getElementDefinition("decimal").newInstance();
|
||||||
value.setValue(theValue == null ? null : BigDecimal.valueOf(theValue));
|
if (theValue == null) {
|
||||||
|
value.setValue(null);
|
||||||
|
} else {
|
||||||
|
BigDecimal decimalValue = BigDecimal.valueOf(theValue);
|
||||||
|
if (decimalValue.scale() < 0) {
|
||||||
|
decimalValue = decimalValue.setScale(0);
|
||||||
|
}
|
||||||
|
value.setValue(decimalValue);
|
||||||
|
}
|
||||||
addPart(theContext, theParameter, theName, value);
|
addPart(theContext, theParameter, theName, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
type: fix
|
||||||
|
issue: 5452
|
||||||
|
title: "Previously, the $mdm-query-link operation would return values of field linkCreated and linkUpdated in scientific
|
||||||
|
notation when the last digits are 0. This is now fixed and always returns in standard notation."
|
@ -9,6 +9,7 @@ import org.hl7.fhir.r4.model.Parameters;
|
|||||||
import org.hl7.fhir.r4.model.StringType;
|
import org.hl7.fhir.r4.model.StringType;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@ -79,4 +80,20 @@ public class ParametersUtilR4Test {
|
|||||||
assertThat(values.get(1), is(TEST_PERSON_ID));
|
assertThat(values.get(1), is(TEST_PERSON_ID));
|
||||||
assertThat(values.get(2), is(TEST_PERSON_ID));
|
assertThat(values.get(2), is(TEST_PERSON_ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddPartDecimalNoScientificNotation() {
|
||||||
|
// setup
|
||||||
|
Double decimalValue = Double.valueOf("10000000");
|
||||||
|
IBaseParameters parameters = ParametersUtil.newInstance(ourFhirContext);
|
||||||
|
IBase resultPart = ParametersUtil.addParameterToParameters(ourFhirContext, parameters, "link");
|
||||||
|
|
||||||
|
// execute
|
||||||
|
ParametersUtil.addPartDecimal(ourFhirContext, resultPart, "linkCreated", decimalValue);
|
||||||
|
|
||||||
|
// verify
|
||||||
|
String expected = BigDecimal.valueOf(decimalValue).toPlainString();
|
||||||
|
List<String> results = ParametersUtil.getNamedParameterPartAsString(ourFhirContext, parameters, "link", "linkCreated");
|
||||||
|
assertEquals(expected, results.get(0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user