Skip to content

Commit

Permalink
fix(actions): Updating action template and forms content (#322)
Browse files Browse the repository at this point in the history
* Add missing additional info instrucitons

* Update attachment label

* Add dynamic instructions for WithdrawPackage

* Details dynamic title

* Dynamic additional info text

* Update zod schemas

* Update required addl info

* use zod for extra conditions

* Update condition

* Update condition

* Schema rule and error updates for withdrawpackage med spa

* Fix respond to rai requirements

* Remove old additional requirement method

* Variable name changes

* Fix submit on cancel button

* Add pre-commit message on template for state user actions

* Refactor preSubmitMessage

* Width fix
  • Loading branch information
Kevin Haube authored Jan 19, 2024
1 parent f2a859d commit f7cbba5
Show file tree
Hide file tree
Showing 18 changed files with 187 additions and 157 deletions.
3 changes: 1 addition & 2 deletions src/packages/shared-utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
export * from "./user-helper";
export * from "./s3-url-parser";
export { isStateUser } from "./is-state-user";
export * from "./rai-helper";
export * from "./regex";
export * from "./package-actions/getAvailableActions";
export * from "./packageCheck";
export * from "./seatool-date-helper"
export * from "./seatool-date-helper";
12 changes: 0 additions & 12 deletions src/packages/shared-utils/is-state-user.ts

This file was deleted.

17 changes: 10 additions & 7 deletions src/packages/shared-utils/package-actions/rules.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { Action, ActionRule, SEATOOL_STATUS, finalDispositionStatuses } from "../../shared-types";
import { isCmsUser, isStateUser, isCmsReadonlyUser, isCmsWriteUser } from "../user-helper";
import { PackageCheck } from "../packageCheck";
import {
Action,
ActionRule,
SEATOOL_STATUS,
finalDispositionStatuses,
} from "../../shared-types";
import { isStateUser, isCmsWriteUser } from "../user-helper";

const arIssueRai: ActionRule = {
action: Action.ISSUE_RAI,
Expand All @@ -24,7 +28,7 @@ const arEnableWithdrawRaiResponse: ActionRule = {
checker.isNotWithdrawn &&
checker.hasRaiResponse &&
!checker.hasEnabledRaiWithdraw &&
isCmsWriteUser(user)
isCmsWriteUser(user),
};

const arDisableWithdrawRaiResponse: ActionRule = {
Expand All @@ -33,7 +37,7 @@ const arDisableWithdrawRaiResponse: ActionRule = {
checker.isNotWithdrawn &&
checker.hasRaiResponse &&
checker.hasEnabledRaiWithdraw &&
isCmsWriteUser(user)
isCmsWriteUser(user),
};

const arWithdrawRaiResponse: ActionRule = {
Expand All @@ -47,8 +51,7 @@ const arWithdrawRaiResponse: ActionRule = {
const arWithdrawPackage: ActionRule = {
action: Action.WITHDRAW_PACKAGE,
check: (checker, user) =>
!checker.hasStatus(finalDispositionStatuses)
&& isStateUser(user),
!checker.hasStatus(finalDispositionStatuses) && isStateUser(user),
};

export default [
Expand Down
29 changes: 19 additions & 10 deletions src/packages/shared-utils/user-helper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { CMS_ROLES, CMS_WRITE_ROLES, CMS_READ_ONLY_ROLES, CognitoUserAttributes, STATE_ROLES } from "../shared-types";
import {
CMS_ROLES,
CMS_WRITE_ROLES,
CMS_READ_ONLY_ROLES,
CognitoUserAttributes,
STATE_ROLES,
} from "../shared-types";

export const isCmsUser = (user: CognitoUserAttributes) => {
const userRoles = user["custom:cms-roles"];
Expand Down Expand Up @@ -31,16 +37,19 @@ export const isCmsReadonlyUser = (user: CognitoUserAttributes) => {
}
}
return false;
}
};

export const isStateUser = (user: CognitoUserAttributes) => {
const userRoles = user["custom:cms-roles"];
export const isStateUser = (user: CognitoUserAttributes | null) => {
if (!user) {
return false;
} else {
const userRoles = user["custom:cms-roles"];

for (const role of STATE_ROLES) {
if (userRoles.includes(role)) {
return true;
for (const role of STATE_ROLES) {
if (userRoles.includes(role)) {
return true;
}
}
return false;
}
return false;

}
};
16 changes: 0 additions & 16 deletions src/services/ui/src/hooks/useActionFormController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,17 @@ import { submit } from "@/api/submissionService";
import { buildActionUrl } from "@/lib";
import { PlanType } from "shared-types";

type DataConditionError = {
message: string;
};

export const useActionSubmitHandler = <D extends FieldValues>({
authority,
addDataConditions,
}: {
formHookReturn: UseFormReturn<D>;
authority: PlanType;
/** Reserved for things zod cannot check. */
addDataConditions?: ((data: D) => DataConditionError | null)[];
}): SubmitHandler<D> => {
const { id, type } = useParams("/action/:id/:type");
const { data: user } = useGetUser();
const { setSuccessModalOpen, setErrorModalOpen } = useModalContext();
return async (data) => {
try {
if (addDataConditions?.length) {
const errors = addDataConditions
.map((fn) => fn(data))
.filter((err) => err) // Filter out nulls
.map((err) => err?.message);
if (errors.length)
throw Error(`Additional conditions were not met: ${errors}`);
}
// TODO: Type update for submit generic
await submit<D & { id: string }>({
data: { ...data, id: id! },
endpoint: buildActionUrl(type!),
Expand Down
35 changes: 18 additions & 17 deletions src/services/ui/src/pages/actions/IssueRai.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as I from "@/components/Inputs";
import { useForm } from "react-hook-form";
import { z } from "zod";
import { zodResolver } from "@hookform/resolvers/zod";
import { opensearch, PlanType } from "shared-types";
import { ActionFormTemplate } from "@/pages/actions/template";
import { useActionSubmitHandler } from "@/hooks/useActionFormController";
import { ActionFormIntro } from "@/pages/actions/common";
import { FormSetup } from "@/pages/actions/setups";

const preSubmitMessage =
"Once you submit this form, a confirmation email is sent to you and to the State.";
export const RaiIssue = ({
item,
schema,
Expand All @@ -26,25 +26,26 @@ export const RaiIssue = ({
item={item}
formController={form}
submitHandler={handleSubmit}
intro={
<ActionFormIntro title={"Formal RAI Details"}>
<I.RequiredIndicator /> Indicates a required field
<p className="font-light mb-6 max-w-4xl">
Issuance of a Formal RAI in OneMAC will create a Formal RAI email
sent to the State. This will also create a section in the package
details summary for you and the State to have record. Please attach
the Formal RAI Letter along with any additional information or
comments in the provided text box. Once you submit this form, a
confirmation email is sent to you and to the State.{" "}
<strong className="bold">
If you leave this page, you will lose your progress on this form.
</strong>
</p>
</ActionFormIntro>
title={"Formal RAI Details"}
description={
<p className="font-light mb-6 max-w-4xl">
Issuance of a Formal RAI in OneMAC will create a Formal RAI email sent
to the State. This will also create a section in the package details
summary for you and the State to have record. Please attach the Formal
RAI Letter along with any additional information or comments in the
provided text box. {preSubmitMessage}
<strong className="bold">
If you leave this page, you will lose your progress on this form.
</strong>
</p>
}
preSubmitMessage={preSubmitMessage}
attachments={attachments}
attachmentFaqLink={"/faq/#medicaid-spa-rai-attachments"}
requireAddlInfo
addlInfoInstructions={
<p>Add anything else that you would like to share with the State.</p>
}
/>
);
};
26 changes: 11 additions & 15 deletions src/services/ui/src/pages/actions/RespondToRai.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as I from "@/components/Inputs";
import { useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import { opensearch, PlanType } from "shared-types";
import { useActionSubmitHandler } from "@/hooks/useActionFormController";
import { ActionFormIntro } from "@/pages/actions/common";
import { ActionFormTemplate } from "@/pages/actions/template";
import { FormSetup } from "@/pages/actions/setups";

const preSubmitMessage =
"Once you submit this form, a confirmation email is sent to you and to CMS. CMS will use this content to review your package, and you will not be able to edit this form. If CMS needs any additional information, they will follow up by email.";
export const RespondToRai = ({
item,
schema,
Expand All @@ -27,20 +27,16 @@ export const RespondToRai = ({
item={item}
formController={form}
submitHandler={handleSubmit}
intro={
<ActionFormIntro title={`${item._source.planType} Formal RAI Details`}>
<I.RequiredIndicator /> Indicates a required field
<p className="font-light mb-6 max-w-4xl">
Once you submit this form, a confirmation email is sent to you and
to CMS. CMS will use this content to review your package, and you
will not be able to edit this form. If CMS needs any additional
information, they will follow up by email.{" "}
<strong className="bold">
If you leave this page, you will lose your progress on this form.
</strong>
</p>
</ActionFormIntro>
title={`${item._source.planType} Formal RAI Details`}
description={
<p className="font-light mb-6 max-w-4xl">
{preSubmitMessage}{" "}
<strong className="bold">
If you leave this page, you will lose your progress on this form.
</strong>
</p>
}
preSubmitMessage={preSubmitMessage}
attachments={attachments}
attachmentFaqLink={"/faq/#medicaid-spa-rai-attachments"}
addlInfoInstructions={
Expand Down
71 changes: 34 additions & 37 deletions src/services/ui/src/pages/actions/WithdrawPackage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,35 @@ import { zodResolver } from "@hookform/resolvers/zod";
import { useActionSubmitHandler } from "@/hooks/useActionFormController";
import { ActionFormTemplate } from "@/pages/actions/template";
import { FormSetup } from "@/pages/actions/setups";
import { SetupOptions } from "@/pages";
import { ReactElement } from "react";

const attachmentInstructions: Record<SetupOptions, ReactElement> = {
"Medicaid SPA": (
<p>
Upload your supporting documentation for withdrawal or explain your need
for withdrawal in the Additional Information section.
</p>
),
"CHIP SPA": (
<p className="font-normal mb-4">
Official withdrawal letters are required and must be on state letterhead
signed by the State Medicaid Director or CHIP Director.
</p>
),
};

const addlInfoInstructions: Record<SetupOptions, ReactElement> = {
"Medicaid SPA": (
<p>
Explain your need for withdrawal, or upload supporting documentation. .
</p>
),
"CHIP SPA": <p>Explain your need for withdrawal.</p>,
};

const preSubmitMessage =
"Once complete, you will not be able to resubmit this package. CMS will be notified and will use this content to review your request. If CMS needs any additional information, they will follow up by email.";
export const WithdrawPackage = ({
item,
schema,
Expand All @@ -21,20 +49,6 @@ export const WithdrawPackage = ({
const handleSubmit = useActionSubmitHandler({
formHookReturn: form,
authority: item?._source.authority as PlanType,
addDataConditions: [
(data) => {
if (
!data.attachments.supportingDocumentation &&
!data.additionalInformation
) {
return {
message: "An Attachment or Additional Information is required.",
};
} else {
return null;
}
},
],
});

if (!item) return <Navigate path={"/"} />; // Prevents optionals below
Expand All @@ -43,35 +57,18 @@ export const WithdrawPackage = ({
item={item}
formController={form}
submitHandler={handleSubmit}
intro={
<ActionFormIntro title={`Withdraw ${item._source.planType} Package`}>
<p>
Complete this form to withdraw a package. Once complete, you will
not be able to resubmit this package. CMS will be notified and will
use this content to review your request. If CMS needs any additional
information, they will follow up by email.
</p>
</ActionFormIntro>
title={`Withdraw ${item._source.planType} Package`}
description={
<p>Complete this form to withdraw a package. {preSubmitMessage}</p>
}
preSubmitMessage={preSubmitMessage}
attachments={attachments}
attachmentFaqLink={"/faq"}
attachmentInstructions={
<p className="font-normal mb-4">
Official withdrawal letters are required and must be on state
letterhead signed by the State Medicaid Director or CHIP Director.
</p>
attachmentInstructions[item!._source.planType as string as SetupOptions]
}
addlInfoInstructions={
<p>
Explain your need for withdrawal, or upload supporting documentation.
<br />
<em>
Once you submit this form, a confirmation email is sent to you and
to CMS. CMS will use this content to review your package. If CMS
needs any additional information, they will follow up by email
</em>
.
</p>
addlInfoInstructions[item!._source.planType as string as SetupOptions]
}
/>
);
Expand Down
20 changes: 10 additions & 10 deletions src/services/ui/src/pages/actions/WithdrawRai.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as I from "@/components/Inputs";
import { zodResolver } from "@hookform/resolvers/zod";
import { useForm } from "react-hook-form";
import { z } from "zod";
import { opensearch, PlanType } from "shared-types";
import { ActionFormTemplate } from "@/pages/actions/template";
import { useActionSubmitHandler } from "@/hooks/useActionFormController";
import { ActionFormIntro } from "@/pages/actions/common";
import { FormSetup } from "@/pages/actions/setups";

const preSubmitMessage =
"Once complete, you and CMS will receive an email confirmation.";
export const WithdrawRai = ({
item,
schema,
Expand All @@ -27,18 +27,18 @@ export const WithdrawRai = ({
item={item}
formController={form}
submitHandler={handleSubmit}
intro={
<ActionFormIntro title={"Withdraw Formal RAI Response Details"}>
<I.RequiredIndicator /> Indicates a required field
<p className="font-light mb-6 max-w-4xl">
Complete this form to withdraw the Formal RAI response. Once
complete, you and CMS will receive an email confirmation.
</p>
</ActionFormIntro>
title={"Withdraw Formal RAI Response Details"}
description={
<p className="font-light mb-6 max-w-4xl">
Complete this form to withdraw the Formal RAI response.{" "}
{preSubmitMessage}
</p>
}
preSubmitMessage={preSubmitMessage}
attachments={attachments}
attachmentFaqLink={"/faq/#medicaid-spa-rai-attachments"}
requireAddlInfo
addlInfoInstructions={<p>Explain your need for withdrawal.</p>}
/>
);
};
Loading

0 comments on commit f7cbba5

Please sign in to comment.