Skip to content

Commit fa4e0af

Browse files
authored
Rollback supporting image enhancement (#1249)
1 parent 2aa4b40 commit fa4e0af

File tree

8 files changed

+1
-12524
lines changed

8 files changed

+1
-12524
lines changed

Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,4 @@ ENV PATH="/tmp/venv/bin:${PATH}"
1010
RUN pip install --upgrade pip
1111
RUN pip install --upgrade pip-tools
1212
RUN pip install --upgrade setuptools
13-
RUN pip install jsonpath-ng
1413
RUN pip install -r requirements/requirements.dev.txt --no-index --find-links ./vendor/

apps/fhir/bluebutton/views/b64card.py

Lines changed: 0 additions & 12432 deletions
This file was deleted.

apps/fhir/bluebutton/views/search.py

Lines changed: 1 addition & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import copy
2-
from jsonpath_ng.ext import parse as ext_parse
31
from rest_framework import (permissions)
42
from rest_framework.response import Response
53
from voluptuous import (
@@ -18,80 +16,11 @@
1816
from apps.authorization.permissions import DataAccessGrantPermission
1917
from apps.capabilities.permissions import TokenHasProtectedCapability
2018
from ..permissions import (SearchCrosswalkPermission, ResourcePermission, ApplicationActivePermission)
21-
from apps.fhir.bluebutton.views.b64card import B64_BLU_CARD, B64_RED_BLU_CARD, B64_BLU_CARD_BG, B64_HUMANA_PTD
22-
23-
24-
# image mapping to part A, B, C, D
25-
# A: B64_BLU_CARD_BG large vertical figma card as background
26-
# B: B64_RED_BLU_CARD classic medicare card image
27-
# C: B64_BLU_CARD horizontal figma card
28-
# D: B64_HUMANA_PTD medicare RX humana part D card
29-
INS_TYPE2CARD = {
30-
"Part A": ''.join(B64_BLU_CARD_BG.splitlines()),
31-
"Part B": ''.join(B64_RED_BLU_CARD.splitlines()),
32-
"Part C": ''.join(B64_BLU_CARD.splitlines()),
33-
"Part D": ''.join(B64_HUMANA_PTD.splitlines())
34-
}
3519

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

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

40-
C4DIC_SUPPORTING_IMAGE_EXT = {
41-
"extension": [
42-
{
43-
"url": "description",
44-
"valueString": "Beneficiary's proof of insurance"
45-
},
46-
{
47-
"url": "image",
48-
"valueAttachment": {
49-
"contentType": "image/png",
50-
"data": "<replace with base64 encoded image png here>"
51-
}
52-
},
53-
{
54-
"url": "label",
55-
"valueString": "CMS Insurance card"
56-
}
57-
],
58-
"url": "http://hl7.org/fhir/us/insurance-card/StructureDefinition/C4DIC-SupportingImage-extension"
59-
}
60-
61-
62-
# POC helper
63-
def lookup_by_path(expr, json_obj):
64-
jsonpath_expr = ext_parse(expr)
65-
return jsonpath_expr.find(json_obj)
66-
67-
68-
# POC helper
69-
def lookup_1_and_get(expr, attribute, json_obj):
70-
r = lookup_by_path(expr, json_obj)
71-
if r and isinstance(r, list):
72-
return r[0].value[attribute]
73-
74-
75-
# POC helper: generate supporting image extension per coverage class type
76-
def get_supporting_image_extension(b64encoded: str):
77-
ext = copy.deepcopy(C4DIC_SUPPORTING_IMAGE_EXT)
78-
for e in ext['extension']:
79-
if e['url'] == 'image':
80-
e['valueAttachment']['data'] = b64encoded
81-
break
82-
return ext
83-
84-
85-
# POC helper
86-
def enrich_supporting_image(resp: Response):
87-
for e in resp.data['entry']:
88-
extensions = e['resource']['extension']
89-
class_type = lookup_1_and_get("$.resource.class[?(@.type.coding[0].code=='plan')]", "value", e)
90-
class_type = "Part A" if class_type is None else class_type
91-
extensions.append(get_supporting_image_extension(INS_TYPE2CARD[class_type]))
92-
93-
return resp
94-
9524

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

186113

187114
class SearchViewExplanationOfBenefit(SearchView):

requirements/requirements.dev.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -422,10 +422,6 @@ jmespath==1.0.1 \
422422
# via
423423
# boto3
424424
# botocore
425-
jsonpath-ng==1.6.1 \
426-
--hash=sha256:086c37ba4917304850bd837aeab806670224d3f038fe2833ff593a672ef0a5fa \
427-
--hash=sha256:8f22cd8273d7772eea9aaa84d922e0841aa36fdb8a2c6b7f6c3791a16a9bc0be
428-
# via -r requirements/requirements.in
429425
jsonschema==4.17.3 \
430426
--hash=sha256:0f864437ab8b6076ba6707453ef8f98a6a0d512a80e93f8abdb676f737ecb60d \
431427
--hash=sha256:a870ad254da1a8ca84b6a2905cac29d265f805acc57af304784962a2aa6508f6
@@ -618,10 +614,6 @@ pluggy==1.5.0 \
618614
--hash=sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1 \
619615
--hash=sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669
620616
# via pytest
621-
ply==3.11 \
622-
--hash=sha256:00c7c1aaa88358b9c765b6d3000c6eec0ba42abca5351b095321aef446081da3 \
623-
--hash=sha256:096f9b8350b65ebd2fd1346b12452efe5b9607f7482813ffca50c22722a807ce
624-
# via jsonpath-ng
625617
psycopg2-binary==2.9.6 \
626618
--hash=sha256:02c0f3757a4300cf379eb49f543fb7ac527fb00144d39246ee40e1df684ab514 \
627619
--hash=sha256:02c6e3cf3439e213e4ee930308dc122d6fb4d4bea9aef4a12535fbd605d1a2fe \

requirements/requirements.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ pyrsistent
3939
typing_extensions
4040
importlib-metadata
4141
certifi
42-
jsonpath-ng
4342

4443
# notifications
4544
django-ses

requirements/requirements.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -335,10 +335,6 @@ jmespath==1.0.1 \
335335
# via
336336
# boto3
337337
# botocore
338-
jsonpath-ng==1.6.1 \
339-
--hash=sha256:086c37ba4917304850bd837aeab806670224d3f038fe2833ff593a672ef0a5fa \
340-
--hash=sha256:8f22cd8273d7772eea9aaa84d922e0841aa36fdb8a2c6b7f6c3791a16a9bc0be
341-
# via -r requirements/requirements.in
342338
jsonschema==4.17.3 \
343339
--hash=sha256:0f864437ab8b6076ba6707453ef8f98a6a0d512a80e93f8abdb676f737ecb60d \
344340
--hash=sha256:a870ad254da1a8ca84b6a2905cac29d265f805acc57af304784962a2aa6508f6
@@ -450,10 +446,6 @@ pkgutil-resolve-name==1.3.10 \
450446
# via
451447
# -r requirements/requirements.in
452448
# jsonschema
453-
ply==3.11 \
454-
--hash=sha256:00c7c1aaa88358b9c765b6d3000c6eec0ba42abca5351b095321aef446081da3 \
455-
--hash=sha256:096f9b8350b65ebd2fd1346b12452efe5b9607f7482813ffca50c22722a807ce
456-
# via jsonpath-ng
457449
psycopg2-binary==2.9.6 \
458450
--hash=sha256:02c0f3757a4300cf379eb49f543fb7ac527fb00144d39246ee40e1df684ab514 \
459451
--hash=sha256:02c6e3cf3439e213e4ee930308dc122d6fb4d4bea9aef4a12535fbd605d1a2fe \
-28.8 KB
Binary file not shown.
-48.4 KB
Binary file not shown.

0 commit comments

Comments
 (0)