From 39e6c405531afed33a3cf008c612473ddeda1e3a Mon Sep 17 00:00:00 2001 From: "Qian (Jim) Fu" Date: Mon, 14 Apr 2025 15:31:37 -0700 Subject: [PATCH 1/6] use SMART App v2 scopes --- server/app.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/server/app.py b/server/app.py index 430ffcd..c53bca8 100644 --- a/server/app.py +++ b/server/app.py @@ -14,6 +14,30 @@ app = Flask(__name__) bb = BlueButton() +## helper trouble shoot +def print_setting(): + print("URL::BlueButton->base_url: {}".format(bb.base_url), flush=True) + print("URL::BlueButton->auth_base_url: {}".format(bb.auth_base_url), flush=True) + print("URL::BlueButton->auth_token_url: {}".format(bb.auth_token_url), flush=True) + print("URL::BlueButton->callback_url: {}".format(bb.callback_url), flush=True) + + +app = Flask(__name__) +bb = BlueButton() + +host_ip = os.environ.get("HOST_IP") + +print_setting() + +if host_ip: + if str(bb.base_url).startswith("http://localhost"): + bb.base_url = str(bb.base_url).replace("http://localhost", "http://{}".format(host_ip)) + if str(bb.auth_base_url).startswith("http://localhost"): + bb.auth_base_url = str(bb.auth_base_url).replace("http://localhost", "http://{}".format(host_ip)) + if str(bb.auth_token_url).startswith("http://localhost"): + bb.auth_token_url = str(bb.auth_token_url).replace("http://localhost", "http://{}".format(host_ip)) + print_setting() + # This is where medicare.gov beneficiary associated # with the current logged in app user, # in real app, this could be the app specific @@ -35,7 +59,11 @@ @app.route('/api/authorize/authurl', methods=['GET']) def get_auth_url(): - redirect_url = bb.generate_authorize_url(auth_data) + # for SMART App v2 scopes usage: explicitly + # provide query parameter scope= + # where is space delimited v2 scope specs (url encoded) + # e.g. patient/ExplanationOfBenefit.rs + redirect_url = bb.generate_authorize_url(auth_data) + "&scope=patient%2FPatient.s%20patient%2FExplanationOfBenefit.rs" return redirect_url From 4bb3f5e9d40bca8b05eb498d41fa4659115ac3c4 Mon Sep 17 00:00:00 2001 From: "Qian (Jim) Fu" Date: Mon, 14 Apr 2025 15:58:59 -0700 Subject: [PATCH 2/6] remove debug code etc. --- server/app.py | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/server/app.py b/server/app.py index c53bca8..938b0b5 100644 --- a/server/app.py +++ b/server/app.py @@ -14,30 +14,10 @@ app = Flask(__name__) bb = BlueButton() -## helper trouble shoot -def print_setting(): - print("URL::BlueButton->base_url: {}".format(bb.base_url), flush=True) - print("URL::BlueButton->auth_base_url: {}".format(bb.auth_base_url), flush=True) - print("URL::BlueButton->auth_token_url: {}".format(bb.auth_token_url), flush=True) - print("URL::BlueButton->callback_url: {}".format(bb.callback_url), flush=True) - app = Flask(__name__) bb = BlueButton() -host_ip = os.environ.get("HOST_IP") - -print_setting() - -if host_ip: - if str(bb.base_url).startswith("http://localhost"): - bb.base_url = str(bb.base_url).replace("http://localhost", "http://{}".format(host_ip)) - if str(bb.auth_base_url).startswith("http://localhost"): - bb.auth_base_url = str(bb.auth_base_url).replace("http://localhost", "http://{}".format(host_ip)) - if str(bb.auth_token_url).startswith("http://localhost"): - bb.auth_token_url = str(bb.auth_token_url).replace("http://localhost", "http://{}".format(host_ip)) - print_setting() - # This is where medicare.gov beneficiary associated # with the current logged in app user, # in real app, this could be the app specific @@ -63,7 +43,8 @@ def get_auth_url(): # provide query parameter scope= # where is space delimited v2 scope specs (url encoded) # e.g. patient/ExplanationOfBenefit.rs - redirect_url = bb.generate_authorize_url(auth_data) + "&scope=patient%2FPatient.s%20patient%2FExplanationOfBenefit.rs" + redirect_url = (bb.generate_authorize_url(auth_data) + + "&scope=patient%2FPatient.s%20patient%2FExplanationOfBenefit.rs") return redirect_url From fe4669c4ac7fb19b6d21d31c7f7ab578ac76e05c Mon Sep 17 00:00:00 2001 From: "Qian (Jim) Fu" Date: Wed, 16 Apr 2025 08:07:07 -0700 Subject: [PATCH 3/6] trim the scope to EOB.rs on auth URL. --- server/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/app.py b/server/app.py index 938b0b5..3d958cb 100644 --- a/server/app.py +++ b/server/app.py @@ -44,7 +44,7 @@ def get_auth_url(): # where is space delimited v2 scope specs (url encoded) # e.g. patient/ExplanationOfBenefit.rs redirect_url = (bb.generate_authorize_url(auth_data) - + "&scope=patient%2FPatient.s%20patient%2FExplanationOfBenefit.rs") + + "&scope=patient%2FExplanationOfBenefit.rs") return redirect_url From 367465613a5ac6126f8cc4b2827be7c1ea5e1eb4 Mon Sep 17 00:00:00 2001 From: "Qian (Jim) Fu" Date: Fri, 18 Apr 2025 13:50:03 -0700 Subject: [PATCH 4/6] remove dup code. --- server/app.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/server/app.py b/server/app.py index 3d958cb..f1117d7 100644 --- a/server/app.py +++ b/server/app.py @@ -11,10 +11,6 @@ ERR_MISSING_AUTH_CODE = "Response was missing access code!" ERR_MISSING_STATE = "State is required when using PKCE" -app = Flask(__name__) -bb = BlueButton() - - app = Flask(__name__) bb = BlueButton() From 5d1e7a79f6351b75065e42337904a56726793560 Mon Sep 17 00:00:00 2001 From: "Qian (Jim) Fu" Date: Wed, 30 Apr 2025 10:59:06 -0700 Subject: [PATCH 5/6] use exact EOB search scope for sample client. --- server/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/app.py b/server/app.py index f1117d7..bd2d17c 100644 --- a/server/app.py +++ b/server/app.py @@ -40,7 +40,7 @@ def get_auth_url(): # where is space delimited v2 scope specs (url encoded) # e.g. patient/ExplanationOfBenefit.rs redirect_url = (bb.generate_authorize_url(auth_data) - + "&scope=patient%2FExplanationOfBenefit.rs") + + "&scope=patient%2FExplanationOfBenefit.s") return redirect_url From e122fc75154d8af158ce43ff26abab91bfc76cd8 Mon Sep 17 00:00:00 2001 From: "Qian (Jim) Fu" Date: Tue, 13 May 2025 14:30:53 -0700 Subject: [PATCH 6/6] fix a strange behavior change of Pipfile and Pipfile.lock - where lib 'click' is included in dependencies, but having module 'click' not found when start runtime, fix is hacky: just pip install it before pipenv (Pipfile.lock) install, note this happens on master. --- server/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/server/Dockerfile b/server/Dockerfile index 161dc3b..984c9dd 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -20,4 +20,5 @@ RUN if [ "$BUILD_DEVELOPMENT" = "True" ]; then \ fi RUN pipenv lock +RUN pip install click RUN pipenv install --system --deploy --ignore-pipfile