From 026c135bfedd6a09e3a814c9a654712accc0de5a Mon Sep 17 00:00:00 2001 From: jimmyfagan Date: Fri, 13 Dec 2024 12:12:14 -0600 Subject: [PATCH] Missing piece of last commit --- client/src/components/patientData.tsx | 13 +++++++++++-- server/index.ts | 11 +++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/client/src/components/patientData.tsx b/client/src/components/patientData.tsx index 27f0fe2..33d1dcf 100644 --- a/client/src/components/patientData.tsx +++ b/client/src/components/patientData.tsx @@ -30,7 +30,11 @@ export default function PatientData() { window.location.href = "/"; }); console.log(authUrlResponseData); - } + } + async function goLoadDefaults() { + const loadDefaultsResponse = await axios.get(`/api/bluebutton/loadDefaults`); + window.location.href = loadDefaultsResponse.data || '/'; + } /* DEVELOPER NOTES: * Here we are hard coding the users information for the sake of saving time @@ -50,7 +54,12 @@ export default function PatientData() {

{ header }

- +
+ +
+
+ +
); diff --git a/server/index.ts b/server/index.ts index 84479e4..f71a070 100644 --- a/server/index.ts +++ b/server/index.ts @@ -1,5 +1,6 @@ import express, { Request, Response } from "express"; import { AuthorizationToken, BlueButton } from "cms-bluebutton-sdk"; +import * as fs from "fs"; interface User { authToken?: AuthorizationToken, @@ -99,6 +100,16 @@ app.get("/api/bluebutton/callback", (req: Request, res: Response) => { )(req, res); }); +app.get("/api/bluebutton/loadDefaults", (req: Request, res: Response) => { + loggedInUser.eobData = loadDataFile("Dataset 1", "eobData"); + res.send(process.env.SELENIUM_TESTS ? 'http://client:3000' : 'http://localhost:3000'); +}); + +// helper to load json data from file +function loadDataFile(dataset_name: string, resource_file_name: string) { + return JSON.parse(fs.readFileSync(`./default_datasets/${dataset_name}/${resource_file_name}.json`, 'utf-8')) +} + // data flow: front end fetch eob app.get("/api/data/benefit", (req: Request, res: Response) => { if (loggedInUser.eobData) {