Skip to content

#1702 - Allow institution to specify custom regulatory body #1763

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

Merged
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export class InstitutionControllerService {
primaryEmail: institutionDetail.primaryEmail,
website: institutionDetail.website,
regulatingBody: institutionDetail.regulatingBody,
otherRegulatingBody: institutionDetail.otherRegulatingBody,
institutionType: institutionDetail.institutionType.id,
institutionTypeName: institutionDetail.institutionType.name,
establishedDate: institutionDetail.establishedDate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import {
LEGAL_OPERATING_NAME_MAX_LENGTH,
} from "@sims/sims-db";

const OTHER_REGULATING_BODY_MAX_LENGTH = 100;

/**
* DTO for institution creation by the institution user during the on board process
* when the institution profile and the admin user must be created altogether.
Expand All @@ -37,6 +39,10 @@ export class CreateInstitutionAPIInDTO {
website: string;
@IsNotEmpty()
regulatingBody: string;
@ValidateIf((e) => e.regulatingBody === "other")
@IsNotEmpty()
@MaxLength(OTHER_REGULATING_BODY_MAX_LENGTH)
otherRegulatingBody: string;
@IsDateString()
establishedDate: string;
@IsPositive()
Expand Down Expand Up @@ -102,6 +108,9 @@ export class InstitutionProfileAPIInDTO extends InstitutionContactAPIInDTO {
website: string;
@IsNotEmpty()
regulatingBody: string;
@ValidateIf((e) => e.regulatingBody === "other")
@IsNotEmpty()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same max length validation needs to added here as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I apologize, I missed it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem.

otherRegulatingBody: string;
@IsDateString()
establishedDate: string;
@IsPositive()
Expand All @@ -114,6 +123,7 @@ export class InstitutionProfileAPIOutDTO extends InstitutionContactAPIOutDTO {
primaryEmail: string;
website: string;
regulatingBody: string;
otherRegulatingBody?: string;
establishedDate: string;
institutionType: number;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface UpdateInstitution {
primaryEmail?: string;
website?: string;
regulatingBody?: string;
otherRegulatingBody?: string;
establishedDate?: string;
institutionType?: number;
primaryContactEmail: string;
Expand Down Expand Up @@ -34,6 +35,7 @@ export interface InstitutionFormModel {
primaryEmail: string;
website: string;
regulatingBody: string;
otherRegulatingBody?: string;
establishedDate: string;
primaryContactFirstName: string;
primaryContactLastName: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ export class InstitutionService extends RecordDataModelService<Institution> {
institution.primaryEmail = institutionModel.primaryEmail;
institution.website = institutionModel.website;
institution.regulatingBody = institutionModel.regulatingBody;
institution.otherRegulatingBody = institutionModel.otherRegulatingBody;
institution.establishedDate = institutionModel.establishedDate;
institution.institutionType = {
id: institutionModel.institutionType,
Expand Down Expand Up @@ -853,6 +854,7 @@ export class InstitutionService extends RecordDataModelService<Institution> {
institution.primaryEmail = updateInstitution.primaryEmail;
institution.website = updateInstitution.website;
institution.regulatingBody = updateInstitution.regulatingBody;
institution.otherRegulatingBody = updateInstitution.otherRegulatingBody;
institution.establishedDate = updateInstitution.establishedDate;
institution.institutionType = {
id: updateInstitution.institutionType,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { MigrationInterface, QueryRunner } from "typeorm";
import { getSQLFileData } from "../utilities/sqlLoader";

export class InstitutionsTableCreateOtherRegulatingBody1677528030804
implements MigrationInterface
{
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
getSQLFileData("Add-col-other-regulating-body.sql", "Institution"),
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
getSQLFileData("Drop-col-other-regulating-body.sql", "Institution"),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- Add other_regulating_body column to institutions table
ALTER TABLE
sims.institutions
ADD
COLUMN IF NOT EXISTS other_regulating_body VARCHAR(100);

COMMENT ON COLUMN sims.institutions.other_regulating_body IS 'Other institution regulating body.';
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- Drop other_regulating_body column from institutions table
ALTER TABLE
sims.institutions DROP COLUMN IF EXISTS other_regulating_body;
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,20 @@ export class Institution extends RecordDataModel {
name: "website",
})
website: string;

@Column({
name: "regulating_body",
})
regulatingBody: string;

/**
* Other regulating body
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Period missing in the comment. Also please try to use the same comment used for the column.

image

*/
@Column({
name: "other_regulating_body",
})
otherRegulatingBody?: string;

@Column({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment is missing for the property. I know that this is a very old entity model that is why it is missing the comments for all the properties of the class.

Here is the Wiki for comment standards we follow on entity models.
https://github.com/bcgov/SIMS/wiki/Development---Standards,-Decisions,-and-Troubleshooting#typeorm-database-models

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. Will do the change

name: "established_date",
type: "date",
Expand Down
Loading