Skip to content

Commit

Permalink
Develop front-end pages & states for code mapping tool (UPLOAD flow) (#…
Browse files Browse the repository at this point in the history
…17321)

* Develop front-end pages & states for code mapping tool (UPLOAD flow)
Fixes #16758
  • Loading branch information
jpandersen87 authored Feb 11, 2025
1 parent 9f2d7ec commit fdf1aea
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 0 deletions.
3 changes: 3 additions & 0 deletions frontend-react/public/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,7 @@
<url>
<loc>https://reportstream.cdc.gov/file-handler/validate</loc>
</url>
<url>
<loc>https://reportstream.cdc.gov/onboarding/code-mapping</loc>
</url>
</urlset>
15 changes: 15 additions & 0 deletions frontend-react/src/AppRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ const FacilityProviderSubmitterDetailsPage = lazy(
() => import("./components/DataDashboard/FacilityProviderSubmitterDetails/FacilityProviderSubmitterDetails"),
);
const NewSettingPage = lazy(() => import("./components/Admin/NewSetting"));
const CodeMappingPage = lazy(() => import("./pages/onboarding/CodeMappingPage"));

const MainLayout = lazy(() => import("./layouts/Main/MainLayout"));

Expand Down Expand Up @@ -494,6 +495,20 @@ export const appRoutes: RouteObject[] = [
</RequireGate>
),
},
{
path: "onboarding",
element: (
<RequireGate auth>
<Outlet />
</RequireGate>
),
children: [
{
path: "code-mapping",
element: <CodeMappingPage />,
},
],
},
/* Handles any undefined route */
{
path: "*",
Expand Down
82 changes: 82 additions & 0 deletions frontend-react/src/components/CodeMapping/CodeMappingForm.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import { Button, ButtonGroup, FileInput } from "@trussworks/react-uswds";
import { FormEventHandler, MouseEventHandler, type PropsWithChildren, useCallback } from "react";
import CodeMappingResults from "./CodeMappingResults";
import site from "../../content/site.json";
import useCodeMappingFormSubmit from "../../hooks/api/UseCodeMappingFormSubmit/UseCodeMappingFormSubmit";
import Spinner from "../Spinner";
import { USLink } from "../USLink";

export type CodeMappingFormProps = PropsWithChildren;

const CodeMappingForm = (props: CodeMappingFormProps) => {
const { data, isPending, mutate } = useCodeMappingFormSubmit();
/**
* TODO: Implement submit handler
*/
const onSubmitHandler = useCallback<FormEventHandler<HTMLFormElement>>(
(ev) => {
ev.preventDefault();
mutate();
return false;
},
[mutate],
);
const onBackHandler = useCallback<MouseEventHandler>((_ev) => {
window.history.back();
}, []);
const onCancelHandler = useCallback<MouseEventHandler>((_ev) => {
// Don't have a proper mechanism to cancel in-flight requests so refresh page
window.location.reload();
}, []);

return (
<>
<p className="font-sans-lg">
Check that your LOINC and SNOMED codes are mapped to conditions so ReportStream can accurately transform
your data
</p>
<p>
Follow <a href="/developer-resources/api/getting-started#2_4">these instructions</a> and use{" "}
<a href={site.assets.codeMapTemplate.path}>our template</a> to format your result and organism codes to
LOINC or SNOMED. Note: Local codes cannot be automatically mapped.
</p>
{data && <CodeMappingResults />}
{isPending && (
<>
<Spinner />
<p className="text-center">
Checking your file for any unmapped codes that will <br /> prevent data from being reported
successfully
</p>
<Button type={"button"} outline onClick={onCancelHandler}>
Cancel
</Button>
</>
)}
{!data && !isPending && (
<form onSubmit={onSubmitHandler}>
<label className="usa-label" htmlFor="file-input-specific">
Upload CSV file
</label>
<span className="usa-hint" id="file-input-specific-hint">
Make sure your file has a .csv extension
</span>
<FileInput id={""} name={"file"} className="maxw-full" accept=".csv" />
<ButtonGroup className="margin-top-5">
<Button type={"button"} outline onClick={onBackHandler}>
Back
</Button>
<Button type={"submit"}>Submit</Button>
</ButtonGroup>
</form>
)}
{props.children}
<p className="margin-top-9">
Questions or feedback? Please email{" "}
<USLink href="mailto:reportstream@cdc.gov">reportstream@cdc.gov</USLink>
</p>
</>
);
};

export default CodeMappingForm;
10 changes: 10 additions & 0 deletions frontend-react/src/components/CodeMapping/CodeMappingResults.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { PropsWithChildren } from "react";

export type CodeMappingResultsProps = PropsWithChildren;

/**
* TODO: Implement result page
*/
const CodeMappingResults = (props: CodeMappingResultsProps) => <>TODO {props.children}</>;

export default CodeMappingResults;
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { useMutation } from "@tanstack/react-query";

/**
* TODO: Implement hook
*/
const useCodeMappingFormSubmit = () => {
const fn = async () => {
// Fake request until implementation
await new Promise((resolve) => setTimeout(resolve, 2500));
};
return useMutation({
mutationFn: fn,
});
};

export default useCodeMappingFormSubmit;
16 changes: 16 additions & 0 deletions frontend-react/src/pages/onboarding/CodeMappingPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { PropsWithChildren } from "react";
import CodeMappingForm from "../../components/CodeMapping/CodeMappingForm";

export type CodeMappingPageProps = PropsWithChildren;

const CodeMappingPage = (props: CodeMappingPageProps) => {
return (
<>
<h1>Code mapping tool</h1>
<CodeMappingForm />
{props.children}
</>
);
};

export default CodeMappingPage;

0 comments on commit fdf1aea

Please sign in to comment.