-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(release): fixes and updates (#1613)
- Loading branch information
Showing
113 changed files
with
7,894 additions
and
1,266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
CodeListLibrary_project/clinicalcode/api/views/Ontology.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
from rest_framework.decorators import (api_view, permission_classes) | ||
from rest_framework.permissions import IsAuthenticatedOrReadOnly | ||
from rest_framework.response import Response | ||
from rest_framework import status | ||
from django.db.models import F | ||
|
||
from ...entity_utils import api_utils | ||
from ...entity_utils import gen_utils | ||
from ...entity_utils import constants | ||
|
||
from ...models.OntologyTag import OntologyTag | ||
|
||
@api_view(['GET']) | ||
@permission_classes([IsAuthenticatedOrReadOnly]) | ||
def get_ontologies(request): | ||
""" | ||
Get all ontology categories and their root nodes, incl. associated data | ||
""" | ||
result = OntologyTag.get_groups([x.value for x in constants.ONTOLOGY_TYPES], default=[]) | ||
return Response( | ||
data=list(result), | ||
status=status.HTTP_200_OK | ||
) | ||
|
||
@api_view(['GET']) | ||
@permission_classes([IsAuthenticatedOrReadOnly]) | ||
def get_ontology_detail(request, ontology_id): | ||
""" | ||
Get specified ontology group detail by the ontology_id type, including associated | ||
data e.g. root nodes, children etc | ||
""" | ||
ontology_id = gen_utils.parse_int(ontology_id, default=None) | ||
if not isinstance(ontology_id, int): | ||
return Response( | ||
data={ | ||
'message': 'Invalid ontology id, expected valid integer' | ||
}, | ||
content_type='json', | ||
status=status.HTTP_400_BAD_REQUEST | ||
) | ||
|
||
result = OntologyTag.get_group_data(ontology_id, default=None) | ||
if not isinstance(result, dict): | ||
return Response( | ||
data={ | ||
'message': f'Ontology of id {ontology_id} does not exist' | ||
}, | ||
content_type='json', | ||
status=status.HTTP_404_NOT_FOUND | ||
) | ||
|
||
return Response( | ||
data=result, | ||
status=status.HTTP_200_OK | ||
) | ||
|
||
@api_view(['GET']) | ||
@permission_classes([IsAuthenticatedOrReadOnly]) | ||
def get_ontology_node(request, node_id): | ||
""" | ||
Get the element details of the specified ontology element by its | ||
node_id including associated data | ||
e.g. tree-related information | ||
""" | ||
node_id = gen_utils.parse_int(node_id, default=None) | ||
if not isinstance(node_id, int): | ||
return Response( | ||
data={ | ||
'message': 'Invalid node id, expected valid integer' | ||
}, | ||
content_type='json', | ||
status=status.HTTP_400_BAD_REQUEST | ||
) | ||
|
||
result = OntologyTag.get_node_data(node_id, default=None) | ||
return Response( | ||
data=result, | ||
status=status.HTTP_200_OK | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.