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