diff --git a/services/app-api/forms/cmit.ts b/services/app-api/forms/cmit.ts index fa22cfc5..dfa585c4 100644 --- a/services/app-api/forms/cmit.ts +++ b/services/app-api/forms/cmit.ts @@ -1,23 +1,22 @@ import { CMIT } from "../types/reports"; -import { DataSource, DeliverySystem } from "../utils/constants"; +import { + DataSource, + DeliverySystem, + MeasureSpecification, +} from "../utils/constants"; export const CMIT_LIST: CMIT[] = [ { - cmit: 111, - name: "my measure", - uid: "abc", - options: "", - deliverySystem: [DeliverySystem.FFS, DeliverySystem.MLTSS], + cmit: 960, + name: "LTSS-1: Comprehensive Assessment and Update", + uid: "960", measureSteward: "CMS", - dataSource: DataSource.Administrative, - }, - { - cmit: 222, - name: "another measure", - uid: "cde", + measureSpecification: [ + MeasureSpecification.CMS, + MeasureSpecification.HEDIS, + ], + deliverySystem: [DeliverySystem.FFS, DeliverySystem.MLTSS], + dataSource: DataSource.Hybrid, options: "", - deliverySystem: [DeliverySystem.FFS], - measureSteward: "CMS", - dataSource: DataSource.Administrative, }, ]; diff --git a/services/app-api/forms/qm.ts b/services/app-api/forms/qm.ts index 4c754f93..cb10bccf 100644 --- a/services/app-api/forms/qm.ts +++ b/services/app-api/forms/qm.ts @@ -4,6 +4,7 @@ import { ElementType, ReportType, MeasureTemplateName, + MeasurePageTemplate, } from "../types/reports"; export const qmReportTemplate: ReportTemplate = { @@ -186,24 +187,19 @@ export const qmReportTemplate: ReportTemplate = { stratified: false, measureTemplate: MeasureTemplateName["LTSS-8"], }, - { - cmit: 234, - required: false, - stratified: false, - measureTemplate: MeasureTemplateName.StandardMeasure, - }, ], }, measureTemplates: { - [MeasureTemplateName.StandardMeasure]: { - id: "req-measure-report", - title: "Example Measure", + [MeasureTemplateName["LTSS-1"]]: { + id: "LTSS-1", + title: "LTSS-1: Comprehensive Assessment and Update", type: PageType.Measure, + substitutable: true, sidebar: false, elements: [ { type: ElementType.ButtonLink, - label: "Return to Required Measures Results Dashboard", + label: "Return to Required Measures Dashboard", to: "req-measure-result", }, { @@ -218,32 +214,72 @@ export const qmReportTemplate: ReportTemplate = { }, { type: ElementType.SubHeader, - text: "Measure Information", + text: "Measure Details", }, { - type: ElementType.Textbox, + type: ElementType.Radio, + label: "Were the reported measure results audited or validated?", + value: [ + { label: "No, I am reporting on this measure", value: "no" }, + { + label: "Yes, CMS is reporting on my behalf", + value: "yes", + checkedChildren: [ + { + type: ElementType.Textbox, + label: + "What is the name of the agency of entity that audited or validated the report?", + }, + ], + }, + ], + }, + { + type: ElementType.Radio, label: - "What is the state performance target for this measure established by the state?", + "What Technical Specifications are you using to report this measure?", + value: [ + { label: "CMS", value: "cms" }, + { label: "HEDIS", value: "hedis" }, + ], }, { type: ElementType.Radio, - label: "Is the performance target approved by CMS?", + label: + "Did you deviate from the [reportYear] Technical Specifications?", value: [ - { label: "Yes", value: "yes" }, { label: "No", value: "no" }, - { label: "In process", value: "inProcess" }, + { + label: "Yes", + value: "yes", + checkedChildren: [ + { + type: ElementType.Textbox, + label: "Please explain the deviation.", + }, + ], + }, + ], + }, + { + type: ElementType.Radio, + label: "Which delivery systems were used to report the LTSS measure?", + value: [ + { label: "Managed Care", value: "managed-care" }, + { label: "Free-For-Service", value: "fee-for-service" }, + { label: "Both", value: "both" }, ], }, + { + type: ElementType.SubHeader, + text: "Quality Measures", + }, + { + type: ElementType.QualityMeasureTable, + measureDisplay: "quality", + }, ], }, - [MeasureTemplateName["LTSS-1"]]: { - id: "LTSS-1", - title: "LTSS-1: Comprehensive Assessment and Update", - type: PageType.Measure, - substitutable: true, - sidebar: false, - elements: [], - }, [MeasureTemplateName["LTSS-2"]]: { id: "LTSS-2", title: "LTSS-2: Comprehensive Person-Centered Plan and Update", @@ -273,5 +309,5 @@ export const qmReportTemplate: ReportTemplate = { sidebar: false, elements: [], }, - }, + } as Record, }; diff --git a/services/app-api/handlers/reports/buildReport.ts b/services/app-api/handlers/reports/buildReport.ts index 8e372acc..550e587e 100644 --- a/services/app-api/handlers/reports/buildReport.ts +++ b/services/app-api/handlers/reports/buildReport.ts @@ -2,12 +2,15 @@ import KSUID from "ksuid"; import { qmReportTemplate } from "../../forms/qm"; import { putReport } from "../../storage/reports"; import { + ElementType, + PageElement, Report, ReportStatus, ReportOptions, ReportType, } from "../../types/reports"; import { User } from "../../types/types"; +import { CMIT_LIST } from "../../forms/cmit"; const reportTemplates = { [ReportType.QM]: qmReportTemplate, @@ -49,6 +52,11 @@ export const buildReport = async ( page.id += measure.cmit; // TODO this will need some logic if a measure is substituted page.stratified = measure.stratified; page.required = measure.required; + page.elements = [ + ...page.elements.map((element) => + findAndReplace(element, measure.cmit) + ), + ]; // TODO: let the parent know what it relates to return page; }); @@ -60,3 +68,13 @@ export const buildReport = async ( await putReport(report); return report; }; + +export const findAndReplace = (element: PageElement, cmit: number) => { + const cmitInfo = CMIT_LIST.find((list) => list.cmit === cmit); + if (cmitInfo) { + if (element.type === ElementType.Header) { + element.text = element.text.replace("{measureName}", cmitInfo.name); + } + } + return element; +}; diff --git a/services/app-api/types/reports.ts b/services/app-api/types/reports.ts index 8c60106f..28a4cee9 100644 --- a/services/app-api/types/reports.ts +++ b/services/app-api/types/reports.ts @@ -1,6 +1,10 @@ // Templates -import { DataSource, DeliverySystem } from "../utils/constants"; +import { + DataSource, + DeliverySystem, + MeasureSpecification, +} from "../utils/constants"; export enum ReportType { QM = "QM", @@ -20,6 +24,7 @@ export interface CMIT { options: string; deliverySystem: DeliverySystem[]; measureSteward: string; + measureSpecification: MeasureSpecification[]; dataSource: DataSource; } @@ -31,7 +36,6 @@ export interface MeasureOptions { } export enum MeasureTemplateName { - StandardMeasure, "LTSS-1", "LTSS-2", "LTSS-6", @@ -156,6 +160,7 @@ export enum ElementType { Radio = "radio", ButtonLink = "buttonLink", MeasureTable = "measureTable", + QualityMeasureTable = "qualityMeasureTable", StatusTable = "statusTable", } @@ -170,6 +175,7 @@ export type PageElement = | RadioTemplate | ButtonLinkTemplate | MeasureTableTemplate + | QualityMeasureTableTemplate | StatusTableTemplate; export type HeaderTemplate = { @@ -221,6 +227,7 @@ export const isResultRowButton = ( export type RadioTemplate = { type: ElementType.Radio; label: string; + helperText?: string; value: ChoiceTemplate[]; }; @@ -233,6 +240,8 @@ export type ButtonLinkTemplate = { export type ChoiceTemplate = { label: string; value: string; + checked?: boolean; + checkedChildren?: PageElement[]; }; export type MeasureTableTemplate = { @@ -240,6 +249,11 @@ export type MeasureTableTemplate = { measureDisplay: "required" | "stratified" | "optional"; }; +export type QualityMeasureTableTemplate = { + type: ElementType.QualityMeasureTable; + measureDisplay: "quality"; +}; + export type StatusTableTemplate = { type: ElementType.StatusTable; to: PageId; diff --git a/services/app-api/utils/constants.ts b/services/app-api/utils/constants.ts index ed872056..c54a1bc7 100644 --- a/services/app-api/utils/constants.ts +++ b/services/app-api/utils/constants.ts @@ -15,12 +15,18 @@ export enum DeliverySystem { export enum DataSource { CaseRecordManagement = "CaseRecordManagement", Administrative = "Administrative", + Hybrid = "Hybrid", } export enum MeasureSteward { CMS = "CMS", } +export enum MeasureSpecification { + CMS = "CMS", + HEDIS = "HEDIS", +} + export enum StateNames { AL = "Alabama", AK = "Alaska", diff --git a/services/ui-src/src/cmit.ts b/services/ui-src/src/cmit.ts new file mode 100644 index 00000000..b4b19c77 --- /dev/null +++ b/services/ui-src/src/cmit.ts @@ -0,0 +1,17 @@ +import { CMIT, DeliverySystem, DataSource, MeasureSpecification } from "types"; + +export const CMIT_LIST: CMIT[] = [ + { + cmit: 960, + name: "LTSS-1: Comprehensive Assessment and Update", + uid: "960", + measureSteward: "CMS", + measureSpecification: [ + MeasureSpecification.CMS, + MeasureSpecification.HEDIS, + ], + deliverySystem: [DeliverySystem.FFS, DeliverySystem.MLTSS], + dataSource: DataSource.Hybrid, + options: "", + }, +]; diff --git a/services/ui-src/src/components/fields/RadioField.test.tsx b/services/ui-src/src/components/fields/RadioField.test.tsx index 7ef12655..f0c4d3ad 100644 --- a/services/ui-src/src/components/fields/RadioField.test.tsx +++ b/services/ui-src/src/components/fields/RadioField.test.tsx @@ -2,7 +2,7 @@ import { render, screen } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; import { RadioField } from "components"; import { useFormContext } from "react-hook-form"; -import { PageElement } from "types"; +import { ElementType, PageElement } from "types"; import { testA11y } from "utils/testing/commonTests"; const mockTrigger = jest.fn(); @@ -37,6 +37,12 @@ const mockRadioElement = { { label: "Choice 2", value: "B", + checkedChildren: [ + { + type: ElementType.Textbox, + label: "mock-text-box", + }, + ], checked: false, }, { @@ -75,6 +81,17 @@ describe("", () => { }); }); + test("RadioField displays children fields after selection", async () => { + mockGetValues(undefined); + render(RadioFieldComponent); + const firstRadio = screen.getByLabelText("Choice 2") as HTMLInputElement; + await userEvent.click(firstRadio); + expect(mockSetValue).toHaveBeenCalledWith("elements.0.answer", "B", { + shouldValidate: true, + }); + expect(screen.getByLabelText("mock-text-box")).toBeInTheDocument(); + }); + testA11y(RadioFieldComponent, () => { mockGetValues(undefined); }); diff --git a/services/ui-src/src/components/fields/RadioField.tsx b/services/ui-src/src/components/fields/RadioField.tsx index 654a534d..09212062 100644 --- a/services/ui-src/src/components/fields/RadioField.tsx +++ b/services/ui-src/src/components/fields/RadioField.tsx @@ -5,13 +5,30 @@ import { useFormContext } from "react-hook-form"; import { ChoiceTemplate, RadioTemplate } from "types"; import { parseCustomHtml } from "utils"; import { ChoiceList as CmsdsChoiceList } from "@cmsgov/design-system"; +import { Page } from "components/report/Page"; + +export const formatChoices = (choices: ChoiceTemplate[], answer?: string) => { + return choices.map((choice) => { + const formatFields = choice?.checkedChildren ? ( + + + + ) : ( + <> + ); + return { + ...choice, + checked: choice.value === answer, + checkedChildren: [formatFields], + }; + }); +}; export const RadioField = (props: PageElementProps) => { const radio = props.element as RadioTemplate; - - const defaultValue = radio.value ?? []; - const [displayValue, setDisplayValue] = - useState(defaultValue); + const [displayValue, setDisplayValue] = useState( + formatChoices(radio.value, radio.answer) ?? [] + ); // get form context and register field const form = useFormContext(); @@ -58,3 +75,12 @@ export const RadioField = (props: PageElementProps) => { ); }; + +const sx = { + children: { + padding: "0 22px", + border: "4px #0071BC solid", + borderWidth: "0 0 0 4px", + margin: "0 14px", + }, +}; diff --git a/services/ui-src/src/components/report/MeasureTable.test.tsx b/services/ui-src/src/components/report/MeasureTable.test.tsx new file mode 100644 index 00000000..25ff3568 --- /dev/null +++ b/services/ui-src/src/components/report/MeasureTable.test.tsx @@ -0,0 +1,40 @@ +import { render, screen } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; +import { MeasureTableElement } from "./MeasureTable"; +import { mockUseStore } from "utils/testing/setupJest"; +import { useStore } from "utils/state/useStore"; +import { ElementType, PageElement } from "types"; + +jest.mock("utils/state/useStore"); +const mockedUseStore = useStore as jest.MockedFunction; +mockedUseStore.mockReturnValue(mockUseStore); + +const mockedMeasureTableElement = { + type: ElementType.MeasureTable, + measureDisplay: "required", +}; + +const MeasureTableComponent = ( + +); + +/* To do: add real test */ +describe("Test MeasureTable", () => { + beforeEach(() => { + render(MeasureTableComponent); + }); + it("Test MeasureTable render", () => { + expect(screen.getByText("mock-title")).toBeInTheDocument(); + }); + it("Test Sustitute button", async () => { + const substituteBtn = screen.getByText("Substitute measure"); + await userEvent.click(substituteBtn); + }); + it("Test Edit button", async () => { + const editBtn = screen.getByText("Edit"); + await userEvent.click(editBtn); + }); +}); diff --git a/services/ui-src/src/components/report/MeasureTable.tsx b/services/ui-src/src/components/report/MeasureTable.tsx index f8e64265..c45082f6 100644 --- a/services/ui-src/src/components/report/MeasureTable.tsx +++ b/services/ui-src/src/components/report/MeasureTable.tsx @@ -21,8 +21,13 @@ import { TableStatusIcon } from "components/tables/TableStatusIcon"; export const MeasureTableElement = (props: PageElementProps) => { const table = props.element as MeasureTableTemplate; - const { report, setModalComponent, setModalOpen, setCurrentPageId } = - useStore(); + const { + report, + setMeasure, + setModalComponent, + setModalOpen, + setCurrentPageId, + } = useStore(); const measures = report?.pages.filter((page) => isMeasureTemplate(page) ) as MeasurePageTemplate[]; @@ -43,6 +48,11 @@ export const MeasureTableElement = (props: PageElementProps) => { setModalComponent(modal); }; + const onEdit = (measure: MeasurePageTemplate) => { + setCurrentPageId(measure.id); + setMeasure(measure.cmit!); + }; + // Build Rows const rows = selectedMeasures.map((measure, index) => { return ( @@ -63,10 +73,7 @@ export const MeasureTableElement = (props: PageElementProps) => { - diff --git a/services/ui-src/src/components/report/Page.test.tsx b/services/ui-src/src/components/report/Page.test.tsx index 81097619..035cdf92 100644 --- a/services/ui-src/src/components/report/Page.test.tsx +++ b/services/ui-src/src/components/report/Page.test.tsx @@ -1,16 +1,17 @@ import { render } from "@testing-library/react"; import { ElementType, PageElement } from "types/report"; import { Page } from "./Page"; +import { mockUseStore } from "utils/testing/setupJest"; +import { useStore } from "utils/state/useStore"; jest.mock("react-router-dom", () => ({ useNavigate: jest.fn(), })); -jest.mock("../../utils/state/useStore", () => ({ - useStore: () => ({ - setCurrentPageId: jest.fn(), - }), -})); +jest.mock("utils/state/useStore"); +const mockedUseStore = useStore as jest.MockedFunction; +mockedUseStore.mockReturnValue(mockUseStore); + jest.mock("react-hook-form", () => ({ useFormContext: () => ({ register: jest.fn(), @@ -21,9 +22,6 @@ jest.mock("react-hook-form", () => ({ jest.mock("./StatusTable", () => { return { StatusTableElement: () =>
Status Table
}; }); -jest.mock("./MeasureTable", () => { - return { MeasureTableElement: () =>
Measure Table
}; -}); const elements: PageElement[] = [ { @@ -55,7 +53,7 @@ const elements: PageElement[] = [ { type: ElementType.Radio, label: "date label", - value: [{ label: "a", value: "1" }], + value: [{ label: "a", value: "1", checkedChildren: [] }], }, { type: ElementType.ButtonLink, @@ -66,9 +64,21 @@ const elements: PageElement[] = [ type: ElementType.MeasureTable, measureDisplay: "stratified", }, + { + type: ElementType.MeasureTable, + measureDisplay: "required", + }, + { + type: ElementType.MeasureTable, + measureDisplay: "optional", + }, { type: ElementType.StatusTable, }, + { + type: ElementType.QualityMeasureTable, + measureDisplay: "quality", + }, ]; describe("Page Component", () => { diff --git a/services/ui-src/src/components/report/Page.tsx b/services/ui-src/src/components/report/Page.tsx index 1fc621a6..11a8cc26 100644 --- a/services/ui-src/src/components/report/Page.tsx +++ b/services/ui-src/src/components/report/Page.tsx @@ -8,6 +8,7 @@ import { } from "./Elements"; import { assertExhaustive, ElementType, PageElement } from "../../types/report"; import { MeasureTableElement } from "./MeasureTable"; +import { QualityMeasureTableElement } from "./QualityMeasureTable"; import { StatusTableElement } from "./StatusTable"; import { TextField, DateField, RadioField } from "components"; @@ -37,6 +38,8 @@ export const Page = ({ elements }: Props) => { return buttonLinkElement; case ElementType.MeasureTable: return MeasureTableElement; + case ElementType.QualityMeasureTable: + return QualityMeasureTableElement; case ElementType.StatusTable: return StatusTableElement; default: diff --git a/services/ui-src/src/components/report/QualityMeasureTable.tsx b/services/ui-src/src/components/report/QualityMeasureTable.tsx new file mode 100644 index 00000000..1324c84c --- /dev/null +++ b/services/ui-src/src/components/report/QualityMeasureTable.tsx @@ -0,0 +1,52 @@ +import { + Button, + Table, + Tbody, + Td, + Th, + Thead, + Tr, + Text, +} from "@chakra-ui/react"; +import { useStore } from "utils"; +import { TableStatusIcon } from "components/tables/TableStatusIcon"; +import { CMIT_LIST } from "cmit"; + +export const QualityMeasureTableElement = () => { + const { cmit } = useStore(); + const cmitInfo = CMIT_LIST.find((item) => item.cmit === cmit); + + // Build Rows + const rows = cmitInfo?.deliverySystem.map((system, index) => { + return ( + + + + + + Delivery Method: {system} + CMIT# {cmit} + + + + + + ); + }); + return ( + + + + + + + + {rows} +
+ Measure Name
+ CMIT Number +
+ ); +}; diff --git a/services/ui-src/src/components/report/ReportPageWrapper.test.tsx b/services/ui-src/src/components/report/ReportPageWrapper.test.tsx index 593f303b..c4bdefb4 100644 --- a/services/ui-src/src/components/report/ReportPageWrapper.test.tsx +++ b/services/ui-src/src/components/report/ReportPageWrapper.test.tsx @@ -1,6 +1,7 @@ import { render, waitFor } from "@testing-library/react"; import { ElementType, + MeasurePageTemplate, MeasureTemplateName, PageType, Report, @@ -53,7 +54,7 @@ const testReport: Report = { ], measureLookup: { defaultMeasures: [], optionGroups: {} }, measureTemplates: { - [MeasureTemplateName.StandardMeasure]: { + [MeasureTemplateName["LTSS-1"]]: { id: "req-measure-report", title: "Example Measure", type: PageType.Measure, @@ -64,9 +65,37 @@ const testReport: Report = { label: "Return to Required Measures Results Dashboard", to: "req-measure-result", }, + { + type: ElementType.QualityMeasureTable, + measureDisplay: "quality", + }, ], }, - }, + [MeasureTemplateName["LTSS-2"]]: { + id: "", + title: "", + type: PageType.Measure, + elements: [], + }, + [MeasureTemplateName["LTSS-6"]]: { + id: "", + title: "", + type: PageType.Measure, + elements: [], + }, + [MeasureTemplateName["LTSS-7"]]: { + id: "", + title: "", + type: PageType.Measure, + elements: [], + }, + [MeasureTemplateName["LTSS-8"]]: { + id: "", + title: "", + type: PageType.Measure, + elements: [], + }, + } as Record, }; const mockUseParams = jest.fn(); diff --git a/services/ui-src/src/types/report.ts b/services/ui-src/src/types/report.ts index 1854a566..4b383aa3 100644 --- a/services/ui-src/src/types/report.ts +++ b/services/ui-src/src/types/report.ts @@ -117,6 +117,7 @@ export enum ElementType { Radio = "radio", ButtonLink = "buttonLink", MeasureTable = "measureTable", + QualityMeasureTable = "qualityMeasureTable", StatusTable = "statusTable", } @@ -130,6 +131,7 @@ export type PageElement = | RadioTemplate | ButtonLinkTemplate | MeasureTableTemplate + | QualityMeasureTableTemplate | StatusTableTemplate; export type HeaderTemplate = { @@ -173,6 +175,11 @@ export type MeasureTableTemplate = { measureDisplay: "required" | "stratified" | "optional"; }; +export type QualityMeasureTableTemplate = { + type: ElementType.QualityMeasureTable; + measureDisplay: "quality"; +}; + export type StatusTableTemplate = { type: ElementType.StatusTable; }; @@ -195,22 +202,29 @@ export type ChoiceTemplate = { label: string; value: string; checked?: boolean; + checkedChildren: PageElement[]; }; export enum DeliverySystem { - FFS, - MLTSS, + FFS = "FFS", + MLTSS = "MLTSS", } export enum DataSource { CaseRecordManagement, Administrative, + Hybrid, } export enum MeasureSteward { CMS, } +export enum MeasureSpecification { + CMS = "CMS", + HEDIS = "HEDIS", +} + export interface ReportOptions { name: string; } @@ -222,6 +236,7 @@ export interface CMIT { options: string; deliverySystem: DeliverySystem[]; measureSteward: string; + measureSpecification: MeasureSpecification[]; dataSource: DataSource; } @@ -233,7 +248,11 @@ export interface MeasureOptions { } export enum MeasureTemplateName { - StandardMeasure, + "LTSS-1", + "LTSS-2", + "LTSS-6", + "LTSS-7", + "LTSS-8", } export interface FormComponent { diff --git a/services/ui-src/src/types/states.ts b/services/ui-src/src/types/states.ts index d7cfafb2..4f1a69fb 100644 --- a/services/ui-src/src/types/states.ts +++ b/services/ui-src/src/types/states.ts @@ -39,6 +39,7 @@ export interface HcbsReportState { modalOpen: boolean; modalComponent?: React.ReactFragment; lastSavedTime?: string; + cmit?: number; // ACTIONS setReport: (report?: Report) => void; @@ -46,4 +47,5 @@ export interface HcbsReportState { setModalOpen: (modalOpen: boolean) => void; setModalComponent: (modalComponent: React.ReactFragment) => void; setAnswers: (answers: any) => void; + setMeasure: (cmit: number) => void; } diff --git a/services/ui-src/src/utils/state/management/reportState.test.ts b/services/ui-src/src/utils/state/management/reportState.test.ts index 75e457d8..d6cdbedb 100644 --- a/services/ui-src/src/utils/state/management/reportState.test.ts +++ b/services/ui-src/src/utils/state/management/reportState.test.ts @@ -1,6 +1,7 @@ import { HcbsReportState } from "types"; import { ElementType, + MeasurePageTemplate, MeasureTemplateName, PageType, Report, @@ -57,7 +58,7 @@ const testReport: Report = { ], measureLookup: { defaultMeasures: [], optionGroups: {} }, measureTemplates: { - [MeasureTemplateName.StandardMeasure]: { + [MeasureTemplateName["LTSS-1"]]: { id: "req-measure-report", title: "Example Measure", type: PageType.Measure, @@ -68,9 +69,37 @@ const testReport: Report = { label: "Return to Required Measures Results Dashboard", to: "req-measure-result", }, + { + type: ElementType.QualityMeasureTable, + measureDisplay: "quality", + }, ], + } as MeasurePageTemplate, + [MeasureTemplateName["LTSS-2"]]: { + id: "", + title: "", + type: PageType.Measure, + elements: [], + }, + [MeasureTemplateName["LTSS-6"]]: { + id: "", + title: "", + type: PageType.Measure, + elements: [], + }, + [MeasureTemplateName["LTSS-7"]]: { + id: "", + title: "", + type: PageType.Measure, + elements: [], + }, + [MeasureTemplateName["LTSS-8"]]: { + id: "", + title: "", + type: PageType.Measure, + elements: [], }, - }, + } as Record, }; describe("state/management/reportState: buildState", () => { diff --git a/services/ui-src/src/utils/state/useStore.ts b/services/ui-src/src/utils/state/useStore.ts index cca13a9a..ee36f6b2 100644 --- a/services/ui-src/src/utils/state/useStore.ts +++ b/services/ui-src/src/utils/state/useStore.ts @@ -68,6 +68,7 @@ const reportStore = (set: Function): HcbsReportState => ({ modalOpen: false, modalComponent: undefined, lastSavedTime: undefined, + cmit: undefined, // actions setReport: (report: Report | undefined) => @@ -88,6 +89,9 @@ const reportStore = (set: Function): HcbsReportState => ({ set((state: HcbsReportState) => mergeAnswers(answers, state), false, { type: "setAnswers", }), + setMeasure: (cmit: number) => { + set(() => ({ cmit }), false, { type: "setMeasure" }); + }, }); export const useStore = create( diff --git a/services/ui-src/src/utils/testing/setupJest.tsx b/services/ui-src/src/utils/testing/setupJest.tsx index 95620f37..d846b825 100644 --- a/services/ui-src/src/utils/testing/setupJest.tsx +++ b/services/ui-src/src/utils/testing/setupJest.tsx @@ -8,6 +8,12 @@ import { HcbsUserState, UserContextShape, AdminBannerState, + HcbsReportState, + ReportType, + ReportStatus, + PageType, + MeasureTemplateName, + MeasurePageTemplate, } from "types"; import { mockBannerData } from "./mockBanner"; // GLOBALS @@ -182,13 +188,63 @@ export const mockAdminUserStore: HcbsUserState = { setShowLocalLogins: () => {}, }; -// BOUND STORE +const mockMeasureTemplate: MeasurePageTemplate = { + id: "mock-template-id", + title: "mock-title", + type: PageType.Measure, + required: true, + substitutable: true, + elements: [], +}; -export const mockUseStore: HcbsUserState & AdminBannerState = { - ...mockStateUserStore, - ...mockBannerStore, +export const mockReportStore: HcbsReportState = { + modalOpen: false, + cmit: 960, + report: { + id: "mock-id", + type: ReportType.QM, + status: ReportStatus.IN_PROGRESS, + title: "mock-report-title", + state: "PR", + pages: [{ ...mockMeasureTemplate, cmit: 960 }], + measureLookup: { + defaultMeasures: [], + optionGroups: {}, + }, + measureTemplates: { + [MeasureTemplateName["LTSS-1"]]: { + ...mockMeasureTemplate, + required: true, + }, + [MeasureTemplateName["LTSS-2"]]: { + ...mockMeasureTemplate, + optional: true, + }, + [MeasureTemplateName["LTSS-6"]]: { + ...mockMeasureTemplate, + stratified: true, + }, + [MeasureTemplateName["LTSS-7"]]: mockMeasureTemplate, + [MeasureTemplateName["LTSS-8"]]: mockMeasureTemplate, + }, + }, + setReport: () => {}, + setCurrentPageId: () => {}, + setModalOpen: () => {}, + setModalComponent: () => {}, + setAnswers: () => {}, + setMeasure: () => {}, }; +// BOUND STORE + +export const mockUseStore: HcbsUserState & AdminBannerState & HcbsReportState = + { + ...mockStateUserStore, + ...mockBannerStore, + ...mockReportStore, + }; + export const mockUseAdminStore: HcbsUserState & AdminBannerState = { ...mockAdminUserStore, ...mockBannerStore,