Skip to content

Commit

Permalink
feature/CE-440v2 (#320)
Browse files Browse the repository at this point in the history
Co-authored-by: Mike Sears <[email protected]>
Co-authored-by: afwilcox <[email protected]>
  • Loading branch information
3 people authored Apr 5, 2024
1 parent 7ce54d7 commit d15d595
Show file tree
Hide file tree
Showing 26 changed files with 982 additions and 494 deletions.
14 changes: 14 additions & 0 deletions backend/src/types/models/case-files/base-case-file-input.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { UUID } from "crypto";

export interface BaseCaseFileInput {
caseIdentifier: UUID;
leadIdentifier: string;

agencyCode: string;
caseCode: string;

actor: UUID;

createUserId: string;
updateUserId: string;
}
5 changes: 5 additions & 0 deletions backend/src/types/models/case-files/case-action.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface CaseAction {
actor: string;
date: Date;
actionCode: string;
}
2 changes: 2 additions & 0 deletions backend/src/types/models/case-files/case-file.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { UUID } from "crypto";
import { AssessmentDetailsDto } from "./assessment-details";
import { Note } from "./supplemental-notes/note";
import { PreventionDetailsDto } from "./prevention-details";

export interface CaseFileDto {
Expand All @@ -11,4 +12,5 @@ export interface CaseFileDto {
assessmentDetails?: AssessmentDetailsDto
preventionDetails?: PreventionDetailsDto
updateUserId: string
note?: Note
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { BaseCaseFileInput } from "../base-case-file-input";

export interface CreateSupplementalNotesInput extends BaseCaseFileInput {
note: string
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { CaseAction } from "../case-action";

export interface Note {
note: string;
action: CaseAction;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { BaseCaseFileInput } from "../base-case-file-input";

export interface UpdateSupplementalNotesInput extends BaseCaseFileInput {
note: string
}
38 changes: 24 additions & 14 deletions backend/src/v1/case_file/case_file.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@ import { JwtRoleGuard } from "../../auth/jwtrole.guard";
import { ApiTags } from "@nestjs/swagger";
import { CaseFileDto } from "src/types/models/case-files/case-file";
import { Token } from "src/auth/decorators/token.decorator";
import { CreateSupplementalNotesInput } from "src/types/models/case-files/supplemental-notes/create-supplemental-notes-input";
import { UpdateSupplementalNotesInput } from "src/types/models/case-files/supplemental-notes/update-supplemental-note-input";

@UseGuards(JwtRoleGuard)
@ApiTags("case")
@Controller(
{
path: "case",
version: "1",
})
@Controller({
path: "case",
version: "1",
})
export class CaseFileController {
constructor(private readonly service: CaseFileService) { }
constructor(private readonly service: CaseFileService) {}

@Post("/createAssessment")
@Roles(Role.COS_OFFICER)
Expand Down Expand Up @@ -49,12 +50,21 @@ export class CaseFileController {
return await this.service.updatePrevention(token, model);
}

@Get("/:complaint_id")
@Roles(Role.COS_OFFICER)
find(
@Param("complaint_id") complaint_id: string,
@Token() token
) {
return this.service.find(complaint_id, token);
}
@Get("/:complaint_id")
@Roles(Role.COS_OFFICER)
find(@Param("complaint_id") complaint_id: string, @Token() token) {
return this.service.find(complaint_id, token);
}

@Post("/note")
@Roles(Role.COS_OFFICER)
async createNote(@Token() token, @Body() model: CreateSupplementalNotesInput): Promise<CaseFileDto> {
return await this.service.createNote(token, model);
}

@Patch("/note")
@Roles(Role.COS_OFFICER)
async UpdateNote(@Token() token, @Body() model: UpdateSupplementalNotesInput): Promise<CaseFileDto> {
return await this.service.updateNote(token, model);
}
}
52 changes: 44 additions & 8 deletions backend/src/v1/case_file/case_file.service.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@

import { Inject, Injectable, Logger, Scope } from "@nestjs/common";
import { InjectMapper } from "@automapper/nestjs";
import { Mapper } from "@automapper/core";
import { get, post } from "../../external_api/case_management";
import { CaseFileDto } from "src/types/models/case-files/case-file";
import { REQUEST } from "@nestjs/core";
import { AxiosResponse, AxiosError } from "axios";
import { CreateSupplementalNotesInput } from "src/types/models/case-files/supplemental-notes/create-supplemental-notes-input";
import { UpdateSupplementalNotesInput } from "src/types/models/case-files/supplemental-notes/update-supplemental-note-input";

@Injectable({ scope: Scope.REQUEST })
export class CaseFileService {
private readonly logger = new Logger(CaseFileService.name);
private mapper: Mapper;
private caseFileQueryFields: string = `
private caseFileQueryFields: string = `
{
caseIdentifier
leadIdentifier
Expand Down Expand Up @@ -40,12 +41,18 @@ export class CaseFileService {
activeIndicator
}
}
note {
note
action {
actor
actionCode
date
}
}
}
`;
constructor(
@Inject(REQUEST) private request: Request,
@InjectMapper() mapper,
) {

constructor(@Inject(REQUEST) private request: Request, @InjectMapper() mapper) {
this.mapper = mapper;
}

Expand Down Expand Up @@ -85,7 +92,7 @@ export class CaseFileService {
return returnValue?.createAssessment;
}

updateAssessment = async (
updateAssessment = async (
token: string,
model: CaseFileDto
): Promise<CaseFileDto> => {
Expand All @@ -103,6 +110,7 @@ export class CaseFileService {

}


createPrevention = async (
token: string,
model: CaseFileDto
Expand Down Expand Up @@ -138,7 +146,7 @@ export class CaseFileService {

}

private handleAPIResponse = async (result: { response: AxiosResponse, error: AxiosError }):
private handleAPIResponse = async (result: { response: AxiosResponse, error: AxiosError }):
Promise<any> => {
if (result?.response?.data?.data) {
const caseFileDto = result.response.data.data;
Expand All @@ -154,4 +162,32 @@ export class CaseFileService {
return null;
}
}

createNote = async (token: any, model: CreateSupplementalNotesInput): Promise<CaseFileDto> => {
const result = await post(token, {
query: `mutation CreateNote($input: CreateSupplementalNoteInput!) {
createNote(input: $input) {
note { note, action { actor,date,actionCode } }
}
}`,
variables: { input: model },
});
const returnValue = await this.handleAPIResponse(result);

return returnValue?.createNotes;
};

updateNote = async (token: any, model: UpdateSupplementalNotesInput): Promise<CaseFileDto> => {
const result = await post(token, {
query: `mutation UpdateNote($input: UpdateSupplementalNoteInput!) {
updateNote(input: $input) {
note { note, action { actor,date,actionCode } }
}
}`,
variables: { input: model },
});
const returnValue = await this.handleAPIResponse(result);

return returnValue?.updateNotes;
};
}
1 change: 1 addition & 0 deletions frontend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ import { BsPencil } from "react-icons/bs";
import { HWCROutcomeReport } from "../outcomes/hwcr-outcome-report";
import AttachmentEnum from "../../../../constants/attachment-enum";

type ComplaintParams = {
export type ComplaintParams = {
id: string;
complaintType: string;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
import { FC } from "react";
import { FC, useEffect } from "react";
import { HWCRComplaintAssessment } from "./hwcr-complaint-assessment";
import { HWCREquipment } from "./hwcr-equipment";
import { HWCROutcomeByAnimal } from "./hwcr-outcome-by-animal";
import { HWCRFileReview } from "./hwcr-file-review";
import { HWCRSupplementalNotes } from "./hwcr-supplemental-notes";
import { HWCRFileAttachments } from "./hwcr-file-attachments";
import { HWCRComplaintPrevention } from "./hwcr-prevention-education";
import { useParams } from "react-router-dom";
import { ComplaintParams } from "../details/complaint-details-edit";
import { useAppDispatch } from "../../../../hooks/hooks";
import { getCaseFile } from "../../../../store/reducers/cases";

export const HWCROutcomeReport: FC = () => {
return (
<div className="comp-hwcr-outcome-report">
<hr className="blue-seperator"/>
<div className="comp-sub-header">
Outcome report
</div>
<HWCRComplaintAssessment/>
<HWCRComplaintPrevention/>
<HWCREquipment/>
<HWCROutcomeByAnimal/>
<HWCRSupplementalNotes/>
<HWCRFileAttachments />
<HWCRFileReview/>
</div>
);
};
export const HWCROutcomeReport: FC = () => {
const { id = "" } = useParams<ComplaintParams>();
const dispatch = useAppDispatch();

useEffect(() => {
dispatch(getCaseFile(id))
}, [id]);

return (
<div className="comp-hwcr-outcome-report">
<hr className="blue-seperator" />
<div className="comp-sub-header">Outcome report</div>
<HWCRComplaintAssessment />
<HWCRComplaintPrevention />
<HWCREquipment />
<HWCROutcomeByAnimal />
<HWCRSupplementalNotes />
<HWCRFileAttachments />
<HWCRFileReview />
</div>
);
};
Loading

0 comments on commit d15d595

Please sign in to comment.