Skip to content

Commit

Permalink
feat: CEEB Outcome export (#734)
Browse files Browse the repository at this point in the history
  • Loading branch information
afwilcox authored Nov 5, 2024
1 parent 5e39e40 commit e936743
Show file tree
Hide file tree
Showing 29 changed files with 382 additions and 164 deletions.
9 changes: 8 additions & 1 deletion backend/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ export class AppModule {
consumer.apply(HTTPLoggerMiddleware).exclude({ path: "", method: RequestMethod.ALL }).forRoutes("*");
consumer
.apply(RequestTokenMiddleware)
.forRoutes("v1/code-table", "v1/case", "v1/configuration", "v1/complaint/search", "v1/complaint/map/search");
.forRoutes(
"v1/code-table",
"v1/case",
"v1/configuration",
"v1/complaint/search",
"v1/complaint/map/search",
"v1/document/export-complaint",
);
}
}
130 changes: 130 additions & 0 deletions backend/src/external_api/case_management.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,136 @@ axios.interceptors.response.use(undefined, (error: AxiosError) => {
return Promise.reject(error);
});

export const caseFileQueryFields: string = `
{
caseIdentifier
leadIdentifier
assessmentDetails {
actionNotRequired
actionJustificationCode
actionJustificationShortDescription
actionJustificationLongDescription
actionJustificationActiveIndicator
actions {
actionId
actor
date
actionCode
shortDescription
longDescription
activeIndicator
}
}
isReviewRequired
reviewComplete {
actor
date
actionCode
actionId
activeIndicator
}
preventionDetails {
actions {
actionId
actor
date
actionCode
shortDescription
longDescription
activeIndicator
}
}
note {
note
action {
actor
actionCode
date,
actionId,
activeIndicator
}
}
equipment {
id
typeCode
activeIndicator
address
xCoordinate
yCoordinate
createDate
actions {
actionId
actor
actionCode
date
}
wasAnimalCaptured
},
subject {
id
species
sex
age
categoryLevel
conflictHistory
outcome
tags {
id
ear
identifier
order
}
drugs {
id
vial
drug
amountUsed
injectionMethod
reactions
remainingUse
amountDiscarded
discardMethod
order
}
actions {
actionId
actor
actionCode
date
}
order
}
decision {
id
schedule
scheduleLongDescription
sector
sectorLongDescription
discharge
dischargeLongDescription
nonCompliance
nonComplianceLongDescription
rationale
inspectionNumber
leadAgency
leadAgencyLongDescription
assignedTo
actionTaken
actionTakenLongDescription
actionTakenDate
}
authorization {
id
type
value
}
}
`;

export const get = (token, params?: {}) => {
let config: AxiosRequestConfig = {
headers: {
Expand Down
36 changes: 31 additions & 5 deletions backend/src/external_api/cdogs/cdogs.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,23 @@ export class CdogsService implements ExternalApiService {
upload = async (apiToken: string, type: string, templateCode: string) => {
const url = `${this.baseUri}/api/v2/template`;

const template =
type === "HWCR"
? "templates/complaint/CDOGS-HWCR-COMPLAINT-TEMPLATE-v1.docx"
: "templates/complaint/CDOGS-ERS-COMPLAINT-TEMPLATE-v1.docx";
let template: string;

switch (templateCode) {
case "HWCTMPLATE":
template = "templates/complaint/CDOGS-HWCR-COMPLAINT-TEMPLATE-v1.docx";
break;
case "ERSTMPLATE":
template = "templates/complaint/CDOGS-ERS-COMPLAINT-TEMPLATE-v1.docx";
break;
case "CEEBTMPLAT":
template = "templates/complaint/CDOGS-CEEB-COMPLAINT-TEMPLATE-v1.docx";
break;
default:
this.logger.error(`exception: unable to find template: ${template}`);
break;
}

const path = join(process.cwd(), template);

try {
Expand Down Expand Up @@ -166,7 +179,20 @@ export class CdogsService implements ExternalApiService {
//-- render complaint to pdf
//--
generate = async (documentName: string, data: any, type: COMPLAINT_TYPE): Promise<AxiosResponse> => {
const templateCode = type === "HWCR" ? CONFIGURATION_CODES.HWCTMPLATE : CONFIGURATION_CODES.ERSTMPLATE;
//-- Determine template to use
let templateCode: string;
switch (type) {
case "HWCR":
templateCode = CONFIGURATION_CODES.HWCTMPLATE;
break;
case "ERS":
if (data.ownedBy === "EPO") {
templateCode = CONFIGURATION_CODES.CEEBTMPLATE;
} else {
templateCode = CONFIGURATION_CODES.ERSTMPLATE;
}
break;
}

try {
const apiToken = await this.authenticate();
Expand Down
8 changes: 8 additions & 0 deletions backend/src/middleware/maps/automapper-entity-to-dto-maps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1189,6 +1189,10 @@ export const mapWildlifeReport = (mapper: Mapper, tz: string = "America/Vancouve
(destination) => destination.createdBy,
mapFrom((source) => source.create_user_id),
),
forMember(
(destination) => destination.ownedBy,
mapFrom((source) => source.complaint_identifier.owned_by_agency_code.agency_code),
),
forMember(
(destination) => destination.reportedOn,
mapFrom((source) => {
Expand Down Expand Up @@ -1487,6 +1491,10 @@ export const mapAllegationReport = (mapper: Mapper, tz: string = "America/Vancou
(destination) => destination.createdBy,
mapFrom((source) => source.create_user_id),
),
forMember(
(destination) => destination.ownedBy,
mapFrom((source) => source.complaint_identifier.owned_by_agency_code.agency_code),
),
forMember(
(destination) => destination.reportedOn,
mapFrom((source) => {
Expand Down
1 change: 1 addition & 0 deletions backend/src/types/configuration-codes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export const CONFIGURATION_CODES = {
HWCTMPLATE: "HWCTMPLATE",
ERSTMPLATE: "ERSTMPLATE",
CEEBTMPLATE: "CEEBTMPLAT",
CDTABLEVER: "CDTABLEVER",
DFLTPAGNUM: "DFLTPAGNUM",
MAXFILESZ: "MAXFILESZ",
Expand Down
4 changes: 4 additions & 0 deletions backend/src/types/models/case-files/case-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { EquipmentDetailsDto } from "./equipment/equipment-details";
import { Note } from "./supplemental-notes/note";
import { PreventionDetailsDto } from "./prevention-details";
import { FileReviewActionDto } from "./file-review-action";
import { PermitSiteDto } from "./ceeb/site/permit-site-input";
import { DecisionDto } from "./ceeb/decision/decision-input";

export interface CaseFileDto {
caseIdentifier: UUID;
Expand All @@ -18,4 +20,6 @@ export interface CaseFileDto {
isReviewRequired: boolean;
reviewComplete: FileReviewActionDto;
note?: Note;
authorization?: PermitSiteDto;
decision?: DecisionDto;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BaseCaseFileInput } from "../../base-case-file-input";
import { DecisionInput } from "./decision-input";
import { DecisionDto } from "./decision-input";

export interface CreateDecisionInput extends BaseCaseFileInput {
decison: DecisionInput;
decison: DecisionDto;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface DecisionInput {
export interface DecisionDto {
id?: string;
schedule: string;
sector: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { BaseCaseFileInput } from "../../base-case-file-input";
import { DecisionInput } from "./decision-input";
import { DecisionDto } from "./decision-input";

export interface UpdateDecisionInput extends BaseCaseFileInput {
agencyCode: string;
caseCode: string;
decison: DecisionInput;
decison: DecisionDto;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BaseCaseFileInput } from "../../base-case-file-input";
import { PermitSiteInput } from "./permit-site-input";
import { PermitSiteDto } from "./permit-site-input";

export interface CreateAuthorizationOutcomeInput extends BaseCaseFileInput {
input: PermitSiteInput;
input: PermitSiteDto;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface PermitSiteInput {
export interface PermitSiteDto {
id?: string;
type: "permit" | "site";
value: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BaseCaseFileInput } from "../../base-case-file-input";
import { PermitSiteInput } from "./permit-site-input";
import { PermitSiteDto } from "./permit-site-input";

export interface UpdateAuthorizationOutcomeInput extends BaseCaseFileInput {
input: PermitSiteInput;
input: PermitSiteDto;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface ComplaintReportData {
generatedOn: string;
updatedOn: Date | string;
createdBy: string;
ownedBy: string;
officerAssigned: string;
status: string;
incidentDateTime: Date | string;
Expand Down
1 change: 1 addition & 0 deletions backend/src/v1/case_file/case_file.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ import { LinkedComplaintXref } from "../linked_complaint_xref/entities/linked_co
],
controllers: [CaseFileController],
providers: [CaseFileService],
exports: [CaseFileService],
})
export class CaseFileModule {}
20 changes: 20 additions & 0 deletions backend/src/v1/case_file/case_file.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ import { TeamCode } from "../team_code/entities/team_code.entity";
import { CompMthdRecvCdAgcyCdXref } from "../comp_mthd_recv_cd_agcy_cd_xref/entities/comp_mthd_recv_cd_agcy_cd_xref";
import { CompMthdRecvCdAgcyCdXrefService } from "../comp_mthd_recv_cd_agcy_cd_xref/comp_mthd_recv_cd_agcy_cd_xref.service";
import { LinkedComplaintXref } from "../linked_complaint_xref/entities/linked_complaint_xref.entity";
import { OfficerService } from "../officer/officer.service";
import { PersonService } from "../person/person.service";
import { OfficeService } from "../office/office.service";
import { CssService } from "../../external_api/css/css.service";
import { ConfigurationService } from "../configuration/configuration.service";
import { Configuration } from "../configuration/entities/configuration.entity";
import { Person } from "../person/entities/person.entity";

describe("Testing: Case File Service", () => {
let service: CaseFileService;
Expand Down Expand Up @@ -192,10 +199,23 @@ describe("Testing: Case File Service", () => {
provide: getRepositoryToken(LinkedComplaintXref),
useValue: {},
},
{
provide: getRepositoryToken(Configuration),
useValue: {},
},
{
provide: getRepositoryToken(Person),
useValue: {},
},
ComplaintUpdatesService,
CaseFileService,
ComplaintService,
CodeTableService,
OfficerService,
OfficeService,
CssService,
ConfigurationService,
PersonService,
PersonComplaintXrefService,
AttractantHwcrXrefService,
CompMthdRecvCdAgcyCdXrefService,
Expand Down
Loading

0 comments on commit e936743

Please sign in to comment.