Skip to content

Commit

Permalink
fixed the bug in creating the new visit_id
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaoPang committed Jan 11, 2025
1 parent 9d0010f commit 6215db4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/cehrbert_data/tools/ehrshot_to_omop.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,13 +667,13 @@ def disconnect_visit_id(data: DataFrame, spark: SparkSession, cache_folder: str)
.rowsBetween(Window.unboundedPreceding, Window.currentRow)
)
).withColumn(
"row_number",
f.row_number().over(Window.orderBy(f.col("visit_id"), f.col("visit_partition")))
"visit_partition_rank",
f.dense_rank().over(Window.orderBy(f.col("visit_id"), f.col("visit_partition")))
).crossJoin(
visit_records.select(f.max("visit_id").alias("max_visit_id"))
).withColumn(
"new_visit_id",
f.col("max_visit_id") + f.col("row_number")
f.col("max_visit_id") + f.col("visit_partition_rank")
).drop(
"max_visit_id", "row_number"
)
Expand Down

0 comments on commit 6215db4

Please sign in to comment.