Skip to content

Commit

Permalink
OpenConceptLab/ocl_issues#2030 FHIR endpoints must be handled with or…
Browse files Browse the repository at this point in the history
… without trailing slash
  • Loading branch information
rkorytkowski committed Nov 27, 2024
1 parent fc90744 commit dc9bdda
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 8 deletions.
2 changes: 1 addition & 1 deletion core/code_systems/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def to_representation(self, instance):

def create(self, validated_data):
concepts = validated_data.pop('concepts', [])
uri = self.context['request'].path + validated_data['mnemonic']
uri = '/'.join([self.context['request'].path.rstrip('/'), validated_data['mnemonic']])
ident = IdentifierSerializer.include_ocl_identifier(uri, RESOURCE_TYPE, validated_data)
source = SourceCreateOrUpdateSerializer().prepare_object(validated_data)

Expand Down
2 changes: 1 addition & 1 deletion core/code_systems/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ def test_put_code_system_without_concepts(self):
@patch('core.sources.models.index_source_mappings', Mock(__name__='index_source_mappings'))
def test_post_code_system_with_concepts(self):
response = self.client.post(
f'/users/{self.user.mnemonic}/CodeSystem/',
f'/users/{self.user.mnemonic}/CodeSystem',
HTTP_AUTHORIZATION='Token ' + self.user_token,
data={
'url': 'http://localhost/url',
Expand Down
5 changes: 4 additions & 1 deletion core/code_systems/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
urlpatterns = [
path('', views.CodeSystemListView.as_view(), name='code-system-list'),
path('$lookup/', views.CodeSystemListLookupView.as_view(), name='code-system-list-lookup'),
path('$lookup', views.CodeSystemListLookupView.as_view(), name='code-system-list-lookup_no_slash'),
path('$validate-code/', views.CodeSystemValidateCodeView.as_view(), name='code-system-validate-code'),
path("<str:source>/", views.CodeSystemRetrieveUpdateView.as_view(), name='code-system-detail')
path('$validate-code', views.CodeSystemValidateCodeView.as_view(), name='code-system-validate-code_no_slash'),
path("<str:source>/", views.CodeSystemRetrieveUpdateView.as_view(), name='code-system-detail'),
path("<str:source>", views.CodeSystemRetrieveUpdateView.as_view(), name='code-system-detail_no_slash'),
]
3 changes: 3 additions & 0 deletions core/code_systems/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ class CodeSystemListLookupView(ConceptRetrieveUpdateDestroyView):
def is_container_version_specified(self):
return True

def verify_scope(self):
pass

def get_queryset(self):
queryset = super().get_queryset()
code = self.request.query_params.get('code')
Expand Down
2 changes: 1 addition & 1 deletion core/concept_maps/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def to_representation(self, instance):

def create(self, validated_data):
mappings = validated_data.pop('mappings', [])
uri = self.context['request'].path + validated_data['mnemonic']
uri = '/'.join([self.context['request'].path.rstrip('/'), validated_data['mnemonic']])
ident = IdentifierSerializer.include_ocl_identifier(uri, RESOURCE_TYPE, validated_data)
source = SourceCreateOrUpdateSerializer().prepare_object(validated_data)

Expand Down
6 changes: 4 additions & 2 deletions core/concept_maps/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

urlpatterns = [
path('', views.ConceptMapListView.as_view(), name='concept-map-list'),
path('$translate', views.ConceptMapTranslateView.as_view(), name='concept-map-list-translate'),
path("<str:source>/", views.ConceptMapRetrieveUpdateView.as_view(), name='concept-map-detail')
path('$translate/', views.ConceptMapTranslateView.as_view(), name='concept-map-list-translate'),
path('$translate', views.ConceptMapTranslateView.as_view(), name='concept-map-list-translate_no_slash'),
path("<str:source>/", views.ConceptMapRetrieveUpdateView.as_view(), name='concept-map-detail'),
path("<str:source>", views.ConceptMapRetrieveUpdateView.as_view(), name='concept-map-detail_no_slash')
]
3 changes: 3 additions & 0 deletions core/orgs/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@
path('<str:org>/repos/', include('core.repos.urls'), name='org-repos-urls'),
path('<str:org>/sources/', include('core.sources.urls')),
path('<str:org>/CodeSystem/', include('core.code_systems.urls'), name='code_systems_urls'),
path('<str:org>/CodeSystem', include('core.code_systems.urls'), name='code_systems_urls_no_slash'),
path('<str:org>/ValueSet/', include('core.value_sets.urls'), name='value_sets_urls'),
path('<str:org>/ValueSet', include('core.value_sets.urls'), name='value_sets_urls_no_slash'),
path('<str:org>/ConceptMap/', include('core.concept_maps.urls'), name='concept_maps_urls'),
path('<str:org>/ConceptMap', include('core.concept_maps.urls'), name='concept_maps_urls_no_slash'),
path('<str:org>/collections/', include('core.collections.urls')),
path('<str:org>/pins/', include('core.pins.urls')),
path('<str:org>/events/', include('core.events.urls')),
Expand Down
3 changes: 3 additions & 0 deletions core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,11 @@
# TODO: require FHIR subdomain
path('fhir/', include('core.fhir.urls'), name='fhir_urls'),
path('fhir/CodeSystem/', include('core.code_systems.urls'), name='code_systems_urls'),
path('fhir/CodeSystem', include('core.code_systems.urls'), name='code_systems_urls_no_slash'),
path('fhir/ValueSet/', include('core.value_sets.urls'), name='value_sets_urls'),
path('fhir/ValueSet', include('core.value_sets.urls'), name='value_sets_urls_no_slash'),
path('fhir/ConceptMap/', include('core.concept_maps.urls'), name='concept_maps_urls'),
path('fhir/ConceptMap', include('core.concept_maps.urls'), name='concept_maps_urls_no_slash'),

path('collections/', include('core.collections.urls'), name='collections_urls'),
path('concepts/', concept_views.ConceptListView.as_view(), name='all_concepts_urls'),
Expand Down
3 changes: 3 additions & 0 deletions core/users/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@

# TODO: require FHIR subdomain
path('<str:user>/CodeSystem/', include('core.code_systems.urls'), name='code_systems_urls'),
path('<str:user>/CodeSystem', include('core.code_systems.urls'), name='code_systems_urls_no_slash'),
path('<str:user>/ValueSet/', include('core.value_sets.urls'), name='value_sets_urls'),
path('<str:user>/ValueSet', include('core.value_sets.urls'), name='value_sets_urls_no_slash'),
path('<str:user>/ConceptMap/', include('core.concept_maps.urls'), name='concept_maps_urls'),
path('<str:user>/ConceptMap', include('core.concept_maps.urls'), name='concept_maps_urls_no_slash'),
]
2 changes: 1 addition & 1 deletion core/value_sets/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class Meta:
'immutable', 'text', 'compose')

def create(self, validated_data):
uri = self.context['request'].path + validated_data['mnemonic']
uri = '/'.join([self.context['request'].path.rstrip('/'), validated_data['mnemonic']])
ident = IdentifierSerializer.include_ocl_identifier(uri, RESOURCE_TYPE, validated_data)
collection = CollectionCreateOrUpdateSerializer().prepare_object(validated_data)
collection_version = collection.version if collection.version != HEAD else '0.1'
Expand Down
7 changes: 6 additions & 1 deletion core/value_sets/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
urlpatterns = [
path('', views.ValueSetListView.as_view(), name='value-set-list'),
path("<str:collection>/$validate-code/", views.ValueSetValidateCodeView.as_view(), name='value-set-validate-code'),
path("<str:collection>/$validate-code", views.ValueSetValidateCodeView.as_view(),
name='value-set-validate-code_no_slash'),
path("$validate-code/", views.ValueSetValidateCodeView.as_view(), name='value-set-validate-code-global'),
path("<str:collection>/$expand/", views.ValueSetExpandView.as_view(), name='value-set-validate-code'),
path("$validate-code", views.ValueSetValidateCodeView.as_view(), name='value-set-validate-code-global_no_slash'),
path("<str:collection>/$expand/", views.ValueSetExpandView.as_view(), name='value-set-expand'),
path("<str:collection>/$expand", views.ValueSetExpandView.as_view(), name='value-set-expand_no_slash'),
path("<str:collection>/", views.ValueSetRetrieveUpdateView.as_view(), name='value-set-detail'),
path("<str:collection>", views.ValueSetRetrieveUpdateView.as_view(), name='value-set-detail_no_slash'),
]

0 comments on commit dc9bdda

Please sign in to comment.