diff --git a/acmc/phen.py b/acmc/phen.py index ff2edc2b3bb8859b1c2fe63cb27cdb297da51178..48931442d0802e38b0d29186b55b809743ec8bb2 100644 --- a/acmc/phen.py +++ b/acmc/phen.py @@ -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)