From f6738fe245fb786296560b59741fa99ff2f170a1 Mon Sep 17 00:00:00 2001 From: Sadibhatla Date: Fri, 31 May 2024 11:07:32 -0700 Subject: [PATCH] Adding current mbi join for matching counts --- .../ab2d/coverage/repository/CoverageServiceRepository.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/coverage/src/main/java/gov/cms/ab2d/coverage/repository/CoverageServiceRepository.java b/coverage/src/main/java/gov/cms/ab2d/coverage/repository/CoverageServiceRepository.java index edf44e436..8e2178d8b 100644 --- a/coverage/src/main/java/gov/cms/ab2d/coverage/repository/CoverageServiceRepository.java +++ b/coverage/src/main/java/gov/cms/ab2d/coverage/repository/CoverageServiceRepository.java @@ -85,8 +85,9 @@ public class CoverageServiceRepository { * * The contract and year must be included to take advantage of the partitions and prevent a table scan */ - private static final String SELECT_COVERAGE_BY_SEARCH_COUNT = "SELECT COUNT(*) FROM coverage " + - " WHERE bene_coverage_search_event_id = :id AND contract = :contract AND year IN (:years) and current_mbi is not null"; + private static final String SELECT_COVERAGE_BY_SEARCH_COUNT = "SELECT COUNT(*) FROM coverage c " + + " join current_mbi m on c.current_mbi=m.mbi" + + " WHERE bene_coverage_search_event_id = :id AND contract = :contract AND year IN (:years) AND opt_out_flag is not false AND current_mbi is not null"; /** * Return a count of all beneficiaries associated with an {@link CoveragePeriod}