Skip to content

Commit

Permalink
feature/CE-39 - Add animal outcome (#271)
Browse files Browse the repository at this point in the history
  • Loading branch information
marqueone-ps authored Feb 13, 2024
1 parent 3be7baf commit a7eab9c
Show file tree
Hide file tree
Showing 51 changed files with 2,811 additions and 384 deletions.
6 changes: 3 additions & 3 deletions backend/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ async function bootstrap() {

process.env.TZ='UTC';
const config = new DocumentBuilder()
.setTitle("Compliance and Enforcement API")
.setDescription("The Complicance and Enforcement API")
.setTitle("Compliance and Enforcement - Complaint Management API")
.setDescription("The Complicance and Enforcement - Complaint Management API")
.setVersion("1.0")
.addTag("Compliance and Enforcement")
.addTag("Compliance and Enforcement - Complaint Management")
.build();

const document = SwaggerModule.createDocument(app, config);
Expand Down
5 changes: 5 additions & 0 deletions backend/src/types/models/code-tables/age.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { BaseCodeTable } from "./code-table";

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

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

export interface DrugMethod extends BaseCodeTable {
method: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { BaseCodeTable } from "./code-table";

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

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

export interface EarTag extends BaseCodeTable {
earTag: string;
}
15 changes: 11 additions & 4 deletions backend/src/types/models/code-tables/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,18 @@ export const AvailableCodeTables = [
"justification",
"assessment-type",
"prevent-education-action",
"sex",
"age",
"threat-level",
"conflict-history",
"ear-tag",
"drugs",
"drug-methods",
"drug-remaining-outcomes",
"wildlife-outcomes",
];

export const AvailableAgencies = [
"cos"
]
export const AvailableAgencies = ["cos"];

export default BaseCodeTable;
export {
Expand All @@ -60,5 +67,5 @@ export {
ReportedBy,
Justification,
AssessmentType,
PreventEducationAction
PreventEducationAction,
};
5 changes: 5 additions & 0 deletions backend/src/types/models/code-tables/sex.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { BaseCodeTable } from "./code-table";

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

export interface ThreatLevel extends BaseCodeTable {
threatLevel: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { BaseCodeTable } from "./code-table";

export interface WildlifeComplaintOutcome extends BaseCodeTable {
outcome: string;
}
99 changes: 99 additions & 0 deletions backend/src/v1/code-table/code-table.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ import { ReportedByCode } from "../reported_by_code/entities/reported_by_code.en
import { Justification } from "src/types/models/code-tables/justification";
import { AssessmentType } from "src/types/models/code-tables/assessment-type";
import { PreventEducationAction } from "src/types/models/code-tables/prevent-education-action";
import { Sex } from "src/types/models/code-tables/sex";
import { Age } from "src/types/models/code-tables/age";
import { ThreatLevel } from "src/types/models/code-tables/threat-level";
import { ConflictHistory } from "src/types/models/code-tables/conflict-history";
import { EarTag } from "src/types/models/code-tables/ear-tag";
import { Drug } from "src/types/models/code-tables/drug";
import { DrugMethod } from "src/types/models/code-tables/drug-method";
import { DrugRemainingOutcome } from "src/types/models/code-tables/drug-remaining-outcome";
import { WildlifeComplaintOutcome } from "src/types/models/code-tables/wildlfe-complaint-outcome";

@Injectable()
export class CodeTableService {
Expand Down Expand Up @@ -428,6 +437,96 @@ export class CodeTableService {
];
return data;
}
case "sex": {
const data: Array<Sex> = [
{ sex: "M", shortDescription: "Male", longDescription: "Male", displayOrder: 1, isActive: true },
{ sex: "F", shortDescription: "Female", longDescription: "Female", displayOrder: 2, isActive: true },
{ sex: "U", shortDescription: "Unknown", longDescription: "Unknown", displayOrder: 3, isActive: true },
]

return data;
}
case "age": {
const data: Array<Age> = [
{ age: "ADLT", shortDescription: "Adult", longDescription: "Adult", displayOrder: 1, isActive: true },
{ age: "YRLN", shortDescription: "Yearling", longDescription: "Yearling", displayOrder: 2, isActive: true },
{ age: "YOFY", shortDescription: "Young of the year", longDescription: "Young of the year", displayOrder: 3, isActive: true },
{ age: "UNKN", shortDescription: "Unknown", longDescription: "Unknown", displayOrder: 4, isActive: true },
]

return data;
}
case "threat-level": {
const data: Array<ThreatLevel> = [
{ threatLevel: "1", shortDescription: "Category 1", longDescription: "Category 1", displayOrder: 1, isActive: true },
{ threatLevel: "2", shortDescription: "Category 2", longDescription: "Category 2", displayOrder: 2, isActive: true },
{ threatLevel: "3", shortDescription: "Category 3", longDescription: "Category 3", displayOrder: 3, isActive: true },
{ threatLevel: "U", shortDescription: "Unknown", longDescription: "Unknown", displayOrder: 4, isActive: true },
]

return data;
}
case "conflict-history": {
const data: Array<ConflictHistory> = [
{ conflictHistory: "L", shortDescription: "Low", longDescription: "Low", displayOrder: 1, isActive: true },
{ conflictHistory: "M", shortDescription: "Medium", longDescription: "Medium", displayOrder: 2, isActive: true },
{ conflictHistory: "H", shortDescription: "High", longDescription: "High", displayOrder: 3, isActive: true },
{ conflictHistory: "U", shortDescription: "Unknown", longDescription: "Unknown", displayOrder: 4, isActive: true },
]

return data;
}
case "ear-tag": {
const data: Array<EarTag> = [
{ earTag: "L", shortDescription: "Left", longDescription: "Left", displayOrder: 1, isActive: true },
{ earTag: "R", shortDescription: "Right", longDescription: "Right", displayOrder: 2, isActive: true },
]

return data;
}
case "drugs": {
const data: Array<Drug> = [
{ drug: "ATPMZ", shortDescription: "Atipamezole", longDescription: "Atipamezole", displayOrder: 1, isActive: true },
{ drug: "BAMII", shortDescription: "BAM II", longDescription: "Butorphanol Azaperone Medetomidine", displayOrder: 2, isActive: true },
{ drug: "MDTMD", shortDescription: "Medetomidine", longDescription: "Medetomidine", displayOrder: 3, isActive: true },
{ drug: "NLTRX", shortDescription: "Naltrexone", longDescription: "Naltrexone", displayOrder: 4, isActive: true },
{ drug: "ZLTIL", shortDescription: "Zoletil", longDescription: "Zoletil", displayOrder: 5, isActive: true },
]

return data;
}
case "drug-methods": {
const data: Array<DrugMethod> = [
{ method: "DART", shortDescription: "Dart", longDescription: "Dart", displayOrder: 1, isActive: true },
{ method: "HINJ", shortDescription: "Hand injection", longDescription: "Hand injection", displayOrder: 2, isActive: true },
{ method: "PSRG", shortDescription: "Pole syringe", longDescription: "Pole syringe", displayOrder: 3, isActive: true },
]

return data;
}
case "drug-remaining-outcomes": {
const data: Array<DrugRemainingOutcome> = [
{ outcome: "DISC", shortDescription: "Discarded", longDescription: "Discarded", displayOrder: 1, isActive: true },
{ outcome: "STOR", shortDescription: "Storage", longDescription: "Storage", displayOrder: 2, isActive: true },
{ outcome: "RDIS", shortDescription: "Reverse distribution", longDescription: "Reverse distribution", displayOrder: 3, isActive: true },
]

return data;
}
case "wildlife-outcomes": {
const data: Array<WildlifeComplaintOutcome> = [
{ outcome: "DEADONARR", shortDescription: "Dead on arrival", longDescription: "Dead on arrival", displayOrder: 1, isActive: true },
{ outcome: "DESTRYCOS", shortDescription: "Destroyed by COS", longDescription: "Destroyed by COS", displayOrder: 2, isActive: true },
{ outcome: "DESTRYOTH", shortDescription: "Destroyed by other", longDescription: "Destroyed by other", displayOrder: 3, isActive: true },
{ outcome: "GONEONARR", shortDescription: "Gone on arrival", longDescription: "Gone on arrival", displayOrder: 4, isActive: true },
{ outcome: "REFRTOBIO", shortDescription: "Referred to biologist", longDescription: "Referred to biologist", displayOrder: 5, isActive: true },
{ outcome: "SHRTRELOC", shortDescription: "Short-distance relocation", longDescription: "Short-distance relocation", displayOrder: 6, isActive: true },
{ outcome: "TRANSLCTD", shortDescription: "Translocated", longDescription: "Translocated", displayOrder: 7, isActive: true },
{ outcome: "TRANSREHB", shortDescription: "Transfer to rehab", longDescription: "Transfer to rehab", displayOrder: 8, isActive: true },
]

return data;
}
}
};

Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,4 @@
"overrides": {
"typescript": "^5.0.4"
}
}
}
4 changes: 2 additions & 2 deletions frontend/src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import ProtectedRoutes from "./components/routing";
import ScrollToTop from "./common/scroll-to-top";
import NotAuthorized, { NotFound } from "./components/containers/pages";
import { ComplaintDetailsEdit } from "./components/containers/complaints/details/complaint-details-edit";
import ColorReference from "./components/reference";
import ColorReference, { MiscReference, SpaceReference } from "./components/reference";
import { ModalComponent as Modal } from "./components/modal/modal";
import { useAppDispatch } from "./hooks/hooks";
import { ZoneAtAGlance } from "./components/containers/zone-at-a-glance/zone-at-a-glance";
Expand Down Expand Up @@ -63,7 +63,7 @@ const App: FC = () => {
</Route>
<Route path="/not-authorized" element={<NotAuthorized />} />
<Route path="*" element={<NotFound />} />
<Route path="/reference" element={<ColorReference />} />
<Route path="/reference" element={<><ColorReference/> <MiscReference/> <SpaceReference /></>} />
</Routes>
</Router>
);
Expand Down
84 changes: 43 additions & 41 deletions frontend/src/app/common/methods.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ export const getAvatarInitials = (input: string): string => {
}
};

export const getSelectedOfficer = (officers: Option[], personGuid: UUID | string, update: ComplaintDto | undefined): any => {
export const getSelectedOfficer = (
officers: Option[],
personGuid: UUID | string,
update: ComplaintDto | undefined
): any => {
if (update && personGuid) {
const { delegates } = update;

Expand Down Expand Up @@ -106,24 +110,22 @@ export const formatDateTime = (input: string | undefined): string => {
// given a filename and complaint identifier, inject the complaint identifier inbetween the file name and extension
export const injectComplaintIdentifierToFilename = (filename: string, complaintIdentifier: string): string => {
// Find the last dot in the filename to separate the extension
const lastDotIndex = filename.lastIndexOf('.');
const lastDotIndex = filename.lastIndexOf(".");

// If there's no dot, just append the complaintId at the end
if (lastDotIndex === -1) {
return (`${filename} ${complaintIdentifier}`);
return `${filename} ${complaintIdentifier}`;
}

const fileNameWithoutExtension = filename.substring(0, lastDotIndex);
const fileExtension = filename.substring(lastDotIndex);

// Otherwise, insert the complaintId before the extension
return (`${fileNameWithoutExtension} ${complaintIdentifier}${fileExtension}`);
}
return `${fileNameWithoutExtension} ${complaintIdentifier}${fileExtension}`;
};

// Used to retrieve the coordinates in the decimal format
export const parseDecimalDegreesCoordinates = (
coordinates: Coordinate,
): { lat: number; lng: number } => {
export const parseDecimalDegreesCoordinates = (coordinates: Coordinate): { lat: number; lng: number } => {
if (!coordinates) {
return { lat: 0, lng: 0 };
}
Expand Down Expand Up @@ -155,10 +157,7 @@ export const isWithinBC = (coordinates: Coordinate): boolean => {
);
};

export const parseCoordinates = (
coordinates: Coordinate,
coordinateType: Coordinates,
): number | string => {
export const parseCoordinates = (coordinates: Coordinate, coordinateType: Coordinates): number | string => {
if (!coordinates) {
return 0;
}
Expand All @@ -179,10 +178,7 @@ export const getComplaintTypeFromUrl = (): number => {
return -1;
};

export const renderCoordinates = (
coordinates: Coordinate,
coordinateType: Coordinates,
): JSX.Element => {
export const renderCoordinates = (coordinates: Coordinate, coordinateType: Coordinates): JSX.Element => {
const result = parseCoordinates(coordinates, coordinateType);

return result === 0 ? <>{"Not Provided"}</> : <>{result}</>;
Expand All @@ -199,60 +195,66 @@ export const applyStatusClass = (state: string): string => {
}
};

export const truncateString = (str: string, maxLength: number): string=> {
export const truncateString = (str: string, maxLength: number): string => {
if (str?.length > maxLength) {
return str.substring(0, maxLength) + '...'; // Adds an ellipsis to indicate truncation
return str.substring(0, maxLength) + "..."; // Adds an ellipsis to indicate truncation
} else {
return str;
}
}
};

export const removeFile = (fileList: FileList, fileToRemove: File): File[] => {
// Convert the FileList to an array
const filesArray = Array.from(fileList);

// Filter out the file you want to remove
const updatedFilesArray = filesArray.filter(file => file !== fileToRemove);
const updatedFilesArray = filesArray.filter((file) => file !== fileToRemove);

return updatedFilesArray;
}
};

export const getStatusByStatusCode = (code: string, codes: Array<ComplaintStatus>): string => {
if(from(codes).any(({complaintStatus}) => complaintStatus === code)){
const selected = from(codes).first(({complaintStatus}) => complaintStatus === code)
export const getStatusByStatusCode = (code: string, codes: Array<ComplaintStatus>): string => {
if (from(codes).any(({ complaintStatus }) => complaintStatus === code)) {
const selected = from(codes).first(({ complaintStatus }) => complaintStatus === code);

return selected.longDescription
return selected.longDescription;
}

return "";
}
};

export const getViolationByViolationCode = (code: string, codes: Array<Violation>): string => {
if(codes && from(codes).any(({violation}) => violation === code)){
const selected = from(codes).first(({violation}) => violation === code);
export const getViolationByViolationCode = (code: string, codes: Array<Violation>): string => {
if (codes && from(codes).any(({ violation }) => violation === code)) {
const selected = from(codes).first(({ violation }) => violation === code);

return selected.longDescription;
}

return ""
}
return "";
};

export const getSpeciesBySpeciesCode = (code: string, codes: Array<Species>): string => {
if(codes && from(codes).any(({species}) => species === code)){
const selected = from(codes).first(({species}) => species === code);
export const getSpeciesBySpeciesCode = (code: string, codes: Array<Species>): string => {
if (codes && from(codes).any(({ species }) => species === code)) {
const selected = from(codes).first(({ species }) => species === code);

return selected.longDescription;
}

return ""
}
return "";
};

export const getNatureOfComplaintByNatureOfComplaintCode = (code: string, codes: Array<NatureOfComplaint>): string => {
if(codes && from(codes).any(({natureOfComplaint}) => natureOfComplaint === code)){
const selected = from(codes).first(({natureOfComplaint}) => natureOfComplaint === code);
export const getNatureOfComplaintByNatureOfComplaintCode = (code: string, codes: Array<NatureOfComplaint>): string => {
if (codes && from(codes).any(({ natureOfComplaint }) => natureOfComplaint === code)) {
const selected = from(codes).first(({ natureOfComplaint }) => natureOfComplaint === code);

return selected.longDescription;
}

return ""
}
return "";
};

export const pad = (num: string, size: number): string => {
num = num.toString();
while (num.length < size) num = "0" + num;
return num;
};
Loading

0 comments on commit a7eab9c

Please sign in to comment.