From f85516c20eddc3fd31259d7e242d92180c805565 Mon Sep 17 00:00:00 2001 From: Avisha Sodhi <38086281+SodhiA1@users.noreply.github.com> Date: Mon, 13 Jan 2025 14:07:49 -0800 Subject: [PATCH] New program eligibility rule --- .../v1/ProgramEligibilityIssueCode.java | 1 + .../impl/SpecialEducationProgramsRule.java | 10 ++- .../ProgramEligibilityRulesProcessorTest.java | 76 +++++++++++++++++++ 3 files changed, 83 insertions(+), 4 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/constants/v1/ProgramEligibilityIssueCode.java b/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/constants/v1/ProgramEligibilityIssueCode.java index 22287eb8e..e030e6944 100644 --- a/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/constants/v1/ProgramEligibilityIssueCode.java +++ b/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/constants/v1/ProgramEligibilityIssueCode.java @@ -16,6 +16,7 @@ public enum ProgramEligibilityIssueCode { NOT_ENROLLED_SPECIAL_ED("NTENRSPED", "The student was not reported in any inclusive education programs."), NON_ELIG_SPECIAL_EDUCATION("NELISPED", "Student must be school-aged or a non-graduated adult reported in a grade other than GA."), FEB_ONLINE_WITH_HISTORICAL_FUNDING("FEBSPEDERR", "Student has already been funded in September collection."), + INDP_FIRST_NATION_SPED("FUND20SPED", "Student with Funding code 20 will not be funded for inclusive education programs."), INDIGENOUS_ADULT("ISADULTAGE", "Student must be school-aged and self-identify as having Indigenous Ancestry to be eligible for funding for Indigenous Support Programs."), YEARS_IN_ELL("ELL5ORLESS", "Student must be school-aged and have been reported in ELL for 5 years or less."), NOT_ENROLLED_ELL("NTENRELL", "The student is not enrolled in the ELL program."), diff --git a/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/rules/programelegibility/impl/SpecialEducationProgramsRule.java b/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/rules/programelegibility/impl/SpecialEducationProgramsRule.java index cbf9db0fc..0a0f73f42 100644 --- a/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/rules/programelegibility/impl/SpecialEducationProgramsRule.java +++ b/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/rules/programelegibility/impl/SpecialEducationProgramsRule.java @@ -1,10 +1,7 @@ package ca.bc.gov.educ.studentdatacollection.api.rules.programelegibility.impl; import ca.bc.gov.educ.studentdatacollection.api.calculator.FteCalculatorUtils; -import ca.bc.gov.educ.studentdatacollection.api.constants.v1.CollectionTypeCodes; -import ca.bc.gov.educ.studentdatacollection.api.constants.v1.FacilityTypeCodes; -import ca.bc.gov.educ.studentdatacollection.api.constants.v1.ProgramEligibilityIssueCode; -import ca.bc.gov.educ.studentdatacollection.api.constants.v1.SchoolGradeCodes; +import ca.bc.gov.educ.studentdatacollection.api.constants.v1.*; import ca.bc.gov.educ.studentdatacollection.api.rules.ProgramEligibilityBaseRule; import ca.bc.gov.educ.studentdatacollection.api.service.v1.ValidationRulesService; import ca.bc.gov.educ.studentdatacollection.api.struct.StudentRuleData; @@ -64,6 +61,11 @@ public List executeValidation(StudentRuleData stude } else if (Boolean.FALSE.equals(isSchoolAged) && (isGraduated || (isAdult && isGA))) { log.debug("ProgramEligibilityBaseRule - SpecialEducationProgramsRule: Is school aged - {}, Is non graduated adult - {}, for sdcSchoolCollectionStudentID :: {}", student.getIsSchoolAged(), student.getIsGraduated(), studentRuleData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID()); errors.add(ProgramEligibilityIssueCode.NON_ELIG_SPECIAL_EDUCATION); + } else if(SchoolCategoryCodes.INDEPENDENTS.contains(studentRuleData.getSchool().getSchoolCategoryCode()) + && StringUtils.isNotEmpty(student.getSchoolFundingCode()) + && SchoolFundingCodes.STATUS_FIRST_NATION.getCode().equals(student.getSchoolFundingCode())) { + log.debug("ProgramEligibilityBaseRule - SpecialEducationProgramsRule: SchoolCategoryCode - {}, SchoolFundingCode - {}, for sdcSchoolCollectionStudentID :: {}", studentRuleData.getSchool().getSchoolCategoryCode(), student.getSchoolFundingCode(), studentRuleData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID()); + errors.add(ProgramEligibilityIssueCode.INDP_FIRST_NATION_SPED); } else if(collectionType.equalsIgnoreCase(CollectionTypeCodes.FEBRUARY.getTypeCode()) && onlineFacilityCodes.contains(facilityType) && historicalStudents.stream().anyMatch(stu -> stu.getFte().compareTo(BigDecimal.ZERO) > 0 && stu.getSpecialEducationNonEligReasonCode() == null)) { log.debug("ProgramEligibilityBaseRule - SpecialEducationProgramsRule: CollectionTypeCodes - {}, facilityType - {}, for sdcSchoolCollectionStudentID :: {}", collectionType, facilityType, studentRuleData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID()); diff --git a/api/src/test/java/ca/bc/gov/educ/studentdatacollection/api/rules/ProgramEligibilityRulesProcessorTest.java b/api/src/test/java/ca/bc/gov/educ/studentdatacollection/api/rules/ProgramEligibilityRulesProcessorTest.java index 516e26b33..df443bc40 100644 --- a/api/src/test/java/ca/bc/gov/educ/studentdatacollection/api/rules/ProgramEligibilityRulesProcessorTest.java +++ b/api/src/test/java/ca/bc/gov/educ/studentdatacollection/api/rules/ProgramEligibilityRulesProcessorTest.java @@ -774,6 +774,82 @@ void testSpecialEdStudentSchoolAgedAdultGANotEligible() { )).isTrue(); } + @Test + void testSpecialEdEligibility_INDPSchools_WithFundingCode20() { + UUID assignedStudentID = UUID.randomUUID(); + + var mockCollection = createMockCollectionEntity(); + mockCollection.setCollectionTypeCode(CollectionTypeCodes.FEBRUARY.getTypeCode()); + mockCollection.setCloseDate(LocalDateTime.now().plusDays(2)); + CollectionEntity collection = collectionRepository.save(mockCollection); + + SchoolTombstone school = createMockSchool(); + school.setSchoolCategoryCode(SchoolCategoryCodes.INDEPEND.getCode()); + UUID schoolId = UUID.fromString(school.getSchoolId()); + doReturn(Optional.of(school)).when(restUtils).getSchoolBySchoolID(schoolId.toString()); + + var sdcSchoolCollectionEntity = createMockSdcSchoolCollectionEntity(collection, schoolId); + sdcSchoolCollectionRepository.save(sdcSchoolCollectionEntity); + + val entity = this.createMockSchoolStudentEntity(sdcSchoolCollectionEntity); + entity.setAssignedStudentId(assignedStudentID); + entity.setEnrolledGradeCode("08"); + entity.setSchoolFundingCode("20"); + + PenMatchResult penMatchResult = getPenMatchResult(); + penMatchResult.getMatchingRecords().get(0).setStudentID(String.valueOf(assignedStudentID)); + when(this.restUtils.getPenMatchResult(any(),any(), anyString())).thenReturn(penMatchResult); + + List listWithoutEnrollmentError = rulesProcessor.processRules( + createMockStudentRuleData( + entity, + school + ) + ); + + assertThat(listWithoutEnrollmentError.stream().anyMatch(e -> + e.equals(ProgramEligibilityIssueCode.INDP_FIRST_NATION_SPED) + )).isTrue(); + } + + @Test + void testSpecialEdEligibility_INDPSchools_WithFundingCode16() { + UUID assignedStudentID = UUID.randomUUID(); + + var mockCollection = createMockCollectionEntity(); + mockCollection.setCollectionTypeCode(CollectionTypeCodes.FEBRUARY.getTypeCode()); + mockCollection.setCloseDate(LocalDateTime.now().plusDays(2)); + CollectionEntity collection = collectionRepository.save(mockCollection); + + SchoolTombstone school = createMockSchool(); + school.setSchoolCategoryCode(SchoolCategoryCodes.INDEPEND.getCode()); + UUID schoolId = UUID.fromString(school.getSchoolId()); + doReturn(Optional.of(school)).when(restUtils).getSchoolBySchoolID(schoolId.toString()); + + var sdcSchoolCollectionEntity = createMockSdcSchoolCollectionEntity(collection, schoolId); + sdcSchoolCollectionRepository.save(sdcSchoolCollectionEntity); + + val entity = this.createMockSchoolStudentEntity(sdcSchoolCollectionEntity); + entity.setAssignedStudentId(assignedStudentID); + entity.setEnrolledGradeCode("08"); + entity.setSchoolFundingCode("16"); + + PenMatchResult penMatchResult = getPenMatchResult(); + penMatchResult.getMatchingRecords().get(0).setStudentID(String.valueOf(assignedStudentID)); + when(this.restUtils.getPenMatchResult(any(),any(), anyString())).thenReturn(penMatchResult); + + List listWithoutEnrollmentError = rulesProcessor.processRules( + createMockStudentRuleData( + entity, + school + ) + ); + + assertThat(listWithoutEnrollmentError.stream().anyMatch(e -> + e.equals(ProgramEligibilityIssueCode.INDP_FIRST_NATION_SPED) + )).isFalse(); + } + @Test void testSpecialEdEligibilityInFebCollection() { UUID assignedStudentID = UUID.randomUUID();