From 8914629149d01667ce213e4616f218867f980f0a Mon Sep 17 00:00:00 2001 From: Marco Villeneuve Date: Mon, 13 Jan 2025 11:09:39 -0800 Subject: [PATCH] Changes for feb versions of special ed headcount reports --- .../SdcSchoolCollectionStudentRepository.java | 68 +++++++++++++++++++ .../service/v1/reports/CSVReportService.java | 11 ++- .../v1/reports/MinistryHeadcountService.java | 16 ++++- 3 files changed, 91 insertions(+), 4 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/repository/v1/SdcSchoolCollectionStudentRepository.java b/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/repository/v1/SdcSchoolCollectionStudentRepository.java index af913e144..9b58e2e52 100644 --- a/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/repository/v1/SdcSchoolCollectionStudentRepository.java +++ b/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/repository/v1/SdcSchoolCollectionStudentRepository.java @@ -1181,6 +1181,46 @@ AND SSCS.enrolledGradeCode NOT IN ('08', '09') "ORDER BY s.sdcSchoolCollection.schoolID") List getSpecialEdCategoryForIndiesAndOffshoreByCollectionId(UUID collectionID); + @Query("SELECT " + + "s.sdcSchoolCollection.schoolID AS schoolID, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode IN ('A', 'B') THEN 1 END) AS levelOnes, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode IN ('C', 'D', 'E', 'F', 'G') THEN 1 END) AS levelTwos, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode IN ('H') THEN 1 END) AS levelThrees, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode IN ('K', 'P', 'Q', 'R') THEN 1 END) AS otherLevels, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode = 'A' THEN 1 END) AS specialEdACodes, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode = 'A' AND s.isAdult = true THEN 1 END) > 0 AS adultsInSpecialEdA, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode = 'B' THEN 1 END) AS specialEdBCodes, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode = 'B' AND s.isAdult = true THEN 1 END) > 0 AS adultsInSpecialEdB, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode = 'C' THEN 1 END) AS specialEdCCodes, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode = 'C' AND s.isAdult = true THEN 1 END) > 0 AS adultsInSpecialEdC, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode = 'D' THEN 1 END) AS specialEdDCodes, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode = 'D' AND s.isAdult = true THEN 1 END) > 0 AS adultsInSpecialEdD, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode = 'E' THEN 1 END) AS specialEdECodes, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode = 'E' AND s.isAdult = true THEN 1 END) > 0 AS adultsInSpecialEdE, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode = 'F' THEN 1 END) AS specialEdFCodes, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode = 'F' AND s.isAdult = true THEN 1 END) > 0 AS adultsInSpecialEdF, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode = 'G' THEN 1 END) AS specialEdGCodes, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode = 'G' AND s.isAdult = true THEN 1 END) > 0 AS adultsInSpecialEdG, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode = 'H' THEN 1 END) AS specialEdHCodes, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode = 'H' AND s.isAdult = true THEN 1 END) > 0 AS adultsInSpecialEdH, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode = 'K' THEN 1 END) AS specialEdKCodes, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode = 'K' AND s.isAdult = true THEN 1 END) > 0 AS adultsInSpecialEdK, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode = 'P' THEN 1 END) AS specialEdPCodes, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode = 'P' AND s.isAdult = true THEN 1 END) > 0 AS adultsInSpecialEdP, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode = 'Q' THEN 1 END) AS specialEdQCodes, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode = 'Q' AND s.isAdult = true THEN 1 END) > 0 AS adultsInSpecialEdQ, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode = 'R' THEN 1 END) AS specialEdRCodes, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode = 'R' AND s.isAdult = true THEN 1 END) > 0 AS adultsInSpecialEdR, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode IN ('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'K', 'P', 'Q', 'R') THEN 1 END) AS allLevels " + + "FROM SdcSchoolCollectionStudentEntity s " + + "WHERE s.sdcSchoolCollection.collectionEntity.collectionID = :collectionID " + + "AND s.sdcSchoolCollection.sdcDistrictCollectionID is null " + + "AND s.sdcSchoolCollectionStudentStatusCode NOT IN ('ERROR', 'DELETED') " + + "AND s.specialEducationNonEligReasonCode IS NULL " + + "GROUP BY s.sdcSchoolCollection.schoolID " + + "ORDER BY s.sdcSchoolCollection.schoolID") + List getSpecialEdCategoryForIndiesAndOffshoreFebruaryByCollectionId(UUID collectionID); + @Query("SELECT " + "s.sdcSchoolCollection.schoolID AS schoolID, " + "COUNT(CASE WHEN s.specialEducationCategoryCode IN ('A', 'B') AND s.fte > 0 THEN 1 END) AS levelOnes, " + @@ -1209,6 +1249,34 @@ AND SSCS.enrolledGradeCode NOT IN ('08', '09') "ORDER BY s.sdcSchoolCollection.schoolID") List getSpecialEdHeadcountsByCollectionId(@Param("collectionID") UUID collectionID); + @Query("SELECT " + + "s.sdcSchoolCollection.schoolID AS schoolID, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode IN ('A', 'B') THEN 1 END) AS levelOnes, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode = 'A' THEN 1 END) AS specialEdACodes, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode = 'B' THEN 1 END) AS specialEdBCodes, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode IN ('C', 'D', 'E', 'F', 'G') THEN 1 END) AS levelTwos, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode = 'C' THEN 1 END) AS specialEdCCodes, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode = 'D' THEN 1 END) AS specialEdDCodes, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode = 'E' THEN 1 END) AS specialEdECodes, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode = 'F' THEN 1 END) AS specialEdFCodes, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode = 'G' THEN 1 END) AS specialEdGCodes, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode IN ('H') THEN 1 END) AS levelThrees, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode = 'H' THEN 1 END) AS specialEdHCodes, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode IN ('K', 'P', 'Q', 'R') THEN 1 END) AS otherLevels, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode = 'K' THEN 1 END) AS specialEdKCodes, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode = 'P' THEN 1 END) AS specialEdPCodes, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode = 'Q' THEN 1 END) AS specialEdQCodes, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode = 'R' THEN 1 END) AS specialEdRCodes, " + + "COUNT(CASE WHEN s.specialEducationCategoryCode IN ('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'K', 'P', 'Q', 'R') THEN 1 END) AS allLevels " + + "FROM SdcSchoolCollectionStudentEntity s " + + "WHERE s.sdcSchoolCollection.collectionEntity.collectionID = :collectionID " + + "AND s.sdcSchoolCollectionStudentStatusCode NOT IN ('ERROR', 'DELETED') " + + "AND s.sdcSchoolCollection.sdcDistrictCollectionID is null " + + "AND s.specialEducationNonEligReasonCode IS NULL " + + "GROUP BY s.sdcSchoolCollection.schoolID " + + "ORDER BY s.sdcSchoolCollection.schoolID") + List getSpecialEdHeadcountsFebruaryByCollectionId(@Param("collectionID") UUID collectionID); + @Query(value = """ SELECT sscs.sdcSchoolCollection.schoolID as schoolID, sscs.homeLanguageSpokenCode as spokenLanguageCode, diff --git a/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/service/v1/reports/CSVReportService.java b/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/service/v1/reports/CSVReportService.java index 959a60de1..411a9628e 100644 --- a/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/service/v1/reports/CSVReportService.java +++ b/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/service/v1/reports/CSVReportService.java @@ -408,12 +408,19 @@ private DownloadableReportResponse generateSeptFsaCsv(UUID collectionID) { // Independent School Inclusive Education Headcounts report public DownloadableReportResponse generateIndySpecialEducationHeadcounts(UUID collectionID) { - List results = sdcSchoolCollectionStudentRepository.getSpecialEdCategoryForIndiesAndOffshoreByCollectionId(collectionID); var collectionOpt = collectionRepository.findById(collectionID); if(collectionOpt.isEmpty()){ throw new EntityNotFoundException(Collection.class, COLLECTION_ID, collectionID.toString()); } + List results; + + if(Objects.equals(collectionOpt.get().getCollectionTypeCode(), CollectionTypeCodes.FEBRUARY.getTypeCode())){ + results = sdcSchoolCollectionStudentRepository.getSpecialEdCategoryForIndiesAndOffshoreFebruaryByCollectionId(collectionID); + } else { + results = sdcSchoolCollectionStudentRepository.getSpecialEdCategoryForIndiesAndOffshoreByCollectionId(collectionID); + } + CSVFormat csvFormat = CSVFormat.DEFAULT.builder() .setHeader( IndySpecialEducationHeadcountHeader.AUTHORITY_NUMBER.getCode(), IndySpecialEducationHeadcountHeader.AUTHORITY_NAME.getCode(), @@ -464,7 +471,7 @@ public DownloadableReportResponse generateIndySpecialEducationHeadcounts(UUID co // Independent School Inclusive Education Funding Headcounts report public DownloadableReportResponse generateIndySpecialEducationFundingHeadcounts(UUID collectionID) { - List collectionRawData = sdcSchoolCollectionStudentRepository.getSpecialEdHeadcountsByCollectionId(collectionID); + List collectionRawData = sdcSchoolCollectionStudentRepository.getSpecialEdHeadcountsFebruaryByCollectionId(collectionID); var mappedSeptData = getLastSeptCollectionSchoolMap(collectionID); CSVFormat csvFormat = CSVFormat.DEFAULT.builder() diff --git a/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/service/v1/reports/MinistryHeadcountService.java b/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/service/v1/reports/MinistryHeadcountService.java index 002540875..bab48798b 100644 --- a/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/service/v1/reports/MinistryHeadcountService.java +++ b/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/service/v1/reports/MinistryHeadcountService.java @@ -161,7 +161,19 @@ public SimpleHeadcountResultsTable getIndySchoolsEnrollmentHeadcounts(UUID colle // Independent School Inclusive Education Headcounts report public SimpleHeadcountResultsTable getSpecialEducationHeadcountsForIndependentsByCollectionID(UUID collectionID) { - List collectionRawData = sdcSchoolCollectionStudentRepository.getSpecialEdCategoryForIndiesAndOffshoreByCollectionId(collectionID); + Optional collectionOpt = collectionRepository.findById(collectionID); + if(collectionOpt.isEmpty()) { + throw new EntityNotFoundException(CollectionEntity.class, COLLECTION_ID, collectionID.toString()); + } + + List collectionRawData; + + if(Objects.equals(collectionOpt.get().getCollectionTypeCode(), CollectionTypeCodes.FEBRUARY.getTypeCode())){ + collectionRawData = sdcSchoolCollectionStudentRepository.getSpecialEdCategoryForIndiesAndOffshoreFebruaryByCollectionId(collectionID); + } else { + collectionRawData = sdcSchoolCollectionStudentRepository.getSpecialEdCategoryForIndiesAndOffshoreByCollectionId(collectionID); + } + SimpleHeadcountResultsTable resultsTable = new SimpleHeadcountResultsTable(); var headerList = new ArrayList(); for (IndySpecialEducationHeadcountHeader header : IndySpecialEducationHeadcountHeader.values()) { @@ -215,7 +227,7 @@ public SimpleHeadcountResultsTable getSpecialEducationHeadcountsForIndependentsB // Independent School Inclusive Education Funding Headcounts report public SimpleHeadcountResultsTable getSpecialEducationFundingHeadcountsForIndependentsByCollectionID(UUID collectionID) { - List collectionRawData = sdcSchoolCollectionStudentRepository.getSpecialEdHeadcountsByCollectionId(collectionID); + List collectionRawData = sdcSchoolCollectionStudentRepository.getSpecialEdHeadcountsFebruaryByCollectionId(collectionID); var mappedSeptData = getLastSeptCollectionSchoolMap(collectionID); SimpleHeadcountResultsTable resultsTable = new SimpleHeadcountResultsTable();