Skip to content

Commit 1dd88b1

Browse files
Add pass through to BFD, make DIC endpoint visible for v3 testclient
1 parent 85f1949 commit 1dd88b1

File tree

5 files changed

+41
-22
lines changed

5 files changed

+41
-22
lines changed

apps/fhir/bluebutton/views/insurancecard.py

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
from waffle import switch_is_active
21
from apps.fhir.bluebutton.views.generic import FhirDataView
32
from apps.fhir.bluebutton.permissions import (SearchCrosswalkPermission,
43
ResourcePermission,
54
ApplicationActivePermission)
65
from apps.authorization.permissions import DataAccessGrantPermission
76
from apps.capabilities.permissions import TokenHasProtectedCapability
8-
from django.http import JsonResponse
97

108
from rest_framework import permissions # pyright: ignore[reportMissingImports]
119

@@ -43,20 +41,15 @@ def has_permission(self, request, view) -> bool: # type: ignore
4341
patient_set = set(HasDigitalInsuranceCardScope.required_patient_read_scopes)
4442
token_set = set(token_scopes)
4543

46-
# print()
47-
# print("CS", coverage_set)
48-
# print("PS", patient_set)
49-
# print("TS", token_set)
44+
print()
45+
print("CS", coverage_set)
46+
print("PS", patient_set)
47+
print("TS", token_set)
5048

5149
return (_is_not_empty(coverage_set.intersection(token_set))
5250
and _is_not_empty(patient_set.intersection(token_set)))
5351

5452

55-
class WaffleSwitchV3IsActive(permissions.BasePermission):
56-
def has_permission(self, request, view):
57-
return switch_is_active('v3_endpoints')
58-
59-
6053
class DigitalInsuranceCardView(FhirDataView):
6154
'''Digital Insurance Card view for handling BFD Endpoint'''
6255

@@ -83,21 +76,15 @@ def initial(self, request, *args, **kwargs):
8376
return super().initial(request, self.resource_type, *args, **kwargs)
8477

8578
def get(self, request, *args, **kwargs):
86-
# return super().get(request, self.resource_type, *args, **kwargs)
87-
return JsonResponse(status=200, data={"ok": "go"})
79+
print("GET OF INSURANCE CARD")
80+
print("request: ", request.__dict__)
81+
print("self.resource_type: ", self.resource_type)
82+
return super().get(request, self.resource_type, *args, **kwargs)
83+
# return JsonResponse(status=200, data={"ok": "go"})
8884

8985
# How do the has_permission herre and the has_permission in the permission classes
9086
# play together? If they pass, can this fail? Visa-versa?
9187

92-
def has_permission(self, request, view):
93-
# TODO: Why is this not being called?
94-
# A print statement where this comment is does not appear when unit tests are run.
95-
# But, the permission classes run. Where/when does has_permission get called?
96-
required_scopes = getattr(view, 'required_scopes', None)
97-
if required_scopes is None:
98-
return False
99-
return request.user.is_authenticated and hasattr(request.user, 'crosswalk')
100-
10188
def build_parameters(self, request):
10289
return {
10390
'_format': 'application/json'

apps/testclient/constants.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class EndpointUrl:
2929
patient = "patient"
3030
explanation_of_benefit = "eob"
3131
coverage = "coverage"
32+
digital_insurance_card = "digital_insurance_card"
3233
nav = "nav"
3334

3435
# TODO - theses are all format=json, not format=application/fhir+json, is this good?
@@ -47,6 +48,9 @@ def fmt(name: str, uri: str, version: int, patient: str = BAD_PATIENT_ID):
4748
return f'{uri}/{version_as_string}/fhir/ExplanationOfBenefit/?_format=application/fhir+json'
4849
case EndpointUrl.coverage:
4950
return f'{uri}/{version_as_string}/fhir/Coverage/?_format=application/fhir+json'
51+
case EndpointUrl.digital_insurance_card:
52+
# return f'{uri}/{version_as_string}/fhir/DigitalInsuranceCard/?_format=application/fhir+json'
53+
return f"{uri}/{version_as_string}/fhir/Patient/{patient}/$generate-insurance-card"
5054
case _:
5155
logger.error(f'Could not match name in EndpointUrl: {name}')
5256

apps/testclient/templates/home.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ <h2>Step 1: Sample Authorization</h2>
7272
{% url 'test_eob_v3' as test_eob_url %}
7373
{% url 'test_patient_v3' as test_patient_url %}
7474
{% url 'test_coverage_v3' as test_coverage_url %}
75+
{% url 'test_digital_insurance_card_v3' as test_digital_insurance_card_url %}
7576
{% endswitch %}
7677
{% else %}
7778
{% url 'authorize_link_v1' as auth_url %}
@@ -100,6 +101,9 @@ <h2>Step 2: API Calls</h2>
100101
<li> <a href="{{ test_patient_url }}">Patient</a> </li>
101102
<li> <a href="{{ test_coverage_url }}">Coverage</a> </li>
102103
<li> <a href="{{ test_userinfo_url }}">Profile </a> (OIDC Userinfo)</li>
104+
{% if api_ver == 3 %}
105+
<li> <a href="{{ test_digital_insurance_card_url }}">Digital Insurance Card</li>
106+
{% endif %}
103107
<li> <a href="{{ meta_url }}?format=json">FHIR Metadata</a> (No Token Needed)</li>
104108
<li> <a href="{{ openid_cfg_url }}">OIDC Discovery</a> (No Token Needed)</li>
105109
</ul>

apps/testclient/urls.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
test_patient_v3,
3434
test_userinfo_v3,
3535

36+
# c4dic
37+
test_digital_insurance_card_v3
38+
3639
)
3740

3841
urlpatterns_unversioned = [
@@ -69,6 +72,7 @@
6972
path('openidConfigV3', test_openid_config_v3, name='test_openid_config_v3'),
7073
path('PatientV3', test_patient_v3, name='test_patient_v3'),
7174
path('userinfoV3', test_userinfo_v3, name='test_userinfo_v3'),
75+
path('DigitalInsuranceCard', test_digital_insurance_card_v3, name='test_digital_insurance_card_v3'),
7276
]
7377

7478
urlpatterns = urlpatterns_unversioned + urlpatterns_v1 + urlpatterns_v2 + urlpatterns_v3

apps/testclient/views.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,20 @@ def _test_userinfo(request: HttpRequest, version=Versions.NOT_AN_API_VERSION):
539539
})
540540

541541

542+
def _test_digital_insurance_card(request: HttpRequest, version=Versions.NOT_AN_API_VERSION):
543+
if _link_session_or_version_is_bad(request.session, version):
544+
return _link_session_or_version_is_bad(request.session, version)
545+
546+
c4dic_info = _get_fhir_data_as_json(request, FhirDataParams(
547+
EndpointUrl.digital_insurance_card, request.session['resource_uri'], version, request.session['patient']))
548+
549+
return render(request, RESULTS_PAGE,
550+
{'fhir_json_pretty': json.dumps(c4dic_info, indent=3),
551+
'response_type': 'Bundle',
552+
'api_ver': version
553+
})
554+
555+
542556
############################################################
543557
# VERSION 1
544558
############################################################
@@ -739,3 +753,9 @@ def test_patient_v3(request: HttpRequest):
739753
@waffle_switch('enable_testclient')
740754
def test_userinfo_v3(request: HttpRequest):
741755
return _test_userinfo(request, version=Versions.V3)
756+
757+
758+
@never_cache
759+
@waffle_switch('enable_testclient')
760+
def test_digital_insurance_card_v3(request: HttpRequest):
761+
return _test_digital_insurance_card(request, version=Versions.V3)

0 commit comments

Comments
 (0)