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
34from apps .authorization .permissions import DataAccessGrantPermission
45from apps .capabilities .permissions import TokenHasProtectedCapability
56from 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"
0 commit comments