Skip to content

Commit

Permalink
Missing piece of last commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyfagan committed Dec 13, 2024
1 parent 39a466d commit 026c135
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
13 changes: 11 additions & 2 deletions client/src/components/patientData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -50,7 +54,12 @@ export default function PatientData() {
<div>
<h4>{ header }</h4>
</div>
<Button id="auth_btn" variation="solid" onClick={goAuthorize}>Authorize</Button>
<div className='ds-u-margin-top--2'>
<Button id="auth_btn" variation="primary" onClick={goAuthorize}>Authorize</Button>
</div>
<div className='ds-u-margin-top--2'>
<Button id="load_defaults_btn" variation="primary" onClick={goLoadDefaults}>Load default data</Button>
</div>
</div>
</div>
);
Expand Down
11 changes: 11 additions & 0 deletions server/index.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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'))

Check failure on line 110 in server/index.ts

View workflow job for this annotation

GitHub Actions / build

This line has a length of 112. Maximum allowed is 100

Check failure on line 110 in server/index.ts

View workflow job for this annotation

GitHub Actions / build

Unsafe return of an `any` typed value
}

// data flow: front end fetch eob
app.get("/api/data/benefit", (req: Request, res: Response) => {
if (loggedInUser.eobData) {
Expand Down

0 comments on commit 026c135

Please sign in to comment.