Skip to content

Commit a666b3d

Browse files
committed
added E-I visit type update in patient block merging
1 parent f7ca396 commit a666b3d

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/cehrbert/data_generators/hf_data_generator/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
DEFAULT_ED_CONCEPT_ID = "Visit/ER"
33
DEFAULT_OUTPATIENT_CONCEPT_ID = "Visit/OP"
44
DEFAULT_INPATIENT_CONCEPT_ID = "Visit/IP"
5+
DEFAULT_ED_TO_INPATIENT_CONCEPT_ID = "Visit/ERIP"

src/cehrbert/data_generators/hf_data_generator/patient_block.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
from meds.schema import birth_code
99
from transformers import logging
1010

11-
from cehrbert.data_generators.hf_data_generator import DEFAULT_INPATIENT_CONCEPT_ID, DEFAULT_OUTPATIENT_CONCEPT_ID
11+
from cehrbert.data_generators.hf_data_generator import (
12+
DEFAULT_ED_TO_INPATIENT_CONCEPT_ID,
13+
DEFAULT_INPATIENT_CONCEPT_ID,
14+
DEFAULT_OUTPATIENT_CONCEPT_ID,
15+
)
1216
from cehrbert.data_generators.hf_data_generator.meds_to_cehrbert_conversion_rules import (
1317
MedsToBertMimic4,
1418
MedsToCehrBertConversion,
@@ -388,6 +392,10 @@ def merge_patient_blocks(patient: meds_reader.Subject, patient_blocks: List[Pati
388392
# Sort the combined events chronologically and by code
389393
prev_block.events = sorted(prev_block.events, key=lambda _: [_.time, _.code])
390394

395+
# Set longer visit to E-I
396+
if prev_block.has_admission and next_block.has_ed_admission:
397+
prev_block.visit_type = DEFAULT_ED_TO_INPATIENT_CONCEPT_ID
398+
391399
# Mark this block to be skipped in the outer loop
392400
block_indices_to_skip.append(next_index)
393401

0 commit comments

Comments
 (0)