@@ -296,37 +296,50 @@ protected FlowThen<ExternalMessageProcessingResult> doCaseSelectedFlow(
296296 (sampleReportIndex , previousSampleResult ) -> createOneSampleAndPathogenTests (caze , sampleReportIndex , false , previousSampleResult );
297297
298298 FlowThen <ExternalMessageProcessingResult > caseFlow = flow .then (previousResult -> {
299- CompletionStage <Void > mismatchInformationStage = CompletableFuture .completedFuture (null );
299+ CompletionStage <Boolean > mismatchInformationStage = CompletableFuture .completedFuture (true );
300300
301301 // Check and inform about symptoms mismatch
302302 if (hasCaseSymptomsMismatch (caze , getExternalMessage ())) {
303- mismatchInformationStage = informCaseSymptomsMismatch (caze , getExternalMessage ());
303+ mismatchInformationStage = confirmCaseSymptomsMismatch (caze , getExternalMessage ());
304304 }
305305
306306 // Chain hospitalization mismatch check
307- mismatchInformationStage = mismatchInformationStage .thenCompose (
308- ignored -> hasCaseHospitalizationMismatch (caze , getExternalMessage ())
309- ? informCaseHospitalizationMismatch (caze , getExternalMessage ())
310- : CompletableFuture .completedFuture (null ));
307+ mismatchInformationStage = mismatchInformationStage .thenCompose (confirmed -> {
308+ if (Boolean .TRUE .equals (confirmed ) && hasCaseHospitalizationMismatch (caze , getExternalMessage ())) {
309+ return confirmCaseHospitalizationMismatch (caze , getExternalMessage ());
310+ } else {
311+ return CompletableFuture .completedFuture (confirmed );
312+ }
313+ });
311314
312315 // Chain exposures mismatch check
313- mismatchInformationStage = mismatchInformationStage .thenCompose (
314- ignored -> hasCaseExposuresMismatch (caze , getExternalMessage ())
315- ? informCaseExposuresMismatch (caze , getExternalMessage ())
316- : CompletableFuture .completedFuture (null ));
316+ mismatchInformationStage = mismatchInformationStage .thenCompose (confirmed -> {
317+ if (Boolean .TRUE .equals (confirmed ) && hasCaseExposuresMismatch (caze , getExternalMessage ())) {
318+ return confirmCaseExposuresMismatch (caze , getExternalMessage ());
319+ } else {
320+ return CompletableFuture .completedFuture (confirmed );
321+ }
322+ });
317323
318324 // Chain activities as case mismatch check
319- mismatchInformationStage = mismatchInformationStage .thenCompose (
320- ignored -> hasCaseActivitiesAsCaseMismatch (caze , getExternalMessage ())
321- ? informCaseActivitiesAsCaseMismatch (caze , getExternalMessage ())
322- : CompletableFuture .completedFuture (null ));
325+ mismatchInformationStage = mismatchInformationStage .thenCompose (confirmed -> {
326+ if (Boolean .TRUE .equals (confirmed ) && hasCaseActivitiesAsCaseMismatch (caze , getExternalMessage ())) {
327+ return confirmCaseActivitiesAsCaseMismatch (caze , getExternalMessage ());
328+ } else {
329+ return CompletableFuture .completedFuture (confirmed );
330+ }
331+ });
323332
324- return mismatchInformationStage .thenCompose (ignored -> {
333+ return mismatchInformationStage .thenCompose (confirmed -> {
325334 ExternalMessageProcessingResult withCase = previousResult .getData ().withSelectedCase (caze );
326335
327- logger .debug ("[MESSAGE PROCESSING] Continue processing with case: {}" , withCase );
328-
329- return ProcessingResult .continueWith (withCase ).asCompletedFuture ();
336+ if (Boolean .TRUE .equals (confirmed )) {
337+ logger .debug ("[MESSAGE PROCESSING] Continue processing with case: {}" , withCase );
338+ return ProcessingResult .continueWith (withCase ).asCompletedFuture ();
339+ } else {
340+ logger .debug ("[MESSAGE PROCESSING] Canceled processing with case: {} information mismatch aborted." , withCase );
341+ return ProcessingResult .withStatus (ProcessingResultStatus .CANCELED , previousResult .getData ()).asCompletedFuture ();
342+ }
330343 });
331344 });
332345 return caseFlow .then (
@@ -944,32 +957,32 @@ protected boolean hasCaseSymptomsMismatch(CaseDataDto caze, ExternalMessageDto e
944957 return false ;
945958 }
946959
947- protected CompletionStage <Void > informCaseSymptomsMismatch (CaseDataDto caze , ExternalMessageDto externalMessage ) {
948- return CompletableFuture .completedFuture (null );
960+ protected CompletionStage <Boolean > confirmCaseSymptomsMismatch (CaseDataDto caze , ExternalMessageDto externalMessage ) {
961+ return CompletableFuture .completedFuture (true );
949962 }
950963
951964 protected boolean hasCaseHospitalizationMismatch (CaseDataDto caze , ExternalMessageDto externalMessage ) {
952965 return false ;
953966 }
954967
955- protected CompletionStage <Void > informCaseHospitalizationMismatch (CaseDataDto caze , ExternalMessageDto externalMessage ) {
956- return CompletableFuture .completedFuture (null );
968+ protected CompletionStage <Boolean > confirmCaseHospitalizationMismatch (CaseDataDto caze , ExternalMessageDto externalMessage ) {
969+ return CompletableFuture .completedFuture (true );
957970 }
958971
959972 protected boolean hasCaseExposuresMismatch (CaseDataDto caze , ExternalMessageDto externalMessage ) {
960973 return false ;
961974 }
962975
963- protected CompletionStage <Void > informCaseExposuresMismatch (CaseDataDto caze , ExternalMessageDto externalMessage ) {
964- return CompletableFuture .completedFuture (null );
976+ protected CompletionStage <Boolean > confirmCaseExposuresMismatch (CaseDataDto caze , ExternalMessageDto externalMessage ) {
977+ return CompletableFuture .completedFuture (true );
965978 }
966979
967980 protected boolean hasCaseActivitiesAsCaseMismatch (CaseDataDto caze , ExternalMessageDto externalMessage ) {
968981 return false ;
969982 }
970983
971- protected CompletionStage <Void > informCaseActivitiesAsCaseMismatch (CaseDataDto caze , ExternalMessageDto externalMessage ) {
972- return CompletableFuture .completedFuture (null );
984+ protected CompletionStage <Boolean > confirmCaseActivitiesAsCaseMismatch (CaseDataDto caze , ExternalMessageDto externalMessage ) {
985+ return CompletableFuture .completedFuture (true );
973986 }
974987
975988 protected abstract void handleCreateSampleAndPathogenTests (
0 commit comments