diff --git a/cypress/local-only/tests/integration/statusReportOrder/status-report-order-description-fields.cy.ts b/cypress/local-only/tests/integration/statusReportOrder/status-report-order-description-fields.cy.ts new file mode 100644 index 00000000000..8b7d96fa55d --- /dev/null +++ b/cypress/local-only/tests/integration/statusReportOrder/status-report-order-description-fields.cy.ts @@ -0,0 +1,112 @@ +import { + FORMATS, + formatNow, +} from '../../../../../shared/src/business/utilities/DateHandler'; +import { + docketNumber, + getLastDraftOrderElementFromDrafts, +} from '../../../support/statusReportOrder'; +import { + loginAsColvin, + loginAsColvinChambers, + loginAsDocketClerk, +} from '../../../../helpers/authentication/login-as-helpers'; +import { logout } from '../../../../helpers/authentication/logout'; + +describe('should default status report order descriptions', () => { + const today = formatNow(FORMATS.MMDDYYYY); + it('should display default description when document type is an Order', () => { + judgeOrChambersCreatesStatusReportOrder(today); + loginAsDocketClerk(); + cy.visit(`/case-detail/${docketNumber}`); + cy.get('#tab-drafts').click(); + getLastDraftOrderElementFromDrafts().click(); + cy.get('[data-testid="add-court-issued-docket-entry-button"]').click(); + cy.get('[data-testid="court-issued-document-type-search"]').should( + 'have.text', + 'Order', + ); + cy.get('[data-testid="document-description-input"]').should( + 'have.value', + `Order parties by ${today} shall file a status report.`, + ); + cy.get('[data-testid="docket-entry-preview-text"]').should( + 'have.text', + `Docket entry preview: Order parties by ${today} shall file a status report.`, + ); + }); + + it('should set event code to OJR when case is stricken from trial session and jurisdiction is retained and display default description', () => { + judgeOrChambersCreatesStatusReportOrder(today, true); + loginAsDocketClerk(); + cy.visit(`/case-detail/${docketNumber}`); + cy.get('#tab-drafts').click(); + getLastDraftOrderElementFromDrafts().click(); + cy.get('[data-testid="add-court-issued-docket-entry-button"]').click(); + cy.get('[data-testid="court-issued-document-type-search"]').should( + 'have.text', + 'Order that jurisdiction is retained', + ); + cy.get('[data-testid="document-description-input"]').should( + 'have.value', + `. Parties by ${today} shall file a status report. Case is stricken from the current trial session.`, + ); + cy.get('[data-testid="judge-select"]').should('have.value', 'Colvin'); + cy.get('[data-testid="docket-entry-preview-text"]').should( + 'have.text', + `Docket entry preview: Order that jurisdiction is retained by Judge Colvin. Parties by ${today} shall file a status report. Case is stricken from the current trial session.`, + ); + }); + + it('should continue to handle OJR and set correct signing judge when status order report is signed by chambers user', () => { + judgeOrChambersCreatesStatusReportOrder(today, true, true); + loginAsDocketClerk(); + cy.visit(`/case-detail/${docketNumber}`); + cy.get('#tab-drafts').click(); + getLastDraftOrderElementFromDrafts().click(); + cy.get('[data-testid="add-court-issued-docket-entry-button"]').click(); + cy.get('[data-testid="court-issued-document-type-search"]').should( + 'have.text', + 'Order that jurisdiction is retained', + ); + cy.get('[data-testid="document-description-input"]').should( + 'have.value', + `. Parties by ${today} shall file a status report. Case is stricken from the current trial session.`, + ); + cy.get('[data-testid="judge-select"]').should('have.value', 'Colvin'); + cy.get('[data-testid="docket-entry-preview-text"]').should( + 'have.text', + `Docket entry preview: Order that jurisdiction is retained by Judge Colvin. Parties by ${today} shall file a status report. Case is stricken from the current trial session.`, + ); + }); +}); + +function judgeOrChambersCreatesStatusReportOrder( + today: string, + jurisdictionRetained: boolean = false, + chambersUser: boolean = false, +) { + if (chambersUser) { + loginAsColvinChambers(); + } else { + loginAsColvin(); + } + cy.visit(`/case-detail/${docketNumber}`); + cy.get('#tab-document-view').click(); + cy.contains('Status Report').click(); + cy.get('[data-testid="status-report-order-button"]').click(); + cy.get('[data-testid="order-type-status-report"]').check({ force: true }); + cy.get('#status-report-due-date-picker').type(today); + + if (jurisdictionRetained) { + cy.get('#stricken-from-trial-sessions-label').click(); + cy.get( + '#jurisdiction-form-group > :nth-child(2) > .usa-radio__label', + ).click(); + cy.get('#jurisdiction-retained').check(); + } + cy.get('[data-testid="save-draft-button"]').click(); + cy.get('[data-testid="sign-pdf-canvas"]').click(); + cy.get('[data-testid="save-signature-button"]').click(); + logout(); +} diff --git a/shared/src/business/entities/EntityConstants.ts b/shared/src/business/entities/EntityConstants.ts index 9fb2dae09a2..7ca9895cc1a 100644 --- a/shared/src/business/entities/EntityConstants.ts +++ b/shared/src/business/entities/EntityConstants.ts @@ -35,6 +35,8 @@ export const DOCUMENT_EXTERNAL_CATEGORIES_MAP: { } = externalFilingEventsJson; export const COURT_ISSUED_EVENT_CODES = courtIssuedEventCodesJson; +export const EVENT_CODES_THAT_ALLOW_FREE_TEXT = ['O', 'NOT', 'OJR']; + export const DOCKET_NUMBER_MATCHER = /^([1-9]\d{2,4}-\d{2})$/; export const CURRENT_YEAR = +formatNow(FORMATS.YEAR); diff --git a/shared/src/business/utilities/replaceBracketed.ts b/shared/src/business/utilities/replaceBracketed.ts index b7a3b0bfc9f..62d3899b3dc 100644 --- a/shared/src/business/utilities/replaceBracketed.ts +++ b/shared/src/business/utilities/replaceBracketed.ts @@ -6,6 +6,7 @@ export const replaceBracketed = ( while (bracketsMatcher.test(template)) { template = template.replace(bracketsMatcher, values.shift() || ''); } + template = template.replace(/\s+\./g, '.'); template = template.trim(); return template; }; diff --git a/web-api/src/business/useCases/courtIssuedOrder/fileCourtIssuedOrderInteractor.test.ts b/web-api/src/business/useCases/courtIssuedOrder/fileCourtIssuedOrderInteractor.test.ts index c83d9a05950..b9b79a2ac5b 100644 --- a/web-api/src/business/useCases/courtIssuedOrder/fileCourtIssuedOrderInteractor.test.ts +++ b/web-api/src/business/useCases/courtIssuedOrder/fileCourtIssuedOrderInteractor.test.ts @@ -8,6 +8,7 @@ import { PARTY_TYPES, PETITIONS_SECTION, ROLES, + STATUS_REPORT_ORDER_OPTIONS, } from '../../../../../shared/src/business/entities/EntityConstants'; import { MOCK_LOCK } from '../../../../../shared/src/test/mockLock'; import { ServiceUnavailableError } from '@web-api/errors/errors'; @@ -21,6 +22,7 @@ import { } from '@shared/test/mockAuthUsers'; import { updateMessage } from '@web-api/persistence/postgres/messages/updateMessage'; +/* eslint-disable max-lines */ describe('fileCourtIssuedOrderInteractor', () => { const mockUserId = applicationContext.getUniqueId(); const caseRecord = { @@ -146,41 +148,6 @@ describe('fileCourtIssuedOrderInteractor', () => { ).toEqual(4); }); - it('should add order document to case and set freeText and draftOrderState.freeText to the document title if it is a generic order (eventCode O)', async () => { - await fileCourtIssuedOrderInteractor( - applicationContext, - { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentTitle: 'Order to do anything', - documentType: 'Order', - draftOrderState: {}, - eventCode: 'O', - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', - }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }, - mockDocketClerkUser, - ); - - expect( - applicationContext.getPersistenceGateway().getCaseByDocketNumber, - ).toHaveBeenCalled(); - expect( - applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] - .caseToUpdate.docketEntries.length, - ).toEqual(4); - expect( - applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] - .caseToUpdate.docketEntries[3], - ).toMatchObject({ - draftOrderState: { freeText: 'Order to do anything' }, - freeText: 'Order to do anything', - }); - }); - it('should delete draftOrderState properties if they exists on the documentMetadata, after saving the document', async () => { await fileCourtIssuedOrderInteractor( applicationContext, @@ -507,4 +474,347 @@ describe('fileCourtIssuedOrderInteractor', () => { identifiers: [`case|${caseRecord.docketNumber}`], }); }); + + describe('freeText', () => { + describe('eventCode "NOT"', () => { + it('should add order document to case and set freeText and draftOrderState.freeText to the document title if it eventCode NOT', async () => { + await fileCourtIssuedOrderInteractor( + applicationContext, + { + documentMetadata: { + docketNumber: caseRecord.docketNumber, + documentTitle: 'Order to do anything', + documentType: 'Order', + draftOrderState: {}, + eventCode: 'NOT', + signedAt: '2019-03-01T21:40:46.415Z', + signedByUserId: mockUserId, + signedJudgeName: 'Dredd', + }, + primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockDocketClerkUser, + ); + + expect( + applicationContext.getPersistenceGateway().getCaseByDocketNumber, + ).toHaveBeenCalled(); + expect( + applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] + .caseToUpdate.docketEntries.length, + ).toEqual(4); + expect( + applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] + .caseToUpdate.docketEntries[3], + ).toMatchObject({ + draftOrderState: { freeText: 'Order to do anything' }, + freeText: 'Order to do anything', + }); + }); + }); + + describe('eventCode "O"', () => { + it('should add order document to case and set freeText and draftOrderState.freeText correctly for orderType status report', async () => { + await fileCourtIssuedOrderInteractor( + applicationContext, + { + documentMetadata: { + draftOrderState: {}, + dueDate: '2024-11-05', + eventCode: 'O', + orderType: + STATUS_REPORT_ORDER_OPTIONS.orderTypeOptions.statusReport, + strickenFromTrialSessions: false, + }, + primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockDocketClerkUser, + ); + + expect( + applicationContext.getPersistenceGateway().getCaseByDocketNumber, + ).toHaveBeenCalled(); + expect( + applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] + .caseToUpdate.docketEntries[3], + ).toMatchObject({ + draftOrderState: { + freeText: 'Order parties by 11/05/2024 shall file a status report.', + }, + freeText: 'Order parties by 11/05/2024 shall file a status report.', + }); + }); + + it('should add order document to case and set freeText and draftOrderState.freeText correctly for orderType status report and when case is stricken from current trial session', async () => { + await fileCourtIssuedOrderInteractor( + applicationContext, + { + documentMetadata: { + draftOrderState: {}, + dueDate: '2024-11-05', + eventCode: 'O', + orderType: + STATUS_REPORT_ORDER_OPTIONS.orderTypeOptions.statusReport, + strickenFromTrialSessions: true, + }, + primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockDocketClerkUser, + ); + + expect( + applicationContext.getPersistenceGateway().getCaseByDocketNumber, + ).toHaveBeenCalled(); + expect( + applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] + .caseToUpdate.docketEntries[3], + ).toMatchObject({ + draftOrderState: { + freeText: + 'Order parties by 11/05/2024 shall file a status report. Case is stricken from the current trial session.', + }, + freeText: + 'Order parties by 11/05/2024 shall file a status report. Case is stricken from the current trial session.', + }); + }); + + it('should add order document to case and set freeText and draftOrderState.freeText correctly for orderType status report and when case is stricken from current trial session and jurisdiction is restored to general docket', async () => { + await fileCourtIssuedOrderInteractor( + applicationContext, + { + documentMetadata: { + draftOrderState: {}, + dueDate: '2024-11-05', + eventCode: 'O', + jurisdiction: + STATUS_REPORT_ORDER_OPTIONS.jurisdictionOptions.restored, + orderType: + STATUS_REPORT_ORDER_OPTIONS.orderTypeOptions.statusReport, + strickenFromTrialSessions: true, + }, + primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockDocketClerkUser, + ); + + expect( + applicationContext.getPersistenceGateway().getCaseByDocketNumber, + ).toHaveBeenCalled(); + expect( + applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] + .caseToUpdate.docketEntries[3], + ).toMatchObject({ + draftOrderState: { + freeText: + 'Order parties by 11/05/2024 shall file a status report. Case is stricken from the current trial session. Case is no longer jurisdiction retained and is restored to the general docket.', + }, + freeText: + 'Order parties by 11/05/2024 shall file a status report. Case is stricken from the current trial session. Case is no longer jurisdiction retained and is restored to the general docket.', + }); + }); + + it('should add order document to case and set freeText and draftOrderState.freeText correctly for orderType status report stipulated decision', async () => { + await fileCourtIssuedOrderInteractor( + applicationContext, + { + documentMetadata: { + draftOrderState: {}, + dueDate: '2024-11-05', + eventCode: 'O', + orderType: + STATUS_REPORT_ORDER_OPTIONS.orderTypeOptions.stipulatedDecision, + strickenFromTrialSessions: false, + }, + primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockDocketClerkUser, + ); + + expect( + applicationContext.getPersistenceGateway().getCaseByDocketNumber, + ).toHaveBeenCalled(); + expect( + applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] + .caseToUpdate.docketEntries[3], + ).toMatchObject({ + draftOrderState: { + freeText: + 'Order parties by 11/05/2024 shall file a status report or proposed stipulated decision.', + }, + freeText: + 'Order parties by 11/05/2024 shall file a status report or proposed stipulated decision.', + }); + }); + + it('should add order document to case and set freeText and draftOrderState.freeText correctly for orderType status report stipulated decision and when case is stricken from current trial session', async () => { + await fileCourtIssuedOrderInteractor( + applicationContext, + { + documentMetadata: { + draftOrderState: {}, + dueDate: '2024-11-05', + eventCode: 'O', + orderType: + STATUS_REPORT_ORDER_OPTIONS.orderTypeOptions.stipulatedDecision, + strickenFromTrialSessions: true, + }, + primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockDocketClerkUser, + ); + + expect( + applicationContext.getPersistenceGateway().getCaseByDocketNumber, + ).toHaveBeenCalled(); + expect( + applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] + .caseToUpdate.docketEntries[3], + ).toMatchObject({ + draftOrderState: { + freeText: + 'Order parties by 11/05/2024 shall file a status report or proposed stipulated decision. Case is stricken from the current trial session.', + }, + freeText: + 'Order parties by 11/05/2024 shall file a status report or proposed stipulated decision. Case is stricken from the current trial session.', + }); + }); + + it('should add order document to case and set freeText and draftOrderState.freeText correctly for orderType status report stipulated decision and when case is stricken from current trial session and jurisdiction is restored to general docket', async () => { + await fileCourtIssuedOrderInteractor( + applicationContext, + { + documentMetadata: { + draftOrderState: {}, + dueDate: '2024-11-05', + eventCode: 'O', + jurisdiction: + STATUS_REPORT_ORDER_OPTIONS.jurisdictionOptions.restored, + orderType: + STATUS_REPORT_ORDER_OPTIONS.orderTypeOptions.stipulatedDecision, + strickenFromTrialSessions: true, + }, + primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockDocketClerkUser, + ); + + expect( + applicationContext.getPersistenceGateway().getCaseByDocketNumber, + ).toHaveBeenCalled(); + expect( + applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] + .caseToUpdate.docketEntries[3], + ).toMatchObject({ + draftOrderState: { + freeText: + 'Order parties by 11/05/2024 shall file a status report or proposed stipulated decision. Case is stricken from the current trial session. Case is no longer jurisdiction retained and is restored to the general docket.', + }, + freeText: + 'Order parties by 11/05/2024 shall file a status report or proposed stipulated decision. Case is stricken from the current trial session. Case is no longer jurisdiction retained and is restored to the general docket.', + }); + }); + }); + + describe('eventcode "OJR"', () => { + it('should add order document to case and set freeText and draftOrderState.freeText correctly when order type is statusReport', async () => { + await fileCourtIssuedOrderInteractor( + applicationContext, + { + documentMetadata: { + docketNumber: caseRecord.docketNumber, + draftOrderState: {}, + dueDate: '2024-11-05', + eventCode: 'O', + jurisdiction: + STATUS_REPORT_ORDER_OPTIONS.jurisdictionOptions.retained, + orderType: + STATUS_REPORT_ORDER_OPTIONS.orderTypeOptions.statusReport, + strickenFromTrialSessions: true, + }, + primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockDocketClerkUser, + ); + expect( + applicationContext.getPersistenceGateway().getCaseByDocketNumber, + ).toHaveBeenCalled(); + expect( + applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] + .caseToUpdate.docketEntries[3], + ).toMatchObject({ + draftOrderState: { + freeText: + '. Parties by 11/05/2024 shall file a status report. Case is stricken from the current trial session.', + }, + freeText: + '. Parties by 11/05/2024 shall file a status report. Case is stricken from the current trial session.', + }); + }); + + it('should add order document to case and set freeText and draftOrderState.freeText correctly when order type is statusReportStipulatedDecision and case is stricken from the current trial session', async () => { + await fileCourtIssuedOrderInteractor( + applicationContext, + { + documentMetadata: { + docketNumber: caseRecord.docketNumber, + draftOrderState: {}, + dueDate: '2024-11-05', + eventCode: 'O', + jurisdiction: + STATUS_REPORT_ORDER_OPTIONS.jurisdictionOptions.retained, + orderType: + STATUS_REPORT_ORDER_OPTIONS.orderTypeOptions.stipulatedDecision, + strickenFromTrialSessions: true, + }, + primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockDocketClerkUser, + ); + expect( + applicationContext.getPersistenceGateway().getCaseByDocketNumber, + ).toHaveBeenCalled(); + expect( + applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] + .caseToUpdate.docketEntries[3], + ).toMatchObject({ + draftOrderState: { + freeText: + '. Parties by 11/05/2024 shall file a status report or proposed stipulated decision. Case is stricken from the current trial session.', + }, + freeText: + '. Parties by 11/05/2024 shall file a status report or proposed stipulated decision. Case is stricken from the current trial session.', + }); + }); + + it('should add order document to case and set freeText and draftOrderState.freeText correctly when case is stricken from the current trial session', async () => { + await fileCourtIssuedOrderInteractor( + applicationContext, + { + documentMetadata: { + docketNumber: caseRecord.docketNumber, + draftOrderState: {}, + eventCode: 'O', + jurisdiction: + STATUS_REPORT_ORDER_OPTIONS.jurisdictionOptions.retained, + strickenFromTrialSessions: true, + }, + primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockDocketClerkUser, + ); + expect( + applicationContext.getPersistenceGateway().getCaseByDocketNumber, + ).toHaveBeenCalled(); + expect( + applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] + .caseToUpdate.docketEntries[3], + ).toMatchObject({ + draftOrderState: { + freeText: '. Case is stricken from the current trial session.', + }, + freeText: '. Case is stricken from the current trial session.', + }); + }); + }); + }); }); diff --git a/web-api/src/business/useCases/courtIssuedOrder/fileCourtIssuedOrderInteractor.ts b/web-api/src/business/useCases/courtIssuedOrder/fileCourtIssuedOrderInteractor.ts index b7402b20a36..fb552b2ac90 100644 --- a/web-api/src/business/useCases/courtIssuedOrder/fileCourtIssuedOrderInteractor.ts +++ b/web-api/src/business/useCases/courtIssuedOrder/fileCourtIssuedOrderInteractor.ts @@ -1,6 +1,14 @@ +import { + COURT_ISSUED_EVENT_CODES, + DOCUMENT_RELATIONSHIPS, + EVENT_CODES_THAT_ALLOW_FREE_TEXT, +} from '../../../../../shared/src/business/entities/EntityConstants'; import { Case } from '../../../../../shared/src/business/entities/cases/Case'; -import { DOCUMENT_RELATIONSHIPS } from '../../../../../shared/src/business/entities/EntityConstants'; import { DocketEntry } from '../../../../../shared/src/business/entities/DocketEntry'; +import { + FORMATS, + formatDateString, +} from '@shared/business/utilities/DateHandler'; import { Message } from '../../../../../shared/src/business/entities/Message'; import { ROLE_PERMISSIONS, @@ -40,11 +48,22 @@ export const fileCourtIssuedOrder = async ( }); const caseEntity = new Case(caseToUpdate, { authorizedUser }); - if (['O', 'NOT'].includes(documentMetadata.eventCode)) { - documentMetadata.freeText = documentMetadata.documentTitle; + if ( + documentMetadata.strickenFromTrialSessions && + documentMetadata.jurisdiction === 'retained' + ) { + const ojrEventCode = COURT_ISSUED_EVENT_CODES.find( + e => e.eventCode === 'OJR', + ); + documentMetadata.documentType = ojrEventCode?.documentType; + documentMetadata.eventCode = 'OJR'; + } + + if (EVENT_CODES_THAT_ALLOW_FREE_TEXT.includes(documentMetadata.eventCode)) { + const freeText = generateFreeText(documentMetadata); + documentMetadata.freeText = freeText; if (documentMetadata.draftOrderState) { - documentMetadata.draftOrderState.freeText = - documentMetadata.documentTitle; + documentMetadata.draftOrderState.freeText = freeText; } } @@ -138,3 +157,56 @@ export const fileCourtIssuedOrderInteractor = withLocking( identifiers: [`case|${documentMetadata.docketNumber}`], }), ); + +function generateFreeText(documentMetadata: { + orderType: string; + documentTitle: string; + dueDate: string; + eventCode: string; + strickenFromTrialSessions: boolean; + jurisdiction: string; +}) { + const { + documentTitle, + dueDate, + eventCode, + jurisdiction, + orderType, + strickenFromTrialSessions, + } = documentMetadata; + + const formattedDueDate = formatDateString(dueDate, FORMATS.MMDDYYYY); + if (eventCode === 'OJR') { + return [ + orderType === 'statusReport' && + `. Parties by ${formattedDueDate} shall file a status report.`, + orderType === 'statusReportStipulatedDecision' && + `. Parties by ${formattedDueDate} shall file a status report or proposed stipulated decision.`, + orderType !== 'statusReportStipulatedDecision' && + orderType !== 'statusReport' && + strickenFromTrialSessions && + '.', + strickenFromTrialSessions && + 'Case is stricken from the current trial session.', + ] + .filter(Boolean) + .join(' '); + } + + if (eventCode === 'O' && (orderType || jurisdiction)) { + return [ + 'Order', + orderType === 'statusReport' && + `parties by ${formattedDueDate} shall file a status report.`, + orderType === 'statusReportStipulatedDecision' && + `parties by ${formattedDueDate} shall file a status report or proposed stipulated decision.`, + strickenFromTrialSessions && + 'Case is stricken from the current trial session.', + jurisdiction === 'restoredToGeneralDocket' && + 'Case is no longer jurisdiction retained and is restored to the general docket.', + ] + .filter(Boolean) + .join(' '); + } + return documentTitle; +} diff --git a/web-client/src/presenter/actions/CourtIssuedDocketEntry/setCourtIssuedDocumentInitialDataAction.test.ts b/web-client/src/presenter/actions/CourtIssuedDocketEntry/setCourtIssuedDocumentInitialDataAction.test.ts index 6d89a183086..a5ac411f5e8 100644 --- a/web-client/src/presenter/actions/CourtIssuedDocketEntry/setCourtIssuedDocumentInitialDataAction.test.ts +++ b/web-client/src/presenter/actions/CourtIssuedDocketEntry/setCourtIssuedDocumentInitialDataAction.test.ts @@ -1,5 +1,6 @@ import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; +import { judgeColvin } from '@shared/test/mockUsers'; import { presenter } from '../../presenter-mock'; import { runAction } from '@web-client/presenter/test.cerebral'; import { setCourtIssuedDocumentInitialDataAction } from './setCourtIssuedDocumentInitialDataAction'; @@ -8,6 +9,8 @@ describe('setCourtIssuedDocumentInitialDataAction', () => { const docketEntryIds = [ 'ddfd978d-6be6-4877-b004-2b5735a41fee', '11597d22-0874-4c5e-ac98-a843d1472baf', + '22597d22-0874-4c5e-ac98-a843d1472baf', + '43737877-0874-4c5e-ac98-dhd83838887j', ]; beforeAll(() => { @@ -22,6 +25,18 @@ describe('setCourtIssuedDocumentInitialDataAction', () => { eventCode: 'O', freeText: 'something', }); + MOCK_CASE.docketEntries.push({ + docketEntryId: docketEntryIds[2], + eventCode: 'OJR', + signedByUserId: judgeColvin.userId, + signedJudgeName: judgeColvin.judgeFullName, + }); + MOCK_CASE.docketEntries.push({ + docketEntryId: docketEntryIds[3], + eventCode: 'OJR', + signedByUserId: 'not-colvins-id', + signedJudgeName: judgeColvin.judgeFullName, + }); }); it('should set correct values on state.form for the docketEntryId passed in via props', async () => { @@ -108,4 +123,50 @@ describe('setCourtIssuedDocumentInitialDataAction', () => { expect(result.state.form).toEqual({}); }); + + it('should set the judge name when eventcode is OJR and docketEntry was signed by the judge', async () => { + const result = await runAction(setCourtIssuedDocumentInitialDataAction, { + modules: { + presenter, + }, + props: { + docketEntryId: docketEntryIds[2], + }, + state: { + caseDetail: MOCK_CASE, + form: {}, + judges: [ + { + judgeFullName: judgeColvin.judgeFullName, + name: judgeColvin.name, + userId: judgeColvin.userId, + }, + ], + }, + }); + expect(result.state.form.judge).toEqual('Colvin'); + }); + + it('should set the judge name when eventcode is OJR and docketEntry was signed by a non judge user', async () => { + const result = await runAction(setCourtIssuedDocumentInitialDataAction, { + modules: { + presenter, + }, + props: { + docketEntryId: docketEntryIds[3], + }, + state: { + caseDetail: MOCK_CASE, + form: {}, + judges: [ + { + judgeFullName: judgeColvin.judgeFullName, + name: judgeColvin.name, + userId: judgeColvin.userId, + }, + ], + }, + }); + expect(result.state.form.judge).toEqual('Colvin'); + }); }); diff --git a/web-client/src/presenter/actions/CourtIssuedDocketEntry/setCourtIssuedDocumentInitialDataAction.ts b/web-client/src/presenter/actions/CourtIssuedDocketEntry/setCourtIssuedDocumentInitialDataAction.ts index a99dd05072c..92e9db0309a 100644 --- a/web-client/src/presenter/actions/CourtIssuedDocketEntry/setCourtIssuedDocumentInitialDataAction.ts +++ b/web-client/src/presenter/actions/CourtIssuedDocketEntry/setCourtIssuedDocumentInitialDataAction.ts @@ -18,6 +18,8 @@ export const setCourtIssuedDocumentInitialDataAction = ({ }: ActionProps) => { const { docketEntries } = get(state.caseDetail); + const judges = get(state.judges); + const docketEntry = docketEntries.find( item => item.docketEntryId === props.docketEntryId, ); @@ -34,6 +36,20 @@ export const setCourtIssuedDocumentInitialDataAction = ({ store.set(state.form.attachments, false); } + if (docketEntry.eventCode === 'OJR') { + const signingJudge = judges.find(judge => { + return ( + judge.judgeFullName && + docketEntry.signedJudgeName && + judge.judgeFullName === docketEntry.signedJudgeName + ); + }); + + if (signingJudge) { + store.set(state.form.judge, signingJudge.name); + } + } + if (docketEntry.freeText) { store.set(state.form.freeText, docketEntry.freeText); } diff --git a/web-client/src/presenter/sequences/gotoAddCourtIssuedDocketEntrySequence.ts b/web-client/src/presenter/sequences/gotoAddCourtIssuedDocketEntrySequence.ts index d115deb4354..20c959566fb 100644 --- a/web-client/src/presenter/sequences/gotoAddCourtIssuedDocketEntrySequence.ts +++ b/web-client/src/presenter/sequences/gotoAddCourtIssuedDocketEntrySequence.ts @@ -1,4 +1,5 @@ import { clearFormAction } from '../actions/clearFormAction'; +import { computeJudgeNameWithTitleAction } from '@web-client/presenter/actions/computeJudgeNameWithTitleAction'; import { generateCourtIssuedDocumentTitleAction } from '../actions/CourtIssuedDocketEntry/generateCourtIssuedDocumentTitleAction'; import { getCaseAction } from '../actions/getCaseAction'; import { getFilterCurrentJudgeUsersAction } from '../actions/getFilterCurrentJudgeUsersAction'; @@ -28,6 +29,7 @@ export const gotoAddCourtIssuedDocketEntrySequence = setDocketEntryIdAction, setCourtIssuedDocumentInitialDataAction, setDefaultServiceStampAction, + computeJudgeNameWithTitleAction, generateCourtIssuedDocumentTitleAction, setIsEditingDocketEntryAction(false), setupCurrentPageAction('CourtIssuedDocketEntry'), diff --git a/web-client/src/views/CourtIssuedDocketEntry/CourtIssuedDocketEntry.tsx b/web-client/src/views/CourtIssuedDocketEntry/CourtIssuedDocketEntry.tsx index a0130b97787..8a0bea98655 100644 --- a/web-client/src/views/CourtIssuedDocketEntry/CourtIssuedDocketEntry.tsx +++ b/web-client/src/views/CourtIssuedDocketEntry/CourtIssuedDocketEntry.tsx @@ -96,7 +96,10 @@ export const CourtIssuedDocketEntry = connect(