Skip to content

Commit

Permalink
added a check on birth_datetime in the meds to cehrbert data conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaoPang committed Dec 2, 2024
1 parent 1271fc5 commit bb4c2a0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/cehrbert/data_generators/hf_data_generator/meds_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,6 @@ def convert_one_patient(
):
age_at_index -= 1

# birth_datetime can not be None
assert (
demographics.birth_datetime is not None
), f"patient_id: {patient.subject_id} does not have a valid birth_datetime"

return CehrBertPatient(
patient_id=patient.subject_id,
birth_datetime=demographics.birth_datetime,
Expand Down Expand Up @@ -233,7 +228,12 @@ def _meds_to_cehrbert_generator(
for shard in shards:
for patient_id, prediction_time, label in shard:
patient = patient_database[patient_id]
yield convert_one_patient(patient, conversion, prediction_time, label)
converted_patient = convert_one_patient(patient, conversion, prediction_time, label)
# there are patients whose birthdate is none
if converted_patient["birth_datetime"] is None:
LOG.warning("patient_id: %s does not have a valid birth_datetime, therefore skipped", patient_id)
else:
yield converted_patient


def _create_cehrbert_data_from_meds(
Expand Down

0 comments on commit bb4c2a0

Please sign in to comment.