Skip to content

Commit 619b390

Browse files
committed
⏪ Revert "👔 Don't match MRN to record_id"
This reverts commit 9c5803f.
1 parent f6b4946 commit 619b390

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

python_jobs/src/hbnmigration/from_ripple/to_redcap.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def set_redcap_columns(
108108
columns_to_rename: dict = {"customId": "mrn"},
109109
) -> pd.DataFrame:
110110
"""
111-
Set appropriate columns.
111+
Set appropriate columns. Prepends 'record_id' matching mrn.
112112
113113
Define the columns you want to select:
114114
Ripple globalId, customId (MRN), contact.*.infos.*.information (contact email).
@@ -139,11 +139,13 @@ def set_redcap_columns(
139139
axis=1,
140140
)
141141
redcap_df.rename(columns=columns_to_rename, inplace=True)
142-
# Convert MRN to integer
142+
# Convert record_id and MRN to integers
143143
redcap_df["mrn"] = redcap_df["mrn"].astype(int)
144-
145-
if "record_id" not in redcap_df.columns:
146-
redcap_df.insert(0, "record_id", "")
144+
# Create the new column 'record_id' from the original 'customId'/mrn
145+
# selected_ripple_df['record_id'] = selected_ripple_df['customId']
146+
# 1. Create the new column 'record_id' and insert it at the first position (index 0)
147+
# We are taking the values from the original 'customId' column.
148+
redcap_df.insert(0, "record_id", redcap_df["mrn"])
147149

148150
return redcap_df[["record_id", *columns_to_keep]].drop_duplicates()
149151

0 commit comments

Comments
 (0)