def dialysis(patient): dialysis = Dialysis() dialysis.patient = patient dialysis.from_date = date(2015, 1, 1) dialysis.to_date = date(2015, 1, 2) dialysis.dialysis_type = DialysisType(id=1) return dialysis
def f(patient, facility, n): for _ in range(n): dialysis = Dialysis() dialysis.patient = patient dialysis.facility = facility dialysis.from_date = random_date(date(2000, 1, 1), date.today()) if random.random() > 0.5: dialysis.to_date = random_date(dialysis.from_date, date.today()) dialysis.dialysis_type = random.choice(dialysis_types) db.session.add(dialysis)