From 724800a35b7ee0d1a024a569995426e35b1faab9 Mon Sep 17 00:00:00 2001 From: mozzy11 Date: Thu, 19 Dec 2024 13:36:32 +0300 Subject: [PATCH 1/2] minor fixes on calculated value --- .../action/util/TestCalculatedUtil.java | 15 +++++++++++++-- .../search/SearchResultsServiceTest.java | 4 ++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/openelisglobal/testcalculated/action/util/TestCalculatedUtil.java b/src/main/java/org/openelisglobal/testcalculated/action/util/TestCalculatedUtil.java index 0c8cf126a0..3ed0f2331b 100644 --- a/src/main/java/org/openelisglobal/testcalculated/action/util/TestCalculatedUtil.java +++ b/src/main/java/org/openelisglobal/testcalculated/action/util/TestCalculatedUtil.java @@ -202,9 +202,12 @@ public List addNewTestsToDBForCalculatedTests(List resultSe ScriptEngine scriptEngine = scriptEngineManager.getEngineByName("JavaScript"); String value = null; try { + Log.debug("Caliculation Rule: " + calculation.getName() + " Function : " + + function.toString()); value = scriptEngine.eval(function.toString()).toString(); + Log.debug("Caliculation Rule: " + calculation.getName() + " Value : " + value); } catch (ScriptException e) { - Log.error("Invalid Calication Rule: " + calculation.getName(), e); + Log.error("Invalid Caliculation Rule: " + calculation.getName(), e); } Analysis analysis = createCalculatedResult(resultCalculation, resultSet, calculation, value, sysUserId); @@ -257,6 +260,9 @@ private Analysis createCalculatedResult(ResultCalculation resultCalculation, Res result.setMaxNormal(resultLimit.getHighNormal()); result.setMinNormal(resultLimit.getLowNormal()); } + if (testResult.getSignificantDigits() != null) { + result.setSignificantDigits(Integer.valueOf(testResult.getSignificantDigits())); + } result.setResultType(testService.getResultType(test)); result.setSysUserId(systemUserId); Boolean resultCalculated = false; @@ -276,6 +282,10 @@ private Analysis createCalculatedResult(ResultCalculation resultCalculation, Res result.setValue(""); } } else if ("N".equals(resultType)) { + if (testResult.getSignificantDigits() != null) { + double factor = Math.pow(10, Double.valueOf(testResult.getSignificantDigits())); + value = String.valueOf(Math.round(Double.valueOf(value) * factor) / factor); + } result.setValue(value); resultCalculated = true; } @@ -360,7 +370,8 @@ private TestResult getTestResultForCalculation(Calculation calculation) { // we are assuming there is only one testResult for a numeric // type result if (!testResultList.isEmpty()) { - return testResultList.get(0); + // get the latest modified test result + return testResultList.get(testResultList.size() - 1); } } diff --git a/src/test/java/org/openelisglobal/search/SearchResultsServiceTest.java b/src/test/java/org/openelisglobal/search/SearchResultsServiceTest.java index 7a29e1a5c5..1901eceb75 100644 --- a/src/test/java/org/openelisglobal/search/SearchResultsServiceTest.java +++ b/src/test/java/org/openelisglobal/search/SearchResultsServiceTest.java @@ -56,24 +56,28 @@ public void tearDown() { personService.deleteAll(personService.getAll()); } + @SuppressWarnings("unused") private Object[] parametersForGetSearchResults_shouldGetSearchResultsFromDB() { return new Object[] { new Object[] { "Jo", "Do", "12/12/1992", "M" }, new Object[] { "Jo", null, null, null }, new Object[] { null, "Do", null, null }, new Object[] { null, null, "12/12/1992", null }, new Object[] { null, null, null, "M" } }; } + @SuppressWarnings("unused") private Object[] parametersForGetSearchResultsExact_shouldGetExactSearchResultsFromDB() { return new Object[] { new Object[] { "John", "Doe", "12/12/1992", "M" }, new Object[] { "John", null, null, null }, new Object[] { null, "Doe", null, null }, new Object[] { null, null, "12/12/1992", null }, new Object[] { null, null, null, "M" } }; } + @SuppressWarnings("unused") private Object[] parametersForGetSearchResults_shouldGetSearchResultsFromLuceneIndexes() { return new Object[] { new Object[] { "Johm", "Doee", "12/12/1992", "M" }, new Object[] { "Johm", null, null, null }, new Object[] { null, "Doee", null, null }, new Object[] { null, null, "12/12/1992", null }, new Object[] { null, null, null, "M" } }; } + @SuppressWarnings("unused") private Object[] parametersForGetSearchResultsExact_shouldGetExactSearchResultsFromLuceneIndexes() { return new Object[] { new Object[] { "John", "Doe", "12/12/1992", "M" }, new Object[] { "John", null, null, null }, new Object[] { null, "Doe", null, null }, From af8dd0f5050754ba5cf487f7b152413cb36bc23d Mon Sep 17 00:00:00 2001 From: mozzy11 Date: Thu, 19 Dec 2024 13:50:42 +0300 Subject: [PATCH 2/2] "Update submodule URL after repository transfer" --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 7663a22cc0..65f496b5d3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "plugins"] path = plugins - url = https://github.com/openelisglobal/openelisglobal-plugins.git + url = https://github.com/I-TECH-UW/openelisglobal-plugins.git [submodule "tools/Liquibase-Outdated"] path = tools/Liquibase-Outdated url = https://github.com/I-TECH-UW/Liquibase-Outdated.git