Skip to content

Commit

Permalink
Merge pull request #450 from bcgov/feature/EDX-2163
Browse files Browse the repository at this point in the history
school aged indigenous support rule
  • Loading branch information
SodhiA1 authored Feb 13, 2024
2 parents 0c71f90 + e1de93d commit 35d86f3
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ public enum StudentValidationIssueTypeCode {
SCHOOL_AGED_GRADUATE_SUPPORT_BLOCKS("SCHLAGEDGRADSUPPORT", "Graduated school-aged students will not receive funding for support blocks."),
GRADUATE_STUDENT_INDEPENDENT("GRADSTUDENTINDEPEND", "Graduated adult students are not eligible for funding."),
ADULT_ZERO_COURSE_HISTORY("ADULTZEROCOURSEH", "Zero courses reported in last two years."),
SCHOOL_AGED_ZERO_COURSE_HISTORY("SCHOOLAGEDZEROCOURSEH", "Zero courses reported in last two years.")
SCHOOL_AGED_ZERO_COURSE_HISTORY("SCHOOLAGEDZEROCOURSEH", "Zero courses reported in last two years."),
SCHOOL_AGED_INDIGENOUS_SUPPORT("SCHOOLAGEDINDIGENOUSSUPPORT", "Only school-aged students will receive funding for Indigenous Support Programs."),
;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public enum ValidationRulesDependencyMatrix {
ENTRY51("V75", new String[]{ENROLLED_CODE_PARSE_ERR.getCode()}),
ENTRY52("V34", new String[]{NO_OF_COURSES_INVALID.getCode(), INVALID_GRADE_CODE.getCode(), DOB_INVALID_FORMAT.getCode()}),
ENTRY53("V47", new String[]{NO_OF_COURSES_INVALID.getCode(), INVALID_GRADE_CODE.getCode(), DOB_INVALID_FORMAT.getCode()}),
ENTRY54("V76", new String[]{SPED_ERR.getCode()});
ENTRY54("V76", new String[]{SPED_ERR.getCode()}),
ENTRY55("V77", new String[]{DOB_INVALID_FORMAT.getCode(), ENROLLED_CODE_PARSE_ERR.getCode(), ENROLLED_CODE_INVALID.getCode()});


@Getter
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package ca.bc.gov.educ.studentdatacollection.api.rules.validationrules.impl;

import ca.bc.gov.educ.studentdatacollection.api.calculator.FteCalculatorUtils;
import ca.bc.gov.educ.studentdatacollection.api.constants.StudentValidationFieldCode;
import ca.bc.gov.educ.studentdatacollection.api.constants.StudentValidationIssueSeverityCode;
import ca.bc.gov.educ.studentdatacollection.api.constants.StudentValidationIssueTypeCode;
import ca.bc.gov.educ.studentdatacollection.api.constants.v1.EnrolledProgramCodes;
import ca.bc.gov.educ.studentdatacollection.api.rules.ValidationBaseRule;
import ca.bc.gov.educ.studentdatacollection.api.service.v1.ValidationRulesService;
import ca.bc.gov.educ.studentdatacollection.api.struct.StudentRuleData;
import ca.bc.gov.educ.studentdatacollection.api.struct.v1.SdcSchoolCollectionStudentValidationIssue;
import ca.bc.gov.educ.studentdatacollection.api.util.DOBUtil;
import lombok.extern.slf4j.Slf4j;

import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
* | ID | Severity | Rule | Dependent On |
* |-----|----------|------------------------------------------------------------------------------|--------------|
* | V77 | WARNING | Only school-aged students should be reported with Indigenous Support | V04, V30 |
* Programs.
*
*/
@Component
@Slf4j
@Order(690)
public class SchoolAgedIndigenousSupportRule implements ValidationBaseRule {
private final ValidationRulesService validationRulesService;

public SchoolAgedIndigenousSupportRule(ValidationRulesService validationRulesService) {
this.validationRulesService = validationRulesService;
}

@Override
public boolean shouldExecute(StudentRuleData studentRuleData, List<SdcSchoolCollectionStudentValidationIssue> validationErrorsMap) {
log.debug("In shouldExecute of AdultIndigenousFundingRule-V77: for collectionType {} and sdcSchoolCollectionStudentID :: {}" , FteCalculatorUtils.getCollectionTypeCode(studentRuleData),
studentRuleData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID());

var shouldExecute = isValidationDependencyResolved("V77", validationErrorsMap);

log.debug("In shouldExecute of AdultIndigenousFundingRule-V77: Condition returned - {} for sdcSchoolCollectionStudentID :: {}" ,
shouldExecute,
studentRuleData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID());

return shouldExecute;
}

@Override
public List<SdcSchoolCollectionStudentValidationIssue> executeValidation(StudentRuleData studentRuleData) {
log.debug("In executeValidation of AdultIndigenousFundingRule-V77 for sdcSchoolCollectionStudentID ::" + studentRuleData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID());

final List<SdcSchoolCollectionStudentValidationIssue> errors = new ArrayList<>();
var student = studentRuleData.getSdcSchoolCollectionStudentEntity();
List<String> studentPrograms = validationRulesService.splitString(student.getEnrolledProgramCodes());

log.debug("AdultIndigenousFundingRule-V77: Invalid age for Indigenous Support Programs for sdcSchoolCollectionStudentID:: {}", studentRuleData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID());
if (EnrolledProgramCodes.getIndigenousProgramCodes().stream().anyMatch(studentPrograms::contains)
&& DOBUtil.isAdult(student.getDob())) {
errors.add(createValidationIssue(StudentValidationIssueSeverityCode.FUNDING_WARNING, StudentValidationFieldCode.ENROLLED_PROGRAM_CODE, StudentValidationIssueTypeCode.SCHOOL_AGED_INDIGENOUS_SUPPORT));
errors.add(createValidationIssue(StudentValidationIssueSeverityCode.FUNDING_WARNING, StudentValidationFieldCode.DOB, StudentValidationIssueTypeCode.SCHOOL_AGED_INDIGENOUS_SUPPORT));
}

return errors;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,23 @@ void testOutOfProvinceSpecialEducRule() {
assertThat(error2).isTrue();
}

@Test
void testSchoolAgedIndigenousSupportRule() {
var collection = collectionRepository.save(createMockCollectionEntity());
var sdcSchoolCollectionEntity = sdcSchoolCollectionRepository.save(createMockSdcSchoolCollectionEntity(collection, null, null));
val entity = this.createMockSchoolStudentEntity(sdcSchoolCollectionEntity);
entity.setEnrolledProgramCodes("33");
entity.setDob("19890101");

val validationError = rulesProcessor.processRules(createMockStudentRuleData(entity, createMockSchool()));
val error1 = validationError.stream().anyMatch(val -> val.getValidationIssueCode().equals(StudentValidationIssueTypeCode.SCHOOL_AGED_INDIGENOUS_SUPPORT.getCode())
&& val.getValidationIssueFieldCode().equals(StudentValidationFieldCode.ENROLLED_PROGRAM_CODE.getCode()));
val error2 = validationError.stream().anyMatch(val -> val.getValidationIssueCode().equals(StudentValidationIssueTypeCode.SCHOOL_AGED_INDIGENOUS_SUPPORT.getCode())
&& val.getValidationIssueFieldCode().equals(StudentValidationFieldCode.DOB.getCode()));
assertThat(error1).isTrue();
assertThat(error2).isTrue();
}

@Test
void testAdultGraduatesRule() {
var collection = collectionRepository.save(createMockCollectionEntity());
Expand Down

0 comments on commit 35d86f3

Please sign in to comment.