From 80e2b0e39c0ae90849c89fbcf85ed5b19b37c593 Mon Sep 17 00:00:00 2001 From: unakb Date: Tue, 24 Sep 2024 11:01:27 +0000 Subject: [PATCH] feat(j-s): New info and cleanup for law and order --- .../app/modules/case/internalCase.service.ts | 6 ++- .../src/app/modules/police/police.service.ts | 6 ++- .../app/modules/cases/models/case.response.ts | 24 +++++----- .../modules/cases/models/cases.response.ts | 15 ++++-- .../modules/cases/models/subpoena.response.ts | 48 +++++++++++++++++-- .../models/utils/translations.strings.ts | 9 ++++ 6 files changed, 84 insertions(+), 24 deletions(-) diff --git a/apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts b/apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts index da3e8ce066b8..4ef8b7b5a247 100644 --- a/apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts +++ b/apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts @@ -1246,7 +1246,11 @@ export class InternalCaseService { { model: Institution, as: 'court' }, { model: Institution, as: 'prosecutorsOffice' }, { model: User, as: 'judge' }, - { model: User, as: 'prosecutor' }, + { + model: User, + as: 'prosecutor', + include: [{ model: Institution, as: 'institution' }], + }, { model: DateLog, as: 'dateLogs' }, ], attributes: ['courtCaseNumber', 'id'], diff --git a/apps/judicial-system/backend/src/app/modules/police/police.service.ts b/apps/judicial-system/backend/src/app/modules/police/police.service.ts index ac21cd766a84..c4659a31c6de 100644 --- a/apps/judicial-system/backend/src/app/modules/police/police.service.ts +++ b/apps/judicial-system/backend/src/app/modules/police/police.service.ts @@ -21,6 +21,7 @@ import { XRoadMemberClass, } from '@island.is/shared/utils/server' +import { normalizeAndFormatNationalId } from '@island.is/judicial-system/formatters' import type { User } from '@island.is/judicial-system/types' import { CaseState, CaseType } from '@island.is/judicial-system/types' @@ -520,6 +521,9 @@ export class PoliceService { const { nationalId: defendantNationalId } = defendant const { name: actor } = user + const normalizedNationalId = + normalizeAndFormatNationalId(defendantNationalId)[0] + const documentName = `Fyrirkall í máli ${workingCase.courtCaseNumber}` const arraignmentInfo = dateLogs?.find( (dateLog) => dateLog.dateType === 'ARRAIGNMENT_DATE', @@ -541,7 +545,7 @@ export class PoliceService { documentBase64: subpoena, courtRegistrationDate: arraignmentInfo?.date, prosecutorSsn: prosecutor?.nationalId, - prosecutedSsn: defendantNationalId, + prosecutedSsn: normalizedNationalId, courtAddress: court?.address, courtRoomNumber: arraignmentInfo?.location || '', courtCeremony: 'Þingfesting', diff --git a/apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/case.response.ts b/apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/case.response.ts index e183aca31023..e9cabafd2afd 100644 --- a/apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/case.response.ts +++ b/apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/case.response.ts @@ -12,7 +12,7 @@ class IndictmentCaseData { caseNumber!: string @ApiProperty({ type: Boolean }) - acknowledged?: boolean + hasBeenServed?: boolean @ApiProperty({ type: [Groups] }) groups!: Groups[] @@ -26,22 +26,22 @@ export class CaseResponse { data!: IndictmentCaseData static fromInternalCaseResponse( - res: InternalCaseResponse, + internalCase: InternalCaseResponse, lang?: string, ): CaseResponse { const t = getTranslations(lang) - const defendant = res.defendants[0] - const subpoenaDateLog = res.dateLogs?.find( + const defendant = internalCase.defendants[0] + const subpoenaDateLog = internalCase.dateLogs?.find( (dateLog) => dateLog.dateType === DateType.ARRAIGNMENT_DATE, ) const subpoenaCreatedDate = subpoenaDateLog?.created.toString() ?? '' //TODO: Change to created from subpoena db entry? const subpoenas = defendant.subpoenas ?? [] return { - caseId: res.id, + caseId: internalCase.id, data: { - caseNumber: `${t.caseNumber} ${res.courtCaseNumber}`, - acknowledged: subpoenas.length > 0 ? subpoenas[0].acknowledged : false, + caseNumber: `${t.caseNumber} ${internalCase.courtCaseNumber}`, + hasBeenServed: subpoenas.length > 0 ? subpoenas[0].acknowledged : false, groups: [ { label: t.defendant, @@ -76,23 +76,23 @@ export class CaseResponse { }, { label: t.courtCaseNumber, - value: res.courtCaseNumber, + value: internalCase.courtCaseNumber, }, { label: t.court, - value: res.court.name, + value: internalCase.court.name, }, { label: t.judge, - value: res.judge.name, + value: internalCase.judge.name, }, { label: t.institution, - value: res.prosecutorsOffice.name, + value: internalCase.prosecutorsOffice.name, }, { label: t.prosecutor, - value: res.prosecutor.name, + value: internalCase.prosecutor.name, }, ], }, diff --git a/apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/cases.response.ts b/apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/cases.response.ts index b8465d6e2782..fc01fd9a5fae 100644 --- a/apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/cases.response.ts +++ b/apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/cases.response.ts @@ -5,6 +5,14 @@ import { isCompletedCase } from '@island.is/judicial-system/types' import { InternalCasesResponse } from './internal/internalCases.response' import { getTranslations } from './utils/translations.strings' +class StateTag { + @ApiProperty({ type: String }) + color!: string + + @ApiProperty({ type: String }) + label!: string +} + export class CasesResponse { @ApiProperty({ type: String }) id!: string @@ -15,11 +23,8 @@ export class CasesResponse { @ApiProperty({ type: String }) type!: string - @ApiProperty({ type: Object }) - state!: { - color: string - label: string - } + @ApiProperty({ type: StateTag }) + state!: StateTag static fromInternalCasesResponse( response: InternalCasesResponse[], diff --git a/apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.ts b/apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.ts index ffbacab59c49..7b309448135d 100644 --- a/apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.ts +++ b/apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.ts @@ -19,17 +19,34 @@ class DefenderInfo { @ApiProperty({ type: () => String }) defenderName?: string + + @ApiProperty({ type: () => Boolean }) + canEdit?: boolean + + @ApiProperty({ type: () => String }) + courtContactInfo?: string +} + +class AlertMessage { + @ApiProperty({ type: () => String }) + type!: string + + @ApiProperty({ type: () => String }) + message!: string } class SubpoenaData { @ApiProperty({ type: () => String }) title!: string - @ApiProperty({ type: Boolean }) - acknowledged?: boolean + @ApiProperty({ type: () => [AlertMessage] }) + alerts?: AlertMessage[] @ApiProperty({ type: () => [Groups] }) groups!: Groups[] + + @ApiProperty({ type: Boolean }) + acknowledged?: boolean } export class SubpoenaResponse { @@ -59,31 +76,48 @@ export class SubpoenaResponse { const waivedRight = defendantInfo?.defenderChoice === DefenderChoice.WAIVE const hasDefender = defendantInfo?.defenderName !== undefined + const subpoena = defendantInfo?.subpoenas ?? [] + const subpoenaAcknowledged = subpoena[0]?.acknowledged ?? false + const canChangeDefenseChoice = !waivedRight && !hasDefender const subpoenaDateLog = internalCase.dateLogs?.find( (dateLog) => dateLog.dateType === DateType.ARRAIGNMENT_DATE, ) const arraignmentDate = subpoenaDateLog?.date ?? '' const subpoenaCreatedDate = subpoenaDateLog?.created ?? '' //TODO: Change to subpoena created in RLS + const arraignmentLocation = `${internalCase.court.name}, Dómsalur ${subpoenaDateLog?.location}` return { caseId: internalCase.id, data: { title: t.subpoena, - acknowledged: false, // TODO: Connect to real data + acknowledged: subpoenaAcknowledged, + alerts: [ + ...(subpoenaAcknowledged + ? [ + { + type: 'success', + message: t.subpoenaServed, + }, + ] + : []), + ], groups: [ { label: `${t.caseNumber} ${internalCase.courtCaseNumber}`, items: [ [t.date, formatDate(subpoenaCreatedDate, 'PP')], - [t.institution, 'Lögreglustjórinn á höfuðborgarsvæðinu'], + [ + t.institution, + internalCase.prosecutor?.institution?.name ?? t.notAvailable, + ], [t.prosecutor, internalCase.prosecutor?.name], [t.accused, defendantInfo?.name], [ t.arraignmentDate, formatDate(arraignmentDate, "d.M.yyyy 'kl.' HH:mm"), ], - [t.location, subpoenaDateLog?.location ?? ''], + [t.location, arraignmentLocation], [t.courtCeremony, t.parliamentaryConfirmation], ].map((item) => ({ label: item[0] ?? '', @@ -100,6 +134,10 @@ export class SubpoenaResponse { !waivedRight && hasDefender ? defendantInfo?.defenderName : undefined, + canEdit: canChangeDefenseChoice, + courtContactInfo: canChangeDefenseChoice + ? t.courtContactInfo + : undefined, } : undefined, } diff --git a/apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/utils/translations.strings.ts b/apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/utils/translations.strings.ts index 112520c77735..6ca747677b74 100644 --- a/apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/utils/translations.strings.ts +++ b/apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/utils/translations.strings.ts @@ -11,6 +11,7 @@ type Translations = { court: string courtCaseNumber: string courtCeremony: string + courtContactInfo: string date: string defendant: string defender: string @@ -29,6 +30,7 @@ type Translations = { prosecutorsOffice: string subpoena: string subpoenaSent: string + subpoenaServed: string type: string waiveRightToCounsel: string } @@ -45,6 +47,8 @@ const translations: Translations = { court: 'Court', courtCaseNumber: 'Case number', courtCeremony: 'Court ceremony', + courtContactInfo: + 'Please contact the court if you wish to change your choice of defender', date: 'Date', defendant: 'Defendant', defender: 'Defender', @@ -63,6 +67,8 @@ const translations: Translations = { prosecutorsOffice: 'Institution', subpoena: 'Subpoena', subpoenaSent: 'Subpoena sent', + subpoenaServed: + 'Confirmation of subpoena service has been sent to the court', type: 'Type', waiveRightToCounsel: 'Right to counsel waived', }, @@ -76,6 +82,8 @@ const translations: Translations = { court: 'Dómstóll', courtCaseNumber: 'Málsnúmer héraðsdóms', courtCeremony: 'Dómsathöfn', + courtContactInfo: + 'Vinsamlegast hafið samband við dómstól til að breyta verjanda vali', date: 'Dagsetning', defendant: 'Varnaraðili', defender: 'Verjandi', @@ -94,6 +102,7 @@ const translations: Translations = { prosecutorsOffice: 'Embætti', subpoena: 'Fyrirkall', subpoenaSent: 'Fyrirkall sent', + subpoenaServed: 'Staðfesting á móttöku hefur verið send á dómstóla', type: 'Tegund', waiveRightToCounsel: 'Ekki er óskað eftir verjanda', },