Skip to content

Commit 9ed9d0b

Browse files
committed
remove the visit_type and discharge_facility events in patient block merging
1 parent a8c6fab commit 9ed9d0b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/cehrbert/data_generators/hf_data_generator/patient_block.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,13 @@ def merge_patient_blocks(patient: meds_reader.Subject, patient_blocks: List[Pati
459459
prev_block, next_block = next_block, prev_block
460460

461461
# Merge the events from next_block into prev_block
462-
prev_block.events.extend(next_block.events)
462+
for e in next_block.events:
463+
# We don't want to take the visit type and discharge facility codes from the patient block that will be merged
464+
if (e.code == next_block.visit_type) or (
465+
next_block.discharged_to is not None and e.code == next_block.discharged_to
466+
):
467+
continue
468+
prev_block.events.append(e)
463469

464470
# Sort the combined events chronologically and by code
465471
prev_block.events = sorted(prev_block.events, key=lambda _: [_.time, _.code])

0 commit comments

Comments
 (0)