Skip to content

Commit

Permalink
feat: CE-936 Add privacy indication field to complaint (#647)
Browse files Browse the repository at this point in the history
Co-authored-by: dmitri-korin-bcps <[email protected]>
Co-authored-by: Barrett Falk <[email protected]>
Co-authored-by: gregorylavery <[email protected]>
Co-authored-by: Scarlett <[email protected]>
Co-authored-by: Mike Sears <[email protected]>
Co-authored-by: jeznorth <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: afwilcox <[email protected]>
Co-authored-by: Scarlett <[email protected]>
  • Loading branch information
10 people authored Sep 24, 2024
1 parent f93511d commit c05bd2d
Show file tree
Hide file tree
Showing 20 changed files with 2,977 additions and 777 deletions.
16 changes: 16 additions & 0 deletions backend/src/middleware/maps/automapper-dto-to-entity-maps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ export const mapComplaintDtoToComplaint = (mapper: Mapper) => {
return null; // This will be handled in the service
}),
),
forMember(
(dest) => dest.is_privacy_requested,
mapFrom((src) => src.isPrivacyRequested),
),
);
};

Expand Down Expand Up @@ -333,6 +337,10 @@ export const mapWildlifeComplaintDtoToHwcrComplaint = (mapper: Mapper) => {
return record;
}),
),
forMember(
(dest) => dest.complaint_identifier.is_privacy_requested,
mapFrom((src) => src.isPrivacyRequested),
),
);
};

Expand Down Expand Up @@ -490,6 +498,10 @@ export const mapAllegationComplaintDtoToAllegationComplaint = (mapper: Mapper) =
(dest) => dest.suspect_witnesss_dtl_text,
mapFrom((src) => src.violationDetails),
),
forMember(
(dest) => dest.complaint_identifier.is_privacy_requested,
mapFrom((src) => src.isPrivacyRequested),
),
);
};

Expand Down Expand Up @@ -593,6 +605,10 @@ export const mapGirComplaintDtoToGirComplaint = (mapper: Mapper) => {
(dest) => dest.gir_complaint_guid,
mapFrom((src) => src.girId),
),
forMember(
(dest) => dest.complaint_identifier.is_privacy_requested,
mapFrom((src) => src.isPrivacyRequested),
),
);
};

Expand Down
28 changes: 28 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 @@ -256,6 +256,10 @@ export const complaintToComplaintDtoMap = (mapper: Mapper) => {
return null;
}),
),
forMember(
(destination) => destination.isPrivacyRequested,
mapFrom((source) => source.is_privacy_requested),
),
);
};

Expand Down Expand Up @@ -702,6 +706,10 @@ export const applyWildlifeComplaintMap = (mapper: Mapper) => {
return null;
}),
),
forMember(
(destination) => destination.isPrivacyRequested,
mapFrom((source) => source.complaint_identifier.is_privacy_requested),
),
);
};

Expand Down Expand Up @@ -921,6 +929,10 @@ export const applyAllegationComplaintMap = (mapper: Mapper) => {
return null;
}),
),
forMember(
(destination) => destination.isPrivacyRequested,
mapFrom((source) => source.complaint_identifier.is_privacy_requested),
),
);
};
export const applyGeneralInfomationComplaintMap = (mapper: Mapper) => {
Expand Down Expand Up @@ -1120,6 +1132,10 @@ export const applyGeneralInfomationComplaintMap = (mapper: Mapper) => {
return complaint_method_received_code?.complaint_method_received_code || null;
}),
),
forMember(
(destination) => destination.isPrivacyRequested,
mapFrom((source) => source.complaint_identifier.is_privacy_requested),
),
);
};

Expand Down Expand Up @@ -1667,6 +1683,18 @@ export const mapAllegationReport = (mapper: Mapper, tz: string = "America/Vancou
return "";
}),
),
forMember(
(destination) => destination.privacyRequested,
mapFrom((source) => {
if (source.complaint_identifier.is_privacy_requested === "Y") {
return "Yes";
} else if (source.complaint_identifier.is_privacy_requested === "N") {
return "No";
} else {
return null;
}
}),
),

//--
forMember(
Expand Down
6 changes: 6 additions & 0 deletions backend/src/middleware/maps/dto-to-table-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ export const mapComplaintDtoToComplaintTable = (mapper: Mapper) => {
};
}),
),
forMember(
(dest) => dest.is_privacy_requested,
mapFrom((src) => {
return src.isPrivacyRequested;
}),
),
);
};

Expand Down
1 change: 1 addition & 0 deletions backend/src/types/models/complaints/complaint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ export interface ComplaintDto {
delegates: Array<DelegateDto>;
webeocId: string;
complaintMethodReceivedCode: string;
isPrivacyRequested: string;
}
7 changes: 7 additions & 0 deletions backend/src/types/models/complaints/update-complaint.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,11 @@ export class UpdateComplaintDto {
description: "Method in which the complaint was created",
})
comp_mthd_recv_cd_agcy_cd_xref: CompMthdRecvCdAgcyCdXref;

@ApiProperty({
example: "true",
description:
"flag to represent that the caller has asked for special care when handling their personal information",
})
is_privacy_requested: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface ComplaintReportData {
complaintMethodReceivedCode: string;

//-- caller information
privacyRequested: string;
name: string;
phone1: string;
phone2: string;
Expand Down
5 changes: 5 additions & 0 deletions backend/src/v1/complaint/complaint.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1563,6 +1563,11 @@ export class ComplaintService {
"AllegationReportData",
);

//-- this is a bit of a hack to hide and show the privacy requested row
if (data.privacyRequested) {
data = { ...data, privacy: [{ value: data.privacyRequested }] };
}

break;
}
}
Expand Down
14 changes: 10 additions & 4 deletions backend/src/v1/complaint/entities/complaint.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,6 @@ export class Complaint {
})
location_geometry_point: Point;

/*
@Column()
location_geometry_point: string;
*/
@ApiProperty({
example: "Near Golden",
description: "The summary text for the location of the complaint",
Expand Down Expand Up @@ -205,6 +201,14 @@ export class Complaint {
@Column()
update_utc_timestamp: Date;

@ApiProperty({
example: "true",
description:
"flag to represent that the caller has asked for special care when handling their personal information",
})
@Column()
is_privacy_requested: string;

constructor(
detail_text?: string,
caller_name?: string,
Expand Down Expand Up @@ -232,6 +236,7 @@ export class Complaint {
person_complaint_xref?: PersonComplaintXref[],
webeoc_identifier?: string,
comp_mthd_recv_cd_agcy_cd_xref?: CompMthdRecvCdAgcyCdXref,
is_privacy_requested?: string,
) {
this.detail_text = detail_text;
this.caller_name = caller_name;
Expand Down Expand Up @@ -259,5 +264,6 @@ export class Complaint {
this.person_complaint_xref = person_complaint_xref;
this.webeoc_identifier = webeoc_identifier;
this.comp_mthd_recv_cd_agcy_cd_xref = comp_mthd_recv_cd_agcy_cd_xref;
this.is_privacy_requested = is_privacy_requested;
}
}
Binary file modified backend/templates/complaint/CDOGS-ERS-COMPLAINT-TEMPLATE-v1.docx
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,33 @@ import { useAppSelector } from "../../../../hooks/hooks";
import { selectComplaintCallerInformation } from "../../../../store/reducers/complaints";
import { formatPhoneNumber } from "react-phone-number-input/input";
import { Card } from "react-bootstrap";
import { FEATURE_TYPES } from "../../../../constants/feature-flag-types";
import { isFeatureActive } from "../../../../store/reducers/app";

export const CallerInformation: FC = () => {
const { name, primaryPhone, secondaryPhone, alternatePhone, address, email, reportedByCode } = useAppSelector(
selectComplaintCallerInformation,
);
const { name, primaryPhone, secondaryPhone, alternatePhone, address, email, reportedByCode, isPrivacyRequested } =
useAppSelector(selectComplaintCallerInformation);
const enablePrivacyFeature = useAppSelector(isFeatureActive(FEATURE_TYPES.PRIV_REQ));

let privacy = "";
if (isPrivacyRequested === "Y") {
privacy = "Yes";
} else if (isPrivacyRequested === "N") {
privacy = "No";
}

return (
<section className="comp-details-section">
<h3>Caller Information</h3>
<Card>
<Card.Body>
<dl>
{enablePrivacyFeature && (
<div>
<dt>Privacy requested</dt>
<dd id="comp-details-name">{privacy}</dd>
</div>
)}
<div>
<dt>Name</dt>
<dd id="comp-details-name">{name}</dd>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { ValidationInput } from "../../../../common/validation-input";
import Option from "../../../../types/app/option";
import { Coordinates } from "../../../../types/app/coordinate-type";
import { useAppDispatch, useAppSelector } from "../../../../hooks/hooks";
import { openModal, selectActiveTab, userId } from "../../../../store/reducers/app";
import { openModal, selectActiveTab, userId, isFeatureActive } from "../../../../store/reducers/app";
import notificationInvalid from "../../../../../assets/images/notification-invalid.png";

import {
Expand All @@ -22,6 +22,7 @@ import {
selectComplaintReceivedMethodDropdown,
selectCreatableComplaintTypeDropdown,
selectHwcrNatureOfComplaintCodeDropdown,
selectPrivacyDropdown,
selectReportedByDropdown,
selectSpeciesCodeDropdown,
selectViolationCodeDropdown,
Expand Down Expand Up @@ -60,6 +61,7 @@ import AttachmentEnum from "../../../../constants/attachment-enum";
import { getUserAgency } from "../../../../service/user-service";
import { useSelector } from "react-redux";
import { ComplaintDetails } from "../../../../types/complaints/details/complaint-details";
import { FEATURE_TYPES } from "../../../../constants/feature-flag-types";

export const CreateComplaint: FC = () => {
const dispatch = useAppDispatch();
Expand Down Expand Up @@ -95,6 +97,9 @@ export const CreateComplaint: FC = () => {
{ value: "No", label: "No" },
];

const privacyDropdown = useAppSelector(selectPrivacyDropdown);
const enablePrivacyFeature = useAppSelector(isFeatureActive(FEATURE_TYPES.PRIV_REQ));

const currentDate = useMemo(() => new Date(), []);

const [complaintData, applyComplaintData] = useState<ComplaintAlias>();
Expand Down Expand Up @@ -170,6 +175,7 @@ export const CreateComplaint: FC = () => {
createdBy: userid,
updatedBy: userid,
complaintMethodReceivedCode: "",
isPrivacyRequested: "U",
};

applyComplaintData(model);
Expand Down Expand Up @@ -358,6 +364,14 @@ export const CreateComplaint: FC = () => {
}
};

const handlePrivacyRequestedChange = (selected: Option | null) => {
if (selected) {
const { value } = selected;
const complaint = { ...complaintData, isPrivacyRequested: value } as ComplaintDto;
applyComplaintData(complaint);
}
};

const handleLocationChange = (value: string) => {
const complaint = { ...complaintData, locationSummary: value?.trim() } as ComplaintDto;
applyComplaintData(complaint);
Expand Down Expand Up @@ -1026,6 +1040,30 @@ export const CreateComplaint: FC = () => {

<fieldset>
<legend>Caller Information</legend>
{enablePrivacyFeature && (
<div
className="comp-details-form-row"
id="privacy-requested-id"
>
<label
id="complaint-caller-info-privacy-label-id"
className="col-auto"
htmlFor="caller-privacy-id"
>
Privacy requested
</label>
<div className="comp-details-edit-input">
<Select
options={privacyDropdown}
placeholder="Select"
id="caller-privacy-id"
classNamePrefix="comp-select"
onChange={(e) => handlePrivacyRequestedChange(e)}
/>
</div>
</div>
)}

<div
className="comp-details-form-row"
id="name-pair-id"
Expand Down
Loading

0 comments on commit c05bd2d

Please sign in to comment.