(case_trigger_info, case_config)
return enrollments
DHIS2 allows tracked entity instances to be enrolled in programs
    without any events, but CommCare does not currently have a mechanism
    for that. Cases/TEIs are enrolled in a program when the first event
    in that program occurs.
DHIS2 allows tracked entity instances to be enrolled in programs
    without any events, but CommCare does not currently have a mechanism
    for that. Cases/TEIs are enrolled in a program when the first event
    in that program occurs.
DHIS2 allows tracked entity instances to be enrolled in programs without any events but CommCare does not currently have a mechanism for that . Cases / TEIs are enrolled in a program when the first event in that program occurs .
def get_enrollments(case_trigger_info, case_config):
    """
    DHIS2 allows tracked entity instances to be enrolled in programs
    without any events, but CommCare does not currently have a mechanism
    for that. Cases/TEIs are enrolled in a program when the first event
    in that program occurs.
    """
    case_org_unit = get_value(case_config.org_unit_id, case_trigger_info)
    programs_by_id = get_programs_by_id(case_trigger_info, case_config)
    enrollments = []
    for program_id, program in programs_by_id.items():
        enrollment = {
            "orgUnit": program["orgUnit"] or case_org_unit,
            "program": program_id,
            "status": program["status"],
            "events": program["events"],
        }
        if program.get("geometry"):
            enrollment["geometry"] = program["geometry"]
        if program.get("enrollmentDate"):
            enrollment["enrollmentDate"] = program["enrollmentDate"]
        if program.get("incidentDate"):
            enrollment["incidentDate"] = program["incidentDate"]
        enrollments.append(enrollment)
    return enrollments
def get_enrollments ( case_trigger_info , case_config ) : case_org_unit = get_value ( case_config . org_unit_id , case_trigger_info ) programs_by_id = get_programs_by_id ( case_trigger_info , case_config ) enrollments = [ ] for program_id , program in programs_by_id . items ( ) : enrollment = { "orgUnit" : program [ "orgUnit" ] or case_org_unit , "program" : program_id , "status" : program [ "status" ] , "events" : program [ "events" ] , } if program . get ( "geometry" ) : enrollment [ "geometry" ] = program [ "geometry" ] if program . get ( "enrollmentDate" ) : enrollment [ "enrollmentDate" ] = program [ "enrollmentDate" ] if program . get ( "incidentDate" ) : enrollment [ "incidentDate" ] = program [ "incidentDate" ] enrollments . append ( enrollment ) return enrollments