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-1126 HWCR assessment changes #100

Merged
merged 8 commits into from
Nov 14, 2024
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
103 changes: 63 additions & 40 deletions backend/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ model age_code {
}

model conflict_history_code {
conflict_history_code String @id(map: "PK_cnfthistcd") @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)
wildlife_wildlife_conflict_history_codeToconflict_history_code wildlife[] @relation("wildlife_conflict_history_codeToconflict_history_code")
conflict_history_code String @id(map: "PK_cnfthistcd") @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)
case_file case_file[]
}

model drug_code {
Expand Down Expand Up @@ -142,16 +142,17 @@ model equipment_code {
}

model threat_level_code {
threat_level_code String @id(map: "PK_thrtlvlcd") @db.VarChar(10)
short_description String @db.VarChar(50)
long_description String? @db.VarChar(250)
threat_level_code String @id(map: "PK_thrtlvlcd") @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)
wildlife_wildlife_threat_level_codeTothreat_level_code wildlife[] @relation("wildlife_threat_level_codeTothreat_level_code")
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)
wildlife_wildlife_threat_level_codeTothreat_level_code wildlife[] @relation("wildlife_threat_level_codeTothreat_level_code")
case_file case_file[]
}

model configuration {
Expand Down Expand Up @@ -279,6 +280,11 @@ model case_file {
action_not_required_ind Boolean?
note_text String?
review_required_ind Boolean?
complainant_contacted_ind Boolean?
attended_ind Boolean?
case_location_code String? @db.VarChar(10)
case_conflict_history_code String? @db.VarChar(10)
case_threat_level_code String? @db.VarChar(10)
create_user_id String @db.VarChar(32)
create_utc_timestamp DateTime @db.Timestamp(6)
update_user_id String? @db.VarChar(32)
Expand All @@ -292,6 +298,9 @@ model case_file {
lead lead[]
site site[]
wildlife wildlife[]
case_file__case_location_code case_location_code? @relation(fields: [case_location_code], references: [case_location_code], map: "FK_case_file__case_location_code")
case_file__conflict_history_code conflict_history_code? @relation(fields: [case_conflict_history_code], references: [conflict_history_code], map: "FK_case_file__case_conflict_history_code")
case_file__threat_level_code threat_level_code? @relation(fields: [case_threat_level_code], references: [threat_level_code], map: "FK_case_file__case_threat_level_code")
}

/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
Expand Down Expand Up @@ -427,28 +436,29 @@ model ear_tag_h {

/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
model wildlife {
wildlife_guid String @id(map: "PK_wildlife_guid") @default(dbgenerated("uuid_generate_v4()")) @db.Uuid
case_file_guid String @db.Uuid
threat_level_code String? @db.VarChar(10)
conflict_history_code String? @db.VarChar(10)
sex_code String? @db.VarChar(10)
age_code String? @db.VarChar(10)
hwcr_outcome_code String? @db.VarChar(10)
species_code String @db.VarChar(10)
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)
active_ind Boolean?
action action[]
drug_administered drug_administered[]
ear_tag ear_tag[]
age_code_wildlife_age_codeToage_code age_code? @relation("wildlife_age_codeToage_code", fields: [age_code], references: [age_code], onDelete: NoAction, onUpdate: NoAction, map: "fk_wildlife__age_code")
case_file case_file @relation(fields: [case_file_guid], references: [case_file_guid], onDelete: NoAction, onUpdate: NoAction, map: "fk_wildlife__case_file_guid")
conflict_history_code_wildlife_conflict_history_codeToconflict_history_code conflict_history_code? @relation("wildlife_conflict_history_codeToconflict_history_code", fields: [conflict_history_code], references: [conflict_history_code], onDelete: NoAction, onUpdate: NoAction, map: "fk_wildlife__conflict_history_code")
hwcr_outcome_code_wildlife_hwcr_outcome_codeTohwcr_outcome_code hwcr_outcome_code? @relation("wildlife_hwcr_outcome_codeTohwcr_outcome_code", fields: [hwcr_outcome_code], references: [hwcr_outcome_code], onDelete: NoAction, onUpdate: NoAction, map: "fk_wildlife__hwcr_outcome_code")
sex_code_wildlife_sex_codeTosex_code sex_code? @relation("wildlife_sex_codeTosex_code", fields: [sex_code], references: [sex_code], onDelete: NoAction, onUpdate: NoAction, map: "fk_wildlife__sex_code")
threat_level_code_wildlife_threat_level_codeTothreat_level_code threat_level_code? @relation("wildlife_threat_level_codeTothreat_level_code", fields: [threat_level_code], references: [threat_level_code], onDelete: NoAction, onUpdate: NoAction, map: "fk_wildlife__threat_level_code")
wildlife_guid String @id(map: "PK_wildlife_guid") @default(dbgenerated("uuid_generate_v4()")) @db.Uuid
case_file_guid String @db.Uuid
threat_level_code String? @db.VarChar(10)
conflict_history_code String? @db.VarChar(10)
sex_code String? @db.VarChar(10)
age_code String? @db.VarChar(10)
hwcr_outcome_code String? @db.VarChar(10)
species_code String @db.VarChar(10)
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)
active_ind Boolean?
identifying_features String? @db.VarChar(4000)
action action[]
drug_administered drug_administered[]
ear_tag ear_tag[]
age_code_wildlife_age_codeToage_code age_code? @relation("wildlife_age_codeToage_code", fields: [age_code], references: [age_code], onDelete: NoAction, onUpdate: NoAction, map: "fk_wildlife__age_code")
case_file case_file @relation(fields: [case_file_guid], references: [case_file_guid], onDelete: NoAction, onUpdate: NoAction, map: "fk_wildlife__case_file_guid")

hwcr_outcome_code_wildlife_hwcr_outcome_codeTohwcr_outcome_code hwcr_outcome_code? @relation("wildlife_hwcr_outcome_codeTohwcr_outcome_code", fields: [hwcr_outcome_code], references: [hwcr_outcome_code], onDelete: NoAction, onUpdate: NoAction, map: "fk_wildlife__hwcr_outcome_code")
sex_code_wildlife_sex_codeTosex_code sex_code? @relation("wildlife_sex_codeTosex_code", fields: [sex_code], references: [sex_code], onDelete: NoAction, onUpdate: NoAction, map: "fk_wildlife__sex_code")
threat_level_code_wildlife_threat_level_codeTothreat_level_code threat_level_code? @relation("wildlife_threat_level_codeTothreat_level_code", fields: [threat_level_code], references: [threat_level_code], onDelete: NoAction, onUpdate: NoAction, map: "fk_wildlife__threat_level_code")
}

/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
Expand Down Expand Up @@ -606,3 +616,16 @@ model site_h {
operation_executed_at DateTime @default(now()) @db.Timestamp(6)
data_after_executed_operation Json?
}

model case_location_code {
case_location_code String @id(map: "PK_case_location_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)
case_file case_file[]
}
1 change: 1 addition & 0 deletions backend/src/action_code/action_code.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class ActionCodeService {
queryResult = await xrefDataContext.findMany({
where: {
action_type_code: actionTypeCode,
active_ind: true,
},
select: {
action_code: true,
Expand Down
2 changes: 2 additions & 0 deletions backend/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { CEEBDecisionActionModule } from "./ceeb_decision_action/ceeb_decision_a
import { AgencyCodeModule } from "./agency_code/agency_code.module";
import { ScheduleSectorXrefModule } from "./schedule_sector_xref/schedule_sector_xref.module";
import { LeadModule } from "./lead/lead.module";
import { CaseLocationCodeModule } from "./code-tables/case_location_code/case_location_code.module";

@Module({
imports: [
Expand Down Expand Up @@ -65,6 +66,7 @@ import { LeadModule } from "./lead/lead.module";
CEEBDecisionActionModule,
ScheduleSectorXrefModule,
LeadModule,
CaseLocationCodeModule,
],
controllers: [AppController],
providers: [AppService, DateScalar],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
type CaseLocationCode {
caseLocationCode: String
shortDescription: String
longDescription: String
displayOrder: Int
activeIndicator: Boolean
}

type Query {
caseLocationCodes: [CaseLocationCode]!
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Module } from "@nestjs/common";
import { PrismaModule } from "nestjs-prisma";
import { CaseLocationCodeService } from "./case_location_code.service";
import { CaseLocationCodeResolver } from "./case_location_code.resolver";

@Module({
imports: [PrismaModule],
providers: [CaseLocationCodeResolver, CaseLocationCodeService],
})
export class CaseLocationCodeModule {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Resolver, Query } from "@nestjs/graphql";
import { UseGuards } from "@nestjs/common";
import { JwtRoleGuard } from "src/auth/jwtrole.guard";
import { Roles } from "src/auth/decorators/roles.decorator";
import { Role } from "src/enum/role.enum";
import { CaseLocationCodeService } from "./case_location_code.service";

@UseGuards(JwtRoleGuard)
@Resolver("CaseLocationCode")
export class CaseLocationCodeResolver {
constructor(private readonly service: CaseLocationCodeService) {}

@Query("caseLocationCodes")
@Roles(Role.COS_OFFICER, Role.CEEB)
findAll() {
return this.service.findAll();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Injectable } from "@nestjs/common";
import { PrismaService } from "nestjs-prisma";
import { CaseLocationCode } from "./entities/case_location_code.entity";

@Injectable()
export class CaseLocationCodeService {
constructor(private prisma: PrismaService) {}

findAll = async (): Promise<Array<CaseLocationCode>> => {
const codes = await this.prisma.case_location_code.findMany({
where: {
active_ind: true,
},
select: {
case_location_code: true,
short_description: true,
long_description: true,
display_order: true,
active_ind: true,
},
orderBy: [{ display_order: "asc" }],
});

return codes.map(({ case_location_code, short_description, long_description, display_order, active_ind }) => ({
caseLocationCode: case_location_code,
shortDescription: short_description,
longDescription: long_description,
displayOrder: display_order,
activeIndicator: active_ind,
}));
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export class CaseLocationCode {
caseLocationCode: string;
shortDescription: string;
longDescription: string;
displayOrder: number;
activeIndicator: boolean;
}
1 change: 1 addition & 0 deletions backend/src/common/action_type_codes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export const ACTION_TYPE_CODES = {
CASEACTION: "CASEACTION",
WILDLIFE: "WILDLIFE",
CEEBACTION: "CEEBACTION",
CAT1ASSESS: "CAT1ASSESS",
};
afwilcox marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
type Query {
HWCRAssessmentActions: [CaseFileAction]!
HWCRAssessmentCat1Actions: [CaseFileAction]!
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,10 @@ export class HWCRAssessmentActionResolver {
find() {
return this.actionCodeService.findAllCodesByType(ACTION_TYPE_CODES.COMPASSESS);
}

@Query("HWCRAssessmentCat1Actions")
@Roles(Role.COS_OFFICER, Role.CEEB)
findCat1Actions() {
return this.actionCodeService.findAllCodesByType(ACTION_TYPE_CODES.CAT1ASSESS);
}
}
Loading
Loading