Skip to content

Commit

Permalink
feat(removing type/subtype): Removing type and subtype from ui (#454)
Browse files Browse the repository at this point in the history
* Update site title

* init fields to medicaid submittion form

* submission comments

* update isprod check for next domain

* update title check test

* adjust layout width

* Revert "adjust layout width"

This reverts commit 9f6889f.

* add subject and description to submit forms

* adjust some fields did some refactoring

* remove temo form

* lots of refactoring

* move dashboard to feature

* getAllForms hood refactor structure

* add types and subtypes schemas

* add subject and description

* add useGetPackageTypes

* refactor authority, type, and subtype.  move to a pattern of lookup indices.

* remove tests... little value, just confusing at this point

* reset file to clear junk diff

* remove commented lines

* remove unused func

* remove comments

* lint

* remove comment

* remove file

* lint

* type to clear vs code red line

* lint

* remove unused vars

* Correct custom resource replies

* added some api calls and hooks

* add subtypes stuff

* filter for do not use

* update query and waiver implimentation

* update submit query

* fix table name typo

* refactor

* refactor inports

* updates per paul

* prettier"

* middle ground ish

* yes

* rename

* asdf

* Add back

* ok

* ok

* asdf

* align names

* asdf

* break the seatool index sink away, for operational speed.

* correct logic for disabled triggers

* update decode record util

* added shared comps

* Refactor our sinks and reindex workflow

* Set status to undefined when undefined

* skip records without a status

* types

* fix conflicts

* update getAllForms

* update types and detail and page

* fix unit tests

* refactor

* lots of refactors

* refactor

* add deconde thing back

* temp comment four fields stuff out

* clean up

* remove unused api/util/seatoolservice

* Remove remaining repack stuff

* uncomment additinal seatool fields

* update details page fields

* update type and subtype fields and stuff

* update more stuff and queries

* update styles

* update that details page sidebar thing

* style updates

* pushing pixels

* pushing pixels

* use a transaction with commit and rollback for submit handler

* write types and subtypes as a single insert to reduce pressure on ksql and increase performance

* collapse action type into main query

* i am danerous, iceman

* fixing an issue... pulling authority id from the static map

* remove transmit begin

* Bring back review team thing

* Bug fixes

* small bug fixes

* substitute some weird characters in type and subtype

* better

* Adding fetchTypes tests and adjust styling

* Add subtype tests and prettierrc file :0

* Combined type/subtype hooks and tests and mocks

* Remove unused files

* Pushing pixels

* Pixel pushing

* Update sidebar for details page

* typo

* Merge with master

* Fixed sidebar bug

* fixing bugs

* fixing bugs

* Bug Fixes

* Add size to query

* Bug fixes withn subtypes

* Remainnig bug squashing

* Squashed the rest of the bugs

* Add waivered shared comps

* Remove type and subtype from ui

* Update default sort order

---------

Co-authored-by: Mike Dial <[email protected]>
Co-authored-by: Mike Dial <[email protected]>
  • Loading branch information
3 people authored Mar 19, 2024
1 parent 627eaff commit 7318884
Show file tree
Hide file tree
Showing 11 changed files with 170 additions and 445 deletions.
175 changes: 91 additions & 84 deletions src/services/api/handlers/submit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ import {
lookupUserAttributes,
} from "../libs/auth/user";

import { Action, Authority, SEATOOL_AUTHORITIES, onemacSchema } from "shared-types";
import {
Action,
Authority,
SEATOOL_AUTHORITIES,
onemacSchema,
} from "shared-types";
import {
getAvailableActions,
getNextBusinessDayTimestamp,
Expand Down Expand Up @@ -52,7 +57,7 @@ export const submit = async (event: APIGatewayEvent) => {
Authority.CHIP_SPA,
Authority.MED_SPA,
Authority["1915b"],
Authority["1915c"], // We accept amendments, renewals, and extensions for Cs
Authority["1915c"], // We accept amendments, renewals, and extensions for Cs
];
if (!activeSubmissionTypes.includes(body.authority)) {
return response({
Expand All @@ -63,76 +68,76 @@ export const submit = async (event: APIGatewayEvent) => {
});
}

const authDetails = getAuthDetails(event);
const userAttr = await lookupUserAttributes(
authDetails.userId,
authDetails.poolId
);
const authDetails = getAuthDetails(event);
const userAttr = await lookupUserAttributes(
authDetails.userId,
authDetails.poolId,
);

// I think we need to break this file up. A switch maybe
if (
[Authority["1915b"], Authority["1915c"]].includes(body.authority) &&
body.seaActionType === "Extend"
) {
console.log("Received a new temporary extension sumbission");

// Check that this action can be performed on the original waiver
const originalWaiver = await getPackage(body.originalWaiverNumber);
console.log(originalWaiver);
const originalWaiverAvailableActions: Action[] = getAvailableActions(
userAttr,
originalWaiver._source
);
if (!originalWaiverAvailableActions.includes(Action.TEMP_EXTENSION)) {
const actionType = Action.TEMP_EXTENSION;
const id = body.originalWaiverNumber;
console.log(
`Package ${body.originalWaiverNumber} is not a candidate to receive a Temporary Extension`
);
return response({
statusCode: 401,
body: {
message: `You are not authorized to perform ${actionType} on ${id}`,
},
});
}

// Safe parse the body
const eventBody = onemacSchema.safeParse(body);
if (!eventBody.success) {
return console.log(
"MAKO Validation Error. The following record failed to parse: ",
JSON.stringify(eventBody),
"Because of the following Reason(s): ",
eventBody.error.message
);
}
// I think we need to break this file up. A switch maybe
if (
[Authority["1915b"], Authority["1915c"]].includes(body.authority) &&
body.seaActionType === "Extend"
) {
console.log("Received a new temporary extension sumbission");

// Check that this action can be performed on the original waiver
const originalWaiver = await getPackage(body.originalWaiverNumber);
console.log(originalWaiver);
const originalWaiverAvailableActions: Action[] = getAvailableActions(
userAttr,
originalWaiver._source,
);
if (!originalWaiverAvailableActions.includes(Action.TEMP_EXTENSION)) {
const actionType = Action.TEMP_EXTENSION;
const id = body.originalWaiverNumber;
console.log(
"Safe parsed event body" + JSON.stringify(eventBody.data, null, 2)
);

await produceMessage(
process.env.topicName as string,
body.id,
JSON.stringify({
...eventBody.data,
submissionDate: getNextBusinessDayTimestamp(),
statusDate: seaToolFriendlyTimestamp(),
changedDate: Date.now(),
})
`Package ${body.originalWaiverNumber} is not a candidate to receive a Temporary Extension`,
);

return response({
statusCode: 200,
body: { message: "success" },
statusCode: 401,
body: {
message: `You are not authorized to perform ${actionType} on ${id}`,
},
});
}

// Safe parse the body
const eventBody = onemacSchema.safeParse(body);
if (!eventBody.success) {
return console.log(
"MAKO Validation Error. The following record failed to parse: ",
JSON.stringify(eventBody),
"Because of the following Reason(s): ",
eventBody.error.message,
);
}
console.log(
"Safe parsed event body" + JSON.stringify(eventBody.data, null, 2),
);

await produceMessage(
process.env.topicName as string,
body.id,
JSON.stringify({
...eventBody.data,
submissionDate: getNextBusinessDayTimestamp(),
statusDate: seaToolFriendlyTimestamp(),
changedDate: Date.now(),
}),
);

return response({
statusCode: 200,
body: { message: "success" },
});
}

const today = seaToolFriendlyTimestamp();
const submissionDate = getNextBusinessDayTimestamp();
console.log(
"Initial Submission Date determined to be: " +
new Date(submissionDate).toISOString()
new Date(submissionDate).toISOString(),
);

// Open the connection pool and transaction outside of the try/catch/finally
Expand All @@ -149,15 +154,15 @@ export const submit = async (event: APIGatewayEvent) => {
"MAKO Validation Error. The following record failed to parse: ",
JSON.stringify(eventBody),
"Because of the following Reason(s): ",
eventBody.error.message
eventBody.error.message,
);
}

// Resolve the the Plan_Type_ID
const authorityId = findAuthorityIdByName(body.authority);
// Resolve the actionTypeID, if applicable
const actionTypeSelect = [Authority["1915b"], Authority.CHIP_SPA].includes(
body.authority
body.authority,
)
? `
SELECT @ActionTypeID = Action_ID FROM SEA.dbo.Action_Types
Expand All @@ -166,23 +171,25 @@ export const submit = async (event: APIGatewayEvent) => {
`
: "SET @ActionTypeID = NULL;";

// Generate INSERT statements for typeIds
const typeIdsValues = body.typeIds
.map((typeId: number) => `('${body.id}', '${typeId}')`)
.join(",\n");
// perhaps someday... but for now... it is but a memory.

// // Generate INSERT statements for typeIds
// const typeIdsValues = body.typeIds
// .map((typeId: number) => `('${body.id}', '${typeId}')`)
// .join(",\n");

const typeIdsInsert = typeIdsValues
? `INSERT INTO SEA.dbo.State_Plan_Service_Types (ID_Number, Service_Type_ID) VALUES ${typeIdsValues};`
: "";
// const typeIdsInsert = typeIdsValues
// ? `INSERT INTO SEA.dbo.State_Plan_Service_Types (ID_Number, Service_Type_ID) VALUES ${typeIdsValues};`
// : "";

// Generate INSERT statements for subTypeIds
const subTypeIdsValues = body.subTypeIds
.map((subTypeId: number) => `('${body.id}', '${subTypeId}')`)
.join(",\n");
// // Generate INSERT statements for subTypeIds
// const subTypeIdsValues = body.subTypeIds
// .map((subTypeId: number) => `('${body.id}', '${subTypeId}')`)
// .join(",\n");

const subTypeIdsInsert = subTypeIdsValues
? `INSERT INTO SEA.dbo.State_Plan_Service_SubTypes (ID_Number, Service_SubType_ID) VALUES ${subTypeIdsValues};`
: "";
// const subTypeIdsInsert = subTypeIdsValues
// ? `INSERT INTO SEA.dbo.State_Plan_Service_SubTypes (ID_Number, Service_SubType_ID) VALUES ${subTypeIdsValues};`
// : "";

const query = `
DECLARE @RegionID INT;
Expand All @@ -200,7 +207,7 @@ export const submit = async (event: APIGatewayEvent) => {
DECLARE @StatusMemo NVARCHAR(MAX) = ${buildStatusMemoQuery(
body.id,
"Package Submitted",
"insert"
"insert",
)}
DECLARE @PlanTypeID INT = ${authorityId}
Expand All @@ -221,13 +228,13 @@ export const submit = async (event: APIGatewayEvent) => {
-- Main insert into State_Plan
INSERT INTO SEA.dbo.State_Plan (ID_Number, State_Code, Title_Name, Summary_Memo, Region_ID, Plan_Type, Submission_Date, Status_Date, Proposed_Date, SPW_Status_ID, Budget_Neutrality_Established_Flag, Status_Memo, Action_Type)
VALUES ('${body.id}', '${body.state}', @TitleName, @SummaryMemo, @RegionID, @PlanTypeID, @SubmissionDate, @StatusDate, @ProposedDate, @SPWStatusID, 0, @StatusMemo, @ActionTypeID);
`;

-- Insert all types into State_Plan_Service_Types
${typeIdsInsert}
// -- Insert all types into State_Plan_Service_Types
// ${typeIdsInsert}

-- Insert all types into State_Plan_Service_SubTypes
${subTypeIdsInsert}
`;
// -- Insert all types into State_Plan_Service_SubTypes
// ${subTypeIdsInsert}

// data for emails
body.notificationMetadata = {
Expand All @@ -243,7 +250,7 @@ export const submit = async (event: APIGatewayEvent) => {
await produceMessage(
process.env.topicName as string,
body.id,
JSON.stringify(eventBody.data)
JSON.stringify(eventBody.data),
);

// Commit transaction if we've made it this far
Expand Down
10 changes: 0 additions & 10 deletions src/services/ui/src/features/submission/spa/chip-intitial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ import { useQuery as useQueryString } from "@/hooks";
import {
DescriptionInput,
SubjectInput,
TypeSelect,
SubTypeSelect,
AdditionalInfoInput,
} from "../shared-components";

Expand All @@ -51,8 +49,6 @@ const formSchema = z.object({
.trim()
.min(1, { message: "This field is required" })
.max(4000, { message: "Description should be under 4000 characters" }),
typeIds: z.array(z.number()).min(1, { message: "Required" }),
subTypeIds: z.array(z.number()).min(1, { message: "Required" }),
attachments: z.object({
currentStatePlan: zAttachmentRequired({ min: 1 }),
amendedLanguage: zAttachmentRequired({ min: 1 }),
Expand Down Expand Up @@ -206,12 +202,6 @@ export const ChipSpaFormPage = () => {
name="description"
helperText="A summary of the SPA. This should include details about a reduction or increase, the amount of the reduction or increase, Federal Budget impact, and fiscal year. If there is a reduction, indicate if the EPSDT population is or isn’t exempt from the reduction."
/>
<TypeSelect
control={form.control}
name="typeIds"
authorityId={124} // chip authority
/>
<SubTypeSelect authorityId={124} />
</SectionCard>
<SectionCard title="Attachments">
<Content.AttachmentsSizeTypesDesc faqLink="/faq/chip-spa-attachments" />
Expand Down
12 changes: 0 additions & 12 deletions src/services/ui/src/features/submission/spa/medicaid-initial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ import { useQuery as useQueryString } from "@/hooks";
import {
AdditionalInfoInput,
DescriptionInput,
SubTypeSelect,
SubjectInput,
TypeSelect,
} from "../shared-components";

const formSchema = z.object({
Expand All @@ -51,8 +49,6 @@ const formSchema = z.object({
.trim()
.min(1, { message: "This field is required" })
.max(4000, { message: "Description should be under 4000 characters" }),
typeIds: z.array(z.number()).min(1, { message: "Required" }),
subTypeIds: z.array(z.number()).min(1, { message: "Required" }),
attachments: z.object({
cmsForm179: zAttachmentRequired({
min: 1,
Expand Down Expand Up @@ -208,14 +204,6 @@ export const MedicaidSpaFormPage = () => {
name="description"
helperText="A summary of the SPA. This should include details about a reduction or increase, the amount of the reduction or increase, Federal Budget impact, and fiscal year. If there is a reduction, indicate if the EPSDT population is or isn’t exempt from the reduction."
/>
<TypeSelect
control={form.control}
name="typeIds"
authorityId={125} // medicaid authority
/>
<SubTypeSelect
authorityId={125}
/>
</SectionCard>
<SectionCard title="Attachments">
<Content.AttachmentsSizeTypesDesc
Expand Down
Loading

0 comments on commit 7318884

Please sign in to comment.