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 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 },