Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README-bb2-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,21 @@ Note: --abort-on-container-exit will abort client and server containers when sel

Note: You may need to clean up already existing Docker containers, if you are having issues or have changed your configuration file.

## Use default data sets

Instead of using the BB2 API to retrieve data from a BB2 server every time you run the
sample client, you can alternatively pre-populate json content to be loaded. To do so,
replace the json files in `server/default_datasets/Dataset 1` with your desired default
data, and then in `client/src/components/patientData.tsx`, update the
`useDefaultDataButton` const to `true`.

Then on the landing page of the sample client, in addition to the normal button
`Authorize` which can be used to query a BB2 server, there will also be a
`Load default data` button which can be used to load the data from the json files.

This is useful when developing front-end content since it shortens the amount of time
it takes to load sample data.

## Visual trouble shoot

Install VNC viewer and point browser to http://localhost:5900 to monitor web UI interactions
Expand Down
32 changes: 19 additions & 13 deletions client/src/components/patientData.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,18 @@
import { Button } from '@cmsgov/design-system';
import axios from 'axios';
import chart from '../images/who-charted.png'
//import { SettingsType } from '../types/settings';
import { SettingsType } from '../types/settings';
import React, { useState } from 'react';
import * as process from 'process';

export default function PatientData() {
const [header] = useState('Add your Medicare Prescription Drug data');
// comment out below because the end point /api/authorize/authurl of
// the server component (on port 3001), does not take parameter such as pkce, version, env
// they are generated by the server component.
//
// const [settingsState] = useState<SettingsType>({
// pkce: true,
// version: 'v2',
// env: 'sandbox'
// });
const [settingsState] = useState<SettingsType>({
useDefaultDataButton: false, // Set to true to use hard coded data
});
async function goAuthorize() {
// comment out '{ params: settingsState }' since /api/authorize/authurl does not take params
const test_url = process.env.TEST_APP_API_URL ? process.env.TEST_APP_API_URL : ''
const authUrlResponseData = await axios.get(`${test_url}/api/authorize/authurl`/*, { params: settingsState } */)
const authUrlResponseData = await axios.get(`${test_url}/api/authorize/authurl`)
.then(response => {
return response.data;
})
Expand All @@ -31,6 +24,10 @@ export default function PatientData() {
});
console.log(authUrlResponseData);
}
async function goLoadDefaults() {
const loadDefaultsData = await axios.get(`/api/bluebutton/loadDefaults`);
window.location.href = loadDefaultsData.data || '/';
}

/* DEVELOPER NOTES:
* Here we are hard coding the users information for the sake of saving time
Expand All @@ -50,7 +47,16 @@ 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="solid" onClick={goAuthorize}>Authorize</Button>
</div>
{
settingsState.useDefaultDataButton ?
<div className='ds-u-margin-top--2'>
<Button id="load_defaults_btn" variation="solid" onClick={goLoadDefaults}>Load default data</Button>
</div> :
null
}
</div>
</div>
);
Expand Down
4 changes: 1 addition & 3 deletions client/src/types/settings.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export type SettingsType = {
env: 'sandbox' | 'local' | 'production',
version: 'v1' | 'v2',
pkce: boolean,
useDefaultDataButton: boolean
}
15 changes: 15 additions & 0 deletions server/app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import json

from flask import redirect, request, Flask
from cms_bluebutton.cms_bluebutton import BlueButton
Expand Down Expand Up @@ -97,6 +98,20 @@ def authorization_callback():
return redirect(get_fe_redirect_url())


@app.route('/api/bluebutton/loadDefaults', methods=['GET'])
def load_default_data():
# TODO: add config var or param to detemine dataset
logged_in_user['eobData'] = load_data_file("Dataset 1", "eobData")
return get_fe_redirect_url()


def load_data_file(dataset_name, resource_file_name):
response_file = open("./default_datasets/{}/{}.json".format(dataset_name, resource_file_name), 'r')
resource = json.load(response_file)
response_file.close()
return resource


@app.route('/api/data/benefit', methods=['GET'])
def get_patient_eob():
"""
Expand Down
Loading
Loading