Skip to content

Commit

Permalink
OpenConceptLab/ocl_issues#1840 CodeSystem listing should include total
Browse files Browse the repository at this point in the history
  • Loading branch information
rkorytkowski committed May 17, 2024
1 parent fd0e4e0 commit 4998548
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions core/code_systems/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def test_public_can_view(self):
response = self.client.get('/fhir/CodeSystem/?url=/some/url')

self.assertEqual(len(response.data['entry']), 1)
self.assertEqual(response.data['total'], 1)

resource = response.data['entry'][0]['resource']
self.assertEqual(
Expand All @@ -57,6 +58,8 @@ def test_private_can_view(self):
response = self.client.get('/fhir/CodeSystem/?url=/some/url', HTTP_AUTHORIZATION='Token ' + self.user_token)

self.assertEqual(len(response.data['entry']), 2)
self.assertEqual(response.data['total'], 2)

resource = response.data['entry'][0]['resource']
self.assertEqual(
resource['identifier'][0]['value'],
Expand Down
2 changes: 1 addition & 1 deletion core/code_systems/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class CodeSystemListView(SourceListView):
@staticmethod
def bundle_response(data, paginator):
bundle = FHIRBundleSerializer(
{'meta': {}, 'type': 'searchset', 'entry': FHIRBundleSerializer.convert_to_entry(data)},
{'meta': {}, 'total': len(data), 'type': 'searchset', 'entry': FHIRBundleSerializer.convert_to_entry(data)},
context={'paginator': paginator}
)
return bundle.data
Expand Down
3 changes: 3 additions & 0 deletions core/concept_maps/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def test_public_can_view(self):
response = self.client.get('/fhir/ConceptMap/?url=/some/url')

self.assertEqual(len(response.data['entry']), 1)
self.assertEqual(response.data['total'], 1)

resource = response.data['entry'][0]['resource']
self.assertEqual(
Expand All @@ -94,6 +95,8 @@ def test_private_can_view(self):
response = self.client.get('/fhir/ConceptMap/?url=/some/url', HTTP_AUTHORIZATION='Token ' + self.user_token)

self.assertEqual(len(response.data['entry']), 2)
self.assertEqual(response.data['total'], 2)

resource = response.data['entry'][0]['resource']
self.assertEqual(
resource['identifier'][0]['value'],
Expand Down
2 changes: 1 addition & 1 deletion core/concept_maps/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ConceptMapListView(SourceListView):
@staticmethod
def bundle_response(data, paginator):
bundle = FHIRBundleSerializer(
{'meta': {}, 'type': 'searchset', 'entry': FHIRBundleSerializer.convert_to_entry(data)},
{'meta': {}, 'total': len(data), 'type': 'searchset', 'entry': FHIRBundleSerializer.convert_to_entry(data)},
context={'paginator': paginator}
)
return bundle.data
Expand Down
1 change: 1 addition & 0 deletions core/value_sets/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def test_public_can_find_globally_without_compose(self):
response = self.client.get('/fhir/ValueSet/?url=http://c1.com')

self.assertEqual(len(response.data['entry']), 1)
self.assertEqual(response.data['total'], 1)

resource = response.data['entry'][0]['resource']

Expand Down
2 changes: 1 addition & 1 deletion core/value_sets/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ValueSetListView(CollectionListView):
@staticmethod
def bundle_response(data, paginator):
bundle = FHIRBundleSerializer(
{'meta': {}, 'type': 'searchset', 'entry': FHIRBundleSerializer.convert_to_entry(data)},
{'meta': {}, 'total': len(data), 'type': 'searchset', 'entry': FHIRBundleSerializer.convert_to_entry(data)},
context={'paginator': paginator}
)
return bundle.data
Expand Down

0 comments on commit 4998548

Please sign in to comment.