def plasmapheresis(patient): plasmapheresis = Plasmapheresis() plasmapheresis.patient = patient plasmapheresis.from_date = date(2015, 1, 1) plasmapheresis.to_date = date(2015, 1, 2) plasmapheresis.no_of_exchanges = 3 plasmapheresis.response = PlasmapheresisResponse(id=1) return plasmapheresis
def f(patient, facility, n): for _ in range(n): plasmapheresis = Plasmapheresis() plasmapheresis.patient = patient plasmapheresis.facility = facility plasmapheresis.from_date = random_date(date(2000, 1, 1), date.today()) if random.random() > 0.5: plasmapheresis.to_date = random_date(plasmapheresis.from_date, date.today()) plasmapheresis.no_of_exchanges = random.randint(1, 10) plasmapheresis.response = random.choice(plasmapheresis_responses) db.session.add(plasmapheresis)