Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BB2-3391: Rollback supporting image enhancement #1249

Merged
merged 1 commit into from
Sep 24, 2024
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
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ ENV PATH="/tmp/venv/bin:${PATH}"
RUN pip install --upgrade pip
RUN pip install --upgrade pip-tools
RUN pip install --upgrade setuptools
RUN pip install jsonpath-ng
RUN pip install -r requirements/requirements.dev.txt --no-index --find-links ./vendor/
12,432 changes: 0 additions & 12,432 deletions apps/fhir/bluebutton/views/b64card.py

This file was deleted.

75 changes: 1 addition & 74 deletions apps/fhir/bluebutton/views/search.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import copy
from jsonpath_ng.ext import parse as ext_parse
from rest_framework import (permissions)
from rest_framework.response import Response
from voluptuous import (
Expand All @@ -18,80 +16,11 @@
from apps.authorization.permissions import DataAccessGrantPermission
from apps.capabilities.permissions import TokenHasProtectedCapability
from ..permissions import (SearchCrosswalkPermission, ResourcePermission, ApplicationActivePermission)
from apps.fhir.bluebutton.views.b64card import B64_BLU_CARD, B64_RED_BLU_CARD, B64_BLU_CARD_BG, B64_HUMANA_PTD


# image mapping to part A, B, C, D
# A: B64_BLU_CARD_BG large vertical figma card as background
# B: B64_RED_BLU_CARD classic medicare card image
# C: B64_BLU_CARD horizontal figma card
# D: B64_HUMANA_PTD medicare RX humana part D card
INS_TYPE2CARD = {
"Part A": ''.join(B64_BLU_CARD_BG.splitlines()),
"Part B": ''.join(B64_RED_BLU_CARD.splitlines()),
"Part C": ''.join(B64_BLU_CARD.splitlines()),
"Part D": ''.join(B64_HUMANA_PTD.splitlines())
}

C4BB_COVERAGE_PROFILE_URL = "http://hl7.org/fhir/us/carin-bb/StructureDefinition/C4BB-Coverage"

C4DIC_COVERAGE_PROFILE_URL = "http://hl7.org/fhir/us/insurance-card/StructureDefinition/C4DIC-Coverage"

C4DIC_SUPPORTING_IMAGE_EXT = {
"extension": [
{
"url": "description",
"valueString": "Beneficiary's proof of insurance"
},
{
"url": "image",
"valueAttachment": {
"contentType": "image/png",
"data": "<replace with base64 encoded image png here>"
}
},
{
"url": "label",
"valueString": "CMS Insurance card"
}
],
"url": "http://hl7.org/fhir/us/insurance-card/StructureDefinition/C4DIC-SupportingImage-extension"
}


# POC helper
def lookup_by_path(expr, json_obj):
jsonpath_expr = ext_parse(expr)
return jsonpath_expr.find(json_obj)


# POC helper
def lookup_1_and_get(expr, attribute, json_obj):
r = lookup_by_path(expr, json_obj)
if r and isinstance(r, list):
return r[0].value[attribute]


# POC helper: generate supporting image extension per coverage class type
def get_supporting_image_extension(b64encoded: str):
ext = copy.deepcopy(C4DIC_SUPPORTING_IMAGE_EXT)
for e in ext['extension']:
if e['url'] == 'image':
e['valueAttachment']['data'] = b64encoded
break
return ext


# POC helper
def enrich_supporting_image(resp: Response):
for e in resp.data['entry']:
extensions = e['resource']['extension']
class_type = lookup_1_and_get("$.resource.class[?(@.type.coding[0].code=='plan')]", "value", e)
class_type = "Part A" if class_type is None else class_type
extensions.append(get_supporting_image_extension(INS_TYPE2CARD[class_type]))

return resp


class SearchView(FhirDataView):
# Base class for FHIR resource search views
Expand Down Expand Up @@ -179,9 +108,7 @@ def get(self, request, *args, **kwargs):
if return_c4dic and profile == C4DIC_COVERAGE_PROFILE_URL:
return Response(get_response_json("bfd-c4dic-coverage-search"))
else:
resp = super().get(request, *args, **kwargs)
# C4DIC POC: inject c4dic supportingImage extension if the _profile indicate C4DIC Coverage search
return enrich_supporting_image(resp) if profile == C4DIC_COVERAGE_PROFILE_URL else resp
return super().get(request, *args, **kwargs)


class SearchViewExplanationOfBenefit(SearchView):
Expand Down
8 changes: 0 additions & 8 deletions requirements/requirements.dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,6 @@ jmespath==1.0.1 \
# via
# boto3
# botocore
jsonpath-ng==1.6.1 \
--hash=sha256:086c37ba4917304850bd837aeab806670224d3f038fe2833ff593a672ef0a5fa \
--hash=sha256:8f22cd8273d7772eea9aaa84d922e0841aa36fdb8a2c6b7f6c3791a16a9bc0be
# via -r requirements/requirements.in
jsonschema==4.17.3 \
--hash=sha256:0f864437ab8b6076ba6707453ef8f98a6a0d512a80e93f8abdb676f737ecb60d \
--hash=sha256:a870ad254da1a8ca84b6a2905cac29d265f805acc57af304784962a2aa6508f6
Expand Down Expand Up @@ -618,10 +614,6 @@ pluggy==1.5.0 \
--hash=sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1 \
--hash=sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669
# via pytest
ply==3.11 \
--hash=sha256:00c7c1aaa88358b9c765b6d3000c6eec0ba42abca5351b095321aef446081da3 \
--hash=sha256:096f9b8350b65ebd2fd1346b12452efe5b9607f7482813ffca50c22722a807ce
# via jsonpath-ng
psycopg2-binary==2.9.6 \
--hash=sha256:02c0f3757a4300cf379eb49f543fb7ac527fb00144d39246ee40e1df684ab514 \
--hash=sha256:02c6e3cf3439e213e4ee930308dc122d6fb4d4bea9aef4a12535fbd605d1a2fe \
Expand Down
1 change: 0 additions & 1 deletion requirements/requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ pyrsistent
typing_extensions
importlib-metadata
certifi
jsonpath-ng

# notifications
django-ses
Expand Down
8 changes: 0 additions & 8 deletions requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,6 @@ jmespath==1.0.1 \
# via
# boto3
# botocore
jsonpath-ng==1.6.1 \
--hash=sha256:086c37ba4917304850bd837aeab806670224d3f038fe2833ff593a672ef0a5fa \
--hash=sha256:8f22cd8273d7772eea9aaa84d922e0841aa36fdb8a2c6b7f6c3791a16a9bc0be
# via -r requirements/requirements.in
jsonschema==4.17.3 \
--hash=sha256:0f864437ab8b6076ba6707453ef8f98a6a0d512a80e93f8abdb676f737ecb60d \
--hash=sha256:a870ad254da1a8ca84b6a2905cac29d265f805acc57af304784962a2aa6508f6
Expand Down Expand Up @@ -450,10 +446,6 @@ pkgutil-resolve-name==1.3.10 \
# via
# -r requirements/requirements.in
# jsonschema
ply==3.11 \
--hash=sha256:00c7c1aaa88358b9c765b6d3000c6eec0ba42abca5351b095321aef446081da3 \
--hash=sha256:096f9b8350b65ebd2fd1346b12452efe5b9607f7482813ffca50c22722a807ce
# via jsonpath-ng
psycopg2-binary==2.9.6 \
--hash=sha256:02c0f3757a4300cf379eb49f543fb7ac527fb00144d39246ee40e1df684ab514 \
--hash=sha256:02c6e3cf3439e213e4ee930308dc122d6fb4d4bea9aef4a12535fbd605d1a2fe \
Expand Down
Binary file removed vendor/jsonpath_ng-1.6.1-py3-none-any.whl
Binary file not shown.
Binary file removed vendor/ply-3.11-py2.py3-none-any.whl
Binary file not shown.
Loading