Skip to content

Commit

Permalink
Merge branch 'release/lewis-moon-snail' into CE-776
Browse files Browse the repository at this point in the history
  • Loading branch information
afwilcox authored Sep 6, 2024
2 parents 518e641 + d011ecb commit ca34b8e
Show file tree
Hide file tree
Showing 49 changed files with 5,269 additions and 1,077 deletions.
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,
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
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const ComplaintListTabs: FC<props> = ({ complaintType, viewType, complain
record = { ...record, name };
break;
case COMPLAINT_TYPES.HWCR:
record = { ...record, name: "Human Wildlife Conflict" };
record = { ...record, name: "Human Wildlife Conflicts" };
break;
case COMPLAINT_TYPES.GIR:
record = { ...record, name: "General Incidents" };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ export const AllegationComplaintListItem: FC<Props> = ({ type, complaint }) => {
const {
person: { firstName, lastName },
} = officer;

const firstInitial = firstName.length > 0 ? firstName.substring(0, 1) : "";

return firstInitial.length > 0 ? `${firstInitial}. ${lastName}` : lastName;
return `${lastName}, ${firstName}`;
}

return "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@ export const GeneralInformationComplaintListItem: FC<Props> = ({ type, complaint
const {
person: { firstName, lastName },
} = officer;

const firstInitial = firstName.length > 0 ? firstName.substring(0, 1) : "";

return firstInitial.length > 0 ? `${firstInitial}. ${lastName}` : lastName;
return `${lastName}, ${firstName}`;
}

return "";
Expand Down
Loading

0 comments on commit ca34b8e

Please sign in to comment.