Skip to content

Commit

Permalink
Merge pull request #462 from bcgov/feature/EDX-2178
Browse files Browse the repository at this point in the history
feat: Add v79 - funding warning no funding for sped
  • Loading branch information
mightycox authored Feb 16, 2024
2 parents 452b448 + fe71bc8 commit 1e2021d
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public enum StudentValidationIssueTypeCode {
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."),
SCHOOL_AGED_ELL("SCHOOLAGEDELL", "Only school-aged students will receive funding for English Language Learning."),
SCHOOL_AGED_SPED("SCHOOLAGEDSPED", "Only school-aged students or non-graduated adults will receive funding for Special Education."),
;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public enum ValidationRulesDependencyMatrix {
ENTRY53("V47", new String[]{NO_OF_COURSES_INVALID.getCode(), INVALID_GRADE_CODE.getCode(), DOB_INVALID_FORMAT.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()}),
ENTRY56("V78", new String[]{DOB_INVALID_FORMAT.getCode(), ENROLLED_CODE_PARSE_ERR.getCode(), ENROLLED_CODE_INVALID.getCode()});
ENTRY56("V78", new String[]{DOB_INVALID_FORMAT.getCode(), ENROLLED_CODE_PARSE_ERR.getCode(), ENROLLED_CODE_INVALID.getCode()}),
ENTRY57("V79", new String[]{DOB_INVALID_FORMAT.getCode(), SPED_ERR.getCode()});

@Getter
private final String ruleID;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
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.rules.ValidationBaseRule;
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.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

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

/**
* | ID | Severity | Rule | Dependent On |
* |-----|----------|------------------------------------------------------------------------------|--------------|
* | V79 | WARNING | Only school-aged students or non-graduated students will receive funding | V04, V60 |
* for Special Education.
*
*/
@Component
@Slf4j
@Order(750)
public class SchoolAgedSpedRule implements ValidationBaseRule {
@Override
public boolean shouldExecute(StudentRuleData studentRuleData, List<SdcSchoolCollectionStudentValidationIssue> validationErrorsMap) {
log.debug("In shouldExecute of SchoolAgedSPEDRule-V79: for collectionType {} and sdcSchoolCollectionStudentID :: {}" , FteCalculatorUtils.getCollectionTypeCode(studentRuleData),
studentRuleData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID());

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

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

return shouldExecute;
}

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

final List<SdcSchoolCollectionStudentValidationIssue> errors = new ArrayList<>();
var student = studentRuleData.getSdcSchoolCollectionStudentEntity();

log.debug("SchoolAgedSpedRule-V79: Only school-aged students or non-graduated adults will receive funding for Special Education for sdcSchoolCollectionStudentID:: {}", studentRuleData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID());
if ((StringUtils.isNotEmpty(student.getSpecialEducationCategoryCode()) && DOBUtil.isAdult(student.getDob()) && BooleanUtils.isTrue(student.getIsGraduated()))
|| (StringUtils.isNotEmpty(student.getSpecialEducationCategoryCode()) && !DOBUtil.isAdult(student.getDob()) && !DOBUtil.isSchoolAged(student.getDob()))) {
errors.add(createValidationIssue(StudentValidationIssueSeverityCode.FUNDING_WARNING, StudentValidationFieldCode.SPECIAL_EDUCATION_CATEGORY_CODE, StudentValidationIssueTypeCode.SCHOOL_AGED_SPED));
errors.add(createValidationIssue(StudentValidationIssueSeverityCode.FUNDING_WARNING, StudentValidationFieldCode.DOB, StudentValidationIssueTypeCode.SCHOOL_AGED_SPED));
}

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

@Test
void testSchoolAgedSpedRule() {
var collection = collectionRepository.save(createMockCollectionEntity());
var sdcSchoolCollectionEntity = sdcSchoolCollectionRepository.save(createMockSdcSchoolCollectionEntity(collection, null, null));
val entity = this.createMockSchoolStudentEntity(sdcSchoolCollectionEntity);
val entity2 = this.createMockSchoolStudentEntity(sdcSchoolCollectionEntity);
entity.setSpecialEducationCategoryCode("A");
entity.setDob("19890101");
entity.setIsGraduated(true);
entity2.setSpecialEducationCategoryCode("A");
entity2.setDob("20230101");

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


val validationError2 = rulesProcessor.processRules(createMockStudentRuleData(entity2, createMockSchool()));
val error21 = validationError2.stream().anyMatch(val -> val.getValidationIssueCode().equals(StudentValidationIssueTypeCode.SCHOOL_AGED_SPED.getCode())
&& val.getValidationIssueFieldCode().equals(StudentValidationFieldCode.SPECIAL_EDUCATION_CATEGORY_CODE.getCode()));
val error22 = validationError2.stream().anyMatch(val -> val.getValidationIssueCode().equals(StudentValidationIssueTypeCode.SCHOOL_AGED_SPED.getCode())
&& val.getValidationIssueFieldCode().equals(StudentValidationFieldCode.DOB.getCode()));
assertThat(error21).isTrue();
assertThat(error22).isTrue();
}

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

0 comments on commit 1e2021d

Please sign in to comment.