Skip to content

Commit

Permalink
Merge pull request #1351 from mozzy11/develop
Browse files Browse the repository at this point in the history
minor fixes on calculated value
  • Loading branch information
mozzy11 authored Dec 19, 2024
2 parents 2677579 + af8dd0f commit 6345a9d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,12 @@ public List<Analysis> addNewTestsToDBForCalculatedTests(List<ResultSet> 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);
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down

0 comments on commit 6345a9d

Please sign in to comment.