diff --git a/src/dug/config.py b/src/dug/config.py index 24aef3d..93bc678 100644 --- a/src/dug/config.py +++ b/src/dug/config.py @@ -28,8 +28,9 @@ class Config: nboost_port: int = 8000 program_sort_list: str = "" - program_description: dict=field( - default_factory=lambda:{}) + program_description: dict=field(default_factory=lambda:{}) + consent_id_path: str= "" + # Preprocessor config that will be passed to annotate.Preprocessor constructor preprocessor: dict = field( @@ -142,6 +143,7 @@ def from_env(cls): "redis_port": "REDIS_PORT", "redis_password": "REDIS_PASSWORD", "program_description": "PROGRAM_DESCRIPTION", + "consent_id_path": "CONSENT_ID_PATH" } kwargs = {} diff --git a/src/dug/core/async_search.py b/src/dug/core/async_search.py index d7d21e0..4ba27cb 100644 --- a/src/dug/core/async_search.py +++ b/src/dug/core/async_search.py @@ -499,7 +499,7 @@ async def search_program(self, program_name=None, offset=0, size=None): "match": {"data_type": program_name} }) - print("query_body", query_body) + #print("query_body", query_body) # Prepare the query body for execution body = query_body @@ -523,7 +523,26 @@ async def search_program(self, program_name=None, offset=0, size=None): # Append the details to the list in the desired format collection_details_list.append(collection_details) - return collection_details_list + + with open(self._cfg.consent_id_path, 'r') as file: + consent_id_mappings = json.load(file) + # Add consent_id to the study + updated_studies = [] + for study in collection_details_list: + collection_id = study["collection_id"] + if collection_id in consent_id_mappings: + consent_ids = consent_id_mappings[collection_id] + for consent_id in consent_ids: + updated_study = study.copy() + updated_study["collection_id"] = f"{collection_id}.{consent_id}" + updated_study["collection_action"] = f"{study['collection_action']}" + updated_studies.append(updated_study) + else: + updated_studies.append(study) + + return updated_studies + +