Skip to content

Commit

Permalink
fixed the visit_rank_order of the death event
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaoPang committed Jan 23, 2025
1 parent b7163aa commit ad3a425
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/cehrbert_data/decorators/death_event_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ def _decorate(self, patient_events: DataFrame):
death_records.where(F.col("standard_concept_id") == VE_TOKEN)
.withColumn(
"record_rank",
F.row_number().over(W.partitionBy("person_id", "cohort_member_id").orderBy(F.desc("date"))),
F.row_number().over(
W.partitionBy("person_id", "cohort_member_id").orderBy(
F.desc("datetime"),
F.desc("visit_rank_order")
)
),
)
.where(F.col("record_rank") == 1)
.drop("record_rank")
Expand Down

0 comments on commit ad3a425

Please sign in to comment.