Skip to content

Commit

Permalink
Disable delivery system edit buttons, unless selected (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
benmartin-coforma authored Jan 22, 2025
1 parent 4e5238c commit 35a9fea
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 29 deletions.
64 changes: 37 additions & 27 deletions services/app-api/forms/qms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
MeasureTemplateName,
MeasurePageTemplate,
} from "../types/reports";
import { DeliverySystem } from "../utils/constants";

export const qmsReportTemplate: ReportTemplate = {
type: ReportType.QMS,
Expand Down Expand Up @@ -312,16 +313,17 @@ export const qmsReportTemplate: ReportTemplate = {
},
{
type: ElementType.Radio,
formKey: "delivery-method-radio",
label: "Which delivery systems were used to report this measure?",
value: [
{ label: "Fee-For-Service (FFS)", value: "fee-for-service" },
{ label: "Fee-For-Service (FFS)", value: DeliverySystem.FFS },
{
label: "Managed Long-Term Services and Supports (MLTSS)",
value: "managed-long-term-services-and-supports",
value: DeliverySystem.MLTSS,
},
{
label: "Both FFS and MLTSS (separate)",
value: "both-ffs-and-mltss",
value: [DeliverySystem.FFS, DeliverySystem.MLTSS].join(","),
},
],
},
Expand Down Expand Up @@ -407,16 +409,17 @@ export const qmsReportTemplate: ReportTemplate = {
},
{
type: ElementType.Radio,
formKey: "delivery-method-radio",
label: "Which delivery systems were used to report this measure?",
value: [
{ label: "Fee-For-Service (FFS)", value: "fee-for-service" },
{ label: "Fee-For-Service (FFS)", value: DeliverySystem.FFS },
{
label: "Managed Long-Term Services and Supports (MLTSS)",
value: "managed-long-term-services-and-supports",
value: DeliverySystem.MLTSS,
},
{
label: "Both FFS and MLTSS (separate)",
value: "both-ffs-and-mltss",
value: [DeliverySystem.FFS, DeliverySystem.MLTSS].join(","),
},
],
},
Expand Down Expand Up @@ -503,16 +506,17 @@ export const qmsReportTemplate: ReportTemplate = {
},
{
type: ElementType.Radio,
formKey: "delivery-method-radio",
label: "Which delivery systems were used to report this measure?",
value: [
{ label: "Fee-For-Service (FFS)", value: "fee-for-service" },
{ label: "Fee-For-Service (FFS)", value: DeliverySystem.FFS },
{
label: "Managed Long-Term Services and Supports (MLTSS)",
value: "managed-long-term-services-and-supports",
value: DeliverySystem.MLTSS,
},
{
label: "Both FFS and MLTSS (separate)",
value: "both-ffs-and-mltss",
value: [DeliverySystem.FFS, DeliverySystem.MLTSS].join(","),
},
],
},
Expand Down Expand Up @@ -599,16 +603,17 @@ export const qmsReportTemplate: ReportTemplate = {
},
{
type: ElementType.Radio,
formKey: "delivery-method-radio",
label: "Which delivery systems were used to report this measure?",
value: [
{ label: "Fee-For-Service (FFS)", value: "fee-for-service" },
{ label: "Fee-For-Service (FFS)", value: DeliverySystem.FFS },
{
label: "Managed Long-Term Services and Supports (MLTSS)",
value: "managed-long-term-services-and-supports",
value: DeliverySystem.MLTSS,
},
{
label: "Both FFS and MLTSS (separate)",
value: "both-ffs-and-mltss",
value: [DeliverySystem.FFS, DeliverySystem.MLTSS].join(","),
},
],
},
Expand Down Expand Up @@ -695,16 +700,17 @@ export const qmsReportTemplate: ReportTemplate = {
},
{
type: ElementType.Radio,
formKey: "delivery-method-radio",
label: "Which delivery systems were used to report this measure?",
value: [
{ label: "Fee-For-Service (FFS)", value: "fee-for-service" },
{ label: "Fee-For-Service (FFS)", value: DeliverySystem.FFS },
{
label: "Managed Long-Term Services and Supports (MLTSS)",
value: "managed-long-term-services-and-supports",
value: DeliverySystem.MLTSS,
},
{
label: "Both FFS and MLTSS (separate)",
value: "both-ffs-and-mltss",
value: [DeliverySystem.FFS, DeliverySystem.MLTSS].join(","),
},
],
},
Expand Down Expand Up @@ -782,16 +788,17 @@ export const qmsReportTemplate: ReportTemplate = {
},
{
type: ElementType.Radio,
formKey: "delivery-method-radio",
label: "Which delivery systems were used to report this measure?",
value: [
{ label: "Fee-For-Service (FFS)", value: "fee-for-service" },
{ label: "Fee-For-Service (FFS)", value: DeliverySystem.FFS },
{
label: "Managed Long-Term Services and Supports (MLTSS)",
value: "managed-long-term-services-and-supports",
value: DeliverySystem.MLTSS,
},
{
label: "Both FFS and MLTSS (separate)",
value: "both-ffs-and-mltss",
value: [DeliverySystem.FFS, DeliverySystem.MLTSS].join(","),
},
],
},
Expand Down Expand Up @@ -868,16 +875,17 @@ export const qmsReportTemplate: ReportTemplate = {
},
{
type: ElementType.Radio,
formKey: "delivery-method-radio",
label: "Which delivery systems were used to report this measure?",
value: [
{ label: "Fee-For-Service (FFS)", value: "fee-for-service" },
{ label: "Fee-For-Service (FFS)", value: DeliverySystem.FFS },
{
label: "Managed Long-Term Services and Supports (MLTSS)",
value: "managed-long-term-services-and-supports",
value: DeliverySystem.MLTSS,
},
{
label: "Both FFS and MLTSS (separate)",
value: "both-ffs-and-mltss",
value: [DeliverySystem.FFS, DeliverySystem.MLTSS].join(","),
},
],
},
Expand Down Expand Up @@ -1034,16 +1042,17 @@ export const qmsReportTemplate: ReportTemplate = {
},
{
type: ElementType.Radio,
formKey: "delivery-method-radio",
label: "Which delivery systems were used to report this measure?",
value: [
{ label: "Fee-For-Service (FFS)", value: "fee-for-service" },
{ label: "Fee-For-Service (FFS)", value: DeliverySystem.FFS },
{
label: "Managed Long-Term Services and Supports (MLTSS)",
value: "managed-long-term-services-and-supports",
value: DeliverySystem.MLTSS,
},
{
label: "Both FFS and MLTSS (separate)",
value: "both-ffs-and-mltss",
value: [DeliverySystem.FFS, DeliverySystem.MLTSS].join(","),
},
],
},
Expand Down Expand Up @@ -1129,16 +1138,17 @@ export const qmsReportTemplate: ReportTemplate = {
},
{
type: ElementType.Radio,
formKey: "delivery-method-radio",
label: "Which delivery systems were used to report this measure?",
value: [
{ label: "Fee-For-Service (FFS)", value: "fee-for-service" },
{ label: "Fee-For-Service (FFS)", value: DeliverySystem.FFS },
{
label: "Managed Long-Term Services and Supports (MLTSS)",
value: "managed-long-term-services-and-supports",
value: DeliverySystem.MLTSS,
},
{
label: "Both FFS and MLTSS (separate)",
value: "both-ffs-and-mltss",
value: [DeliverySystem.FFS, DeliverySystem.MLTSS].join(","),
},
],
},
Expand Down
1 change: 1 addition & 0 deletions services/ui-src/src/components/report/Page.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ mockedUseStore.mockReturnValue(mockUseStore);
jest.mock("react-hook-form", () => ({
useFormContext: () => ({
register: jest.fn(),
getValues: jest.fn(),
}),
}));

Expand Down
3 changes: 2 additions & 1 deletion services/ui-src/src/components/report/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ export const Page = ({ elements }: Props) => {

const composedElements = elements.map((element, index) => {
const ComposedElement = renderElement(element);
const formKey = (element as any).formKey ?? buildFormKey(index);
return (
<ComposedElement
formkey={buildFormKey(index)}
formkey={formKey}
key={index}
element={element}
disabled={!userIsEndUser}
Expand Down
28 changes: 28 additions & 0 deletions services/ui-src/src/components/report/QualityMeasureTable.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { QualityMeasureTableElement } from "./QualityMeasureTable";
import { render, screen } from "@testing-library/react";
import { useStore } from "utils";
import { mockUseStore } from "utils/testing/setupJest";

jest.mock("utils/state/useStore");
const mockedUseStore = useStore as jest.MockedFunction<typeof useStore>;
mockedUseStore.mockReturnValue({ ...mockUseStore });

jest.mock("react-hook-form", () => ({
useFormContext: jest.fn().mockReturnValue({
getValues: jest.fn().mockReturnValue({ answer: "FFS" }),
}),
}));

describe("Quality Measure Table", () => {
it("should enable each delivery system's button correctly", () => {
render(<QualityMeasureTableElement />);

const ffsRow = screen.getByRole("row", { name: /FFS CMIT# 960/ });
const ffsButton = ffsRow.querySelector("button");
expect(ffsButton).toBeEnabled();

const mltssRow = screen.getByRole("row", { name: /MLTSS CMIT# 960/ });
const mltssButton = mltssRow.querySelector("button");
expect(mltssButton).toBeDisabled();
});
});
11 changes: 10 additions & 1 deletion services/ui-src/src/components/report/QualityMeasureTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@ import {
import { useStore } from "utils";
import { TableStatusIcon } from "components/tables/TableStatusIcon";
import { CMIT_LIST } from "cmit";
import { useFormContext } from "react-hook-form";

export const QualityMeasureTableElement = () => {
const { cmit } = useStore();
const cmitInfo = CMIT_LIST.find((item) => item.cmit === cmit);
const form = useFormContext();

// Build Rows
const rows = cmitInfo?.deliverySystem.map((system, index) => {
const selections = form.getValues("delivery-method-radio")?.answer ?? "";
const deliverySystemIsSelected = selections.split(",").includes(system);

return (
<Tr key={index}>
<Td>
Expand All @@ -28,7 +33,11 @@ export const QualityMeasureTableElement = () => {
<Text>CMIT# {cmit}</Text>
</Td>
<Td>
<Button variant="outline" onClick={() => {}}>
<Button
variant="outline"
disabled={!deliverySystemIsSelected}
onClick={() => {}}
>
Edit
</Button>
</Td>
Expand Down

0 comments on commit 35a9fea

Please sign in to comment.