Skip to content

Commit 3bfc4c7

Browse files
add TODOs and fix fhir_id not being available in a "list"
1 parent 5e98104 commit 3bfc4c7

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

apps/fhir/bluebutton/v3/urls.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
# C4DIC
5656
# Digital Insurance Card ViewSet
5757
# TODO - Change the URI for this endpoint when we finalize
58+
# TODO - We are sending this to list even though it is a retrieve BECAUSE we're not asking for a resource id by the
59+
# application, which means we're kinda breaking REST principles here.
5860
re_path(
5961
r'DigitalInsuranceCard[/]?',
6062
waffle_switch('v3_endpoints')(DigitalInsuranceCardViewSet.as_view({'get': 'list'}, version=3)),

apps/fhir/bluebutton/views/insurancecard_viewset.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
from rest_framework import viewsets, permissions
2-
from apps.fhir.bluebutton.views.generic import FhirDataView
1+
from rest_framework import permissions
2+
from apps.fhir.bluebutton.models import Crosswalk
3+
from apps.fhir.bluebutton.views.viewsets_base import ResourceViewSet
34
from apps.authorization.permissions import DataAccessGrantPermission
45
from apps.capabilities.permissions import TokenHasProtectedCapability
56
from apps.fhir.bluebutton.permissions import (
@@ -15,7 +16,7 @@ def has_permission(self, request, view) -> bool: # type: ignore
1516
return True
1617

1718

18-
class DigitalInsuranceCardViewSet(FhirDataView, viewsets.ViewSet):
19+
class DigitalInsuranceCardViewSet(ResourceViewSet):
1920
"""Digital Insurance Card (bundle) django-rest-framework ViewSet experiment
2021
2122
Args:
@@ -50,8 +51,10 @@ def build_url(self, fhir_settings, resource_type, resource_id=None, *args, **kwa
5051
# only if called by tests
5152
return f"{fhir_settings.fhir_url}{resource_type}/"
5253
else:
54+
# TODO - is this preferred (explicit), or should we keep using the implicit model APIS that Django creates?
55+
fhir_id = Crosswalk.objects.get(user=self.request.user).fhir_id(self.version)
5356
if self.version == 3 and getattr(fhir_settings, 'fhir_url_v3', None):
5457
fhir_url = fhir_settings.fhir_url_v3
5558
else:
5659
fhir_url = fhir_settings.fhir_url
57-
return f"{fhir_url}/v{self.version}/fhir/Patient/{resource_id}/$generate-insurance-card"
60+
return f"{fhir_url}/v{self.version}/fhir/Patient/{fhir_id}/$generate-insurance-card"

apps/fhir/bluebutton/views/viewsets_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def list(self, request, *args, **kwargs):
3535
out = self.fetch_data(request, self.resource_type, *args, **kwargs)
3636
return Response(out)
3737

38-
def retrieve(self, request, resource_id=None, *args, **kwargs):
38+
def retrieve(self, request, resource_id, *args, **kwargs):
3939
out = self.fetch_data(request, self.resource_type, resource_id=resource_id, *args, **kwargs)
4040
return Response(out)
4141

@@ -70,4 +70,4 @@ def filter_parameters(self, request):
7070

7171
# TODO - investigate if this is needed, or if we can assume application/json+fhir everywhere
7272
def build_parameters(self, request):
73-
return {'_format': 'application/json+fhir'}
73+
return {'_format': 'application/json'}

0 commit comments

Comments
 (0)