Skip to content

Commit

Permalink
OpenConceptLab/ocl_issues#1839 Add code searchParam for CodeSystem (fix)
Browse files Browse the repository at this point in the history
  • Loading branch information
rkorytkowski committed May 21, 2024
1 parent 7c4280a commit 0103dfd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 2 additions & 4 deletions core/code_systems/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,9 @@ def test_find_by_code(self):
self.assertEqual(resource['version'], 'v2')

def test_find_by_non_supported_param(self):
with self.assertRaises(Exception) as context:
self.client.get('/fhir/CodeSystem/?non_supported_param=' + self.concept_1.mnemonic)
response = self.client.get('/fhir/CodeSystem/?non_supported_param=' + self.concept_1.mnemonic)

self.assertEqual(str(context.exception), 'The following query params are not supported: {'
'"non_supported_param": "' + self.concept_1.mnemonic + '"}')
self.assertEqual(response.status_code, 400)

def test_private_can_list(self):
response = self.client.get('/fhir/CodeSystem/', HTTP_AUTHORIZATION='Token ' + self.user_token)
Expand Down
4 changes: 3 additions & 1 deletion core/common/fhir_helpers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import json

from django.core.exceptions import BadRequest


def translate_fhir_query(fhir_query_fields, query_params, queryset):
remaining_query_params = query_params.copy()
Expand Down Expand Up @@ -42,7 +44,7 @@ def translate_fhir_query(fhir_query_fields, query_params, queryset):
queryset = queryset.filter(**kwargs)

if remaining_query_params:
raise Exception('The following query params are not supported: ' + json.dumps(remaining_query_params))
raise BadRequest('The following query params are not supported: ' + json.dumps(remaining_query_params))

return queryset

Expand Down

0 comments on commit 0103dfd

Please sign in to comment.