Skip to content
Snippets Groups Projects
Commit 3c3ae717 authored by Jakub Dylag's avatar Jakub Dylag
Browse files

Allow multiple files per concept set - validation passed

parent 7ec0e5c5
Branches
No related tags found
No related merge requests found
......@@ -514,46 +514,47 @@ def validate(phen_dir: str):
# create a list of all the concept set names defined in the concept set configuration
concept_set_names = []
for item in phenotype["concept_sets"]:
# if item["name"] in concept_set_names:
# validation_errors.append(
# f"Duplicate concept set defined in concept sets {item['name'] }"
# )
# else:
concept_set_names.append(item["name"])
# check codes definition
for item in phenotype["concept_sets"]:
# check concepte code file exists
concept_code_file_path = concepts_path / item["file"]["path"]
if not concept_code_file_path.exists():
validation_errors.append(
f"Coding file {str(concept_code_file_path.resolve())} does not exist"
)
# check concepte code file is not empty
if concept_code_file_path.stat().st_size == 0:
if item["name"] in concept_set_names:
validation_errors.append(
f"Coding file {str(concept_code_file_path.resolve())} is an empty file"
f"Duplicate concept set defined in concept sets {item['name'] }"
)
else:
concept_set_names.append(item["name"])
# check code file type is supported
if concept_code_file_path.suffix not in CODE_FILE_TYPES:
raise ValueError(
f"Unsupported filetype {concept_code_file_path.suffix}, only support csv, xlsx, xls code file types"
)
# check codes definition
for files in phenotype["concept_sets"]:
for item in files["files"]:
# check concepte code file exists
concept_code_file_path = concepts_path / item["path"]
if not concept_code_file_path.exists():
validation_errors.append(
f"Coding file {str(concept_code_file_path.resolve())} does not exist"
)
# check columns specified are a supported medical coding type
for column in item["file"]["columns"]:
if column not in code_types:
# check concepte code file is not empty
if concept_code_file_path.stat().st_size == 0:
validation_errors.append(
f"Column type {column} for file {concept_code_file_path} is not supported"
f"Coding file {str(concept_code_file_path.resolve())} is an empty file"
)
# check the actions are supported
if "actions" in item["file"]:
for action in item["file"]["actions"]:
if action not in COL_ACTIONS:
validation_errors.append(f"Action {action} is not supported")
# check code file type is supported
if concept_code_file_path.suffix not in CODE_FILE_TYPES:
raise ValueError(
f"Unsupported filetype {concept_code_file_path.suffix}, only support csv, xlsx, xls code file types"
)
# check columns specified are a supported medical coding type
for column in item["columns"]:
if column not in code_types:
validation_errors.append(
f"Column type {column} for file {concept_code_file_path} is not supported"
)
# check the actions are supported
if "actions" in item:
for action in item["actions"]:
if action not in COL_ACTIONS:
validation_errors.append(f"Action {action} is not supported")
if len(validation_errors) > 0:
_logger.error(validation_errors)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment