Skip to content
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

feat: CE-977 create ceeb decison #607

Merged
merged 37 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d690860
feat: added outcome report container for ceeb complaints
Aug 26, 2024
ac0bee2
feat: new ceeb outcome components created
Aug 26, 2024
1ee808e
feat: update code-table service for new code-tables
Aug 27, 2024
7981a61
feat: updated code-table reducer, added new redux migration
Aug 27, 2024
4503b68
fix: added new selectors file for new code-table selectors
Aug 27, 2024
46ebfb8
feat: starting to add code tables to decision view
Aug 27, 2024
38cfcb3
feat: redux and component updates
Aug 28, 2024
5d91f9c
feat: starting to add support for crud operations
Aug 28, 2024
14c239b
feat: reorganized components, added missing data
Aug 28, 2024
7262642
feat: upsert decision thunk created
Aug 29, 2024
17a5704
feat: create decision complete, select case updated
Aug 30, 2024
022f517
feat: decision-item rendering values
Aug 30, 2024
0eec4ed
feat: updated editable mode functionality
Aug 30, 2024
146858f
Merge branch 'release/red-irish-lord' into feat/CE-977
marqueone-ps Aug 30, 2024
1c9b07b
fix: fixed migrations after merge conflict, code cleanup
Aug 30, 2024
abe7bd6
feat: added update decsion functionality
Aug 30, 2024
b790362
Merge branch 'release/red-irish-lord' into feat/CE-977
marqueone-ps Aug 30, 2024
d52462c
fix: code smell updates
Aug 30, 2024
e02cf9f
feat: added functionality to pre-select assigned to
Sep 3, 2024
4a605b7
Merge branch 'release/red-irish-lord' into feat/CE-977
marqueone-ps Sep 3, 2024
c32b4fe
fix: fixed problem with merge confict
Sep 3, 2024
c542ef2
feat: review update, added new migration for decisons
Sep 3, 2024
c28a0e4
fix: missed migration update
Sep 3, 2024
1b3898f
fix: merge conflict error in backend code-table service
Sep 3, 2024
9609b5f
fix: merge conflict error in backend code-table service
Sep 3, 2024
a71ea56
fix: incorrect guard role applied to decison endpoint
Sep 3, 2024
a3923e6
fix: code-smell updates
Sep 3, 2024
0d56261
fix: updated problem when editing decision action taken
Sep 3, 2024
9124a83
fix: fixed issue found in demo
Sep 4, 2024
923cee0
fix: changes to redux migration script, removed empty .sql file
Sep 5, 2024
310a64e
feat: added officer assignment, migration update
Sep 5, 2024
ccd3d54
Merge branch 'release/lewis-moon-snail' into feat/CE-977
marqueone-ps Sep 5, 2024
c5a3929
fix: missed file update
Sep 5, 2024
69fe130
Merge remote-tracking branch 'origin/feat/CE-977' into feat/CE-977
Sep 5, 2024
dd35234
Merge branch 'release/lewis-moon-snail' into feat/CE-977
barrfalk Sep 5, 2024
b45ff80
Merge branch 'release/lewis-moon-snail' into feat/CE-977
afwilcox Sep 6, 2024
dd07506
Merge branch 'release/lewis-moon-snail' into feat/CE-977
afwilcox Sep 6, 2024
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
@@ -0,0 +1,6 @@
import { BaseCaseFileInput } from "../../base-case-file-input";
import { DecisionInput } from "./decision-input";

export interface CreateDecisionInput extends BaseCaseFileInput {
decison: DecisionInput;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export interface DecisionInput {
id?: string;
schedule: string;
sector: string;
discharge: string;
nonCompliance: string;
rationale: string;
inspectionNumber?: string;
leadAgency?: string;
assignedTo: string;
actionTaken: string;
actionTakenDate: Date | null;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { BaseCaseFileInput } from "../../base-case-file-input";
import { DecisionInput } from "./decision-input";

export interface UpdateDecisionInput extends BaseCaseFileInput {
agencyCode: string;
caseCode: string;
decison: DecisionInput;
}
5 changes: 5 additions & 0 deletions backend/src/types/models/code-tables/decision-type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { BaseCodeTable } from "../../models/code-tables/code-table";

export interface DecisionType extends BaseCodeTable {
decisionType: string;
}
5 changes: 5 additions & 0 deletions backend/src/types/models/code-tables/discharge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { BaseCodeTable } from "./code-table";

export interface Discharge extends BaseCodeTable {
discharge: string;
}
6 changes: 6 additions & 0 deletions backend/src/types/models/code-tables/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ export const AvailableCodeTables = [
"wildlife-outcomes",
"equipment",
"gir-type",
"discharge",
"rationale",
"non-compliance",
"sector",
"schedule",
"decision-type",
"team",
];

Expand Down
5 changes: 5 additions & 0 deletions backend/src/types/models/code-tables/non-compliance.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { BaseCodeTable } from "./code-table";

export interface NonCompliance extends BaseCodeTable {
nonCompliance: string;
}
5 changes: 5 additions & 0 deletions backend/src/types/models/code-tables/rationale.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { BaseCodeTable } from "./code-table";

export interface Rationale extends BaseCodeTable {
rationale: string;
}
5 changes: 5 additions & 0 deletions backend/src/types/models/code-tables/schedule.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { BaseCodeTable } from "./code-table";

export interface Schedule extends BaseCodeTable {
schedule: string;
}
5 changes: 5 additions & 0 deletions backend/src/types/models/code-tables/sector-code.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { BaseCodeTable } from "./code-table";

export interface SectorCode extends BaseCodeTable {
sector: string;
}
17 changes: 16 additions & 1 deletion backend/src/v1/case_file/case_file.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { FileReviewInput } from "../../types/models/case-files/file-review-input
import { CreateWildlifeInput } from "../../types/models/case-files/wildlife/create-wildlife-input";
import { DeleteWildlifeInput } from "../../types/models/case-files/wildlife/delete-wildlife-outcome";
import { UpdateWildlifeInput } from "../../types/models/case-files/wildlife/update-wildlife-input";
import { CreateDecisionInput } from "../../types/models/case-files/ceeb/decision/create-decision-input";
import { UpdateDecisionInput } from "../../types/models/case-files/ceeb/decision/update-decison-input";

@UseGuards(JwtRoleGuard)
@ApiTags("case")
Expand Down Expand Up @@ -86,7 +88,7 @@ export class CaseFileController {
}

@Get("/:complaint_id")
@Roles(Role.COS_OFFICER)
@Roles(Role.COS_OFFICER, Role.CEEB)
find(@Param("complaint_id") complaint_id: string, @Token() token) {
return this.service.find(complaint_id, token);
}
Expand Down Expand Up @@ -152,4 +154,17 @@ export class CaseFileController {

return await this.service.deleteWildlife(token, input as DeleteWildlifeInput);
}

@Post("/decision")
@Roles(Role.CEEB)
async createDecision(@Token() token, @Body() model: CreateDecisionInput): Promise<CaseFileDto> {
return await this.service.createDecision(token, model);
}
@Patch("/decision")
@Roles(Role.CEEB)
async updateDecision(@Token() token, @Body() model: UpdateDecisionInput): Promise<CaseFileDto> {
const result = await this.service.updateDecision(token, model);

return Promise.resolve(result);
}
}
43 changes: 43 additions & 0 deletions backend/src/v1/case_file/case_file.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { DeleteEquipmentDto } from "../../types/models/case-files/equipment/dele
import { CreateWildlifeInput } from "../../types/models/case-files/wildlife/create-wildlife-input";
import { DeleteWildlifeInput } from "../../types/models/case-files/wildlife/delete-wildlife-outcome";
import { UpdateWildlifeInput } from "../../types/models/case-files/wildlife/update-wildlife-input";
import { CreateDecisionInput } from "src/types/models/case-files/ceeb/decision/create-decision-input";
import { UpdateDecisionInput } from "src/types/models/case-files/ceeb/decision/update-decison-input";

@Injectable({ scope: Scope.REQUEST })
export class CaseFileService {
Expand Down Expand Up @@ -123,6 +125,19 @@ export class CaseFileService {
}
order
}
decision {
id
schedule
sector
discharge
nonCompliance
rationale
inspectionNumber
leadAgency
assignedTo
actionTaken
actionTakenDate
}
}
`;

Expand Down Expand Up @@ -398,4 +413,32 @@ export class CaseFileService {
const returnValue = await this.handleAPIResponse(result);
return returnValue?.deleteWildlife;
};

createDecision = async (token: any, model: CreateDecisionInput): Promise<CaseFileDto> => {
const result = await post(token, {
query: `mutation createDecision($input: CreateDecisionInput!) {
createDecision(input: $input) {
caseIdentifier
}
}`,
variables: { input: model },
});

const returnValue = await this.handleAPIResponse(result);
return returnValue?.createDecison;
};

updateDecision = async (token: any, model: UpdateDecisionInput): Promise<CaseFileDto> => {
const result = await post(token, {
query: `mutation updateDecision($input: UpdateDecisionInput!) {
updateDecision(input: $input) {
caseIdentifier
}
}`,
variables: { input: model },
});

const returnValue = await this.handleAPIResponse(result);
return returnValue?.updateDecision;
};
}
118 changes: 117 additions & 1 deletion backend/src/v1/code-table/code-table.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable, Logger } from "@nestjs/common";
import { InjectRepository } from "@nestjs/typeorm";
import { Code, Repository, SelectQueryBuilder } from "typeorm";
import { Repository, SelectQueryBuilder } from "typeorm";

import BaseCodeTable, {
Agency,
Expand Down Expand Up @@ -47,6 +47,12 @@ import { DrugRemainingOutcome } from "src/types/models/code-tables/drug-remainin
import { WildlifeComplaintOutcome } from "src/types/models/code-tables/wildlfe-complaint-outcome";
import { get } from "../../external_api/case_management";
import { GirTypeCode } from "../gir_type_code/entities/gir_type_code.entity";
import { Schedule } from "src/types/models/code-tables/schedule";
import { SectorCode } from "src/types/models/code-tables/sector-code";
import { Discharge } from "src/types/models/code-tables/discharge";
import { NonCompliance } from "src/types/models/code-tables/non-compliance";
import { DecisionType } from "src/types/models/code-tables/decision-type";
import { Rationale } from "src/types/models/code-tables/rationale";
import { TeamCode } from "../team_code/entities/team_code.entity";
import { TeamType } from "src/types/models/code-tables/team-type";

Expand Down Expand Up @@ -544,6 +550,116 @@ export class CodeTableService {
});
return results;
}
case "schedule": {
const { data } = await get(token, {
query: "{scheduleCodes{scheduleCode shortDescription longDescription displayOrder activeIndicator}}",
});
const results = data.scheduleCodes.map(
({ scheduleCode, shortDescription, longDescription, displayOrder, activeIndicator }) => {
const table: Schedule = {
schedule: scheduleCode,
shortDescription: shortDescription,
gregorylavery marked this conversation as resolved.
Show resolved Hide resolved
longDescription: longDescription,
displayOrder: displayOrder,
isActive: activeIndicator,
};
return table;
},
);
return results;
}
case "sector": {
const { data } = await get(token, {
query: "{sectorCodes{sectorCode shortDescription longDescription displayOrder activeIndicator}}",
});
const results = data.sectorCodes.map(
({ sectorCode, shortDescription, longDescription, displayOrder, activeIndicator }) => {
const table: SectorCode = {
sector: sectorCode,
shortDescription: shortDescription,
longDescription: longDescription,
displayOrder: displayOrder,
isActive: activeIndicator,
};
return table;
},
);
return results;
}
case "discharge": {
const { data } = await get(token, {
query: "{ dischargeCodes { dischargeCode shortDescription longDescription displayOrder activeIndicator} }",
});
const results = data.dischargeCodes.map(
({ dischargeCode, shortDescription, longDescription, displayOrder, activeIndicator }) => {
const table: Discharge = {
discharge: dischargeCode,
shortDescription: shortDescription,
longDescription: longDescription,
displayOrder: displayOrder,
isActive: activeIndicator,
};
return table;
},
);
return results;
}
case "rationale": {
const { data } = await get(token, {
query: "{rationaleCodes{rationaleCode shortDescription longDescription displayOrder activeIndicator}}",
});
const results = data.rationaleCodes.map(
({ rationaleCode, shortDescription, longDescription, displayOrder, activeIndicator }) => {
const table: Rationale = {
rationale: rationaleCode,
shortDescription: shortDescription,
longDescription: longDescription,
displayOrder: displayOrder,
isActive: activeIndicator,
};
return table;
},
);
return results;
}
case "non-compliance": {
const { data } = await get(token, {
query:
"{nonComplianceCodes{nonComplianceCode shortDescription longDescription displayOrder activeIndicator}}",
});
const results = data.nonComplianceCodes.map(
({ nonComplianceCode, shortDescription, longDescription, displayOrder, activeIndicator }) => {
const table: NonCompliance = {
nonCompliance: nonComplianceCode,
shortDescription: shortDescription,
longDescription: longDescription,
displayOrder: displayOrder,
isActive: activeIndicator,
};
return table;
},
);
return results;
}
case "decision-type": {
const { data } = await get(token, {
query:
"{CEEBDecisionActions{actionTypeCode actionCode displayOrder activeIndicator shortDescription longDescription}}",
});
const results = data.CEEBDecisionActions.map(
({ actionCode, shortDescription, longDescription, displayOrder, activeIndicator }) => {
const table: DecisionType = {
decisionType: actionCode,
shortDescription: shortDescription,
longDescription: longDescription,
displayOrder: displayOrder,
isActive: activeIndicator,
};
return table;
},
);
return results;
}
case "team": {
const data = await this._teamCodeRepository.find({ order: { display_order: "ASC" } });
let results = data.map(({ team_code, short_description, long_description, display_order, active_ind }) => {
Expand Down
Loading
Loading