From 92c73429a3e548f0f2b14d11020e24549f1d2769 Mon Sep 17 00:00:00 2001 From: mozzy11 Date: Tue, 18 Jun 2024 19:01:25 +0300 Subject: [PATCH] Fix Rule Builder --- .../action/util/TestCalculatedUtil.java | 38 +++++++++++++------ .../action/util/TestReflexUtil.java | 8 +++- 2 files changed, 33 insertions(+), 13 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 7548820830..035f050f84 100644 --- a/src/main/java/org/openelisglobal/testcalculated/action/util/TestCalculatedUtil.java +++ b/src/main/java/org/openelisglobal/testcalculated/action/util/TestCalculatedUtil.java @@ -113,20 +113,27 @@ public List addNewTestsToDBForCalculatedTests( map.put(Integer.valueOf(test.getId()), null); }); // insert innitial result value - map.put( - Integer.valueOf(resultSet.result.getTestResult().getTest().getId()), - Integer.valueOf(resultSet.result.getId())); + if (resultSet.result.getTestResult().getTest().getId() != null + && resultSet.result.getId() != null) { + map.put( + Integer.valueOf(resultSet.result.getTestResult().getTest().getId()), + Integer.valueOf(resultSet.result.getId())); + } calc.setTestResultMap(map); resultcalculationService.insert(calc); } } else { for (ResultCalculation resultCalculation : resultCalculations) { - resultCalculation - .getTestResultMap() - .put( - Integer.valueOf(resultSet.result.getTestResult().getTest().getId()), - Integer.valueOf(resultSet.result.getId())); + if (resultSet.result.getTestResult().getTest().getId() != null + && resultSet.result.getId() != null) { + resultCalculation + .getTestResultMap() + .put( + Integer.valueOf(resultSet.result.getTestResult().getTest().getId()), + Integer.valueOf(resultSet.result.getId())); + } + resultcalculationService.update(resultCalculation); } } @@ -181,7 +188,7 @@ public List addNewTestsToDBForCalculatedTests( function.append(number).append(" "); } } catch (NumberFormatException e) { - + } break; case MATH_FUNCTION: @@ -530,9 +537,18 @@ private Analysis createCalculatedAnalysis( generatedAnalysis.setSysUserId(systemUserId); generatedAnalysis.setResultCalculated(resultCalculated); if (existingAnalysis != null) { - analysisService.update(generatedAnalysis); + try { + analysisService.update(generatedAnalysis); + } catch (Exception e) { + return null; + } + } else { - analysisService.insert(generatedAnalysis); + try { + analysisService.insert(generatedAnalysis); + } catch (Exception e) { + return null; + } } if (resultCalculated) { createInternalNote( diff --git a/src/main/java/org/openelisglobal/testreflex/action/util/TestReflexUtil.java b/src/main/java/org/openelisglobal/testreflex/action/util/TestReflexUtil.java index 53a23c05f1..4d1088bfd1 100644 --- a/src/main/java/org/openelisglobal/testreflex/action/util/TestReflexUtil.java +++ b/src/main/java/org/openelisglobal/testreflex/action/util/TestReflexUtil.java @@ -704,8 +704,12 @@ private Optional addReflexTest( currentAnalysis.setSysUserId(sysUserId); currentAnalysis.setTriggeredReflex(Boolean.TRUE); - analysisService.insert(newAnalysis); - analysisService.update(currentAnalysis); + try { + analysisService.insert(newAnalysis); + analysisService.update(currentAnalysis); + } catch (Exception e) { + return Optional.empty(); + } List notes = new ArrayList<>(); notes.add(