-
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 all 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 |
---|---|---|
|
@@ -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 { DisabilityStatus } from "@sims/sims-db"; | ||
import { DISABILITY_REQUEST_NOT_ALLOWED } from "../../constants"; | ||
|
||
@AllowAuthorizedParty(AuthorizedParties.student) | ||
@RequiresStudentAccount() | ||
|
@@ -29,40 +31,41 @@ export class ATBCStudentController extends BaseController { | |
} | ||
|
||
/** | ||
* Creates the request for ATBC PD evaluation. | ||
* Student should only be allowed to check the PD status once and the | ||
* Creates the request for ATBC disability evaluation. | ||
* Student should only be allowed to check the disability status once and the | ||
* SIN validation must be already done with a successful result. | ||
*/ | ||
@Patch("apply-pd-status") | ||
@Patch("apply-disability-status") | ||
@ApiUnprocessableEntityResponse({ | ||
description: | ||
"Either the client does not have a validated SIN or the request was already sent to ATBC.", | ||
}) | ||
async applyForPDStatus( | ||
async applyForDisabilityStatus( | ||
@UserToken() studentUserToken: StudentUserToken, | ||
): Promise<void> { | ||
// Get student details | ||
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 disability status, SIN validation must be completed for the student and | ||
// not applied for disability status already. | ||
if ( | ||
!student.sinValidation.isValidSIN || | ||
!!student.studentPDSentAt || | ||
student.studentPDVerified !== null | ||
student.disabilityStatus !== DisabilityStatus.NotRequested | ||
ann-aot marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) { | ||
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 disability status already.", | ||
DISABILITY_REQUEST_NOT_ALLOWED, | ||
), | ||
); | ||
} | ||
// This is the only place in application where we call an external application | ||
// in API instead of using queues. This is because once the student applies for PD, | ||
// after a successful API call the apply for PD button needs to be disabled to avoid | ||
// duplicate requests coming. | ||
await this.atbcIntegrationProcessingService.applyForPDStatus(student.id); | ||
await this.atbcIntegrationProcessingService.applyForDisabilityStatus( | ||
student.id, | ||
); | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm"; | ||
import { getSQLFileData } from "../utilities/sqlLoader"; | ||
|
||
export class AddStudentDisabilityStatusCol1689350242512 | ||
implements MigrationInterface | ||
{ | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
getSQLFileData("Create-disability-status.sql", "Types"), | ||
); | ||
await queryRunner.query( | ||
getSQLFileData("Add-col-disability-status.sql", "Student"), | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
getSQLFileData("Drop-col-disability-status.sql", "Student"), | ||
); | ||
await queryRunner.query( | ||
getSQLFileData("Drop-disability-status.sql", "Types"), | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
ALTER TABLE | ||
sims.students | ||
ADD | ||
COLUMN IF NOT EXISTS disability_status sims.disability_status NOT NULL DEFAULT 'Not requested'; | ||
|
||
COMMENT ON COLUMN sims.students.disability_status IS 'Disability status of the student. The disability could be PD or PPD.'; | ||
|
||
-- Update the disability_status column based on pd_verified and pd_date_sent for existing data. | ||
UPDATE | ||
sims.students | ||
SET | ||
disability_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' | ||
ann-aot marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ELSE 'Not requested' :: sims.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 get this update is written for the existing data in Test, but is there a chance that any PDs can be PPDs? are we considering any update in the existing data update from ATBC? 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. There is no PPD in our system so far so we cannot do anything in the query about it. If a student is PPD, ATBC response will be read and updated in our system. |
||
END; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE | ||
sims.students DROP COLUMN disability_status; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
CREATE TYPE sims.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.disability_status; |
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.
👍