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

feature/CE-39 - Add animal outcome #271

Merged
merged 39 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
e994bd6
added new code-table types, hardcoded backend while graphql backend i…
marqueone-ps Jan 29, 2024
db8b497
fixed base-code-table path, updated code-table list of available code…
marqueone-ps Jan 29, 2024
09ece19
starting to put things together, input component created, basic valid…
marqueone-ps Jan 30, 2024
57b786a
animal tags added, add, remove update values
marqueone-ps Feb 1, 2024
62b210b
adding drugs to the animal outcome
marqueone-ps Feb 1, 2024
e54981f
clean up, removed incorectly placed officer for drugs
marqueone-ps Feb 2, 2024
de6d65e
clean up, adding default values
marqueone-ps Feb 2, 2024
c2214dd
finally got a simple hover state for tag and animal removal working
marqueone-ps Feb 6, 2024
cc23229
adding outcome result item
marqueone-ps Feb 7, 2024
20dd9cf
Merge branch 'main' into feature/CE-39
marqueone-ps Feb 8, 2024
c3426f4
component wired up
marqueone-ps Feb 8, 2024
49e5593
clenaing up styles
marqueone-ps Feb 8, 2024
3874a78
fixed add drug and ear tag buttons
marqueone-ps Feb 8, 2024
e9a65cf
added missing outcome
marqueone-ps Feb 8, 2024
ea8fbf8
code smell cleanup
marqueone-ps Feb 8, 2024
59ab3ee
code smell
marqueone-ps Feb 8, 2024
3b47000
added custom icon button, code smell
marqueone-ps Feb 9, 2024
2a2a839
code smell
marqueone-ps Feb 9, 2024
6d0a21e
code smell cleanup
marqueone-ps Feb 9, 2024
288cd3f
Merge branch 'main' into feature/CE-39
marqueone-ps Feb 9, 2024
682d734
reverted package.json and package-lock.json
marqueone-ps Feb 9, 2024
fc635bd
updated prop name
marqueone-ps Feb 9, 2024
9a91e0f
Merge branch 'main' into feature/CE-39
marqueone-ps Feb 9, 2024
cae1ced
updated incorrect labels, updated component to show existing animals …
marqueone-ps Feb 9, 2024
feda08d
updated component to restrict number of ear tags to max of two
marqueone-ps Feb 9, 2024
cfe9266
updated Officer labels
marqueone-ps Feb 9, 2024
410de33
updated eart tag number value, can use any characters, limited to 4 c…
marqueone-ps Feb 9, 2024
01c4673
update to drug labels
marqueone-ps Feb 9, 2024
e377f32
updated drug input item spacing
marqueone-ps Feb 9, 2024
864e47a
updated drug authorization behaviour to correct problem selecting an …
marqueone-ps Feb 9, 2024
72b7659
updated inputs to fix probelm preventing users from removing first ch…
marqueone-ps Feb 9, 2024
99eaa32
updates to animal outcome via feedback
marqueone-ps Feb 12, 2024
e588a2f
updated labels, and spacing in drug item
marqueone-ps Feb 12, 2024
504aed7
creating edit component
marqueone-ps Feb 13, 2024
127e4a0
enabled editing of animal outcomes
marqueone-ps Feb 13, 2024
9820960
code smell
marqueone-ps Feb 13, 2024
9c54091
code smell
marqueone-ps Feb 13, 2024
0e2cd9a
code smell
marqueone-ps Feb 13, 2024
d433764
Merge branch 'main' into feature/CE-39
marqueone-ps Feb 13, 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
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
Loading