From 2ced6c1ac5537f94c4cb57288e3fddf949b80987 Mon Sep 17 00:00:00 2001 From: mozzy11 Date: Tue, 13 Aug 2024 21:51:13 +0300 Subject: [PATCH] fix numeric reflex --- .../action/util/TestReflexUtil.java | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) 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 6ee675ec4e..d02f64d0e0 100644 --- a/src/main/java/org/openelisglobal/testreflex/action/util/TestReflexUtil.java +++ b/src/main/java/org/openelisglobal/testreflex/action/util/TestReflexUtil.java @@ -331,20 +331,15 @@ private List getReflexTests(TestReflexBean reflexBean) { return new ArrayList<>(); } String resultType = testService.getResultType(reflexBean.getResult().getTestResult().getTest()); - List reflexesForResult = reflexResolver.getTestReflexesForResult(reflexBean.getResult()); + List reflexesForResult; if (resultType.equals("D")) { - reflexesForResult = applyDictionaryRelationRulesForReflex(reflexBean.getResult()); - } else if (!resultType.equals("D")) { - if (resultType.equals("N")) { - reflexesForResult = reflexesForResult.stream() - .filter(test -> applyNumericRelationRulesForReflex(test, reflexBean.getResult())) - .collect(Collectors.toList()); - } else { - reflexesForResult = reflexesForResult.stream() - .filter(test -> applyTextRelationRulesForReflex(test, reflexBean.getResult())) - .collect(Collectors.toList()); - } + reflexesForResult = reflexResolver.getTestReflexsByAnalyteAndTest(reflexBean.getResult()); + } else { + reflexesForResult = reflexResolver.getTestReflexesForResult(reflexBean.getResult()); } + reflexesForResult = reflexesForResult.stream() + .filter(e -> isTestTriggeredByResult(e.getAddedTest(), reflexBean.getResult())) + .collect(Collectors.toList()); return reflexesForResult; } @@ -895,13 +890,13 @@ public boolean doesDictionaryRelationRulesForReflexApply(Test potentialReflexTes private boolean doesNumericRulesForReflexApply(Test potentialReflexTest, Result potentialTriggerResult) { List reflexesForResult = reflexResolver.getTestReflexesForResult(potentialTriggerResult); - return reflexesForResult.stream().anyMatch(test -> test.getAddedTest().equals(potentialReflexTest) + return reflexesForResult.stream().anyMatch(test -> test.getAddedTest().getId().equals(potentialReflexTest.getId()) && applyNumericRelationRulesForReflex(test, potentialTriggerResult)); } private boolean doesGenericRulesForReflexApply(Test potentialReflexTest, Result potentialTriggerResult) { List reflexesForResult = reflexResolver.getTestReflexesForResult(potentialTriggerResult); - return reflexesForResult.stream().anyMatch(test -> test.getAddedTest().equals(potentialReflexTest) + return reflexesForResult.stream().anyMatch(test -> test.getAddedTest().getId().equals(potentialReflexTest.getId()) && applyTextRelationRulesForReflex(test, potentialTriggerResult)); } }