Skip to content

Commit

Permalink
fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
JFU-NAVA-PBC committed Jan 13, 2025
1 parent f05539d commit 6e0b073
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions apps/authorization/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def has_object_permission(self, request, view, obj):
def is_resource_for_patient(obj, patient_id):

if (obj is not None
and obj.get('resourceType') is not None
and obj.get('resourceType') == 'OperationOutcome'):
and obj.get('resourceType') is not None
and obj.get('resourceType') == 'OperationOutcome'):
return True

try:
Expand Down
10 changes: 6 additions & 4 deletions apps/fhir/bluebutton/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# 4xx client error – the request contains bad syntax or cannot be fulfilled
# 5xx server error – the server failed to fulfil an apparently valid request


def process_error_response(response: Fhir_Response) -> APIException:
""" Need to be revised to new handling logic
Process errors coming from FHIR endpoints.
Expand All @@ -34,12 +35,12 @@ def process_error_response(response: Fhir_Response) -> APIException:
if response.status_code == 404:
# not found is not bad gateway
err = NotFound('The requested resource does not exist')
elif (response.status_code in range(400, 600) and
not _is_operation_outcome(r)):
elif (response.status_code in range(400, 600)
and not _is_operation_outcome(r)):
# only back end response with 4xx, 5xx and the payload is not FHIR OperationOutcome
# are treated as bad gateway
# TODO: add more back end response content to the BAD GATEWAY message?
# it helps trouble shooting, concern: would there be PII/PHI/sensitive info in the back end response?
# it helps trouble shooting, concern: would there be PII/PHI/sensitive info in the back end response?
err = UpstreamServerException('An error occurred contacting the upstream server')
else:
# 1xx - rare case, proceed to caller
Expand All @@ -55,6 +56,7 @@ class UpstreamServerException(APIException):
# status_code = status.HTTP_400_BAD_REQUEST
#


# helper to check if the response is a FHIR OperationOutcome
def _is_operation_outcome(r: Fhir_Response):
result = False
Expand All @@ -68,4 +70,4 @@ def _is_operation_outcome(r: Fhir_Response):
# TODO: consider debug logging the body content (e.g. a html string)
# to help trouble shooting
pass
return result
return result
4 changes: 2 additions & 2 deletions apps/fhir/bluebutton/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ def has_object_permission(self, request, view, obj):
# Return 404 on error to avoid notifying unauthorized user the object exists

if (obj is not None
and obj.get('resourceType') is not None
and obj.get('resourceType') == 'OperationOutcome'):
and obj.get('resourceType') is not None
and obj.get('resourceType') == 'OperationOutcome'):
return True

try:
Expand Down
2 changes: 1 addition & 1 deletion apps/fhir/bluebutton/views/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def get(self, request, resource_type, *args, **kwargs):

out_data, status_code = self.fetch_data(request, resource_type, *args, **kwargs)

return Response(out_data,status_code)
return Response(out_data, status_code)

def fetch_data(self, request, resource_type, *args, **kwargs):
resource_router = get_resourcerouter(request.crosswalk)
Expand Down

0 comments on commit 6e0b073

Please sign in to comment.