Skip to content

Commit

Permalink
Merge branch '10502-dxox' of github.com:flexion/ef-cms into 10502-dxox
Browse files Browse the repository at this point in the history
  • Loading branch information
pixiwyn committed Jan 10, 2025
2 parents 70566ca + b43a416 commit 5742a7f
Show file tree
Hide file tree
Showing 37 changed files with 141 additions and 337 deletions.
3 changes: 3 additions & 0 deletions __TODO-10502.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
- Case title, petitioner advanced syntax
- Can we remove formatWorkItemResult and formatMessageResult? What about formatDocketEntryResult?

- if we use the trigram search, run on the db CREATE EXTENSION IF NOT EXISTS pg_trgm;
- upsertPractitionersOnCase: we have two versions
- Some TODOs are marked with "10502 TODO", so search for this (without the quotes) as needed. (solo, meetup as needed)
- Make sure that report data for case-mapping reports (above) is correct, and make sure indices are added for efficiency as needed for all case-based reports (pair)
- Make sure getCasesMetadataByUserId (previously called getCasesForUser) is working. It relies on processPractitionerMappingEntries streaming things into PractitionerOnCaseTable (pair)
Expand All @@ -19,6 +21,7 @@
# Things to test:

- Be consistent with Case and RawCase (maybe? not a big deal) and with returning undefined vs. throwing a not-found error in persistence methods
- Places where we createCase/upsertCases sometimes also need to create/upsert rows in related tables (petitionerOnCase, etc.) that used to be children objects on Case dynamo records.
- We removed duplicative getCountOfConsolidatedCases. Make sure that everything works as expected--Chris H mentioned that consolidated cases have had several refactors, so there might be a reason this existed after all.
- Are there any unhappy paths in which latency-induced data discrepancies can occur between Postgres and Open Search?

Expand Down
13 changes: 0 additions & 13 deletions shared/src/business/test/createTestApplicationContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ import {
compareStrings,
} from '@shared/business/utilities/sortFunctions';
import { copyPagesAndAppendToTargetPdf } from '@shared/business/utilities/copyPagesAndAppendToTargetPdf';
import { createCase } from '@web-api/persistence/dynamo/cases/createCase';
import { createCaseAndAssociations } from '@web-api/business/useCaseHelper/caseAssociation/createCaseAndAssociations';
import { createDocketNumber } from '@web-api/persistence/dynamo/cases/docketNumberGenerator';
import { createMockDocumentClient } from './createMockDocumentClient';
import { deleteRecord } from '@web-api/persistence/elasticsearch/deleteRecord';
import { documentUrlTranslator } from '@web-api/utilities/documentUrlTranslator';
Expand Down Expand Up @@ -110,10 +108,8 @@ import { setConsolidationFlagsForDisplay } from '@shared/business/utilities/setC
import { setItem } from '@web-client/persistence/localStorage/setItem';
import { setNoticesForCalendaredTrialSessionInteractor } from '@shared/proxies/trialSessions/setNoticesForCalendaredTrialSessionProxy';
import { setPdfFormFields } from '@web-api/business/useCaseHelper/pdf/setPdfFormFields';
import { setServiceIndicatorsForCase } from '@shared/business/utilities/setServiceIndicatorsForCase';
import { setupPdfDocument } from '@shared/business/utilities/setupPdfDocument';
import { unsealDocketEntryInteractor } from '@web-api/business/useCases/docketEntry/unsealDocketEntryInteractor';
import { updateCase } from '@web-api/persistence/dynamo/cases/updateCase';
import { updateCaseAndAssociations } from '@web-api/business/useCaseHelper/caseAssociation/updateCaseAndAssociations';
import { updateCaseAutomaticBlock } from '@web-api/business/useCaseHelper/automaticBlock/updateCaseAutomaticBlock';
import { updateCaseCorrespondence } from '@web-api/persistence/dynamo/correspondence/updateCaseCorrespondence';
Expand Down Expand Up @@ -328,9 +324,6 @@ export const createTestApplicationContext = () => {
setConsolidationFlagsForDisplay: jest
.fn()
.mockImplementation(setConsolidationFlagsForDisplay),
setServiceIndicatorsForCase: jest
.fn()
.mockImplementation(setServiceIndicatorsForCase),
setupPdfDocument: jest.fn().mockImplementation(setupPdfDocument),
sleep: jest.fn(),
sortDocketEntries: jest.fn().mockImplementation(sortDocketEntries),
Expand Down Expand Up @@ -461,7 +454,6 @@ export const createTestApplicationContext = () => {
addCaseToHearing: jest.fn(),
bulkDeleteRecords: jest.fn().mockImplementation(bulkDeleteRecords),
bulkIndexRecords: jest.fn().mockImplementation(bulkIndexRecords),
createCase: jest.fn().mockImplementation(createCase),
createCaseTrialSortMappingRecords: jest.fn(),
createElasticsearchReindexRecord: jest.fn(),
createLock: jest.fn().mockImplementation(() => Promise.resolve(null)),
Expand Down Expand Up @@ -523,7 +515,6 @@ export const createTestApplicationContext = () => {
setPriorityOnAllWorkItems: jest.fn(),
setTrialSessionJobStatusForCase: jest.fn(),
setTrialSessionProcessingStatus: jest.fn(),
updateCase: jest.fn().mockImplementation(updateCase),
updateCaseCorrespondence: jest
.fn()
.mockImplementation(updateCaseCorrespondence),
Expand All @@ -544,10 +535,6 @@ export const createTestApplicationContext = () => {

const mockDocumentClient = createMockDocumentClient();

const mockCreateDocketNumberGenerator = {
createDocketNumber: jest.fn().mockImplementation(createDocketNumber),
};

const mockBroadcastGateway = {
postMessage: jest.fn(),
};
Expand Down
4 changes: 2 additions & 2 deletions shared/src/business/utilities/aggregatePartiesForService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Case } from '../entities/cases/Case';
import { SERVICE_INDICATOR_TYPES } from '../entities/EntityConstants';
import { setServiceIndicatorsForCase } from './setServiceIndicatorsForCase';
import { setServiceIndicatorsForPetitionersOnCase } from '@shared/business/utilities/setServiceIndicatorsForPetitionersOnCase';

export const aggregatePartiesForService = (
rawCase: RawCase,
Expand All @@ -10,7 +10,7 @@ export const aggregatePartiesForService = (
paper: any[];
electronic: Array<{ email: string; name: string }>;
} => {
const formattedCase = setServiceIndicatorsForCase(rawCase);
const formattedCase = setServiceIndicatorsForPetitionersOnCase(rawCase);

let allParties;

Expand Down
5 changes: 2 additions & 3 deletions shared/src/business/utilities/getFormattedCaseDetail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser';
import { cloneDeep, isEmpty, sortBy } from 'lodash';
import { isMiscellaneousDocketEntry } from '@shared/business/utilities/isMiscellaneousDocketEntry';
import { setServiceIndicatorsForPetitionersOnCase } from '@shared/business/utilities/setServiceIndicatorsForPetitionersOnCase';

const computeIsInProgress = ({ formattedEntry }) => {
return (
Expand Down Expand Up @@ -497,9 +498,7 @@ export const getFormattedCaseDetail = ({
authorizedUser: UnknownAuthUser;
}) => {
const result = {
...applicationContext
.getUtilities()
.setServiceIndicatorsForCase(caseDetail),
...setServiceIndicatorsForPetitionersOnCase(caseDetail),
...formatCase(applicationContext, caseDetail, authorizedUser),
};
result.formattedDocketEntries = sortDocketEntries(
Expand Down
26 changes: 0 additions & 26 deletions shared/src/business/utilities/setServiceIndicatorsForCase.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
getContactSecondary,
getPetitionerById,
} from '../entities/cases/Case';
import { setServiceIndicatorsForCase } from './setServiceIndicatorsForCase';
import { setServiceIndicatorsForPetitionersOnCase } from './setServiceIndicatorsForPetitionersOnCase';

describe('setServiceIndicatorsForCases', () => {
let baseCaseDetail;
Expand Down Expand Up @@ -56,7 +56,7 @@ describe('setServiceIndicatorsForCases', () => {
petitioners: [{ ...baseCaseDetail.petitioners[0], email: undefined }],
};

const result = setServiceIndicatorsForCase(caseDetail);
const result = setServiceIndicatorsForPetitionersOnCase(caseDetail);

expect(getContactPrimary(result).serviceIndicator).toEqual(
SERVICE_INDICATOR_TYPES.SI_PAPER,
Expand All @@ -66,7 +66,7 @@ describe('setServiceIndicatorsForCases', () => {
it(`should return ${SERVICE_INDICATOR_TYPES.SI_ELECTRONIC} for a Petitioner (contactPrimary) with no representing counsel filing electronically`, () => {
const caseDetail = { ...baseCaseDetail };

const result = setServiceIndicatorsForCase(caseDetail);
const result = setServiceIndicatorsForPetitionersOnCase(caseDetail);

expect(getContactPrimary(result).serviceIndicator).toEqual(
SERVICE_INDICATOR_TYPES.SI_ELECTRONIC,
Expand All @@ -87,7 +87,7 @@ describe('setServiceIndicatorsForCases', () => {
privatePractitioners: [{ ...basePractitioner }],
};

const result = setServiceIndicatorsForCase(caseDetail);
const result = setServiceIndicatorsForPetitionersOnCase(caseDetail);

expect(getContactSecondary(result).serviceIndicator).toEqual(
SERVICE_INDICATOR_TYPES.SI_ELECTRONIC,
Expand All @@ -109,7 +109,7 @@ describe('setServiceIndicatorsForCases', () => {
privatePractitioners: [{ ...basePractitioner }],
};

const result = setServiceIndicatorsForCase(caseDetail);
const result = setServiceIndicatorsForPetitionersOnCase(caseDetail);

expect(getContactSecondary(result).serviceIndicator).toEqual(
SERVICE_INDICATOR_TYPES.SI_ELECTRONIC,
Expand All @@ -129,7 +129,7 @@ describe('setServiceIndicatorsForCases', () => {
],
};

const result = setServiceIndicatorsForCase(caseDetail);
const result = setServiceIndicatorsForPetitionersOnCase(caseDetail);

expect(getContactPrimary(result).serviceIndicator).toEqual(
SERVICE_INDICATOR_TYPES.SI_NONE,
Expand All @@ -145,7 +145,7 @@ describe('setServiceIndicatorsForCases', () => {
],
};

const result = setServiceIndicatorsForCase(caseDetail);
const result = setServiceIndicatorsForPetitionersOnCase(caseDetail);

expect(getContactPrimary(result).serviceIndicator).toEqual(
SERVICE_INDICATOR_TYPES.SI_NONE,
Expand All @@ -161,7 +161,7 @@ describe('setServiceIndicatorsForCases', () => {
],
};

const result = setServiceIndicatorsForCase(caseDetail);
const result = setServiceIndicatorsForPetitionersOnCase(caseDetail);

expect(getContactPrimary(result).serviceIndicator).toEqual(
SERVICE_INDICATOR_TYPES.SI_NONE,
Expand All @@ -181,7 +181,7 @@ describe('setServiceIndicatorsForCases', () => {
privatePractitioners: [{ ...basePractitioner }],
};

const result = setServiceIndicatorsForCase(caseDetail);
const result = setServiceIndicatorsForPetitionersOnCase(caseDetail);

expect(getContactSecondary(result).serviceIndicator).toEqual(
SERVICE_INDICATOR_TYPES.SI_PAPER,
Expand All @@ -202,7 +202,7 @@ describe('setServiceIndicatorsForCases', () => {
privatePractitioners: [],
};

const result = setServiceIndicatorsForCase(caseDetail);
const result = setServiceIndicatorsForPetitionersOnCase(caseDetail);

expect(getContactPrimary(result).serviceIndicator).toEqual(
SERVICE_INDICATOR_TYPES.SI_PAPER,
Expand All @@ -223,7 +223,7 @@ describe('setServiceIndicatorsForCases', () => {
privatePractitioners: [{ ...basePractitioner }],
};

const result = setServiceIndicatorsForCase(caseDetail);
const result = setServiceIndicatorsForPetitionersOnCase(caseDetail);

expect(getContactSecondary(result).serviceIndicator).toEqual(
SERVICE_INDICATOR_TYPES.SI_NONE,
Expand All @@ -246,7 +246,7 @@ describe('setServiceIndicatorsForCases', () => {
],
};

const result = setServiceIndicatorsForCase(caseDetail);
const result = setServiceIndicatorsForPetitionersOnCase(caseDetail);

expect(getContactSecondary(result).serviceIndicator).toEqual(
SERVICE_INDICATOR_TYPES.SI_NONE,
Expand All @@ -260,7 +260,7 @@ describe('setServiceIndicatorsForCases', () => {
privatePractitioners: [{ ...basePractitioner }],
};

const result = setServiceIndicatorsForCase(caseDetail);
const result = setServiceIndicatorsForPetitionersOnCase(caseDetail);

expect(result.privatePractitioners[0].serviceIndicator).toEqual(
SERVICE_INDICATOR_TYPES.SI_PAPER,
Expand All @@ -272,7 +272,7 @@ describe('setServiceIndicatorsForCases', () => {
...baseCaseDetail,
irsPractitioners: [{ ...baseRespondent }],
};
const result = setServiceIndicatorsForCase(caseDetail);
const result = setServiceIndicatorsForPetitionersOnCase(caseDetail);

expect(result.irsPractitioners[0].serviceIndicator).toEqual(
SERVICE_INDICATOR_TYPES.SI_PAPER,
Expand All @@ -295,7 +295,7 @@ describe('setServiceIndicatorsForCases', () => {
],
};

const result = setServiceIndicatorsForCase(caseDetail);
const result = setServiceIndicatorsForPetitionersOnCase(caseDetail);

expect(
getPetitionerById(result, OTHER_CONTACT_ID).serviceIndicator,
Expand All @@ -316,7 +316,7 @@ describe('setServiceIndicatorsForCases', () => {
privatePractitioners: undefined,
};

const result = setServiceIndicatorsForCase(caseDetail);
const result = setServiceIndicatorsForPetitionersOnCase(caseDetail);

expect(
getPetitionerById(result, OTHER_CONTACT_ID).serviceIndicator,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Case } from '../entities/cases/Case';
import { SERVICE_INDICATOR_TYPES } from '../entities/EntityConstants';

export const setServiceIndicatorsForPetitionersOnCase = caseDetail => {
const { petitioners } = caseDetail;

petitioners?.forEach(petitioner => {
if (petitioner.serviceIndicator) {
return;
}
if (Case.isPetitionerRepresented(caseDetail, petitioner.contactId)) {
petitioner.serviceIndicator = SERVICE_INDICATOR_TYPES.SI_NONE;
} else {
const serviceIsPaper = !petitioner.email;
petitioner.serviceIndicator = serviceIsPaper
? SERVICE_INDICATOR_TYPES.SI_PAPER
: SERVICE_INDICATOR_TYPES.SI_ELECTRONIC;
}
});

return caseDetail;
};
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { Case } from '../../../../../shared/src/business/entities/cases/Case';
import { CaseDeadline } from '../../../../../shared/src/business/entities/CaseDeadline';
import { CaseFactory } from '@shared/business/entities/cases/CaseFactory';
import { Correspondence } from '../../../../../shared/src/business/entities/Correspondence';
import { DocketEntry } from '../../../../../shared/src/business/entities/DocketEntry';
import { IrsPractitioner } from '../../../../../shared/src/business/entities/IrsPractitioner';
import { Message } from '../../../../../shared/src/business/entities/Message';
import { PrivatePractitioner } from '../../../../../shared/src/business/entities/PrivatePractitioner';
import { Case } from '@shared/business/entities/cases/Case';
import { CaseDeadline } from '@shared/business/entities/CaseDeadline';
import { Correspondence } from '@shared/business/entities/Correspondence';
import { DocketEntry } from '@shared/business/entities/DocketEntry';
import { IrsPractitioner } from '@shared/business/entities/IrsPractitioner';
import { Message } from '@shared/business/entities/Message';
import { PrivatePractitioner } from '@shared/business/entities/PrivatePractitioner';
import { ServerApplicationContext } from '@web-api/applicationContext';
import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser';
import { WorkItem } from '../../../../../shared/src/business/entities/WorkItem';
import { WorkItem } from '@shared/business/entities/WorkItem';
import { getCaseByDocketNumber } from '@web-api/persistence/postgres/cases/getCaseByDocketNumber';
import { getMessagesByDocketNumber } from '@web-api/persistence/postgres/messages/getMessagesByDocketNumber';
import { getWorkItemsByDocketNumber } from '@web-api/persistence/postgres/workitems/getWorkItemsByDocketNumber';
Expand Down Expand Up @@ -425,9 +424,8 @@ export const updateCaseAndAssociations = async ({
}): Promise<RawCase> => {
const newCaseEntity: Case = caseToUpdate.validate
? caseToUpdate
: CaseFactory.getFullCase({
rawCase: caseToUpdate,
user: authorizedUser,
: new Case(caseToUpdate, {
authorizedUser,
});

const oldCaseEntity = await getCaseByDocketNumber({
Expand All @@ -437,9 +435,8 @@ export const updateCaseAndAssociations = async ({

const validNewRawCaseEntity = newCaseEntity.validate().toRawObject();

const validRawOldCaseEntity = CaseFactory.getFullCase({
rawCase: oldCaseEntity,
user: authorizedUser,
const validRawOldCaseEntity = new Case(oldCaseEntity, {
authorizedUser,
})
.validate()
.toRawObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { TUserContact } from '@web-api/business/useCases/user/generateChangeOfAd
import { aggregatePartiesForService } from '@shared/business/utilities/aggregatePartiesForService';
import { clone } from 'lodash';
import { generateAndServeDocketEntry } from '@web-api/business/useCaseHelper/service/createChangeItems';
import { getCaseByDocketNumber } from '@web-api/persistence/postgres/cases/getCaseByDocketNumber';

/**
* generateChangeOfAddressHelper
Expand Down Expand Up @@ -52,12 +53,10 @@ export const generateChangeOfAddressHelper = async ({
try {
const newData = contactInfo;

const userCase = await applicationContext
.getPersistenceGateway()
.getCaseByDocketNumber({
applicationContext,
docketNumber,
});
const userCase = await getCaseByDocketNumber({
applicationContext,
docketNumber,
});
let caseEntity = new Case(userCase, {
authorizedUser,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
formatNow,
} from '../../../../../shared/src/business/utilities/DateHandler';
import { PetitionService } from '@shared/business/utilities/emailGenerator/emailTemplates/PetitionService';
import { setServiceIndicatorsForPetitionersOnCase } from '@shared/business/utilities/setServiceIndicatorsForPetitionersOnCase';
import React from 'react';
import ReactDOM from 'react-dom/server';

Expand All @@ -19,9 +20,7 @@ export const sendIrsSuperuserPetitionEmail = async ({
throw new Error('Cannot serve a docket entry without an index.');
}

const caseDetail = applicationContext
.getUtilities()
.setServiceIndicatorsForCase(caseEntity);
const caseDetail = setServiceIndicatorsForPetitionersOnCase(caseEntity);

const {
caseCaption,
Expand Down
Loading

0 comments on commit 5742a7f

Please sign in to comment.