Skip to content

Commit 06e8ffc

Browse files
JackScanlonieuans
andauthored
feat: DOIs, GA4 and DataSource enhancements
Co-authored-by: ieuans <ieuans@users.noreply.github.com>
1 parent bf944e6 commit 06e8ffc

File tree

70 files changed

+3522
-1203
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+3522
-1203
lines changed

.github/workflows/testing-pipline.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ jobs:
8282
8383
- name: Run application
8484
run: |
85-
export $(grep -v '^#' docker/.env/remote.test.env | xargs)
85+
export $(grep -v '^#' docker/env/remote.test.env | xargs)
8686
cd CodeListLibrary_project
8787
python manage.py runserver 0.0.0.0:8000 > /dev/null &
8888
8989
- name: Run tests
9090
run: |
91-
export $(grep -v '^#' docker/.env/remote.test.env | xargs)
91+
export $(grep -v '^#' docker/env/remote.test.env | xargs)
9292
cd CodeListLibrary_project
9393
pytest -vv -s --random-order --cov-report xml --cov . --html=report.html --self-contained-html --alluredir=./clinicalcode/tests/allure-results
9494
env:

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ __pycache__
44

55
# Py env
66
**/env/
7-
**/.env/
87
**/venv/
98
**/.venv/
109

@@ -47,7 +46,7 @@ CodeListLibrary_project/staticroot/*
4746
**/engagelens/.env
4847

4948
# Allow docker env directory
50-
!**/docker/.env/
49+
!**/docker/env/
5150
!**/docker/**/env/
5251

5352
# Platform / OS files

CodeListLibrary_project/clinicalcode/api/views/DataSource.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def get_datasources(request):
2222
| id | `int/list[int]` | `NULL` | Match by a single `int` _id_ field, or match by array overlap |
2323
| name | `str` | `NULL` | Case insensitive direct match of _name_ field |
2424
| uid | `str/uuid` | `NULL` | Case insensitive direct match of _uid_ field |
25-
| datasource_id | `int` | `NULL` | Match by exact _datasource_id_ |
25+
| datasource_id | `int` | `NULL` | Match by exact _datasource_id_ (HDRUK ID) |
2626
| url | `str` | `NULL` | Case insensitive direct match of _url_ field |
2727
| source | `str` | `NULL` | Case insensitive direct match of _source_ field |
2828
"""
@@ -54,7 +54,7 @@ def get_datasources(request):
5454
@permission_classes([IsAuthenticatedOrReadOnly])
5555
def get_datasource_internal_detail(request, datasource_id):
5656
"""
57-
Get detail of specified datasource by by its internal Id
57+
Get detail of specified datasource by by its internal `id`
5858
"""
5959
query = None
6060
if gen_utils.parse_int(datasource_id, default=None) is not None:
@@ -134,6 +134,7 @@ def get_datasource_internal_detail(request, datasource_id):
134134
'url': datasource.url,
135135
'uid': datasource.uid,
136136
'description': datasource.description,
137+
'datasource_id': datasource.datasource_id,
137138
'source': datasource.source,
138139
'phenotypes': list(entities)
139140
}
@@ -147,13 +148,13 @@ def get_datasource_internal_detail(request, datasource_id):
147148
@permission_classes([IsAuthenticatedOrReadOnly])
148149
def get_datasource_detail(request, datasource_id):
149150
"""
150-
Get detail of specified datasource by `datasource_id`, _i.e._ the HDRUK DataSource `pid` or its `UUID` for linkage between applications, including associated published entities.
151+
Get detail of specified datasource by its internal `id` or its `UUID` for linkage between applications (see HDRUK HealthDataGateway), including associated published entities.
151152
"""
152153
query = None
153154
if gen_utils.is_valid_uuid(datasource_id):
154155
query = { 'uid': datasource_id }
155156
elif gen_utils.parse_int(datasource_id, default=None) is not None:
156-
query = { 'datasource_id': int(datasource_id) }
157+
query = { 'id': int(datasource_id) }
157158

158159
if not query:
159160
return Response(
@@ -228,6 +229,7 @@ def get_datasource_detail(request, datasource_id):
228229
'url': datasource.url,
229230
'uid': datasource.uid,
230231
'description': datasource.description,
232+
'datasource_id': datasource.datasource_id,
231233
'source': datasource.source,
232234
'phenotypes': list(entities)
233235
}

CodeListLibrary_project/clinicalcode/context_processors/general.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ def general_var(request):
1919
'SHOW_COOKIE_ALERT': settings.SHOW_COOKIE_ALERT,
2020
'IS_HDRUK_EXT': settings.IS_HDRUK_EXT,
2121
'CANONICAL_PATH': get_canonical_path(request),
22-
'APPROVED_STATUS_DICT': {e.name: e.value for e in constants.APPROVAL_STATUS}
22+
'APPROVED_STATUS_DICT': {e.name: e.value for e in constants.APPROVAL_STATUS},
23+
'DOI_ACTIVE': settings.DOI_ACTIVE,
2324
}

CodeListLibrary_project/clinicalcode/entity_utils/constants.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,10 @@ class ONTOLOGY_TYPES(int, enum.Enum, metaclass=IterableMeta):
623623
'allowed_brands': [3],
624624
'allow_null': True,
625625
},
626-
'HDRUK': 'allow_null',
626+
'HDRUK': {
627+
'allowed_brands': [1, 2, 3],
628+
'allow_null': True,
629+
},
627630
'HDRN': True,
628631
'SAIL': False,
629632
},

CodeListLibrary_project/clinicalcode/entity_utils/create_utils.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1427,7 +1427,16 @@ def compute_brand_context(request, form_data, form_entity=None):
14271427
if len(collections) > 0:
14281428
related_brands.update(collections)
14291429

1430-
return list(related_brands)
1430+
related_brands = list(related_brands)
1431+
1432+
# Ensure brand is first in list (for referral)
1433+
if brand is not None:
1434+
idx = next((i for i, x in enumerate(related_brands) if x == brand.id), None)
1435+
if idx is not None and idx != 0:
1436+
related_brands[idx] = related_brands[0]
1437+
related_brands[0] = brand.id
1438+
1439+
return related_brands
14311440

14321441
@transaction.atomic
14331442
def create_or_update_entity_from_form(request, form, errors=[], override_dirty=False):

0 commit comments

Comments
 (0)