-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#2001 - Changes to handle PD PPD Part 1 #2115
Changes from 5 commits
eb9ff85
aab3384
4ac4553
fa0f438
769ef00
4639583
3730968
2983cca
ecd4945
7720d9a
5b554da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -306,7 +306,7 @@ describe("ApplicationOfferingChangeRequestInstitutionsController(e2e)-getComplet | |
|
||
const searchKeyword = "TestStudent"; | ||
const endpoint = `/institutions/location/${collegeFLocation.id}/application-offering-change-request/completed?page=0&pageLimit=10&searchCriteria=${searchKeyword}`; | ||
console.log(endpoint); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
||
// Act/Assert | ||
await request(app.getHttpServer()) | ||
.get(endpoint) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,9 +12,11 @@ import { | |
UserToken, | ||
} from "../../auth/decorators"; | ||
import { StudentUserToken } from "../../auth/userToken.interface"; | ||
import { ClientTypeBaseRoute } from "../../types"; | ||
import { ApiProcessError, ClientTypeBaseRoute } from "../../types"; | ||
import BaseController from "../BaseController"; | ||
import { ATBCIntegrationProcessingService } from "@sims/integrations/atbc-integration"; | ||
import { PDStatus } from "@sims/sims-db"; | ||
import { PD_REQUEST_NOT_ALLOWED } from "../../constants"; | ||
|
||
@AllowAuthorizedParty(AuthorizedParties.student) | ||
@RequiresStudentAccount() | ||
|
@@ -45,18 +47,17 @@ export class ATBCStudentController extends BaseController { | |
const student = await this.studentService.getStudentById( | ||
studentUserToken.studentId, | ||
); | ||
// Check the PD status in DB. Student should only be allowed to check the PD status once. | ||
// studentPDSentAt is set when student apply for PD status for the first. | ||
// studentPDVerified is null before PD scheduled job update status. | ||
// studentPDVerified is true if PD confirmed by ATBC or is true from sfas_individual table. | ||
// studentPDVerified is false if PD denied by ATBC. | ||
// To apply for a PD, SIN validation must be completed for the student and | ||
// not applied for PD already. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dheepak-aot , can you confirm this? In our grooming, I remember saying that the student can apply for PD multiple times, especially for the PPD There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for bring this up. Let me know if it is still not clear. We can talk. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @dheepak-aot for the details. Ya, adding it to the ticket will make it easier for future development. Keeping it open for other devs |
||
if ( | ||
!student.sinValidation.isValidSIN || | ||
!!student.studentPDSentAt || | ||
student.studentPDVerified !== null | ||
student.pdStatus !== PDStatus.NotRequested | ||
) { | ||
throw new UnprocessableEntityException( | ||
"Either the client does not have a validated SIN or the request was already sent to ATBC.", | ||
new ApiProcessError( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❤️ |
||
"Either SIN validation is not complete or requested for PD already.", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe that we can have it adjusted to PD/PPD for now.
sh16011993 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
PD_REQUEST_NOT_ALLOWED, | ||
), | ||
); | ||
} | ||
// This is the only place in application where we call an external application | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ import { | |
mockUserLoginInfo, | ||
} from "../../../../testHelpers"; | ||
import { saveFakeStudent } from "@sims/test-utils"; | ||
import { determinePDStatus, getUserFullName } from "../../../../utilities"; | ||
import { getUserFullName } from "../../../../utilities"; | ||
import { TestingModule } from "@nestjs/testing"; | ||
|
||
describe("StudentInstitutionsController(e2e)-getStudentProfile", () => { | ||
|
@@ -62,7 +62,7 @@ describe("StudentInstitutionsController(e2e)-getStudentProfile", () => { | |
}, | ||
phone: student.contactInfo.phone, | ||
}, | ||
pdStatus: determinePDStatus(student), | ||
pdStatus: student.pdStatus, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
validSin: student.sinValidation.isValidSIN, | ||
sin: student.sinValidation.sin, | ||
}); | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm"; | ||
import { getSQLFileData } from "../utilities/sqlLoader"; | ||
|
||
export class AddStudentPDStatusCol1689350242512 implements MigrationInterface { | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
getSQLFileData("Create-permanent-disability-status.sql", "Types"), | ||
); | ||
await queryRunner.query(getSQLFileData("Add-col-pd-status.sql", "Student")); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
getSQLFileData("Drop-col-pd-status.sql", "Student"), | ||
); | ||
await queryRunner.query( | ||
getSQLFileData("Drop-permanent-disability-status.sql", "Types"), | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
ALTER TABLE | ||
sims.students | ||
ADD | ||
COLUMN IF NOT EXISTS pd_status sims.permanent_disability_status; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I hope that it will not open a can of worms about naming possibilities 😉
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As per discussion with the dev team, we decided to use disability status instead of permanent disability status and try to change the existing code as much as possible. |
||
|
||
COMMENT ON COLUMN sims.students.pd_status IS 'Permanent disability status of the student.'; | ||
|
||
-- Update the pd_status column based on pd_verified and pd_date_sent for existing data. | ||
UPDATE | ||
sims.students | ||
SET | ||
pd_status = CASE | ||
WHEN pd_verified IS NULL | ||
AND pd_date_sent IS NOT NULL THEN 'Requested' | ||
WHEN pd_verified = true THEN 'PD' | ||
WHEN pd_verified = false THEN 'Declined' | ||
ELSE 'Not requested' :: sims.permanent_disability_status | ||
END; | ||
|
||
-- Set not null constraint after updating the column. | ||
ALTER TABLE | ||
sims.students | ||
ALTER COLUMN | ||
pd_status | ||
SET | ||
NOT NULL; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE | ||
sims.students DROP COLUMN pd_status; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
CREATE TYPE sims.permanent_disability_status AS ENUM ( | ||
'Not requested', | ||
'Requested', | ||
'PD', | ||
'PPD', | ||
'Declined' | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP TYPE sims.permanent_disability_status; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
import { Injectable } from "@nestjs/common"; | ||
import { | ||
PDStatus, | ||
RecordDataModelService, | ||
SINValidation, | ||
Student, | ||
User, | ||
} from "@sims/sims-db"; | ||
import { getUTCNow } from "@sims/utilities"; | ||
import { InjectLogger, LoggerService } from "@sims/utilities/logger"; | ||
import { DataSource, EntityManager } from "typeorm"; | ||
import { DataSource, EntityManager, UpdateResult } from "typeorm"; | ||
|
||
@Injectable() | ||
export class StudentService extends RecordDataModelService<Student> { | ||
|
@@ -32,23 +33,25 @@ export class StudentService extends RecordDataModelService<Student> { | |
} | ||
|
||
/** | ||
* Update the PD Sent Date | ||
* Update the PD status to requested. | ||
* @param studentId student who's PD status is to be updated. | ||
* @param auditUser user who is making the changes. | ||
* @returns Student who's PD sent date is updated. | ||
* @returns update result. | ||
*/ | ||
async updatePDSentDate(studentId: number, auditUser: User): Promise<Student> { | ||
// get the Student Object | ||
const studentToUpdate = await this.repo.findOneOrFail({ | ||
where: { id: studentId }, | ||
}); | ||
if (studentToUpdate) { | ||
const now = new Date(); | ||
studentToUpdate.studentPDSentAt = now; | ||
studentToUpdate.modifier = auditUser; | ||
studentToUpdate.updatedAt = now; | ||
return this.repo.save(studentToUpdate); | ||
} | ||
async updatePDRequested( | ||
studentId: number, | ||
auditUser: User, | ||
): Promise<UpdateResult> { | ||
const now = new Date(); | ||
return this.repo.update( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❤️ |
||
{ id: studentId }, | ||
{ | ||
studentPDSentAt: now, | ||
modifier: auditUser, | ||
updatedAt: now, | ||
pdStatus: PDStatus.Requested, | ||
}, | ||
); | ||
} | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** | ||
* Permanent disability status of student. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Everything is SIMS used to be named using PD as permanent disability which is no longer true with the inclusion of PPD. |
||
*/ | ||
export enum PDStatus { | ||
NotRequested = "Not requested", | ||
Requested = "Requested", | ||
PD = "PD", | ||
PPD = "PPD", | ||
Declined = "Declined", | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The requests are no longer specifically for permanent disability.