Skip to content

Commit

Permalink
fix omop_teva
Browse files Browse the repository at this point in the history
  • Loading branch information
svittoz committed Apr 25, 2024
1 parent 7fb049a commit 958a99e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion eds_scikit/io/omop_teva_default_config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
default_omop_teva_config = {
"visit_occurrence": {
"category_columns": [
"visit_occurrence_id" "care_site_short_name",
"visit_occurrence_id",
"care_site_short_name",
"stay_source_value",
"visit_source_value",
"admission_reason_source_value",
Expand Down
13 changes: 13 additions & 0 deletions eds_scikit/plot/omop_teva.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import os

from loguru import logger
import pickle

from eds_scikit.io import HiveData
from eds_scikit.io.omop_teva_default_config import default_omop_teva_config
from eds_scikit.plot.table_viz import reduce_table, visualize_table

def save_pickle(obj, path : str):
with open(path, "wb") as outp:
pickle.dump(obj, outp)


def generate_omop_teva(
data: HiveData,
Expand Down Expand Up @@ -50,6 +55,8 @@ def generate_omop_teva(
config["date_column"],
"visit_occurrence_id",
]
print(visit_columns)
print(visit_occurrence.columns)
visit_occurrence = visit_occurrence[visit_columns]

visit_occurrence_count = reduce_table(
Expand All @@ -66,6 +73,7 @@ def generate_omop_teva(
chart = visualize_table(
visit_occurrence_count, title="visit_occurrence table dashboard"
)
save_pickle(f"{output_dir}/visit_occurrence_count")
chart.save(f"{output_dir}/visit_occurrence_chart.html")

logger.info("visit_occurrence processing done.")
Expand Down Expand Up @@ -101,6 +109,7 @@ def generate_omop_teva(
chart = visualize_table(
procedure_occurrence_count, title="procedure_occurrence table dashboard"
)
save_pickle(f"{output_dir}/procedure_occurrence_count")
chart.save(f"{output_dir}/procedure_occurrence_chart.html")

logger.info("procedure_occurrence processing done.")
Expand Down Expand Up @@ -137,6 +146,7 @@ def generate_omop_teva(
chart = visualize_table(
condition_occurrence_count, title="condition_occurrence table dashboard"
)
save_pickle(f"{output_dir}/condition_occurrence_count")
chart.save(f"{output_dir}/condition_occurrence_chart.html")

logger.info("condition_occurrence processing done.")
Expand All @@ -161,6 +171,7 @@ def generate_omop_teva(
end_date=end_date,
mapper=config["mapper"],
)
save_pickle(f"{output_dir}/note_count")
note_count = note_count[~(note_count == 0).any(axis=1)]
chart = visualize_table(note_count, title="note table dashboard")
chart.save(f"{output_dir}/note_chart.html")
Expand Down Expand Up @@ -197,6 +208,7 @@ def generate_omop_teva(
chart = visualize_table(
drg_exposure_count, title="drug exposure prescription table dashboard"
)
save_pickle(f"{output_dir}/drg_exposure_prescription_count")
chart.save(f"{output_dir}/drug_exposure_prescription.html")

logger.info("drug exposure prescription processing done.")
Expand Down Expand Up @@ -231,6 +243,7 @@ def generate_omop_teva(
chart = visualize_table(
drg_exposure_count, title="drug exposure administration table dashboard"
)
save_pickle(f"{output_dir}/drug_exposure_administration_count")
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 @@ -146,7 +146,7 @@ def reduce_table(
def visualize_table(
table_count: DataFrame,
title: str = "table exploration dashboard",
description=False,
description=True,
) -> alt.Chart:

"""Generate reduced table dashboard.
Expand Down

0 comments on commit 958a99e

Please sign in to comment.