def processBatch(a_b): a, b = a_b d = DatastoreClient() p = Patient() e = Encounter() m = Medication() o = Observations() dr = DiagnosticReport() md = MedicationDispense() pr = Procedure() all_patient = sorted(p.all_patient()) for i in range(a, b): if i >= len(all_patient): break id = all_patient[i] getPatientRecords(d, p, e, m, o, dr, md, pr, id) return True