-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new env variable for setting Value set version #32
base: main
Are you sure you want to change the base?
Changes from all commits
48fdc92
040e585
44cdd40
27dcaf9
e5d249f
acad50a
cc15108
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
import json | ||
import os | ||
|
||
TERMINOLOGY_SERVER_ADDRESS = os.environ.get('ONTOLOGY_SERVER_ADDRESS') | ||
SERVER_CERTIFICATE = os.environ.get('SERVER_CERTIFICATE') | ||
PRIVATE_KEY = os.environ.get('PRIVATE_KEY') | ||
|
||
# Get the current working directory | ||
current_working_dir = os.getcwd() | ||
print(current_working_dir) | ||
mapping_path = os.environ.get('ONTO_MAPPING_PATH', os.path.join(current_working_dir, '..', '..', 'mapping.json')) | ||
with open(mapping_path, 'r') as file: | ||
MAPPING_ONTO_VERSION = json.load(file) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
import bisect | ||
import logging | ||
from typing import List | ||
|
||
import requests | ||
import locale | ||
|
||
from sortedcontainers import SortedSet | ||
|
||
from TerminologService.TermServerConstants import TERMINOLOGY_SERVER_ADDRESS, SERVER_CERTIFICATE, PRIVATE_KEY | ||
from TerminologService.TermServerConstants import TERMINOLOGY_SERVER_ADDRESS, SERVER_CERTIFICATE, PRIVATE_KEY, MAPPING_ONTO_VERSION | ||
from model.UiDataModel import TermCode, TermEntry | ||
|
||
locale.setlocale(locale.LC_ALL, 'de_DE') | ||
|
@@ -22,7 +23,23 @@ def expand_value_set(url: str, onto_server: str = TERMINOLOGY_SERVER_ADDRESS): | |
if '|' in url: | ||
url = url.replace('|', '&version=') | ||
term_codes = SortedSet() | ||
response = requests.get(onto_server + f"ValueSet/$expand?url={url}", cert=(SERVER_CERTIFICATE, PRIVATE_KEY)) | ||
version = MAPPING_ONTO_VERSION.get('canonical_address') | ||
onto_server = TERMINOLOGY_SERVER_ADDRESS | ||
|
||
if version: | ||
canonical_address = f"ValueSet/$expand?url={url}&system-version={version}" | ||
else: | ||
canonical_address = f"ValueSet/$expand?url={url}" | ||
logging.debug(f"No version found for canonical address: {canonical_address}") | ||
Comment on lines
+31
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The log output is not in line with the implementation. You never look up {canonical_address} but "canonical_address" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would that be a better logging message which clarifys the purpose of the error? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes |
||
|
||
complete_url = onto_server + canonical_address | ||
print(complete_url) | ||
try: | ||
response = requests.get(complete_url, cert=(SERVER_CERTIFICATE, PRIVATE_KEY)) | ||
response.raise_for_status() | ||
except requests.exceptions.RequestException as e: | ||
logging.error(f"An error occurred while requesting the ontology server: {e}") | ||
|
||
print(response.status_code) | ||
if response.status_code == 200: | ||
value_set_data = response.json() | ||
|
@@ -50,7 +67,6 @@ def expand_value_set(url: str, onto_server: str = TERMINOLOGY_SERVER_ADDRESS): | |
print(response.content) | ||
return [] | ||
# raise Exception(response.status_code, response.content) | ||
print(term_codes) | ||
return term_codes | ||
|
||
|
||
|
This file was deleted.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can only assume this intended to be the canonical address of the valueset that requires the snomed version? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The mapping.json file, which contains version information, has been updated as follows: Currently, only one version of SNOMED is provided in this file because this update specifically applies to ICU use cases. Additional versions will be added as they become available and relevant to other domains. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where do you get the key information from? It shouldn't be static. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"canonical_address": "http%3A%2F%2Fsnomed.info%2Fsct%7Chttp%3A%2F%2Fsnomed.info%2Fsct%2F900000000000207008%2Fversion%2F20240101" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use a file if you always get the same version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It ensures that the system remains adaptable and scalable as more version-specific requirements emerge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure but please a variable here and not a string in that case. Probably you want to use the actual canonical_adress not a string.