Skip to content

Commit

Permalink
feat: add linked complaint to export (#792)
Browse files Browse the repository at this point in the history
  • Loading branch information
afwilcox authored Dec 5, 2024
1 parent 8334274 commit 3cee106
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions backend/src/v1/case_file/case_file.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ import { CssService } from "../../external_api/css/css.service";
import { ConfigurationService } from "../configuration/configuration.service";
import { Configuration } from "../configuration/entities/configuration.entity";
import { Person } from "../person/entities/person.entity";
import { LinkedComplaintXrefService } from "../linked_complaint_xref/linked_complaint_xref.service";

describe("Testing: Case File Service", () => {
let service: CaseFileService;
Expand Down Expand Up @@ -212,6 +213,7 @@ describe("Testing: Case File Service", () => {
ComplaintService,
CodeTableService,
OfficerService,
LinkedComplaintXrefService,
OfficeService,
CssService,
ConfigurationService,
Expand Down
12 changes: 12 additions & 0 deletions backend/src/v1/complaint/complaint.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ import { CssService } from "../../external_api/css/css.service";
import { ConfigurationService } from "../configuration/configuration.service";
import { Person } from "../person/entities/person.entity";
import { Configuration } from "../configuration/entities/configuration.entity";
import { LinkedComplaintXrefService } from "../linked_complaint_xref/linked_complaint_xref.service";
import { LinkedComplaintXref } from "../linked_complaint_xref/entities/linked_complaint_xref.entity";

describe("Testing: Complaint Service", () => {
let service: ComplaintService;
Expand Down Expand Up @@ -108,10 +110,15 @@ describe("Testing: Complaint Service", () => {
provide: getRepositoryToken(Person),
useValue: {},
},
{
provide: getRepositoryToken(LinkedComplaintXref),
useValue: {},
},
ComplaintUpdatesService,
ComplaintService,
PersonComplaintXrefService,
OfficerService,
LinkedComplaintXrefService,
OfficeService,
CssService,
ConfigurationService,
Expand Down Expand Up @@ -388,10 +395,15 @@ describe("Testing: Complaint Service", () => {
provide: getRepositoryToken(Person),
useValue: {},
},
{
provide: getRepositoryToken(LinkedComplaintXref),
useValue: {},
},
ComplaintUpdatesService,
ComplaintService,
PersonComplaintXrefService,
OfficerService,
LinkedComplaintXrefService,
OfficeService,
CssService,
ConfigurationService,
Expand Down
10 changes: 10 additions & 0 deletions backend/src/v1/complaint/complaint.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ import { RelatedDataDto } from "src/types/models/complaints/related-data";
import { CompMthdRecvCdAgcyCdXrefService } from "../comp_mthd_recv_cd_agcy_cd_xref/comp_mthd_recv_cd_agcy_cd_xref.service";
import { OfficerService } from "../officer/officer.service";
import { SpeciesCode } from "../species_code/entities/species_code.entity";
import { LinkedComplaintXrefService } from "../linked_complaint_xref/linked_complaint_xref.service";

type complaintAlias = HwcrComplaint | AllegationComplaint | GirComplaint;
@Injectable({ scope: Scope.REQUEST })
Expand Down Expand Up @@ -104,6 +105,7 @@ export class ComplaintService {
private readonly _attractantService: AttractantHwcrXrefService,
private readonly _compMthdRecvCdAgcyCdXrefService: CompMthdRecvCdAgcyCdXrefService,
private readonly _officerService: OfficerService,
private readonly _linkedComplaintsXrefService: LinkedComplaintXrefService,
private dataSource: DataSource,
) {
this.mapper = mapper;
Expand Down Expand Up @@ -2015,6 +2017,14 @@ export class ComplaintService {
//-- get any updates a complaint may have
data.updates = await _getUpdates(id);

//-- find the linked complaints
data.linkedComplaints = data.linkedComplaintIdentifier
? await this._linkedComplaintsXrefService.findParentComplaint(id) //if there is a linkedComplaintIdentifer it's parent
: await this._linkedComplaintsXrefService.findChildComplaints(id); //otherwise there may or may not be children

//-- helper flag to easily hide/show linked complaint section
data.hasLinkedComplaints = data.linkedComplaints?.length > 0;

//-- this is a workaround to hide empty rows in the carbone templates
//-- It could possibly be removed if the CDOGS version of Carbone is updated
if (data.privacyRequested) {
Expand Down
7 changes: 7 additions & 0 deletions backend/src/v1/document/document.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ import { PersonService } from "../person/person.service";
import { OfficeService } from "../office/office.service";
import { CssService } from "../../external_api/css/css.service";
import { Person } from "../person/entities/person.entity";
import { LinkedComplaintXref } from "../linked_complaint_xref/entities/linked_complaint_xref.entity";
import { LinkedComplaintXrefService } from "../linked_complaint_xref/linked_complaint_xref.service";

describe("DocumentController", () => {
let controller: DocumentController;
Expand Down Expand Up @@ -200,11 +202,16 @@ describe("DocumentController", () => {
provide: getRepositoryToken(Person),
useValue: {},
},
{
provide: getRepositoryToken(LinkedComplaintXref),
useValue: {},
},
ComplaintUpdatesService,
ComplaintService,
CodeTableService,
PersonComplaintXrefService,
OfficerService,
LinkedComplaintXrefService,
OfficeService,
CssService,
PersonService,
Expand Down
7 changes: 7 additions & 0 deletions backend/src/v1/document/document.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ import { PersonService } from "../person/person.service";
import { OfficeService } from "../office/office.service";
import { CssService } from "../../external_api/css/css.service";
import { Person } from "../person/entities/person.entity";
import { LinkedComplaintXrefService } from "../linked_complaint_xref/linked_complaint_xref.service";
import { LinkedComplaintXref } from "../linked_complaint_xref/entities/linked_complaint_xref.entity";

describe("DocumentService", () => {
let service: DocumentService;
Expand Down Expand Up @@ -199,11 +201,16 @@ describe("DocumentService", () => {
provide: getRepositoryToken(Person),
useValue: {},
},
{
provide: getRepositoryToken(LinkedComplaintXref),
useValue: {},
},
ComplaintUpdatesService,
ComplaintService,
CodeTableService,
PersonComplaintXrefService,
OfficerService,
LinkedComplaintXrefService,
OfficeService,
CssService,
PersonService,
Expand Down
Binary file not shown.

0 comments on commit 3cee106

Please sign in to comment.