Closed jodahoney closed 9 months ago
I do not understand why you would call
index_values = err_row.index.get_level_values('study_id').tolist()
index_values += err_row.index.get_level_values('redcap_event_name').tolist()
instead of getting this info directly from subject_data ? I am asking as if the subject is not in any arm your call will fail . Not sure the arm should be part of the error code given that it is independent of the arm
@kipohl
subject_data
but it does exist in mr_sessions_redcap
. So when it is trying to map every value in mr_sessions_redcap over subject_data, it throws the key error because it doesn't exist
>>> subject_data.loc[subject_data.index.get_level_values('study_id') == 'E-00140-M-1']
Empty DataFrame
Columns: [dob, siblings_enrolled___true, siblings_id1, enroll_exception___drinking, exclude]
Index: []
>>> mr_sessions_redcap.loc[mr_sessions_redcap.index.get_level_values('study_id') == 'E-00140-M-
1']
visit_date ... redcap_data_access_group
study_id redcap_event_name ...
E-00140-M-1 recovery_baseline_arm_2 2024-01-24 ... NaN
[1 rows x 7 columns]
Just to clarify what I am thinking, because I may be understanding this incorrectly, `mr_sessions_redcap` is just the filtered exported visit log of redcap, so if a subject has any sort of visit associated it gets pulled.
The point of `excluded_subjects` is to go through all those visits and check the related `subject_data` for whether they are excluded or not. This error is caused because there is a subject that has a visit, but has no `excluded` information in their `subject_data` because they don't have anything in Arm 1.
thanks for clarifying / you are right - so then lets leave as it
Link to error that it generates: https://github.com/sibis-platform/ncanda-operations/issues/14550 Post update:
Pre update: