11from new_ldot_workflows .logging_utils import logged_request
2+ import json
23
34def get_incomplete_subjects (ldot_client , study_id : str , eaid_survey_invitation_completed : str = None , eaid_survey_progress_completed : str = None ) -> list :
45 """Get subjects that have not yet completed the survey by checking their event actions"""
@@ -17,11 +18,11 @@ def get_incomplete_subjects(ldot_client, study_id: str, eaid_survey_invitation_c
1718
1819 subjects_with_survey_invitation_completed = set ()
1920
20- # print(result.json())
21- # for action in result.json().get("Data", {}).get("StudyEventActions", []):
22- # subjects_with_survey_invitation_completed.add(action["SubjectGuid"])
21+ print (result .json ())
22+ for action in result .json ().get ("Data" , {}).get ("StudyEventActions" , []):
23+ subjects_with_survey_invitation_completed .add (action ["SubjectGuid" ])
2324
24- # print(f"Subjects with survey invitation completed: {subjects_with_survey_invitation_completed}")
25+ print (f"Subjects with survey invitation completed: { subjects_with_survey_invitation_completed } " )
2526
2627 result = logged_request (
2728 "GET" ,
@@ -33,19 +34,33 @@ def get_incomplete_subjects(ldot_client, study_id: str, eaid_survey_invitation_c
3334 )
3435 print (result .json ())
3536
36- # subjects_with_survey_progress_completed = set()
37- # for action in result.json().get("Data", {}).get("StudyEventActions", []):
38- # subjects_with_survey_progress_completed.add(action["SubjectGuid"])
37+ subjects_with_survey_progress_completed = set ()
38+ for action in result .json ().get ("Data" , {}).get ("StudyEventActions" , []):
39+ subjects_with_survey_progress_completed .add (action ["SubjectGuid" ])
3940
40- # print(f"Subjects with survey progress completed: {subjects_with_survey_progress_completed}")
41+ print (f"Subjects with survey progress completed: { subjects_with_survey_progress_completed } " )
4142
42- # incomplete_subjects = subjects_with_survey_invitation_completed - subjects_with_survey_progress_completed
43- # return list(incomplete_subjects)
43+ incomplete_subjects = subjects_with_survey_invitation_completed - subjects_with_survey_progress_completed
44+ return list (incomplete_subjects )
4445
4546if __name__ == "__main__" :
4647 # This would typically be initialized with the actual Ldot client
47- ldot_client = None # Replace with actual Ldot client initialization
48- ldot_study_id = "5c9c6a47-c8d7-8142-a8c8-ccdcb8a8044b"
49- eaid_survey_invitation_completed = "337ecba2-3dd3-1141-8c38-6cffdcfbd7eb"
50- eaid_survey_progress_completed = "120d298d-9aa9-084b-abc6-432148db0e10"
51- print (get_incomplete_subjects (ldot_study_id , eaid_survey_invitation_completed , eaid_survey_progress_completed ))
48+ with open ("new_ldot_workflows/ldot_config.json" ) as f :
49+ config = json .load (f )
50+ LDOT_TOKEN_URL = config ["LDOT_TOKEN_URL" ]
51+ LDOT_API_URL = config ["LDOT_API_URL" ]
52+ CLIENT_ID = config ["client_id" ]
53+ CLIENT_SECRET = config ["client_secret" ]
54+
55+ # ldot_client = LdotClient(
56+ # token_url=LDOT_TOKEN_URL,
57+ # api_url=LDOT_API_URL,
58+ # client_id=CLIENT_ID,
59+ # client_secret=CLIENT_SECRET
60+ # )
61+ # # print(ldot_client.headers)
62+
63+ # ldot_study_id = "5c9c6a47-c8d7-8142-a8c8-ccdcb8a8044b"
64+ # eaid_survey_invitation_completed = "337ecba2-3dd3-1141-8c38-6cffdcfbd7eb"
65+ # eaid_survey_progress_completed = "120d298d-9aa9-084b-abc6-432148db0e10"
66+ # print(get_incomplete_subjects(ldot_client, ldot_study_id, eaid_survey_invitation_completed, eaid_survey_progress_completed))
0 commit comments