Skip to content
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

Fix consent id #362

Merged
merged 3 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/dug/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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 = {}
Expand Down
23 changes: 21 additions & 2 deletions src/dug/core/async_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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





Expand Down
Loading