neurobooth_terra.redcap.rename_subject_ids

neurobooth_terra.redcap.rename_subject_ids(table_subject, redcap_df)[source]

Rename subject_id in table_subject using data in redcap_df.

Parameters
table_subjectinstance of Table

The subject table.

redcap_dfinstance of dataframe

The dataframe of subject from redcap.

Notes

Let’s say the table in database has the following

subject_id first_name last_name date_of_birth old_subject_id

1001 anoopum gupta 28/11/1985 NULL 1002 adonay nunes 13/09/1987 NULL

Now, redcap has been modified in the following way

901 anoopum gupta 28/11/1985 1001 1002 adonay nunes 13/09/1987 NULL 1003 sheraz khan 15/05/1980 NULL

Our protocol is the following:

  1. Fetch database table into Python dataframe

  2. Inner join Redcap dataframe to database dataframe based on match in first_name, last_name and date_of_birth

  3. Select rows from the inner join where Redcap.old_subject_id != database.old_subject_id AND Redcap.subject_id = database.old_subject_id

  4. Insert these rows into database, updating the subject_id and old_subject_id