Пример #1
0
def create_renal_imaging(patient, facility, n):
    for _ in range(n):
        renal_imaging = RenalImaging()
        renal_imaging.patient = patient
        renal_imaging.facility = facility
        renal_imaging.date = random_date(date(2000, 1, 1), date.today())
        renal_imaging.imaging_type = random.choice(['USS', 'CT', 'MRI'])
        renal_imaging.right_present = random_bool()
        renal_imaging.left_present = random_bool()

        if renal_imaging.right_present:
            renal_imaging.right_type = random.choice(['transplant', 'natural'])
            renal_imaging.right_length = random.randint(11, 14)
            renal_imaging.right_cysts = random_bool()
            renal_imaging.right_calcification = random_bool()

            if renal_imaging.right_calcification:
                renal_imaging.right_nephrocalcinosis = random_bool()
                renal_imaging.right_nephrolithiasis = random_bool()

        if renal_imaging.left_present:
            renal_imaging.left_type = random.choice(['transplant', 'natural'])
            renal_imaging.left_length = random.randint(11, 14)
            renal_imaging.left_cysts = random_bool()
            renal_imaging.left_calcification = random_bool()

            if renal_imaging.left_calcification:
                renal_imaging.left_nephrocalcinosis = random_bool()
                renal_imaging.left_nephrolithiasis = random_bool()

        db.session.add(renal_imaging)
Пример #2
0
    def f(patient, facility, n):
        for _ in range(n):
            transplant = Transplant()
            transplant.patient = patient
            transplant.facility = facility
            transplant.transplant_date = random_date(date(2000, 1, 1), date.today())
            transplant.transplant_type = random.choice(transplant_types)
            transplant.recurred = random_bool()

            if transplant.recurred:
                transplant.date_recurred = random_date(transplant.transplant_date, date.today())

            if random.random() > 0.75:
                transplant.date_failed = random_date(transplant.transplant_date, date.today())

            db.session.add(transplant)