database/schedule_models.py
def find_pending_events(
            participant: Participant = None, survey: Survey or str = None,
            tz: tzinfo = gettz('America/New_York'),
    ):
        """ THIS FUNCTION IS FOR DEBUGGING PURPOSES ONLY

        Throw in a participant and or survey object, OR THEIR IDENTIFYING STRING and we make it work
        'tz' will normalize timestamps to that timezone, default is us east.
        """
        # this is a simplified, modified version ofg the find_notification_events on ArchivedEvent.
        filters = {}
        if participant:
            filters['participant'] = participant
        if survey:
            filters["survey"] = survey
        elif participant:  # if no survey, yes participant:
            filters["survey__in"] = participant.study.surveys.all()

        query = ScheduledEvent.objects.filter(**filters).order_by(
            "survey__object_id", "participant__patient_id", "-scheduled_time"
        )
        survey_id = ""
        for a in query:
            # only print participant name and survey id when it changes
            if a.survey.object_id != survey_id:
                print(f"{a.survey.survey_type} {TxtClr.CYAN}{a.survey.object_id}{TxtClr.BLACK}:")
                survey_id = a.survey.object_id

            # data points of interest for sending information
            sched_time = localtime(a.scheduled_time, tz)
            sched_time_print = datetime.strftime(sched_time, DEV_TIME_FORMAT)
            print(
                f"  {a.get_schedule_type()} FOR {TxtClr.CYAN}{a.participant.patient_id}{TxtClr.BLACK}"
                f" AT {TxtClr.GREEN}{sched_time_print}{TxtClr.BLACK}",
            )
 THIS FUNCTION IS FOR DEBUGGING PURPOSES ONLY

        Throw in a participant and or survey object, OR THEIR IDENTIFYING STRING and we make it work
        'tz' will normalize timestamps to that timezone, default is us east.
        
THIS FUNCTION IS FOR DEBUGGING PURPOSES ONLY
Throw in a participant and or survey object, OR THEIR IDENTIFYING STRING and we make it work
'tz' will normalize timestamps to that timezone, default is us east.
THIS FUNCTION IS FOR DEBUGGING PURPOSES ONLY Throw in a participant and or survey object OR THEIR IDENTIFYING STRING and we make it work ' tz ' will normalize timestamps to that timezone default is us east .
def find_pending_events(
            participant: Participant = None, survey: Survey or str = None,
            tz: tzinfo = gettz('America/New_York'),
    ):
        filters = {}
        if participant:
            filters['participant'] = participant
        if survey:
            filters["survey"] = survey
        elif participant:  
            filters["survey__in"] = participant.study.surveys.all()
        query = ScheduledEvent.objects.filter(**filters).order_by(
            "survey__object_id", "participant__patient_id", "-scheduled_time"
        )
        survey_id = ""
        for a in query:
            if a.survey.object_id != survey_id:
                print(f"{a.survey.survey_type} {TxtClr.CYAN}{a.survey.object_id}{TxtClr.BLACK}:")
                survey_id = a.survey.object_id
            sched_time = localtime(a.scheduled_time, tz)
            sched_time_print = datetime.strftime(sched_time, DEV_TIME_FORMAT)
            print(
                f"  {a.get_schedule_type()} FOR {TxtClr.CYAN}{a.participant.patient_id}{TxtClr.BLACK}"
                f" AT {TxtClr.GREEN}{sched_time_print}{TxtClr.BLACK}",
            )
def find_pending_events ( participant : Participant = None , survey : Survey or str = None , tz : tzinfo = gettz ( 'America/New_York' ) , ) : filters = { } if participant : filters [ 'participant' ] = participant if survey : filters [ "survey" ] = survey elif participant : filters [ "survey__in" ] = participant . study . surveys . all ( ) query = ScheduledEvent . objects . filter ( ** filters ) . order_by ( "survey__object_id" , "participant__patient_id" , "-scheduled_time" ) survey_id = "" for a in query : if a . survey . object_id != survey_id : print ( f"{a.survey.survey_type} {TxtClr.CYAN}{a.survey.object_id}{TxtClr.BLACK}:" ) survey_id = a . survey . object_id sched_time = localtime ( a . scheduled_time , tz ) sched_time_print = datetime . strftime ( sched_time , DEV_TIME_FORMAT ) print ( f"  {a.get_schedule_type()} FOR {TxtClr.CYAN}{a.participant.patient_id}{TxtClr.BLACK}" f" AT {TxtClr.GREEN}{sched_time_print}{TxtClr.BLACK}" , )
THIS FUNCTION IS FOR DEBUGGING PURPOSES ONLY
Throw in a participant and or survey object, OR THEIR IDENTIFYING STRING and we make it work
'tz' will normalize timestamps to that timezone, default is us east.
THIS FUNCTION IS FOR DEBUGGING PURPOSES ONLY Throw in a participant and or survey object OR THEIR IDENTIFYING STRING and we make it work ' tz ' will normalize timestamps to that timezone default is us east .
""" THIS FUNCTION IS FOR DEBUGGING PURPOSES ONLY

        Throw in a participant and or survey object, OR THEIR IDENTIFYING STRING and we make it work
        'tz' will normalize timestamps to that timezone, default is us east.
        """ # this is a simplified, modified version ofg the find_notification_events on ArchivedEvent.
 # if no survey, yes participant:
 # only print participant name and survey id when it changes
 # data points of interest for sending information

participant
Participant
survey
Survey or str
tz
tzinfo