Skip to content

Commit 5b354cb

Browse files
author
James Fuqian
committed
address review feedback.
1 parent bb03f31 commit 5b354cb

7 files changed

Lines changed: 33 additions & 56 deletions

File tree

ErrorResponses.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,25 @@ This document serves as a supplementary to Blue Button 2.0 API Developer Documen
1111

1212
| Status Code | End Point URL | Error Message | Action | Comments |
1313
| -------------- | --------------- | -------------------------- | ----------------- | ------------------------------------------------------ |
14-
| 400<br>BAD REQUEST | /v[12]/o/.* | the response comes from blue button.<br>Example message:<br>error: unsupported grant type | Report, No Retry<br>Fix the request<br> | request has invalid parameter(s) |
15-
| 403<br>FORBIDDEN | /v[12]/o/authorize/<br>/v[12]/o/authorize/(?P<uuid>[\w-]+)/$<br>/v[12]/o/token | You do not have permission to perform this action. | Report, No Retry | request does not pass permission check |
16-
| 403<br>FORBIDDEN | /v[12]/o/authorize/<br>/v[12]/o/authorize/(?P<uuid>[\w-]+)/$ | This application, {your app name}, is temporarily inactive. <br>If you are the app maintainer, please contact the Blue Button 2.0 API team. <br>If you are a Medicare Beneficiary and need assistance, please contact the application's support team <br>or call 1-800-MEDICARE (1-800-633-4227) | Report, No Retry | the app is disabled by Blue Button 2.0 API administrator usually <br>due to abnormal usage pattern etc., contact CMS as instructed, <br>it is recommended to stop the app and resolve with Blue Button 2.0 API team |
17-
| 404<br>NOT FOUND | /v[12]/o/.* | Medicare is unable to retrieve your data at this time due to an internal issue.<br>Our team is aware of the issue and is working to resolve it.<br>Please try again at a later time. We apologize for any inconvenience. | Report, No Retry | If any abnormality encountered during authorization, e.g. <br>the patient is not found by mbi hash / hicn hash lookup, the message will be <br>rendered as html page to the beneficiary, and with a 404 status code.<br>the authorization process aborted. |
18-
| 502<br>BAD GATEWAY | /v[12]/o/.* | An error occurred connecting to medicare.gov account<br><br>other additional messages:<br><br>BBMyMedicareSLSxTokenException, or<br>BBMyMedicareSLSxSignoutException, or<br>BBMyMedicareSLSxValidateSignoutException, or<br>BBMyMedicareCallbackAuthenticateSlsUserInfoValidateException, or<br>BBMyMedicareSLSxUserinfoException at /mymedicare/sls-callback | Report, No Retry | Abnormality encountered during authorization for various causes as indicated by <br>error name in addition to the general message:<br><br>An error occurred connecting to medicare.gov account
19-
|
20-
| 500<br>SERVER ERROR | /v[12]/o/.* | The root cause of the 500 error, some times, is indicated by the error message, <br>the app can choose to retry the failed request depend on the nature of the root cause, <br>examples that might be retriable are those related to network down (temporarily):<br>Example:<br>ConnectionError at /mymedicare/login<br>HTTPSConnectionPool(host='test.accounts.cms.gov', port=443): <br>Max retries exceeded with url: /health (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f46599dafd0>: <br>Failed to establish a new connection: [Errno -2] Name or service not known')) | Report, Retry not recommended | App retry on request during authorization<br>is not recommended. |
14+
| 400<br>BAD REQUEST | /v[12]/o/.* | the response comes from blue button.<br>Example message:<br>error: unsupported grant type | Fix the request<br> | request has invalid parameter(s) |
15+
| 403<br>FORBIDDEN | /v[12]/o/authorize/<br>/v[12]/o/authorize/(?P<uuid>[\w-]+)/$<br>/v[12]/o/token | You do not have permission to perform this action. | | request does not pass permission check |
16+
| 403<br>FORBIDDEN | /v[12]/o/authorize/<br>/v[12]/o/authorize/(?P<uuid>[\w-]+)/$ | This application, {your app name}, is temporarily inactive. <br>If you are the app maintainer, please contact the Blue Button 2.0 API team. <br>If you are a Medicare Beneficiary and need assistance, please contact the application's support team <br>or call 1-800-MEDICARE (1-800-633-4227) | | the app is disabled by Blue Button 2.0 API administrator usually <br>due to abnormal usage pattern etc., contact CMS as instructed, <br>it is recommended to stop the app and resolve with Blue Button 2.0 API team |
17+
| 404<br>NOT FOUND | /v[12]/o/.* | Medicare is unable to retrieve your data at this time due to an internal issue.<br>Our team is aware of the issue and is working to resolve it.<br>Please try again at a later time. We apologize for any inconvenience. | | If any abnormality encountered during authorization, e.g. <br>the patient is not found by mbi hash / hicn hash lookup, the message will be <br>rendered as html page to the beneficiary, and with a 404 status code.<br>the authorization process aborted. |
18+
| 502<br>BAD GATEWAY | /v[12]/o/.* | An error occurred connecting to medicare.gov account<br><br>other additional messages:<br><br>BBMyMedicareSLSxTokenException, or<br>BBMyMedicareSLSxSignoutException, or<br>BBMyMedicareSLSxValidateSignoutException, or<br>BBMyMedicareCallbackAuthenticateSlsUserInfoValidateException, or<br>BBMyMedicareSLSxUserinfoException at /mymedicare/sls-callback | | Abnormality encountered during authorization for various causes as indicated by <br>error name in addition to the general message:<br><br>An error occurred connecting to medicare.gov account |
19+
| 500<br>SERVER ERROR | /v[12]/o/.* | The root cause of the 500 error, some times, is indicated by the error message, <br>the app can choose to retry the failed request depend on the nature of the root cause, <br>examples that might be retriable are those related to network down (temporarily):<br>Example:<br>ConnectionError at /mymedicare/login<br>HTTPSConnectionPool(host='test.accounts.cms.gov', port=443): <br>Max retries exceeded with url: /health (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f46599dafd0>: <br>Failed to establish a new connection: [Errno -2] Name or service not known')) | | App retry on request during authorization<br>is not recommended. |
2120

2221

2322
### Data Requests
2423

2524

2625
| Status Code | End Point URL | Error Message | Action | Comments |
2726
| -------------- | --------------- | -------------------------- | ----------------- | ------------------------------------------------------ |
28-
| 400<br>BAD REQUEST | /v[12]/fhir/.* | the response comes from FHIR data backend.<br>Example message:<br>details: IllegalArgumentException: Unsupported ID pattern | Report, No Retry<br>Fix the request<br> | fhir request has invalid parameter(s) |
29-
| 403<br>FORBIDDEN | /v[12]/fhir/.* | You do not have permission to perform this action. | Report, No Retry | the request is not in the scope of the grant authorized, <br>e.g. the beneficiary did not grant access to the demographic data |
30-
| 403<br>FORBIDDEN | /v[12]/fhir/.* | This application, {your app name}, is temporarily inactive. <br>If you are the app maintainer, please contact the Blue Button 2.0 API team. <br>If you are a Medicare Beneficiary and need assistance, please contact the application's support team <br>or call 1-800-MEDICARE (1-800-633-4227) | Report, No Retry | the app is disabled by Blue Button 2.0 API administrator usually <br>due to abnormal usage pattern etc., contact CMS as instructed, <br>it is recommended to stop the app and resolve with Blue Button 2.0 API team |
31-
| 404<br>NOT FOUND | /v[12]/fhir/.* | The requested resource does not exist | Report, No Retry | for example, for a fhir read request as:<br>/v2/fhir/Patient/-1234567890<br>but there is not a patient with<br>fhir_id = -1234567890, a 404 is returned |
32-
| 502<br>BAD GATEWAY | /v[12]/fhir/.* | An error occurred contacting the upstream server: <error details><br>Example:<br>UpstreamServerException('An error occurred contacting the upstream server:Failed to call access method: <br>java.lang.IllegalArgumentException: _lastUpdate lower bound has an invalid prefix') | Report, No Retry | An error occurred in FHIR data backend when retrieving the resources, <br>it could be client side error e.g. a malformed query parameter in the URL where the error code should be 400 BAD REQUEST, <br>or a back end internal error.<br>the action on the 502 error is on a case by case basis, e.g. if the root cause of the 502 is actually a bad query parameter, <br>then retry is a sensible action. |
33-
| 500<br>SERVER ERROR | /v[12]/fhir/.* | The root cause of the 500 error, some times, is indicated by the error message, <br>the app can choose to retry the failed request depend on the nature of the root cause, <br>examples that might be retriable are those related to network down (temporarily):<br>Example:<br>ConnectionError at /mymedicare/login<br>HTTPSConnectionPool(host='test.accounts.cms.gov', port=443): <br>Max retries exceeded with url: /health (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f46599dafd0>: <br>Failed to establish a new connection: [Errno -2] Name or service not known')) | Report, Heuristic on Retry | App can choose to retry on some of the 500 errors as shown by the example, this is a heuristic approach. |
27+
| 400<br>BAD REQUEST | /v[12]/fhir/.* | the response comes from FHIR data backend.<br>Example message:<br>details: IllegalArgumentException: Unsupported ID pattern | <br>Fix the request<br> | fhir request has invalid parameter(s) |
28+
| 403<br>FORBIDDEN | /v[12]/fhir/.* | You do not have permission to perform this action. | | the request is not in the scope of the grant authorized, <br>e.g. the beneficiary did not grant access to the demographic data |
29+
| 403<br>FORBIDDEN | /v[12]/fhir/.* | This application, {your app name}, is temporarily inactive. <br>If you are the app maintainer, please contact the Blue Button 2.0 API team. <br>If you are a Medicare Beneficiary and need assistance, please contact the application's support team <br>or call 1-800-MEDICARE (1-800-633-4227) | | the app is disabled by Blue Button 2.0 API administrator usually <br>due to abnormal usage pattern etc., contact CMS as instructed, <br>it is recommended to stop the app and resolve with Blue Button 2.0 API team |
30+
| 404<br>NOT FOUND | /v[12]/fhir/.* | The requested resource does not exist | | for example, for a fhir read request as:<br>/v2/fhir/Patient/-1234567890<br>but there is not a patient with<br>fhir_id = -1234567890, a 404 is returned |
31+
| 502<br>BAD GATEWAY | /v[12]/fhir/.* | An error occurred contacting the upstream server: <error details><br>Example:<br>UpstreamServerException('An error occurred contacting the upstream server:Failed to call access method: <br>java.lang.IllegalArgumentException: _lastUpdate lower bound has an invalid prefix') | | An error occurred in FHIR data backend when retrieving the resources, <br>it could be client side error e.g. a malformed query parameter in the URL where the error code should be 400 BAD REQUEST, <br>or a back end internal error.<br>the action on the 502 error is on a case by case basis, e.g. if the root cause of the 502 is actually a bad query parameter, <br>then retry is a sensible action. |
32+
| 500<br>SERVER ERROR | /v[12]/fhir/.* | The root cause of the 500 error, some times, is indicated by the error message, <br>the app can choose to retry the failed request depend on the nature of the root cause, <br>examples that might be retriable are those related to network down (temporarily):<br>Example:<br>ConnectionError at /mymedicare/login<br>HTTPSConnectionPool(host='test.accounts.cms.gov', port=443): <br>Max retries exceeded with url: /health (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f46599dafd0>: <br>Failed to establish a new connection: [Errno -2] Name or service not known')) | Heuristic on Retry | App can choose to retry on some of the 500 errors as shown by the example, this is a heuristic approach. |
3433

3534

3635
### Retry

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ To start the sample in native OS (e.g. Linux) with server and client components
7373
2. yarn --cwd server start:dev
7474
3. run below to start the client:
7575
1. yarn --cwd client install
76-
2. yarn --cwd client start2
76+
2. yarn --cwd client start-native
7777

7878
To stop the sample:
7979

client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
},
2525
"scripts": {
2626
"start": "REACT_APP_CTX=docker react-scripts start",
27-
"start2": "REACT_APP_CTX=native react-scripts start",
27+
"start-native": "REACT_APP_CTX=native react-scripts start",
2828
"build": "react-scripts build",
2929
"test": "react-scripts test",
3030
"eject": "react-scripts eject"

server/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,9 @@
7070
"jet-logger": "^1.0.4",
7171
"jsonfile": "^6.1.0",
7272
"module-alias": "^2.2.2",
73-
"morgan": "^1.10.0",
74-
"node-cron": "^3.0.0"
73+
"morgan": "^1.10.0"
7574
},
7675
"devDependencies": {
77-
"@types/node-cron": "^3.0.0",
7876
"@types/command-line-args": "^5.0.0",
7977
"@types/cookie-parser": "^1.4.2",
8078
"@types/express": "^4.17.11",

server/src/routes/Data.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ export async function getBenefitData(req: Request, res: Response) {
1616
const loggedInUser = getLoggedInUser(db);
1717
const envConfig = config[db.settings.env];
1818
// get EOB end point
19-
const response = await get(envConfig.bb2BaseUrl + '/' + db.settings.version + '/fhir/ExplanationOfBenefit/', req.query, `${loggedInUser.authToken?.access_token}`);
19+
// const response = await get(envConfig.bb2BaseUrl + '/' + db.settings.version + '/fhir/ExplanationOfBenefit/', req.query, `${loggedInUser.authToken?.access_token}`);
20+
const response = await get(`${envConfig.bb2BaseUrl}/${db.settings.version}/fhir/ExplanationOfBenefit/`, req.query, `${loggedInUser.authToken?.access_token}`);
2021
return (response) ? response.data : null;
2122
}
2223

@@ -37,23 +38,26 @@ export async function getPatientData(req: Request, res: Response) {
3738
const loggedInUser = getLoggedInUser(db);
3839
const envConfig = config[db.settings.env];
3940
// get Patient end point
40-
const response = await get(envConfig.bb2BaseUrl + '/' + db.settings.version + '/fhir/Patient/', req.query, `${loggedInUser.authToken?.access_token}`);
41+
// const response = await get(envConfig.bb2BaseUrl + '/' + db.settings.version + '/fhir/Patient/', req.query, `${loggedInUser.authToken?.access_token}`);
42+
const response = await get(`${envConfig.bb2BaseUrl}/${db.settings.version}/fhir/Patient/`, req.query, `${loggedInUser.authToken?.access_token}`);
4143
res.json(response.data);
4244
}
4345

4446
export async function getCoverageData(req: Request, res: Response) {
4547
const loggedInUser = getLoggedInUser(db);
4648
const envConfig = config[db.settings.env];
4749
// get Coverage end point
48-
const response = await get(envConfig.bb2BaseUrl + '/' + db.settings.version + '/fhir/Coverage/', req.query, `${loggedInUser.authToken?.access_token}`);
50+
// const response = await get(envConfig.bb2BaseUrl + '/' + db.settings.version + '/fhir/Coverage/', req.query, `${loggedInUser.authToken?.access_token}`);
51+
const response = await get(`${envConfig.bb2BaseUrl}/${db.settings.version}/fhir/Coverage/`, req.query, `${loggedInUser.authToken?.access_token}`);
4952
res.json(response.data);
5053
}
5154

5255
export async function getUserProfileData(req: Request, res: Response) {
5356
const loggedInUser = getLoggedInUser(db);
5457
const envConfig = config[db.settings.env];
5558
// get usrinfo end point
56-
const response = await get(envConfig.bb2BaseUrl + '/' + db.settings.version + '/connect/userinfo', req.query, `${loggedInUser.authToken?.access_token}`);
59+
// const response = await get(envConfig.bb2BaseUrl + '/' + db.settings.version + '/connect/userinfo', req.query, `${loggedInUser.authToken?.access_token}`);
60+
const response = await get(`${envConfig.bb2BaseUrl}/${db.settings.version}/connect/userinfo`, req.query, `${loggedInUser.authToken?.access_token}`);
5761
res.json(response.data);
5862
}
5963

server/src/utils/request.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ export async function post(endpoint_url: string, data: FormData, extra: any) {
1010
headers: extra}, true);
1111
}
1212

13-
export async function get(endpoint_url: string, req_qry: any, token: string) {
13+
export async function get(endpointUrl: string, params: any, authToken: string) {
1414
return await request({
1515
method: 'get',
16-
url: endpoint_url,
17-
params: req_qry,
16+
url: endpointUrl,
17+
params: params,
1818
headers: {
19-
'Authorization': `Bearer ${token}`
19+
'Authorization': `Bearer ${authToken}`
2020
}}, true);
2121
}
2222

23-
export async function request(config: any, retry_flag: boolean) {
24-
var resp = null
23+
export async function request(config: any, retryFlag: boolean) {
24+
let resp = null
2525
try {
2626
resp = await axios(config);
2727
} catch (error: any) {
@@ -33,7 +33,7 @@ export async function request(config: any, retry_flag: boolean) {
3333
console.log("response text: " + error.response.data)
3434
// DEVELOPER NOTES:
3535
// check for retryable (e.g. 500 & fhir) errors and do retrying...
36-
if (retry_flag && is_retryable(error)) {
36+
if (retryFlag && isRetryable(error)) {
3737
console.log("Request failed and is retryable, entering retry process...")
3838
var retry_resp = await do_retry(config)
3939
if (retry_resp) {
@@ -57,7 +57,7 @@ export async function request(config: any, retry_flag: boolean) {
5757
return resp
5858
}
5959

60-
function is_retryable(error: any) {
60+
function isRetryable(error: any) {
6161
if (error.response && error.response.status === 500) {
6262
if (error.request.path && error.request.path.match("^/v[12]/fhir/.*")) {
6363
return true;
@@ -93,9 +93,9 @@ async function do_retry(config: any) {
9393
return resp
9494
}
9595

96-
function sleep(ms: any) {
96+
function sleep(time: number) {
9797
return new Promise((resolve) => {
98-
setTimeout(resolve, ms);
98+
setTimeout(resolve, time);
9999
});
100100
}
101101

server/yarn.lock

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,6 @@
168168
dependencies:
169169
"@types/node" "*"
170170

171-
"@types/node-cron@^3.0.0":
172-
version "3.0.0"
173-
resolved "https://registry.yarnpkg.com/@types/node-cron/-/node-cron-3.0.0.tgz#f946cefb5c05c64f460090f6be97bd50460c8898"
174-
integrity sha512-RNBIyVwa/1v2r8/SqK8tadH2sJlFRAo5Ghac/cOcCv4Kp94m0I03UmAh9WVhCqS9ZdB84dF3x47p9aTw8E4c4A==
175-
176171
"@types/node@*", "@types/node@^15.0.1":
177172
version "15.0.1"
178173
resolved "https://registry.yarnpkg.com/@types/node/-/node-15.0.1.tgz#ef34dea0881028d11398be5bf4e856743e3dc35a"
@@ -1686,18 +1681,6 @@ module-alias@^2.2.2:
16861681
resolved "https://registry.yarnpkg.com/module-alias/-/module-alias-2.2.2.tgz#151cdcecc24e25739ff0aa6e51e1c5716974c0e0"
16871682
integrity sha512-A/78XjoX2EmNvppVWEhM2oGk3x4lLxnkEA4jTbaK97QKSDjkIoOsKQlfylt/d3kKKi596Qy3NP5XrXJ6fZIC9Q==
16881683

1689-
moment-timezone@^0.5.31:
1690-
version "0.5.33"
1691-
resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.33.tgz#b252fd6bb57f341c9b59a5ab61a8e51a73bbd22c"
1692-
integrity sha512-PTc2vcT8K9J5/9rDEPe5czSIKgLoGsH8UNpA4qZTVw0Vd/Uz19geE9abbIOQKaAQFcnQ3v5YEXrbSc5BpshH+w==
1693-
dependencies:
1694-
moment ">= 2.9.0"
1695-
1696-
"moment@>= 2.9.0":
1697-
version "2.29.1"
1698-
resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.1.tgz#b2be769fa31940be9eeea6469c075e35006fa3d3"
1699-
integrity sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==
1700-
17011684
morgan@^1.10.0:
17021685
version "1.10.0"
17031686
resolved "https://registry.yarnpkg.com/morgan/-/morgan-1.10.0.tgz#091778abc1fc47cd3509824653dae1faab6b17d7"
@@ -1739,13 +1722,6 @@ negotiator@0.6.2:
17391722
resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.2.tgz#feacf7ccf525a77ae9634436a64883ffeca346fb"
17401723
integrity sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==
17411724

1742-
node-cron@^3.0.0:
1743-
version "3.0.0"
1744-
resolved "https://registry.yarnpkg.com/node-cron/-/node-cron-3.0.0.tgz#b33252803e430f9cd8590cf85738efa1497a9522"
1745-
integrity sha512-DDwIvvuCwrNiaU7HEivFDULcaQualDv7KoNlB/UU1wPW0n1tDEmBJKhEIE6DlF2FuoOHcNbLJ8ITL2Iv/3AWmA==
1746-
dependencies:
1747-
moment-timezone "^0.5.31"
1748-
17491725
nodemon@^2.0.7:
17501726
version "2.0.7"
17511727
resolved "https://registry.yarnpkg.com/nodemon/-/nodemon-2.0.7.tgz#6f030a0a0ebe3ea1ba2a38f71bf9bab4841ced32"

0 commit comments

Comments
 (0)