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

feat: CE-1398 Call cetner actions taken to exports #919

Merged
merged 7 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
37 changes: 36 additions & 1 deletion backend/src/v1/complaint/complaint.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ import { SpeciesCode } from "../species_code/entities/species_code.entity";
import { LinkedComplaintXrefService } from "../linked_complaint_xref/linked_complaint_xref.service";
import { Attachment, AttachmentType } from "../../types/models/general/attachment";
import { getFileType } from "../../common/methods";
import { ActionTaken } from "../complaint/entities/action_taken.entity";

const WorldBounds: Array<number> = [-180, -90, 180, 90];
type complaintAlias = HwcrComplaint | AllegationComplaint | GirComplaint;
@Injectable({ scope: Scope.REQUEST })
Expand All @@ -93,6 +95,8 @@ export class ComplaintService {
private readonly _girComplaintRepository: Repository<GirComplaint>;
@InjectRepository(ComplaintUpdate)
private readonly _complaintUpdateRepository: Repository<ComplaintUpdate>;
@InjectRepository(ActionTaken)
private _actionTakenRepository: Repository<ActionTaken>;
afwilcox marked this conversation as resolved.
Show resolved Hide resolved
@InjectRepository(Officer)
private readonly _officertRepository: Repository<Officer>;
@InjectRepository(Office)
Expand Down Expand Up @@ -1805,9 +1809,37 @@ export class ComplaintService {
return updates;
};

const _getActions = async (id: string) => {
const result = await this._actionTakenRepository.find({
where: {
complaintIdentifier: {
complaint_identifier: id,
},
},
order: {
actionUtcTimestamp: "DESC",
},
});

const actions = result?.map((item) => {
const utcDate = toDate(item.actionUtcTimestamp, { timeZone: "UTC" });
const zonedDate = toZonedTime(utcDate, tz);
let updatedOn = format(zonedDate, "yyyy-MM-dd", { timeZone: tz });
let updatedAt = format(zonedDate, "HH:mm", { timeZone: tz });
let record = {
actionDetailsTxt: item.actionDetailsTxt,
loggedByTxt: item.loggedByTxt,
actionLogged: `${updatedOn} ${updatedAt}`,
};
return record;
});

return actions;
};

const _applyTimezone = (input: Date, tz: string, output: "date" | "time" | "datetime"): string => {
if (!input) {
return "N/A"; // No date, so just return a placeholder string for the report
return "N/A"; // No date, so just return a placeholder string for the report
}

const utcDate = toDate(input, { timeZone: "UTC" });
Expand Down Expand Up @@ -2197,6 +2229,9 @@ export class ComplaintService {
//-- get any updates a complaint may have
data.updates = await _getUpdates(id);

// -- get any webeoc callce tner actions on the complaint
data.actions = await _getActions(id);

//-- find the linked complaints
data.linkedComplaints = data.linkedComplaintIdentifier
? await this._linkedComplaintsXrefService.findParentComplaint(id) //if there is a linkedComplaintIdentifer it's parent
Expand Down
Binary file not shown.
Binary file modified backend/templates/complaint/CDOGS-ERS-COMPLAINT-TEMPLATE-v1.docx
Binary file not shown.
Binary file not shown.
Loading
Loading