Skip to content

Commit

Permalink
Add additional Analysis Methods (#11994)
Browse files Browse the repository at this point in the history
Co-authored-by: brittbujacich <[email protected]>
Co-authored-by: Jon Holman <[email protected]>
  • Loading branch information
3 people authored Jan 10, 2025
1 parent 35d3302 commit d0dc4f1
Show file tree
Hide file tree
Showing 8 changed files with 427 additions and 46 deletions.
126 changes: 117 additions & 9 deletions services/app-api/forms/naaar.json
Original file line number Diff line number Diff line change
Expand Up @@ -284,20 +284,12 @@
}
]
},
"dashboardTitle": "",
"dashboardTitle": "Analysis method <br/> Frequency and plan utilization",
"addEntityButtonText": "Add other analysis method",
"editEntityButtonText": "",
"readOnlyEntityButtonText": "",
"tableHeader": "Analysis method <br/> Frequency and plan utilization",
"addEditModalAddTitle": "Analysis method: Add other",
"addEditModalEditTitle": "Analysis method: Edit other",
"deleteEntityButtonAltText": "Delete other analysis method",
"deleteModalTitle": "Are you sure you want to delete this analysis method?",
"deleteModalConfirmButtonText": "Yes, delete method",
"deleteModalWarning": "Are you sure you want to proceed? You will lose all information entered for this analysis method in the NAAAR. The method will remain in previously submitted NAAAR reports if applicable.",
"entityUnfinishedMessage": "Complete the remaining indicators for this access measure by entering details.",
"enterEntityDetailsButtonText": "Enter",
"readOnlyEntityDetailsButtonText": "View",
"drawerTitle": "Analysis method: "
},
"drawerForm": {
Expand Down Expand Up @@ -390,6 +382,15 @@
{
"id": "tvCUw5CcaGUFSIMByAopjF",
"label": "Fill in plans here"
},
{
"id": "tvCUw5CcaGUFSIMByAopjA",
"label": "Second plan"
}
,
{
"id": "tvCUw5CcaGUFSIMByAopjB",
"label": "Third plan with the absolutest most longest name you ever did see in a plan like this one"
}
]
}
Expand All @@ -400,6 +401,113 @@
}
}
]
},
"addEntityDrawerForm": {
"id": "iamnew",
"fields": [
{
"id": "custom_analysis_method_name",
"type": "text",
"validation": "text",
"props": {
"label": "Analysis method",
"hint": "Enter an analysis method utilized to assess plan compliance with the state’s 42 C.F.R. § 438.68 and 42 C.F.R. § 438.206 standards that is not already listed in the system."
}
},
{
"id": "custom_analysis_method_description",
"type": "textarea",
"validation": "textarea",
"props": {
"label": "Analysis method description",
"hint": "Describe the method."
}
},
{
"id": "analysis_method_frequency",
"type": "radio",
"validation": {
"type": "radio",
"nested": true,
"parentFieldName": "analysis_applicable"
},
"props": {
"label": "Frequency of analysis",
"choices": [
{
"id": "Sol1W6HJCixyOVxw4vDgXQ",
"label": "Weekly"
},
{
"id": "YjI3qT3Ml9cZfP4a1RV6G9",
"label": "Bi-weekly"
},
{
"id": "L8q1N1DXEYv8LsDfGkdbOe",
"label": "Monthly"
},
{
"id": "05ThR4UN7kYDGpKaTWESOB",
"label": "Bi-monthly"
},
{
"id": "Y0Rkz7e3Kkxw0T4aFDb38j",
"label": "Quarterly"
},
{
"id": "mcn99pzTOqnEmr3uXiEOYs",
"label": "Semi-annually"
},
{
"id": "r938vpeMJxkPOqk53N7qW0",
"label": "Other, specify",
"children": [
{
"id": "analysis_method_frequency-otherText",
"type": "textarea",
"validation": {
"type": "text",
"nested": true,
"parentFieldName": "analysis_method_frequency"
}
}
]
},
{
"id": "WkqIis4bGGtK8Nzzqa6rPl",
"label": "Varies by plan"
}
]
}
},
{
"id": "analysis_method_applicable_plans",
"type": "checkbox",
"validation": {
"type": "checkbox",
"nested": true,
"parentFieldName": "analysis_applicable"
},
"props": {
"label": "Plans utilizing this method",
"choices": [
{
"id": "tvCUw5CcaGUFSIMByAopjF",
"label": "Fill in plans here"
},
{
"id": "tvCUw5CcaGUFSIMByAopjA",
"label": "Second plan"
}
,
{
"id": "tvCUw5CcaGUFSIMByAopjB",
"label": "Third plan with the absolutest most longest name you ever did see in a plan like this one"
}
]
}
}
]
}
}
]
Expand Down
2 changes: 2 additions & 0 deletions services/app-api/utils/types/reports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export interface DrawerReportPageShape extends ReportPageShapeBase {
entityType: string;
verbiage: DrawerReportPageVerbiage;
drawerForm: FormJson;
addEntityDrawerForm?: FormJson;
modalForm?: never;
overlayForm?: never;
form?: never;
Expand Down Expand Up @@ -115,6 +116,7 @@ export interface DrawerReportPageVerbiage extends ReportPageVerbiage {
dashboardTitle: string;
countEntitiesInTitle?: boolean;
drawerTitle: string;
addEntityButtonText?: string;
drawerInfo?: CustomHtmlElement[];
missingEntityMessage?: CustomHtmlElement[];
missingIlosMessage?: CustomHtmlElement[];
Expand Down
Binary file added services/ui-src/src/assets/icons/icon_add_blue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
162 changes: 161 additions & 1 deletion services/ui-src/src/components/reports/DrawerReportPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ import {
mockEntityStore,
mockVerbiageIntro,
mockDrawerForm,
mockNaaarReportStore,
mockNaaarReportContext,
} from "utils/testing/setupJest";
// constants
import { saveAndCloseText } from "../../constants";
import { DEFAULT_ANALYSIS_METHODS, saveAndCloseText } from "../../constants";
// types
import { McrEntityState } from "types";

const mockUseNavigate = jest.fn();
jest.mock("react-router-dom", () => ({
Expand Down Expand Up @@ -306,6 +310,162 @@ describe("Test DrawerReportPage with completed entity", () => {
});
});

describe("Test DrawerReportPage with custom entities", () => {
afterEach(() => {
jest.clearAllMocks();
});
const mockAnalysisMethodEntityStore: McrEntityState = {
entities: [],
entityType: "analysisMethods",
selectedEntity: {
id: "k9t7YoOeTOAXX3s7qF6XfN33",
name: "Geomapping",
isRequired: true,
},
// ACTIONS
setSelectedEntity: () => {},
setEntityType: () => {},
setEntities: () => {},
};
const mockAnalysisMethodsReportPageJson = {
name: "mock-route",
path: "/naaar/analysis-methods",
pageType: "drawer",
entityType: "analysisMethods",
verbiage: {
intro: mockVerbiageIntro,
dashboardTitle: "Mock dashboard title",
drawerTitle: "Mock drawer title",
addEntityButtonText: "Add other analysis method",
},
drawerForm: {
id: "am",
fields: [
{
id: "am_default_text",
type: "text",
validation: "text",
props: {
label: "Fill in info on analysis method",
},
},
],
},
addEntityDrawerForm: {
id: "am_custom",
fields: [
{
id: "am_custom_text",
type: "text",
validation: "text",
props: {
label: "Fill in info on custom analysis method",
},
},
],
},
};

const mockNaaarReportContextWithAnalysisMethods: any = mockNaaarReportContext;
mockNaaarReportContextWithAnalysisMethods.report.fieldData[
"analysisMethods"
] = [DEFAULT_ANALYSIS_METHODS[0]];

const mockCustomNaaarReportStore = {
...mockNaaarReportStore,
report: mockNaaarReportContextWithAnalysisMethods.report,
reportsByState: [mockNaaarReportContextWithAnalysisMethods.report],
};
const drawerReportPageWithCustomEntities = (
<RouterWrappedComponent>
<ReportContext.Provider value={mockNaaarReportContextWithAnalysisMethods}>
<DrawerReportPage route={mockAnalysisMethodsReportPageJson} />
</ReportContext.Provider>
</RouterWrappedComponent>
);
it("Can enter default analysis method drawer", async () => {
mockedUseStore.mockReturnValue({
...mockStateUserStore,
...mockCustomNaaarReportStore,
...mockAnalysisMethodEntityStore,
});

render(drawerReportPageWithCustomEntities);
const enterDefaultMethod = screen.getAllByText("Enter")[0];
await userEvent.click(enterDefaultMethod);
expect(screen.getByRole("dialog")).toBeVisible();
const textField = await screen.getByLabelText(
"Fill in info on analysis method"
);
expect(textField).toBeVisible();
});

it("Can enter custom analysis method drawer and fill out form", async () => {
const mockAnalysisMethodNoSelectedEntityStore =
mockAnalysisMethodEntityStore;
mockAnalysisMethodNoSelectedEntityStore.selectedEntity = undefined;
mockedUseStore.mockReturnValue({
...mockStateUserStore,
...mockCustomNaaarReportStore,
...mockAnalysisMethodNoSelectedEntityStore,
});

render(drawerReportPageWithCustomEntities);
const addCustomMethod = screen.getByText("Add other analysis method");
await userEvent.click(addCustomMethod);
expect(screen.getByRole("dialog")).toBeVisible();
const customTextField = await screen.getByLabelText(
"Fill in info on custom analysis method"
);
expect(customTextField).toBeVisible();
await userEvent.type(customTextField, "new analysis method");
const saveCustomMethod = screen.getByText("Save & close");
await userEvent.click(saveCustomMethod);
const enterDefaultMethod = screen.getAllByText("Enter")[0];
expect(enterDefaultMethod).toBeVisible();
});

it("Can shows statusing for custom analysis methods", async () => {
const mockNaaarReportContextWithCustomAnalysisMethods: any =
mockNaaarReportContext;
mockNaaarReportContextWithCustomAnalysisMethods.report.fieldData[
"analysisMethods"
] = [
DEFAULT_ANALYSIS_METHODS[0],
{
id: "custom_entity",
name: "custom entity",
},
];

const mockCustomNaaarReportStore = {
...mockNaaarReportStore,
report: mockNaaarReportContextWithCustomAnalysisMethods.report,
reportsByState: [mockNaaarReportContextWithCustomAnalysisMethods.report],
};

mockedUseStore.mockReturnValue({
...mockStateUserStore,
...mockCustomNaaarReportStore,
...mockAnalysisMethodEntityStore,
});

const drawerReportPageWithCustomEntities = (
<RouterWrappedComponent>
<ReportContext.Provider
value={mockNaaarReportContextWithCustomAnalysisMethods}
>
<DrawerReportPage route={mockAnalysisMethodsReportPageJson} />
</ReportContext.Provider>
</RouterWrappedComponent>
);

render(drawerReportPageWithCustomEntities);
const iconAltText = screen.getAllByAltText("Entity is incomplete");
expect(iconAltText.length).toBeGreaterThan(0);
});
});

describe("Test DrawerReportPage accessibility", () => {
it("Should not have basic accessibility issues", async () => {
mockedUseStore.mockReturnValue({
Expand Down
Loading

0 comments on commit d0dc4f1

Please sign in to comment.