Skip to content

Commit

Permalink
precommit
Browse files Browse the repository at this point in the history
  • Loading branch information
svittoz committed Apr 18, 2024
1 parent 28b1ba6 commit dc4759f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 24 deletions.
27 changes: 13 additions & 14 deletions eds_scikit/io/omop_explorer_default_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"mapper": {
"visit_occurrence_id": {"not NaN": ".*"},
"condition_source_value": {"not NaN": ".*"},
},
},
},
"note": {
"category_columns": [
Expand All @@ -59,7 +59,7 @@
"mapper": {
"note_class_source_value": {"CR": r"^CR", "CRH": r"^CRH", "LT": r"^LT"},
"visit_occurrence_id": {"not NaN": ".*"},
},
},
},
"drug_exposure_prescription": {
"category_columns": [
Expand All @@ -72,19 +72,19 @@
"dose_unit_source_value",
"drug_ucd_source_value",
"prescription_type_source_value",
"cdm_source"
"cdm_source",
],
"date_column": "drug_exposure_start_datetime",
"mapper": {
"visit_occurrence_id": {"not NaN": ".*"},
"drug_type_source_value": {"not NaN": ".*"},
"drug_source_value": {"not NaN": ".*"},
"drug_class_source_value": {"not NaN": ".*"},
"drug_ucd_source_value" : {"not NaN": ".*"},
"route_source_value" : {"not NaN": ".*"},
"dose_unit_source_value" : {"not NaN": ".*"},
"prescription_type_source_value" : {"not NaN": ".*"},
},
"drug_ucd_source_value": {"not NaN": ".*"},
"route_source_value": {"not NaN": ".*"},
"dose_unit_source_value": {"not NaN": ".*"},
"prescription_type_source_value": {"not NaN": ".*"},
},
},
"drug_exposure_administration": {
"category_columns": [
Expand All @@ -96,18 +96,17 @@
"route_source_value",
"dose_unit_source_value",
"drug_ucd_source_value",
"cdm_source"
"cdm_source",
],
"date_column": "drug_exposure_start_datetime",
"mapper": {
"visit_occurrence_id": {"not NaN": ".*"},
"drug_type_source_value": {"not NaN": ".*"},
"drug_source_value": {"not NaN": ".*"},
"drug_class_source_value": {"not NaN": ".*"},
"drug_ucd_source_value" : {"not NaN": ".*"},
"route_source_value" : {"not NaN": ".*"},
"dose_unit_source_value" : {"not NaN": ".*"},
},
"drug_ucd_source_value": {"not NaN": ".*"},
"route_source_value": {"not NaN": ".*"},
"dose_unit_source_value": {"not NaN": ".*"},
},
},

}
32 changes: 23 additions & 9 deletions eds_scikit/plot/omop_explorer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

from loguru import logger

from eds_scikit.io import HiveData
Expand All @@ -24,7 +26,7 @@ def generate_omop_explorer(
output_dir : str, optional
Output directory path, by default "omop_explorer"
"""

if not os.path.exists(f"{output_dir}/"):
os.makedirs(f"{output_dir}/")

Expand Down Expand Up @@ -146,15 +148,19 @@ def generate_omop_explorer(
chart.save(f"{output_dir}/note_chart.html")

logger.info("notes processing done.")

# Drug Exposure Prescription

logger.info("Starting drug exposure prescription processing.")

drg_exposure = data.drug_exposure_prescription
config = explorer_config["drug_exposure_prescription"]
drg_exposure = drg_exposure.merge(visit_occurrence, on="visit_occurrence_id", how="left")
drg_exposure["visit_occurrence_id"] = drg_exposure["visit_occurrence_id"].astype(str)
drg_exposure = drg_exposure.merge(
visit_occurrence, on="visit_occurrence_id", how="left"
)
drg_exposure["visit_occurrence_id"] = drg_exposure["visit_occurrence_id"].astype(
str
)

drg_exposure_count = reduce_table(
drg_exposure,
Expand All @@ -165,19 +171,25 @@ def generate_omop_explorer(
mapper=config["mapper"],
)
drg_exposure_count = drg_exposure_count[~(drg_exposure_count == 0).any(axis=1)]
chart = visualize_table(drg_exposure_count, title="drug exposure prescription table dashboard")
chart = visualize_table(
drg_exposure_count, title="drug exposure prescription table dashboard"
)
chart.save(f"{output_dir}/drug_exposure_prescription.html")

logger.info("drug exposure prescription processing done.")

# Drug Exposure Administration

logger.info("Starting drug exposure administration processing.")

drg_exposure = data.drug_exposure_administration
config = explorer_config["drug_exposure_administration"]
drg_exposure = drg_exposure.merge(visit_occurrence, on="visit_occurrence_id", how="left")
drg_exposure["visit_occurrence_id"] = drg_exposure["visit_occurrence_id"].astype(str)
drg_exposure = drg_exposure.merge(
visit_occurrence, on="visit_occurrence_id", how="left"
)
drg_exposure["visit_occurrence_id"] = drg_exposure["visit_occurrence_id"].astype(
str
)

drg_exposure_count = reduce_table(
drg_exposure,
Expand All @@ -188,7 +200,9 @@ def generate_omop_explorer(
mapper=config["mapper"],
)
drg_exposure_count = drg_exposure_count[~(drg_exposure_count == 0).any(axis=1)]
chart = visualize_table(drg_exposure_count, title="drug exposure administration table dashboard")
chart = visualize_table(
drg_exposure_count, title="drug exposure administration table dashboard"
)
chart.save(f"{output_dir}/drug_exposure_administration.html")

logger.info("drug exposure administration processing done.")
2 changes: 1 addition & 1 deletion eds_scikit/plot/table_viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import altair as alt
import pandas as pd
from eds_scikit.plot.altair_utils import generate_color_map

from eds_scikit.plot.altair_utils import generate_color_map
from eds_scikit.utils.checks import check_columns
from eds_scikit.utils.framework import get_framework, to

Expand Down

0 comments on commit dc4759f

Please sign in to comment.