From 7fdebb00263249df59e7bf48cd52e6ab60e06cff Mon Sep 17 00:00:00 2001
From: Michael Boniface <m.j.boniface@soton.ac.uk>
Date: Thu, 27 Feb 2025 09:01:20 +0000
Subject: [PATCH] fix: moved omop export to concept-sets, moved concept set csv
 files to subdirectory of concept-sets. closes #42

---
 acmc/main.py  | 1 -
 acmc/omop.py  | 2 +-
 acmc/phen.py  | 9 +++++----
 docs/index.md | 5 +++--
 4 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/acmc/main.py b/acmc/main.py
index e2765e8..ec29b5d 100644
--- a/acmc/main.py
+++ b/acmc/main.py
@@ -66,7 +66,6 @@ def phen_diff(args):
     phen.diff(args.phen_dir, args.phen_dir_old)
 
 
-
 def main():
     parser = argparse.ArgumentParser(description="ACMC command-line tool")
     parser.add_argument("--debug", action="store_true", help="Enable debug mode")
diff --git a/acmc/omop.py b/acmc/omop.py
index d3f1710..7bc5dce 100644
--- a/acmc/omop.py
+++ b/acmc/omop.py
@@ -21,7 +21,7 @@ OMOP_DB_FILENAME = f"omop_{OMOP_CDM_Version}.sqlite"
 DB_PATH = VOCAB_PATH / OMOP_DB_FILENAME
 VERSION_FILE = "omop_version.yaml"
 VERSION_PATH = VOCAB_PATH / VERSION_FILE
-EXPORT_FILE = "omop_export.db"
+EXPORT_FILE = f"omop_{OMOP_CDM_Version}_export.sqlite"
 
 vocabularies = {
     "source": "OHDSI Athena",
diff --git a/acmc/phen.py b/acmc/phen.py
index d35d3bf..05ac0d1 100644
--- a/acmc/phen.py
+++ b/acmc/phen.py
@@ -32,8 +32,9 @@ DEFAULT_PHEN_PATH = Path("./workspace") / PHEN_DIR
 CODES_DIR = "codes"
 MAP_DIR = "map"
 CONCEPT_SET_DIR = "concept-set"
-OMOP_DIR = "omop"
-DEFAULT_PHEN_DIR_LIST = [CODES_DIR, MAP_DIR, CONCEPT_SET_DIR, OMOP_DIR]
+CSV_PATH = Path(CONCEPT_SET_DIR) / "csv"
+OMOP_PATH = Path(CONCEPT_SET_DIR) / "omop"
+DEFAULT_PHEN_DIR_LIST = [CODES_DIR, MAP_DIR, CONCEPT_SET_DIR]
 CONFIG_FILE = "config.yaml"
 VOCAB_VERSION_FILE = "vocab_version.yaml"
 
@@ -739,7 +740,7 @@ def map_target_code_type(phen_path, phenotype, target_code_type):
     logger.info(f"Saved mapped concepts to {str(map_path.resolve())}")
 
     # save concept sets as separate files
-    concept_set_path = phen_path / CONCEPT_SET_DIR / target_code_type
+    concept_set_path = phen_path / CSV_PATH / target_code_type
 
     # empty the concept-set directory if it exists but keep the .git file
     git_items = [".git", ".gitkeep"]
@@ -866,7 +867,7 @@ def export(phen_dir, version):
     if not map_path.exists():
         logger.warning(f"Map path does not exist '{map_path}'")
 
-    export_path = phen_path / OMOP_DIR
+    export_path = phen_path / OMOP_PATH
     # check export directory exists and if not create it
     if not export_path.exists():
         export_path.mkdir(parents=True)
diff --git a/docs/index.md b/docs/index.md
index d25b74e..fd3ad67 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -46,10 +46,11 @@ The tool supports verification and mapping across diagnostic coding formats belo
 workspace/                          # Default workspace directory
 ├── phen/                           # Default phenotype directory
 │   ├── codes/                      # Phenotype source concept code lists directory
-│   ├── concept-set/                # Processed phenotype concept sets in CSV format
+│   ├── concept-set/                # Processed phenotype concept sets
+│   │   ├── csv/                    # Processed phenotype concept sets in ACMC CSV format
+│   │   ├── omop/                   # Processed phenotype concept sets in OMOP CDM database exported as CSV files
 │   ├── map/                        # Process mapping from source to target code types
 │   │   ├── errors/                 # Errors recorded during mapping process
-│   ├── omop/                       # Processed phenotype concept sets in OMOP database CSV files
 │   ├── config.yaml                 # Phenotype configuration file
 │   ├── vocab_versions.yaml         # Versions file for vocabularies used to generate concept sets
 ``` 
-- 
GitLab