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: Return long descriptions in decision section to support CEEB exports #99

Merged
merged 2 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
15 changes: 4 additions & 11 deletions backend/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,14 @@ model agency_code {
agency_code String @id(map: "PK_agency_code") @db.VarChar(10)
short_description String? @db.VarChar(50)
long_description String? @db.VarChar(250)
display_order Int?
active_ind Boolean?
create_user_id String @db.VarChar(32)
create_utc_timestamp DateTime @db.Timestamp(6)
update_user_id String? @db.VarChar(32)
update_utc_timestamp DateTime? @db.Timestamp(6)
display_order Int?
case_file case_file[]
decision decision[]
inaction_reason_code_inaction_reason_code_agency_codeToagency_code inaction_reason_code[] @relation("inaction_reason_code_agency_codeToagency_code")
}

Expand Down Expand Up @@ -466,7 +467,7 @@ model decision {
case_file_guid String @db.Uuid
schedule_sector_xref_guid String @db.Uuid
discharge_code String @db.VarChar(10)
rationale_text String? @db.VarChar(10)
rationale_text String? @db.VarChar(4000)
inspection_number Int?
lead_agency_code String? @db.VarChar(10)
non_compliance_decision_matrix_code String? @db.VarChar(10)
Expand All @@ -478,6 +479,7 @@ model decision {
action action[]
case_file case_file @relation(fields: [case_file_guid], references: [case_file_guid], onDelete: NoAction, onUpdate: NoAction, map: "fk_decision__case_file_guid")
discharge_code_decision_discharge_codeTodischarge_code discharge_code @relation("decision_discharge_codeTodischarge_code", fields: [discharge_code], references: [discharge_code], onDelete: NoAction, onUpdate: NoAction, map: "fk_decision__discharge_code")
agency_code agency_code? @relation(fields: [lead_agency_code], references: [agency_code], onDelete: NoAction, onUpdate: NoAction, map: "fk_decision__lead_agency_code")
non_compliance_decision_matrix_code_decision_non_compliance_decision_matrix_codeTonon_compliance_decision_matrix_code non_compliance_decision_matrix_code? @relation("decision_non_compliance_decision_matrix_codeTonon_compliance_decision_matrix_code", fields: [non_compliance_decision_matrix_code], references: [non_compliance_decision_matrix_code], onDelete: NoAction, onUpdate: NoAction, map: "fk_decision__ncdm_code")
schedule_sector_xref schedule_sector_xref @relation(fields: [schedule_sector_xref_guid], references: [schedule_sector_xref_guid], onDelete: NoAction, onUpdate: NoAction, map: "fk_decision__schedule_sector_xref_guid")
}
Expand Down Expand Up @@ -604,12 +606,3 @@ model site_h {
operation_executed_at DateTime @default(now()) @db.Timestamp(6)
data_after_executed_operation Json?
}

/// This table contains check constraints and requires additional setup for migrations. Visit https://pris.ly/d/check-constraints for more info.
model spatial_ref_sys {
srid Int @id
auth_name String? @db.VarChar(256)
auth_srid Int?
srtext String? @db.VarChar(2048)
proj4text String? @db.VarChar(2048)
}
65 changes: 54 additions & 11 deletions backend/src/case_file/case_file.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,15 +302,41 @@ export class CaseFileService {
},
select: {
decision_guid: true,
discharge_code: true,
discharge_code_decision_discharge_codeTodischarge_code: {
select: {
discharge_code: true,
long_description: true,
},
},
rationale_text: true,
inspection_number: true,
lead_agency_code: true,
non_compliance_decision_matrix_code: true,
agency_code: {
select: {
agency_code: true,
long_description: true,
},
},
non_compliance_decision_matrix_code_decision_non_compliance_decision_matrix_codeTonon_compliance_decision_matrix_code:
{
select: {
non_compliance_decision_matrix_code: true,
long_description: true,
},
},
schedule_sector_xref: {
select: {
schedule_code: true,
sector_code: true,
schedule_code_schedule_sector_xref_schedule_codeToschedule_code: {
select: {
schedule_code: true,
long_description: true,
},
},
sector_code_schedule_sector_xref_sector_codeTosector_code: {
select: {
sector_code: true,
long_description: true,
},
},
},
},
},
Expand Down Expand Up @@ -408,21 +434,38 @@ export class CaseFileService {

let record: Decision = {
id: decision[0].decision_guid,
schedule: decision[0].schedule_sector_xref.schedule_code,
sector: decision[0].schedule_sector_xref.sector_code,
discharge: decision[0].discharge_code,
nonCompliance: decision[0]?.non_compliance_decision_matrix_code,
schedule:
decision[0].schedule_sector_xref.schedule_code_schedule_sector_xref_schedule_codeToschedule_code
.schedule_code,
scheduleLongDescription:
decision[0].schedule_sector_xref.schedule_code_schedule_sector_xref_schedule_codeToschedule_code
.long_description,
sector: decision[0].schedule_sector_xref.sector_code_schedule_sector_xref_sector_codeTosector_code.sector_code,
sectorLongDescription:
decision[0].schedule_sector_xref.sector_code_schedule_sector_xref_sector_codeTosector_code.long_description,
discharge: decision[0].discharge_code_decision_discharge_codeTodischarge_code.discharge_code,
dischargeLongDescription: decision[0].discharge_code_decision_discharge_codeTodischarge_code.long_description,
nonCompliance:
decision[0]
?.non_compliance_decision_matrix_code_decision_non_compliance_decision_matrix_codeTonon_compliance_decision_matrix_code
?.non_compliance_decision_matrix_code,
nonComplianceLongDescription:
decision[0]
?.non_compliance_decision_matrix_code_decision_non_compliance_decision_matrix_codeTonon_compliance_decision_matrix_code
?.long_description,
rationale: decision[0]?.rationale_text,
assignedTo: action[0]?.actor,
actionTaken: action[0]?.actionCode,
actionTakenLongDescription: action[0]?.longDescription,
actionTakenDate: action[0]?.date,
};

if (decision[0].inspection_number) {
record = { ...record, inspectionNumber: decision[0].inspection_number.toString() };
}
if (decision[0].lead_agency_code) {
record = { ...record, leadAgency: decision[0].lead_agency_code };
if (decision[0].agency_code) {
record = { ...record, leadAgency: decision[0].agency_code.agency_code };
record = { ...record, leadAgencyLongDescription: decision[0].agency_code.long_description };
}

caseFile.decision = record;
Expand Down
6 changes: 6 additions & 0 deletions backend/src/case_file/case_file_types.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,20 @@ type Drug {
type Decision {
id: String
schedule: String
scheduleLongDescription: String
sector: String
sectorLongDescription: String
discharge: String
dischargeLongDescription: String
nonCompliance: String
nonComplianceLongDescription: String
rationale: String
inspectionNumber: String
leadAgency: String
leadAgencyLongDescription: String
assignedTo: String
actionTaken: String
actionTakenLongDescription: String
actionTakenDate: Date
}

Expand Down
6 changes: 6 additions & 0 deletions backend/src/case_file/entities/decision-entity.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
export interface Decision {
id?: string;
schedule: string;
scheduleLongDescription?: string;
sector: string;
sectorLongDescription?: string;
discharge: string;
dischargeLongDescription?: string;
nonCompliance?: string;
nonComplianceLongDescription?: string;
rationale?: string;
inspectionNumber?: string;
leadAgency?: string;
leadAgencyLongDescription?: string;
assignedTo?: string;
actionTaken?: string;
actionTakenLongDescription?: string;
actionTakenDate?: Date;
}
Loading