Skip to content

Commit 026c135

Browse files
committed
Missing piece of last commit
1 parent 39a466d commit 026c135

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

client/src/components/patientData.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ export default function PatientData() {
3030
window.location.href = "/";
3131
});
3232
console.log(authUrlResponseData);
33-
}
33+
}
34+
async function goLoadDefaults() {
35+
const loadDefaultsResponse = await axios.get(`/api/bluebutton/loadDefaults`);
36+
window.location.href = loadDefaultsResponse.data || '/';
37+
}
3438

3539
/* DEVELOPER NOTES:
3640
* Here we are hard coding the users information for the sake of saving time
@@ -50,7 +54,12 @@ export default function PatientData() {
5054
<div>
5155
<h4>{ header }</h4>
5256
</div>
53-
<Button id="auth_btn" variation="solid" onClick={goAuthorize}>Authorize</Button>
57+
<div className='ds-u-margin-top--2'>
58+
<Button id="auth_btn" variation="primary" onClick={goAuthorize}>Authorize</Button>
59+
</div>
60+
<div className='ds-u-margin-top--2'>
61+
<Button id="load_defaults_btn" variation="primary" onClick={goLoadDefaults}>Load default data</Button>
62+
</div>
5463
</div>
5564
</div>
5665
);

server/index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import express, { Request, Response } from "express";
22
import { AuthorizationToken, BlueButton } from "cms-bluebutton-sdk";
3+
import * as fs from "fs";
34

45
interface User {
56
authToken?: AuthorizationToken,
@@ -99,6 +100,16 @@ app.get("/api/bluebutton/callback", (req: Request, res: Response) => {
99100
)(req, res);
100101
});
101102

103+
app.get("/api/bluebutton/loadDefaults", (req: Request, res: Response) => {
104+
loggedInUser.eobData = loadDataFile("Dataset 1", "eobData");
105+
res.send(process.env.SELENIUM_TESTS ? 'http://client:3000' : 'http://localhost:3000');
106+
});
107+
108+
// helper to load json data from file
109+
function loadDataFile(dataset_name: string, resource_file_name: string) {
110+
return JSON.parse(fs.readFileSync(`./default_datasets/${dataset_name}/${resource_file_name}.json`, 'utf-8'))
111+
}
112+
102113
// data flow: front end fetch eob
103114
app.get("/api/data/benefit", (req: Request, res: Response) => {
104115
if (loggedInUser.eobData) {

0 commit comments

Comments
 (0)