File tree Expand file tree Collapse file tree
python_jobs/src/hbnmigration/from_ripple Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments