Skip to content

Commit

Permalink
Merge pull request #1509 from bcgov/feature/EDX-2400
Browse files Browse the repository at this point in the history
EDX-2400 Adds in districts enrollment duplicate screens
  • Loading branch information
alexmcdermid authored May 6, 2024
2 parents 767986f + 9971c1f commit f1d4f3c
Show file tree
Hide file tree
Showing 16 changed files with 604 additions and 14 deletions.
8 changes: 8 additions & 0 deletions backend/src/components/cache-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ let authoritiesMap = new Map();
let bandCodesMap = new Map();
let enrolledProgramCodesMap = new Map();
let careerProgramCodesMap = new Map();
let duplicateResolutionCodesMap = new Map();
let schoolFundingCodesMap = new Map();
let specialEducationCodesMap = new Map();
let rolePermissionsMap = new Map();
Expand Down Expand Up @@ -257,6 +258,13 @@ const cacheService = {
});
return careerProgramCodesMap;
},
getAllDuplicateResolutionCodesMap() {
let duplicateResolutionCodes = cachedData[constants.CACHE_KEYS.SDC_DUPLICATE_RESOLUTION_CODES].records;
duplicateResolutionCodes.forEach(duplicateResolutionCode => {
duplicateResolutionCodesMap.set(duplicateResolutionCode.duplicateResolutionCode, duplicateResolutionCode);
});
return duplicateResolutionCodesMap;
},
getEnrolledProgramCodesMap() {
let enrolledProgramCodesRaw = cachedData[constants.CACHE_KEYS.SDC_ENROLLED_PROGRAM_CODES].activeRecords;
let enrolledProgramCodes = enrolledProgramCodesRaw.map(item => {
Expand Down
72 changes: 68 additions & 4 deletions backend/src/components/sdc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { getAccessToken, handleExceptionResponse, getData, postData, putData, get
const HttpStatus = require('http-status-codes');
const log = require('./logger');
const config = require('../config');
const { FILTER_OPERATION, VALUE_TYPE, CONDITION, ENROLLED_PROGRAM_TYPE_CODE_MAP} = require('../util/constants');
const { FILTER_OPERATION, VALUE_TYPE, CONDITION, ENROLLED_PROGRAM_TYPE_CODE_MAP, DUPLICATE_TYPE_CODES} = require('../util/constants');
const {createMoreFiltersSearchCriteria} = require('./studentFilters');
const {REPORT_TYPE_CODE_MAP} = require('../util/constants');
const cacheService = require('./cache-service');
Expand Down Expand Up @@ -210,8 +210,7 @@ async function getSDCSchoolCollectionStudentPaginated(req, res) {

if(req?.params?.sdcDistrictCollectionID){
data?.content.forEach(value => {
value.schoolName = cacheService.getSchoolBySchoolID(value.schoolID)?.schoolName;
value.mincode = cacheService.getSchoolBySchoolID(value.schoolID)?.mincode;
value.schoolName = getSchoolName(cacheService.getSchoolBySchoolID(value.schoolID));
});
data?.content.sort((a,b) => {
if (a.schoolName > b.schoolName) {
Expand Down Expand Up @@ -642,6 +641,70 @@ async function getSdcSchoolCollectionMonitoringBySdcDistrictCollectionId(req, re
}
}

async function getInDistrictDuplicates(req, res) {
try {
const token = getAccessToken(req);
let sdcDuplicates = await getData(token, `${config.get('sdc:districtCollectionURL')}/${req.params.sdcDistrictCollectionID}/in-district-duplicates`, req.session?.correlationID);

const result = {
enrollmentDuplicates: {
NON_ALLOW: [],
ALLOWABLE: [],
RESOLVED: []
},
programDuplicates: {
NON_ALLOW: [],
RESOLVED: []
}
};
sdcDuplicates.forEach(sdcDuplicate => {
const school = cacheService.getSchoolBySchoolID(sdcDuplicate.sdcSchoolCollectionStudent1Entity?.schoolID);
sdcDuplicate.sdcSchoolCollectionStudent1Entity.schoolName = getSchoolName(school);
sdcDuplicate.sdcSchoolCollectionStudent2Entity.schoolName = getSchoolName(school);

if (sdcDuplicate?.duplicateTypeCode === DUPLICATE_TYPE_CODES.ENROLLMENT && sdcDuplicate.duplicateResolutionCode) {
setStudentResolvedMessage(sdcDuplicate);
result.enrollmentDuplicates.RESOLVED.push(sdcDuplicate);
}
else if (sdcDuplicate?.duplicateTypeCode === DUPLICATE_TYPE_CODES.ENROLLMENT) {
setIfOnlineStudentAndCanChangeGrade(sdcDuplicate, school);
result.enrollmentDuplicates[sdcDuplicate.duplicateSeverityCode].push(sdcDuplicate);
}
else if (sdcDuplicate?.duplicateTypeCode === DUPLICATE_TYPE_CODES.PROGRAM) {
result.programDuplicates.push(sdcDuplicate);
}
});
res.status(HttpStatus.OK).json(result);
} catch (e) {
log.error('Error retrieving the in district duplicates', e.stack);
return handleExceptionResponse(e, res);
}
}

function getSchoolName(school) {
return school.mincode + ' - ' + school.schoolName;
}

function setStudentResolvedMessage(sdcDuplicate) {
const resolutionCodes = cacheService.getAllDuplicateResolutionCodesMap();
const retainedId = sdcDuplicate.retainedSdcSchoolCollectionStudentEntity?.sdcSchoolCollectionStudentID;
if (sdcDuplicate.sdcSchoolCollectionStudent1Entity.sdcSchoolCollectionStudentID === retainedId) {
sdcDuplicate.sdcSchoolCollectionStudent1Entity.resolution = resolutionCodes.get(sdcDuplicate.duplicateResolutionCode) !== undefined ? resolutionCodes.get(sdcDuplicate.duplicateResolutionCode)?.message : null;
}
else if (sdcDuplicate.sdcSchoolCollectionStudent2Entity.sdcSchoolCollectionStudentID === retainedId) {
sdcDuplicate.sdcSchoolCollectionStudent2Entity.resolution = resolutionCodes.get(sdcDuplicate.duplicateResolutionCode) !== undefined ? resolutionCodes.get(sdcDuplicate.duplicateResolutionCode)?.message : null;
}
}

function setIfOnlineStudentAndCanChangeGrade(sdcDuplicate, school) {
if(['DIST_LEARN', 'DISTONLINE'].includes(school.facilityTypeCode) && ['08', '09'].includes(sdcDuplicate.sdcSchoolCollectionStudent1Entity.enrolledGradeCode)) {
sdcDuplicate.sdcSchoolCollectionStudent1Entity.canChangeGrade = true;
}
if(['DIST_LEARN', 'DISTONLINE'].includes(school.facilityTypeCode) && ['08', '09'].includes(sdcDuplicate.sdcSchoolCollectionStudent2Entity.enrolledGradeCode)) {
sdcDuplicate.sdcSchoolCollectionStudent2Entity.canChangeGrade = true;
}
}

module.exports = {
getCollectionBySchoolId,
uploadFile,
Expand All @@ -663,5 +726,6 @@ module.exports = {
markSdcSchoolCollectionStudentAsDifferent,
getStudentHeadcounts,
getSdcSchoolCollectionMonitoringBySdcDistrictCollectionId,
getDistrictHeadcounts
getDistrictHeadcounts,
getInDistrictDuplicates
};
3 changes: 2 additions & 1 deletion backend/src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ nconf.defaults({
specialEdCodesURL: process.env.SDC_API_ENDPOINT + '/specialEducation-codes',
validationIssueTypeCodesURL: process.env.SDC_API_ENDPOINT + '/validation-issue-type-codes',
programEligibilityTypeCodesURL: process.env.SDC_API_ENDPOINT + '/program-eligibility-issue-codes',
zeroFteReasonCodesURL: process.env.SDC_API_ENDPOINT + '/zero-fte-reason-codes'
zeroFteReasonCodesURL: process.env.SDC_API_ENDPOINT + '/zero-fte-reason-codes',
duplicateResolutionCodesURL: process.env.SDC_API_ENDPOINT + '/duplicate-resolution-codes',
},
frontendConfig: {
bannerEnvironment: process.env.BANNER_ENVIRONMENT,
Expand Down
4 changes: 3 additions & 1 deletion backend/src/routes/sdc.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions backend/src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ if(process.env.NODE_ENV !== 'test'){ //do not cache for test environment to sto
}).catch((e) => {
log.error('Error loading SDC_SPECIAL_ED_CODES data during boot.', e);
});
cacheService.loadDataToCache(constants.CACHE_KEYS.SDC_DUPLICATE_RESOLUTION_CODES, 'sdc:duplicateResolutionCodesURL').then(() => {
log.info('Loaded SDC_DUPLICATE_RESOLUTION_CODES data to memory');
}).catch((e) => {
log.error('Error loading SDC_DUPLICATE_RESOLUTION_CODES data during boot.', e);
});
}
}

Expand Down
11 changes: 9 additions & 2 deletions backend/src/util/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ cacheKeys = {
SDC_SPECIAL_ED_CODES: 'sdc_special_ed_codes',
SDC_VALIDATION_ISSUE_TYPE_CODES: 'sdc_validation_issue_type_codes',
SDC_PROGRAM_ELIGIBILITY_TYPE_CODES: 'sdc_program_eligibility_type_codes',
SDC_ZERO_FTE_REASON_CODES: 'sdc_zero_fte_reason_codes'
SDC_ZERO_FTE_REASON_CODES: 'sdc_zero_fte_reason_codes',
SDC_DUPLICATE_RESOLUTION_CODES: 'sdc_duplicate_resolution_codes'
};
const CACHE_KEYS = Object.freeze(cacheKeys);
const EVENT_WS_TOPIC = 'EVENT_WS_TOPIC';
Expand All @@ -191,6 +192,11 @@ const ENROLLED_PROGRAM_TYPE_CODE_MAP = Object.freeze({
ENGLISH_ENROLLED_PROGRAM_CODES: ['17'],
});

const DUPLICATE_TYPE_CODES = Object.freeze({
ENROLLMENT: 'ENROLLMENT',
PROGRAM: 'PROGRAM'
});

module.exports = {
FILTER_OPERATION,
CONDITION,
Expand All @@ -203,7 +209,8 @@ module.exports = {
INSTITUTE_CACHE_REFRESH_TOPIC,
CACHE_KEYS,
MOVE_SCHOOL_TOPIC,
ENROLLED_PROGRAM_TYPE_CODE_MAP
ENROLLED_PROGRAM_TYPE_CODE_MAP,
DUPLICATE_TYPE_CODES
};
/**
* Test comment
Expand Down
1 change: 1 addition & 0 deletions frontend/src/common/apiService.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ export default {
getAllValidationIssueTypeCodes:getCodes(`${ApiRoutes.sdc.SDC_VALIDATION_ISSUE_TYPE_CODES}`),
getAllProgramEligibilityTypeCodes:getCodes(`${ApiRoutes.sdc.SDC_PROGRAM_ELIGIBILITY_TYPE_CODES}`),
getAllZeroFteReasonCodes:getCodes(`${ApiRoutes.sdc.SDC_ZERO_FTE_REASON_CODES}`),
getAllDuplicateResolutionCodes:getCodes(`${ApiRoutes.sdc.SDC_DUPLICATE_RESOLUTION_CODES}`),
getAllActiveBandCodes:getCodes(`${ApiRoutes.sdc.SDC_BAND_CODES}?active=true`),
getAllActiveCareerProgramCodes:getCodes(`${ApiRoutes.sdc.SDC_CAREER_PROGRAM_CODES}?active=true`),
getAllActiveEnrolledProgramCodes:getCodes(`${ApiRoutes.sdc.SDC_ENROLLED_PROGRAM_CODES}?active=true`),
Expand Down
23 changes: 21 additions & 2 deletions frontend/src/components/common/CustomTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@
:to="{ name: 'sdcCollection', params: { schoolCollectionID: props.item['sdcSchoolCollectionID'] }}"
target="_blank"
@click.stop
>
{{ props.item['mincode'] }} - {{ props.item['schoolName'] }}
>
{{ props.item['schoolName'] }}
</router-link>
</div>

Expand Down Expand Up @@ -127,6 +127,17 @@
<div>-</div>
</template>
</div>
<span v-else-if="column.key === 'resolution'">
<slot
:sdc-school-collection-student="props.item"
name="resolution"
>
<template v-if="props.item[column.key]">
{{ props.item[column.key] }}
</template>
<template v-else>-</template>
</slot>
</span>
<span v-else-if="props.item[column.key]">{{ props.item[column.key] }}</span>
<span v-else-if="column.title !== 'select'">-</span>

Expand All @@ -147,6 +158,10 @@
</td>
</tr>
</template>
<template
v-if="hidePagination"
#bottom
/>
</v-data-table-server>
</div>
</template>
Expand All @@ -172,6 +187,10 @@ export default {
required: true,
default: null
},
hidePagination: {
type: Boolean,
default: false
},
totalElements: {
type: Number,
required: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,18 @@
reverse-transition="false"
>
<StepThreeVerifyData
:district-collection-object="districtCollectionObject"
:is-step-complete="isStepComplete"
@next="next"
/>
</v-stepper-window-item>
<v-stepper-window-item
:value="4"
transition="false"
reverse-transition="false"
>
<StepFourInDistrictDuplicates
:district-collection-object="districtCollectionObject"
:is-step-complete="isStepComplete"
@next="next"
/>
Expand All @@ -129,11 +141,13 @@ import {SDC_STEPS_DISTRICT} from '../../../utils/institute/SdcSteps';
import {mapState} from 'pinia';
import StepTwoMonitor from './StepTwoMonitor.vue';
import StepThreeVerifyData from './stepThreeVerifyData/StepThreeVerifyData.vue';
import StepFourInDistrictDuplicates from './stepFourInDistrictDuplicates/StepFourInDistrictDuplicates.vue';
export default defineComponent({
name: 'SDCDistrictCollectionView',
components: {
StepFourInDistrictDuplicates,
StepOneUploadData,
StepTwoMonitor,
StepThreeVerifyData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@
>
<p class="form-hint mr-3">
{{ monitorSdcSchoolCollectionsResponse?.totalSchools - monitorSdcSchoolCollectionsResponse?.schoolsSubmitted }}
schools not
school(s) not
submitted
</p>
</v-row>
Expand Down
Loading

0 comments on commit f1d4f3c

Please sign in to comment.