From 23accef93ff32c11219427dc40a3fa147f7f598d Mon Sep 17 00:00:00 2001 From: katrina-aot-git <165210668+katrina-aot-git@users.noreply.github.com> Date: Thu, 13 Jun 2024 08:37:49 -0700 Subject: [PATCH] #2831 - Update student gender options (#3401) Update student gender options. --- ...proveStudentAccountApplication.e2e-spec.ts | 2 +- .../testHelpers/fake-entities/student-fake.ts | 2 +- .../1718050524263-UpdateGenderOptions.ts | 16 ++++++++ .../Rollback-update-gender-options.sql | 32 +++++++++++++++ .../src/sql/Student/Update-gender-options.sql | 39 +++++++++++++++++++ ...-process-integration.scheduler.e2e-spec.ts | 2 +- ...aa-process-integration.scheduler.models.ts | 6 +-- ...cert-full-time-integration.service.spec.ts | 2 +- .../e-cert-files/e-cert-file-record.ts | 2 +- ...cert-part-time-integration.service.spec.ts | 2 +- .../e-cert-files/e-cert-file-record.ts | 2 +- .../sin-validation-file-request.ts | 2 +- .../libs/test-utils/src/factories/student.ts | 2 +- .../backend/libs/utilities/src/esdc-utils.ts | 12 ++++-- .../src/form-definitions/studentprofile.json | 16 ++++---- .../form-io-application-submission/models.ts | 2 +- 16 files changed, 117 insertions(+), 24 deletions(-) create mode 100644 sources/packages/backend/apps/db-migrations/src/migrations/1718050524263-UpdateGenderOptions.ts create mode 100644 sources/packages/backend/apps/db-migrations/src/sql/Student/Rollback-update-gender-options.sql create mode 100644 sources/packages/backend/apps/db-migrations/src/sql/Student/Update-gender-options.sql diff --git a/sources/packages/backend/apps/api/src/route-controllers/student-account-applications/_test_/e2e/student-account-application.aest.controller.approveStudentAccountApplication.e2e-spec.ts b/sources/packages/backend/apps/api/src/route-controllers/student-account-applications/_test_/e2e/student-account-application.aest.controller.approveStudentAccountApplication.e2e-spec.ts index bd6731444a..f0f299739c 100644 --- a/sources/packages/backend/apps/api/src/route-controllers/student-account-applications/_test_/e2e/student-account-application.aest.controller.approveStudentAccountApplication.e2e-spec.ts +++ b/sources/packages/backend/apps/api/src/route-controllers/student-account-applications/_test_/e2e/student-account-application.aest.controller.approveStudentAccountApplication.e2e-spec.ts @@ -265,7 +265,7 @@ describe("StudentAccountApplicationAESTController(e2e)-approveStudentAccountAppl mode: "aest-account-approval", identityProvider: "bceidboth", sinConsent: true, - gender: "X", + gender: "nonBinary", addressLine1: "address 1", city: "Victoria", country: "Canada", diff --git a/sources/packages/backend/apps/api/src/testHelpers/fake-entities/student-fake.ts b/sources/packages/backend/apps/api/src/testHelpers/fake-entities/student-fake.ts index 67aed37b68..7ebdbd7121 100644 --- a/sources/packages/backend/apps/api/src/testHelpers/fake-entities/student-fake.ts +++ b/sources/packages/backend/apps/api/src/testHelpers/fake-entities/student-fake.ts @@ -9,7 +9,7 @@ export function createFakeStudent(user?: User): Student { const student = new Student(); student.user = user ?? createFakeUser(); student.birthDate = faker.date.past(18).toISOString(); - student.gender = "X"; + student.gender = "nonBinary"; student.contactInfo = { address: { addressLine1: faker.address.streetAddress(), diff --git a/sources/packages/backend/apps/db-migrations/src/migrations/1718050524263-UpdateGenderOptions.ts b/sources/packages/backend/apps/db-migrations/src/migrations/1718050524263-UpdateGenderOptions.ts new file mode 100644 index 0000000000..e0ee3e4b90 --- /dev/null +++ b/sources/packages/backend/apps/db-migrations/src/migrations/1718050524263-UpdateGenderOptions.ts @@ -0,0 +1,16 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; +import { getSQLFileData } from "../utilities/sqlLoader"; + +export class UpdateGenderOptions1718050524263 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + getSQLFileData("Update-gender-options.sql", "Student"), + ); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + getSQLFileData("Rollback-update-gender-options.sql", "Student"), + ); + } +} diff --git a/sources/packages/backend/apps/db-migrations/src/sql/Student/Rollback-update-gender-options.sql b/sources/packages/backend/apps/db-migrations/src/sql/Student/Rollback-update-gender-options.sql new file mode 100644 index 0000000000..b68a752538 --- /dev/null +++ b/sources/packages/backend/apps/db-migrations/src/sql/Student/Rollback-update-gender-options.sql @@ -0,0 +1,32 @@ +UPDATE + sims.students +SET + gender = 'male' +WHERE + gender = 'man'; + +UPDATE + sims.students +SET + gender = 'diverse' +WHERE + gender = 'nonBinary'; + +UPDATE + sims.students +SET + gender = 'female' +WHERE + gender = 'woman'; + +UPDATE + sims.students +SET + gender = 'unknown' +WHERE + gender = 'preferNotToAnswer'; + +ALTER TABLE + sims.students +ALTER COLUMN + gender TYPE varchar(10); \ No newline at end of file diff --git a/sources/packages/backend/apps/db-migrations/src/sql/Student/Update-gender-options.sql b/sources/packages/backend/apps/db-migrations/src/sql/Student/Update-gender-options.sql new file mode 100644 index 0000000000..d457d79359 --- /dev/null +++ b/sources/packages/backend/apps/db-migrations/src/sql/Student/Update-gender-options.sql @@ -0,0 +1,39 @@ +ALTER TABLE + sims.students +ALTER COLUMN + gender TYPE varchar(50); + +UPDATE + sims.students +SET + gender = 'man' +WHERE + gender = 'male'; + +UPDATE + sims.students +SET + gender = 'nonBinary' +WHERE + gender = 'X'; + +UPDATE + sims.students +SET + gender = 'nonBinary' +WHERE + gender = 'diverse'; + +UPDATE + sims.students +SET + gender = 'woman' +WHERE + gender = 'female'; + +UPDATE + sims.students +SET + gender = 'preferNotToAnswer' +WHERE + gender = 'unknown'; \ No newline at end of file diff --git a/sources/packages/backend/apps/queue-consumers/src/processors/schedulers/esdc-integration/msfaa-integration/_tests_/msfaa-part-time-process-integration.scheduler.e2e-spec.ts b/sources/packages/backend/apps/queue-consumers/src/processors/schedulers/esdc-integration/msfaa-integration/_tests_/msfaa-part-time-process-integration.scheduler.e2e-spec.ts index 91b8cfd415..b8e464521d 100644 --- a/sources/packages/backend/apps/queue-consumers/src/processors/schedulers/esdc-integration/msfaa-integration/_tests_/msfaa-part-time-process-integration.scheduler.e2e-spec.ts +++ b/sources/packages/backend/apps/queue-consumers/src/processors/schedulers/esdc-integration/msfaa-integration/_tests_/msfaa-part-time-process-integration.scheduler.e2e-spec.ts @@ -113,7 +113,7 @@ describe( `2000000001000900000000PABCD19950630${processDateFormatted}Doe John MMAddress Line 1 Address Line 2 Calgary AB H1H 1H1 Canada 00000000001111111111john.doe@somedomain.com PT `, ); expect(msfaaPartTimeOtherCountry).toBe( - `2000000001001900000001PEFDG20000101${processDateFormatted}Other Doe Jane OSAddress Line 1 Some city on United State United States 00000000000000000049jane.doe@somedomain.com PT `, + `2000000001001900000001PEFDG20000101${processDateFormatted}Other Doe Jane SAddress Line 1 Some city on United State United States 00000000000000000049jane.doe@somedomain.com PT `, ); expect(msfaaPartTimeRelationshipOther).toBe( `2000000001002900000002PIHKL20011231${processDateFormatted}Other Doe Other John FOAddress Line 1 Address Line 2 Victoria BC H1H 1H1 Canada 99999999999999999999jane.doe@someotherdomain.com PT `, diff --git a/sources/packages/backend/apps/queue-consumers/src/processors/schedulers/esdc-integration/msfaa-integration/_tests_/msfaa-process-integration.scheduler.models.ts b/sources/packages/backend/apps/queue-consumers/src/processors/schedulers/esdc-integration/msfaa-integration/_tests_/msfaa-process-integration.scheduler.models.ts index da5ed44119..890d9e9ea6 100644 --- a/sources/packages/backend/apps/queue-consumers/src/processors/schedulers/esdc-integration/msfaa-integration/_tests_/msfaa-process-integration.scheduler.models.ts +++ b/sources/packages/backend/apps/queue-consumers/src/processors/schedulers/esdc-integration/msfaa-integration/_tests_/msfaa-process-integration.scheduler.models.ts @@ -36,7 +36,7 @@ export const MSFAA_PART_TIME_MARRIED: MSFAATestInputData = { birthDate: "1995-06-30", surname: "Doe", givenName: "John", - gender: "male", + gender: "man", maritalStatus: RelationshipStatus.Married, addressLine1: "Address Line 1", addressLine2: "Address Line 2", @@ -56,7 +56,7 @@ export const MSFAA_PART_TIME_OTHER_COUNTRY: MSFAATestInputData = { birthDate: "2000-01-01", surname: "Other Doe", givenName: "Jane", - gender: "unknown", + gender: "preferNotToAnswer", maritalStatus: RelationshipStatus.Single, addressLine1: "Address Line 1", addressLine2: undefined, @@ -76,7 +76,7 @@ export const MSFAA_PART_TIME_RELATIONSHIP_OTHER: MSFAATestInputData = { birthDate: "2001-12-31", surname: "Other Doe", givenName: "Other John", - gender: "female", + gender: "woman", maritalStatus: RelationshipStatus.Other, addressLine1: "Address Line 1", addressLine2: "Address Line 2", diff --git a/sources/packages/backend/libs/integrations/src/esdc-integration/e-cert-integration/e-cert-full-time-integration/_tests_/unit/e-cert-full-time-integration.service.spec.ts b/sources/packages/backend/libs/integrations/src/esdc-integration/e-cert-integration/e-cert-full-time-integration/_tests_/unit/e-cert-full-time-integration.service.spec.ts index 76cc6f1371..5889c0c29a 100644 --- a/sources/packages/backend/libs/integrations/src/esdc-integration/e-cert-integration/e-cert-full-time-integration/_tests_/unit/e-cert-full-time-integration.service.spec.ts +++ b/sources/packages/backend/libs/integrations/src/esdc-integration/e-cert-integration/e-cert-full-time-integration/_tests_/unit/e-cert-full-time-integration.service.spec.ts @@ -64,7 +64,7 @@ describe("ECertFullTimeIntegrationService-createRequestContent", () => { provinceState: "BC", postalCode: "V1V1V1", email: "simsthree@test.ca", - gender: "male", + gender: "man", calculatedPDPPDStatus: true, maritalStatus: RelationshipStatus.Other, studentNumber: "", diff --git a/sources/packages/backend/libs/integrations/src/esdc-integration/e-cert-integration/e-cert-full-time-integration/e-cert-files/e-cert-file-record.ts b/sources/packages/backend/libs/integrations/src/esdc-integration/e-cert-integration/e-cert-full-time-integration/e-cert-files/e-cert-file-record.ts index 9fe785c041..c5187c34dc 100644 --- a/sources/packages/backend/libs/integrations/src/esdc-integration/e-cert-integration/e-cert-full-time-integration/e-cert-files/e-cert-file-record.ts +++ b/sources/packages/backend/libs/integrations/src/esdc-integration/e-cert-integration/e-cert-full-time-integration/e-cert-files/e-cert-file-record.ts @@ -147,7 +147,7 @@ export class ECertFullTimeFileRecord extends ECertFileRecord { */ postalCode?: string; /** - * Student gender M=Male F=Female. + * Gender (M=man, F=woman, X=nonBinary empty=preferNotToAnswer). */ gender: string; /** diff --git a/sources/packages/backend/libs/integrations/src/esdc-integration/e-cert-integration/e-cert-part-time-integration/_tests_/unit/e-cert-part-time-integration.service.spec.ts b/sources/packages/backend/libs/integrations/src/esdc-integration/e-cert-integration/e-cert-part-time-integration/_tests_/unit/e-cert-part-time-integration.service.spec.ts index 0e995cbf7c..243d0f89c0 100644 --- a/sources/packages/backend/libs/integrations/src/esdc-integration/e-cert-integration/e-cert-part-time-integration/_tests_/unit/e-cert-part-time-integration.service.spec.ts +++ b/sources/packages/backend/libs/integrations/src/esdc-integration/e-cert-integration/e-cert-part-time-integration/_tests_/unit/e-cert-part-time-integration.service.spec.ts @@ -65,7 +65,7 @@ describe("ECertPartTimeIntegrationService-createRequestContent", () => { provinceState: "BC", postalCode: "V1V1V1", email: "simsthree@test.ca", - gender: "male", + gender: "man", calculatedPDPPDStatus: true, maritalStatus: RelationshipStatus.Other, studentNumber: "", diff --git a/sources/packages/backend/libs/integrations/src/esdc-integration/e-cert-integration/e-cert-part-time-integration/e-cert-files/e-cert-file-record.ts b/sources/packages/backend/libs/integrations/src/esdc-integration/e-cert-integration/e-cert-part-time-integration/e-cert-files/e-cert-file-record.ts index 0d030d1a47..36f6bd05e0 100644 --- a/sources/packages/backend/libs/integrations/src/esdc-integration/e-cert-integration/e-cert-part-time-integration/e-cert-files/e-cert-file-record.ts +++ b/sources/packages/backend/libs/integrations/src/esdc-integration/e-cert-integration/e-cert-part-time-integration/e-cert-files/e-cert-file-record.ts @@ -108,7 +108,7 @@ export class ECertPartTimeFileRecord extends ECertFileRecord { */ postalCode?: string; /** - * Student gender M=Male F=Female. + * Gender (M=man, F=woman, X=nonBinary empty=preferNotToAnswer). */ gender: string; /** diff --git a/sources/packages/backend/libs/integrations/src/esdc-integration/sin-validation/sin-validation-files/sin-validation-file-request.ts b/sources/packages/backend/libs/integrations/src/esdc-integration/sin-validation/sin-validation-files/sin-validation-file-request.ts index 6ddc6c2deb..0d8f5397ee 100644 --- a/sources/packages/backend/libs/integrations/src/esdc-integration/sin-validation/sin-validation-files/sin-validation-file-request.ts +++ b/sources/packages/backend/libs/integrations/src/esdc-integration/sin-validation/sin-validation-files/sin-validation-file-request.ts @@ -29,7 +29,7 @@ export class SINValidationFileRequest implements FixedFormatFileLine { */ lastName: string; /** - * Gender (M=Male, F=Female, O=Other). + * Gender (M=man, F=woman, X=nonBinary empty=preferNotToAnswer). */ gender: string; /** diff --git a/sources/packages/backend/libs/test-utils/src/factories/student.ts b/sources/packages/backend/libs/test-utils/src/factories/student.ts index 1e74923d0e..0bbc15e189 100644 --- a/sources/packages/backend/libs/test-utils/src/factories/student.ts +++ b/sources/packages/backend/libs/test-utils/src/factories/student.ts @@ -15,7 +15,7 @@ export function createFakeStudent( student.birthDate = options?.initialValue?.birthDate ?? getISODateOnlyString(faker.date.past(18)); - student.gender = "X"; + student.gender = "nonBinary"; student.contactInfo = options?.initialValue?.contactInfo ?? { address: { addressLine1: faker.address.streetAddress(), diff --git a/sources/packages/backend/libs/utilities/src/esdc-utils.ts b/sources/packages/backend/libs/utilities/src/esdc-utils.ts index 99ee7e1cff..36171693c7 100644 --- a/sources/packages/backend/libs/utilities/src/esdc-utils.ts +++ b/sources/packages/backend/libs/utilities/src/esdc-utils.ts @@ -24,10 +24,16 @@ export function getMaritalStatusCode( * Gets the gender code conversion for the ESDC request files. */ export function getGenderCode(gender: string): string { - if (gender === "male") { - return "M"; + switch (gender) { + case "man": + return "M"; + case "woman": + return "F"; + case "nonBinary": + return "X"; + default: + return ""; } - return gender === "female" ? "F" : "O"; } /** diff --git a/sources/packages/forms/src/form-definitions/studentprofile.json b/sources/packages/forms/src/form-definitions/studentprofile.json index cc7ecaaf8d..c32e6d3a96 100644 --- a/sources/packages/forms/src/form-definitions/studentprofile.json +++ b/sources/packages/forms/src/form-definitions/studentprofile.json @@ -1502,20 +1502,20 @@ "data": { "values": [ { - "label": "Male", - "value": "male" + "label": "Man", + "value": "man" }, { - "label": "Female", - "value": "female" + "label": "Non-Binary", + "value": "nonBinary" }, { - "label": "Unknown", - "value": "unknown" + "label": "Woman", + "value": "woman" }, { - "value": "diverse", - "label": "Diverse" + "label": "Prefer not to answer", + "value": "preferNotToAnswer" } ], "json": "", diff --git a/sources/packages/load-test/src/_tests_/form-io/form-io-application-submission/models.ts b/sources/packages/load-test/src/_tests_/form-io/form-io-application-submission/models.ts index 82329bd4de..5b3bcdf368 100644 --- a/sources/packages/load-test/src/_tests_/form-io/form-io-application-submission/models.ts +++ b/sources/packages/load-test/src/_tests_/form-io/form-io-application-submission/models.ts @@ -25,7 +25,7 @@ export const APPLICATION_SUBMISSION_PAYLOAD = { studentHomeAddress: "123 Humboldt St, Victoria, BC, V9V1V1, canada", studentEmail: "simsfive@test.ca", studentLastName: "FRANKY", - studentGender: "male", + studentGender: "man", studentPhoneNumber: "7789221234", disabilityStatus: "Requested", studentInfoConfirmed: true,