-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
9067 pbf disable search for inactive payees (#181)
* 9067: Added the Payee Status to the mapping response * 9067: Updated validation to make cancel date still active * 9067: Updated test for payee mappings * 9067: Added validation for non active payee * 9067: Updated to return first active payee record * 9067: Updated to check if payee is active * 9067: Renamed method * 9067: Updates from code review * 9067: Added parameter for contact number * 9067: Updated message
- Loading branch information
Showing
13 changed files
with
264 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...c/main/java/ca/bc/gov/hlth/hnweb/persistence/repository/pbf/PBFClinicPayeeRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,22 @@ | ||
package ca.bc.gov.hlth.hnweb.persistence.repository.pbf; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
|
||
import ca.bc.gov.hlth.hnweb.persistence.entity.pbf.PBFClinicPayee; | ||
|
||
public interface PBFClinicPayeeRepository extends JpaRepository<PBFClinicPayee, Long> { | ||
|
||
/** | ||
* Counts the number of active records for a payee | ||
* | ||
* @param payeeNumber | ||
* @return the number of active records for a payee | ||
*/ | ||
@Query("select count(pcp) from PBFClinicPayee pcp" | ||
+ " where pcp.payeeNumber = :payeeNumber" | ||
+ " and pcp.archived = false" | ||
+ " and pcp.effectiveDate <= CURRENT_DATE" | ||
+ " and (pcp.cancelDate IS NULL OR pcp.cancelDate >= CURRENT_DATE)") | ||
public long countActivePayeeEntries(String payeeNumber); | ||
} |
38 changes: 38 additions & 0 deletions
38
backend/src/main/java/ca/bc/gov/hlth/hnweb/service/PBFClinicPayeeService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package ca.bc.gov.hlth.hnweb.service; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
import ca.bc.gov.hlth.hnweb.persistence.repository.pbf.PBFClinicPayeeRepository; | ||
|
||
/** | ||
* Service for processing PBF clinic payee requests | ||
* | ||
*/ | ||
@Service | ||
public class PBFClinicPayeeService extends BaseService { | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(PBFClinicPayeeService.class); | ||
|
||
@Autowired | ||
private PBFClinicPayeeRepository pbfClinicPayeeRepository; | ||
|
||
/** | ||
* Determines the status of the payee by checking if an active record exists in PBFClinicPayee table | ||
* | ||
* @param payeeNumber | ||
* @return returns true if an active record is found otherwise returns false | ||
*/ | ||
public boolean getPayeeActiveStatus(String payeeNumber) { | ||
long activeCount = pbfClinicPayeeRepository.countActivePayeeEntries(payeeNumber); | ||
|
||
if (activeCount > 1) { | ||
logger.warn("{} active records found for Payee {}.", activeCount, payeeNumber); | ||
} | ||
|
||
return activeCount > 0; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
backend/src/test/java/ca/bc/gov/hlth/hnweb/service/PBFClinicPayeeServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package ca.bc.gov.hlth.hnweb.service; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.context.jdbc.Sql; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@SpringBootTest | ||
@Transactional | ||
@Sql({ "classpath:scripts/bcsc_payee_mapping.sql", "classpath:scripts/pbf_clinic_payee.sql" }) | ||
public class PBFClinicPayeeServiceTest { | ||
|
||
@Autowired | ||
private PBFClinicPayeeService pbfClinicPayeeService; | ||
|
||
@Test | ||
public void testfindActiveStatusByPayeeNumber_payee_not_found() { | ||
|
||
boolean isActive = pbfClinicPayeeService.getPayeeActiveStatus("1234"); | ||
assertFalse(isActive); | ||
} | ||
|
||
@Test | ||
public void testfindActiveStatusByPayeeNumber_payee_archived() { | ||
|
||
boolean isActive = pbfClinicPayeeService.getPayeeActiveStatus("00053"); | ||
assertFalse(isActive); | ||
} | ||
|
||
@Test | ||
public void testfindActiveStatusByPayeeNumber_payee_is_active_no_cancel_date() { | ||
|
||
boolean isActive = pbfClinicPayeeService.getPayeeActiveStatus("00023"); | ||
assertTrue(isActive); | ||
} | ||
|
||
@Test | ||
public void testfindActiveStatusByPayeeNumber_payee_is_active_future_cancel_date() { | ||
|
||
boolean isActive = pbfClinicPayeeService.getPayeeActiveStatus("00033"); | ||
assertTrue(isActive); | ||
} | ||
|
||
@Test | ||
public void testfindActiveStatusByPayeeNumber_payee_is_active_effective_today() { | ||
|
||
boolean isActive = pbfClinicPayeeService.getPayeeActiveStatus("00043"); | ||
assertTrue(isActive); | ||
} | ||
|
||
@Test | ||
public void testfindActiveStatusByPayeeNumber_payee_not_yet_active_effective_tomorrow() { | ||
|
||
boolean isActive = pbfClinicPayeeService.getPayeeActiveStatus("T0055"); | ||
assertFalse(isActive); | ||
} | ||
|
||
@Test | ||
public void testfindActiveStatusByPayeeNumber_payee_is_active_cancelled_today() { | ||
|
||
boolean isActive = pbfClinicPayeeService.getPayeeActiveStatus("T0053"); | ||
assertTrue(isActive); | ||
} | ||
|
||
@Test | ||
public void testfindActiveStatusByPayeeNumber_payee_not_active_cancelled_yesterday() { | ||
|
||
boolean isActive = pbfClinicPayeeService.getPayeeActiveStatus("X0053"); | ||
assertFalse(isActive); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.