def insert_patient(user=None):
    patient = Patient(
        first_name='John',
        last_name='Richmond',
        dob='1950-01-01',
        ssn='111-11-1111'
    )
    db.session.add(patient)
    db.session.commit()
    
    if user:
        patient.created_by = user
        db.session.commit()

    return patient
Beispiel #2
0
    def test_attributes_assignment(self):
        self.assertEqual(TreatmentTable.__tablename__, 'treatment_tables')
        patient = Patient(first_name='John',
                          last_name='Doe',
                          email='*****@*****.**')
        table = TreatmentTable(name='Table 1', patient=patient)

        self.assertEqual(table.name, 'Table 1')
        self.assertEqual(table.patient, patient)
Beispiel #3
0
def create_patient(request):
    instance = Patient()
    form = PatientForm(request.POST or None, instance=instance)
    if request.POST and form.is_valid():
        patient = form.save(commit=False)
        patient.author = UserProfile.objects.by_user(request.user)
        patient.save()
        return HttpResponseRedirect(reverse('patients'))
    return render(request, 'create_form.html', {'form': form})
 def add_patient(self):
     p = Patient(
         id="3123f5a6-e224-4255-b5ba-f7238fb7d0f5",
         age=26,
         name="Mimi Altenwerth",
         gender="female",
     )
     db.session.add(p)
     db.session.commit()
 def add_patient(self):
     p = Patient(
         id="40f680c8-238b-426b-b1c0-1649c780ce69",
         age=5,
         name="Winford Altenwerth",
         gender="male",
     )
     db.session.add(p)
     db.session.commit()
Beispiel #6
0
    def test_patients_patient(self):
        user1 = User(first_name='one',
                     last_name='one',
                     username='******',
                     email='*****@*****.**',
                     password='******')
        user2 = User(first_name='two',
                     last_name='two',
                     username='******',
                     email='*****@*****.**',
                     password='******')
        patient1 = Patient(first_name='patient1',
                           last_name='patient1',
                           email='*****@*****.**')
        patient2 = Patient(first_name='patient2',
                           last_name='patient2',
                           email='*****@*****.**')
        patient1.users.append(user1)
        patient2.users.append(user2)
        db.session.add_all([user1, user2, patient1, patient2])
        db.session.commit()

        with self.client:
            self.client.post(url_for('auth.login'),
                             data={
                                 'email': '*****@*****.**',
                                 'username': '******',
                                 'password': '******'
                             })
            # test patient_id that does not exist
            response = self.client.get(url_for('patients.patient', id=100))
            self.assertEqual(response.status_code, 404)

            # test patient that does not belong to current_user
            response = self.client.get(url_for('patients.patient', id=2))
            self.assertEqual(response.status_code, 403)

            # test on patient that does belong to current user
            response = self.client.get(url_for('patients.patient', id=1))
            data = response.get_data(as_text=True)
            self.assertEqual(response.status_code, 200)
            self.assertTrue('one' in data)
            self.assertTrue('*****@*****.**' in data)
Beispiel #7
0
def add_patient():
    form = AddPatientForm()
    if form.validate_on_submit():
        try:
            patient = Patient(first_name=form.first_name.data,
                              last_name=form.last_name.data,
                              age=form.age.data,
                              sex=form.sex.data,
                              email=form.email.data)
            db.session.add(patient)
            patient.add_doctor(current_user)
            db.session.commit()
            flash('Patient succesfully added.')
        except Exception as e:
            flash('Failed to add patient. ' + str(e))
        return redirect(url_for('auth.add_patient'))
    return render_template('auth/add_patient.html',
                           title='Add Patient',
                           form=form)
Beispiel #8
0
def insert_patient():
    patient = Patient(
        first_name='John',
        last_name='Richmond',
        dob='1950-01-01',
        ssn='111-11-1111'
    )
    db.session.add(patient)
    db.session.commit()
    return patient
Beispiel #9
0
def newpatient():
    """Form to add a new patient to the database."""
    form = NewPatientForm()
    if form.validate_on_submit():
        p = Patient(name=form.name.data, age=int(form.age.data), qr_code=form.qr_code.data)
        db.session.add(p)
        db.session.commit()
        flash('New Patient Registered :' + form.name.data)
        return redirect(url_for('index'))
    return render_template('addpatient.html', title='Add Patient', form=form)
Beispiel #10
0
 def patient_init_func(row):
     p = Patient(age=row['age'],
                 bio_code=row['bio_code'],
                 birthday=row['birthday'],
                 clinical_data=row['clinical_data'],
                 code=row['code'],
                 id=row['id'],
                 order_id=row['order_id'],
                 origin_id=row['origin_id'],
                 sexe=row['sexe'])
     return p
Beispiel #11
0
def edit_patient(request, pid):
    instance = Patient() if not pid else get_object_or_404(Patient, pk=pid)
    form = PatientForm(request.POST or None, instance=instance)
    if request.POST:
        if 'delete' in request.POST:
            Patient.objects.delete(pid)
            return HttpResponseRedirect(reverse('patients'))
        elif 'save' in request.POST and form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('patients'))
    return render(request, 'edit_form.html', {'form': form})
Beispiel #12
0
    def patient(self):
        return Patient(
            first_name=fake.first_name(),
            last_name=fake.last_name(),
            dob=fake.date_time_between(start_date="-110y", end_date="now").date(),
            ssn=fake.ssn(),

            email=fake.email(),
            has_transport_yn=choice(constants.YN_CHOICES),

            gender=choice(constants.GENDER_CHOICES),
            transgender=choice(constants.TRANSGENDER_CHOICES),
            race=choice(constants.RACE_CHOICES),
            ethnicity=choice(constants.ETHNICITY_CHOICES),
            language=choice(constants.LANGUAGE_CHOICES),
            has_interpreter_yn=choice(constants.YNNA_CHOICES),
            education_level='High school',
            marital_status=choice(constants.MARITAL_STATUS_CHOICES),
            veteran_yn=choice(constants.YN_CHOICES),
            housing_status=choice(constants.HOUSING_STATUS_CHOICES),
            years_living_in_area=fake.random_int(min=0, max=20),
            months_living_in_area=fake.random_int(min=0, max=11),
            # city_or_county_of_residence = 'Richmond',
            temp_visa_yn=choice(constants.YN_CHOICES),

            student_status=choice(constants.STUDENT_STATUS_CHOICES),
            employment_status=choice(constants.EMPLOYMENT_STATUS_CHOICES),
            spouse_employment_status=choice(constants.EMPLOYMENT_STATUS_CHOICES),
            years_unemployed=fake.random_int(min=0, max=5),
            months_unemployed=fake.random_int(min=0, max=11),
            spouse_years_unemployed=fake.random_int(min=0, max=5),
            spouse_months_unemployed=fake.random_int(min=0, max=11),

            # last_healthcare = '2 years ago.',
            insurance_status=choice(constants.YN_CHOICES),
            coverage_type=choice(constants.COVERAGE_TYPE_CHOICES),
            has_prescription_coverage_yn=choice(constants.YNN_NONULL_CHOICES),
            has_vcc=choice(constants.YN_CHOICES),
            eligible_insurance_types=choice(constants.COVERAGE_ELIGIBILITY_CHOICES),
            applied_for_vets_benefits_yn=choice(constants.YNNA_CHOICES),
            eligible_for_vets_benefits_yn=choice(constants.YNN_NONULL_CHOICES),
            applied_for_medicaid_yn=choice(constants.YN_CHOICES),
            # medicaid_date_effective
            applied_for_ssd_yn=choice(constants.YN_CHOICES),
            # ssd_date_effective
            care_due_to_accident_yn=choice(constants.YN_CHOICES),
            accident_work_related_yn=choice(constants.YN_CHOICES),

            filed_taxes_yn=choice(constants.YN_CHOICES),
            claimed_as_dependent_yn=choice(constants.YNN_CHOICES),
            # how_food_and_shelter
            # how_other_expenses
        )
Beispiel #13
0
def search():
    if not g.search_form.validate():
        return redirect(url_for('main.index'))
    page = request.args.get('page', 1, type=int)
    patients, total = Patient.search(g.search_form.q.data, page,
                                current_app.config['PATIENTS_PER_PAGE'])
    next_url = url_for('main.search', q=g.search_form.q.data, page=page+1) \
        if total > page * current_app.config['PATIENTS_PER_PAGE'] else None
    prev_url = url_for('main.search', q=g.search_form.q.data, page=page-1) \
        if page > 1 else None
    return render_template('search.html', title='Search', patients=patients,
                            next_url=next_url, prev_url=prev_url)
Beispiel #14
0
    def test_appointments_relationship(self):
        start = datetime.utcnow()
        end = datetime.utcnow() + timedelta(days=1)
        appointment1 = Appointment(title='title1',
                                   description='description1',
                                   date_start=start,
                                   date_end=end)
        appointment2 = Appointment(title='title2',
                                   description='description2',
                                   date_start=start,
                                   date_end=end)
        patient = Patient(first_name='John',
                          last_name='Elliot',
                          email="*****@*****.**")
        user = User(first_name='John',
                    last_name='Elliot',
                    username='******',
                    email="*****@*****.**",
                    password='******')
        treatment = Treatment(name='Tylenol')

        # before connecting
        self.assertEqual(len(patient.appointments.all()), 0)
        self.assertEqual(len(user.appointments.all()), 0)
        self.assertEqual(len(treatment.appointments.all()), 0)

        # after connecting appointment1
        appointment1.patient = patient
        appointment1.user = user
        appointment1.treatment = treatment

        db.session.add_all(
            [patient, user, treatment, appointment1, appointment2])
        db.session.commit()

        self.assertEqual(len(patient.appointments.all()), 1)
        self.assertTrue(appointment1 in patient.appointments.all())
        self.assertEqual(appointment1.patient_id, patient.id)
        self.assertFalse(appointment2 in patient.appointments.all())
        self.assertNotEqual(appointment2.patient_id, patient.id)

        self.assertEqual(len(user.appointments.all()), 1)
        self.assertTrue(appointment1 in user.appointments.all())
        self.assertEqual(appointment1.user_id, user.id)
        self.assertFalse(appointment2 in user.appointments.all())
        self.assertNotEqual(appointment2.user_id, user.id)

        self.assertEqual(len(treatment.appointments.all()), 1)
        self.assertTrue(appointment1 in treatment.appointments.all())
        self.assertEqual(appointment1.treatment_id, treatment.id)
        self.assertFalse(appointment2 in treatment.appointments.all())
        self.assertNotEqual(appointment2.treatment_id, treatment.id)
Beispiel #15
0
def patients_view(request):
    if request.method == 'GET':
        patients = Patient.objects.filter(creator=request.user)
        serialized = PatientSerializer(patients, many=True)
        return Response(success_msg("Retrieved patients successfully",
                                    serialized.data),
                        status=status.HTTP_200_OK)
    elif request.method == 'POST':
        full_name = request.data.get('full_name', None)
        covid_id = request.data.get('covid_id', generate_covid_id())
        nationality = request.data.get('nationality')
        state = request.data.get('state')
        creator = request.user
        patient = Patient(full_name=full_name,
                          covid_id=covid_id,
                          nationality=nationality,
                          state=state,
                          creator=creator)
        patient.save()
        serialized = PatientSerializer(patient)
        return Response(success_msg("Patient created successfully",
                                    serialized.data),
                        status=status.HTTP_201_CREATED)
Beispiel #16
0
    def setUp(self):

        db.session.commit()
        db.drop_all()
        db.create_all()
        admin = User(email="*****@*****.**",
                     first_name='Alexander',
                     last_name='Bogdanowicz',
                     password="******")
        patient = Patient(date_of_birth=datetime.today(), user=admin)

        db.session.add(admin)
        db.session.add(patient)
        db.session.commit()
Beispiel #17
0
def completeSignUp(current_user):
    if current_user.account_verified == 0:
        return make_response('Forbidden: First confirm your account', 403)

    auth = request.json


    patient = Patient.query\
                    .filter_by(id_user = current_user.id)\
                    .first()

    hospital = Hospital.query\
                    .filter_by(id_user = current_user.id)\
                    .first()

    if patient or hospital or current_user.rol == 3:
        return jsonify({"message" : "Sign up have been completed yet"}), 409
    #PATIENT
    if current_user.rol == 1:
        name = auth['name']
        address = auth['address']
        birthdate = datetime.strptime(auth['birthdate'], '%d/%m/%y')
        id_user = current_user.id

        complete_signup = Patient(name, address, birthdate, id_user)

        if not name or not address or not birthdate:
            return make_response('Patient information incomplete', 422)
        else:
            db.session.add(complete_signup)
            db.session.commit()
            return jsonify({'message' : 'Sign Up Completed Successfully'}), 200


    #HOSPITAL
    if current_user.rol == 2:
        name = auth['name']
        address = auth['address']
        id_medicalservice = auth['id_medicalservice']
        id_user = current_user.id

        complete_signup = Hospital(name, address, id_medicalservice, id_user)


        if not name or not address or not id_medicalservice:
            return make_response('Hospital information incomplete', 422)
        else:
            db.session.add(complete_signup)
            db.session.commit()
            return jsonify({'message' : 'Sign Up Completed Successfully'}), 200
Beispiel #18
0
def patient_create():
    patient = Patient()
    episodes = []

    form = PatientEditForm(obj=patient)
    form.hospital_id.choices = _hospital_id_choices()

    if form.validate_on_submit():
        patient.name = form.name.data
        patient.email = form.email.data
        patient.hospital_id = form.hospital_id.data
        patient.gender = form.gender.data
        patient.phone1 = form.phone.data
        patient.address = form.address.data

        patient.created_by = current_user
        patient.updated_by = current_user

        db.session.add(patient)
        db.session.commit()
        flash('New patient details for {} have been registered.'.format(patient.name))
        return redirect(url_for('patient', id=patient.id))

    return render_template('patient.html', title='Register New Patient', form=form, episodes=episodes)
Beispiel #19
0
 def test_get_patients(self):
     hospital = Hospital(name='Severance')
     user = User(first_name='one',
                 last_name='one',
                 email='*****@*****.**',
                 username='******',
                 password='******')
     patient1 = Patient(first_name='patient',
                        last_name='1',
                        email='*****@*****.**')
     patient2 = Patient(first_name='patient',
                        last_name='2',
                        email='*****@*****.**')
     patient3 = Patient(first_name='patient',
                        last_name='3',
                        email='*****@*****.**')
     patient1.users.append(user)
     patient2.users.append(user)
     user.hospital = hospital
     db.session.add_all([hospital, user, patient1, patient2, patient3])
     db.session.commit()
     self.assertTrue(patient1 in hospital.get_patients().all())
     self.assertTrue(patient2 in hospital.get_patients().all())
     self.assertFalse(patient3 in hospital.get_patients().all())
Beispiel #20
0
    def test_doctor_has_patient(self):
        d1 = Doctor(name = 'Gabi')
        d2 = Doctor(name = 'Dan')

        p1 = Patient(first_name = 'Josh', age = 22)
        p2 = Patient(first_name = 'Kelsey', age = 27)

        db.session.add_all([d1, d2, p1, p2])
        db.session.commit()
        self.assertEqual(d1.patients.all(), [])
        self.assertEqual(d2.patients.all(), [])

        d1.add_patient(p1)
        db.session.commit()
        self.assertTrue(d1.has_patient(p1))
        self.assertEqual(d1.patients.count(), 1)
        self.assertEqual(d1.patients.first().first_name, 'Josh')

        self.assertFalse(d2.has_patient(p1))
        self.assertEqual(d2.patients.count(), 0)

        d1.add_patient(p2)
        db.session.commit()
        patients = d1.get_all_patients().all()
        self.assertEqual(patients, [p1, p2])

        d1.remove_patient(p1)
        db.session.commit()
        self.assertFalse(d1.has_patient(p1))
        self.assertTrue(d1.has_patient(p2))
        self.assertEqual(d1.patients.count(), 1)

        d1.remove_patient(p2)
        db.session.commit()
        self.assertFalse(d1.has_patient(p2))
        self.assertEqual(d1.patients.count(), 0)
Beispiel #21
0
def generate_search_results(form):
    def dict_factory(cursor, row):
        d = {}
        for idx, col in enumerate(cursor.description):
            d[col[0]] = row[idx]
        return d

    connection = sqlite3.connect('app.db')
    connection.row_factory = dict_factory
    cursor = connection.cursor()
    query = '%' + form.keyword.data + '%'

    cursor.execute(
        "SELECT * FROM patients WHERE hx LIKE ? OR DOB LIKE ? OR name LIKE ? OR phone_number LIKE ? OR address LIKE ?",
        (
            query,
            query,
            query,
            query,
            query,
        ))

    patient_dicts = []

    patient_dicts = cursor.fetchall()

    patients = []

    for p in patient_dicts:
        current = Patient(name=p['name'],
                          DOB=p['DOB'],
                          id=p['id'],
                          hx=p['hx'],
                          phone_number=p['phone_number'],
                          address=p['address'])
        patients.append(current)
        # this isn't working properly...
        #patients.sort(key=lambda p: p.name.split()[-1])
    connection.commit()

    search_data = [patients, form.keyword.data, form]
    global recent_searches
    global search_id
    search_id += 1
    recent_searches[search_id] = search_data
    return search_id
Beispiel #22
0
def test_create_invalid_appointment_missing_provider():
    """
    Test creating an appointment with a patient and no provider
    """
    # Arrange
    patient = Patient(first_name="Aly", last_name="Sivji")
    now = datetime.now()
    a = Appointment(start=now, end=now, department='foo', patient=patient)

    # Act
    db.session.add(a)

    # Assert
    with pytest.raises(IntegrityError):
        db.session.commit()

    db.session.rollback()
    assert len(Appointment.query.all()) == 0
Beispiel #23
0
    def test_save_patient_to_db(self):
        response = self.client().get(
            f"http://localhost:5000/v2/patient/{self.patient_id}"
        )
        response = response.get_json()

        patient = Patient(
            id=response["data"]["id"],
            fullname=response["data"]["fullName"],
            email=response["data"]["email"],
            phone=response["data"]["phone"],
            clinic=response["data"]["clinic"]["id"],
            active=response["data"]["active"],
        )
        models_db.session.add(patient)
        models_db.session.commit()

        query_patient = Patient.query.filter_by(id=response["data"]["id"]).first()
        self.assertEqual(response["data"]["id"], query_patient.id)
Beispiel #24
0
def _patients(num: int, hospitals, users) -> List[Patient]:
    patients = []
    for i in range(0, num):
        gender = random.choice(['M', 'F'])
        name = names.name(gender)
        email = names.email(name)

        patients.append(
            Patient(name=name,
                    gender=gender,
                    birth_year=date.today().year - random.randint(18, 90),
                    email=email,
                    address=names.address(),
                    phone=names.phone(),
                    hospital=random.choice(hospitals),
                    created_by=random.choice(users),
                    updated_by=random.choice(users)))

    return patients
Beispiel #25
0
def new_patient():
    form = PatientForm()
    if form.validate_on_submit():

        preg = int(form.pregnancies.data)
        gluc = int(form.glucose.data)
        bm = int(form.bmi.data)
        pedigree = int(form.pedigree_function.data)
        ag = int(form.age.data)
        arr = np.array([[preg, gluc, bm, pedigree, ag]])
        #loading model
        loaded_model = pickle.load(
            open('../second_diabetes_classification_model.sav', 'rb'))
        result = loaded_model.predict(arr)

        if result[0] == 1:
            output = 1
            word = "Patient likely to be Diabetic"
        else:
            output = 0
            word = "Patient not Diabetic"

        patient = Patient(pregnancies=form.pregnancies.data,
                          glucose=form.glucose.data,
                          bmi=form.bmi.data,
                          pedigree_function=form.pedigree_function.data,
                          age=form.age.data,
                          author=current_user,
                          outcome=output)

        db.session.add(patient)
        db.session.commit()
        msg = Markup(
            "Patient data has been added successfully, Prediction for added patient: <b><u>"
            + word + "</u></b>")
        flash(msg, 'success')

        return redirect(url_for('main.view'))
    return render_template("create_patient.html",
                           title="New Patient",
                           form=form,
                           legend='New Patient')
Beispiel #26
0
def seed_patients():
    for i in range(1000):
        fake_profile = fake.profile()
        fake_middle_name = None
        add_middle_name = fake.boolean(chance_of_getting_true=45)
        first_name_check = fake_profile['name'].split(' ')[0]
        last_name_check = fake_profile['name'].split(' ')[-1]

        while (
            first_name_check == 'Mr.' or
            first_name_check == 'Ms.' or
            first_name_check == 'Mrs.' or
            first_name_check == 'Dr.' or
            last_name_check == 'MD' or
            last_name_check == 'PhD' or
            last_name_check == 'Jr.' or
            last_name_check == 'DVM' or
            last_name_check == 'DDS'
        ):
            fake_profile = fake.profile()
            first_name_check = fake_profile['name'].split(' ')[0]
            last_name_check = fake_profile['name'].split(' ')[-1]

        if add_middle_name:
            fake_middle_name = fake.profile()['name'].split(' ')[-1]

        new_patient = Patient(
            insurance_id=fake.pyint(min_value=1, max_value=9),
            first_name=fake_profile['name'].split(' ')[0],
            middle_name=fake_middle_name,
            last_name=fake_profile['name'].split(' ')[-1],
            dob=fake_profile['birthdate'],
            mrn=fake.pyint(min_value=1, max_value=9999),
            ssn=fake.pyint(min_value=100000000, max_value=999999999),
            primary_address=fake_profile['address'],
            phone_number=fake.pyint(min_value=1000000, max_value=9999999),
            active=fake.boolean(chance_of_getting_true=50),
            authorized_visits=fake.pyint(min_value=1, max_value=10)
        )
        db.session.add(new_patient)

    db.session.commit()
Beispiel #27
0
def test_create_patient():
    """
    Test creating a patient
    """
    # Arrange
    p = Patient(first_name="Aly", last_name="Sivji")

    # Act
    db.session.add(p)
    db.session.commit()

    # Assert
    assert len(Patient.query.all()) == 1

    queried_patient = Patient.query.one()
    assert queried_patient.first_name == 'Aly'
    assert queried_patient.last_name == 'Sivji'

    db.session.delete(p)
    db.session.commit()
Beispiel #28
0
def add_patient():
    # if current_user.is_authenticated:
    #     return redirect(url_for('main.index'))
    form = AddPatientForm()
    if form.validate_on_submit():
        patient = Patient(
            first_name=form.first_name.data,
            second_name=form.second_name.data,
            phone_number=form.phone_number.data,
            patronymic=form.patronymic.data,
            medic=form.doctors.data,
            age=form.age.data,
        )
        db.session.add(patient)
        db.session.commit()
        flash('Новый пациент добавлен')
        return redirect(url_for('patasys.index'))
    return render_template('patasys/add_patient.html',
                           title='Add Patient',
                           form=form)
Beispiel #29
0
    def test_attributes_assignment(self):
        date = datetime.utcnow()
        amount = "1 mg Dose"
        note = "Additional Note"
        treatment = Treatment(name='Treatment 1')
        patient = Patient(first_name='John',
                          last_name='Doe',
                          email='*****@*****.**')
        table = TreatmentTable(name='Table 1', patient=patient)

        entry = TreatmentTableEntry(timestamp=date,
                                    amount=amount,
                                    note=note,
                                    treatment=treatment,
                                    treatment_table=table)

        self.assertEqual(entry.timestamp, date)
        self.assertEqual(entry.amount, '1 mg Dose')
        self.assertEqual(entry.note, "Additional Note")
        self.assertEqual(entry.treatment, treatment)
        self.assertEqual(entry.treatment_table, table)
Beispiel #30
0
def newPatient():
    form = NewPatientForm()
    if form.validate_on_submit() and not Patient.query.get(form.ssn.data):
        p = Patient(ssn=form.ssn.data,
                    full_name=form.full_name.data,
                    dob=form.dob.data,
                    phone=form.phone.data,
                    gender=form.gender.data)
        db.session.add(p)
        db.session.commit()
        print("Added: ", form.ssn.data, form.full_name.data, form.dob.data,
              form.phone.data, form.gender.data)
        #Redirect instead of render_template?
        return render_template('index.html', create="Patient", form=form)
    elif Patient.query.get(form.ssn.data):
        print("NON UNIQUE PATIENT ERROR")
        return render_template('newpatient.html',
                               title='NewPatient',
                               form=form,
                               error="NON UNIQUE PATIENT ERROR")
    return render_template('newpatient.html', title='NewPatient', form=form)
Beispiel #31
0
def addPatient():
    form = NewPatientForm()
    #if form.validate_on_submit() and not Patient.query.get(form.patientID.data):
    p = Patient(patientID=form.patientID.data,
                name=form.name.data,
                preExistCond=form.preExistCond.data,
                age=form.age.data,
                gender=form.gender.data,
                healthInsurance=form.healthInsurance.data)
    db.session.add(p)
    db.session.commit()
    print("Added Patient", form.name.data)
    print("Patient ID:", form.patientID.data)
    print("Pre-Existing Condition:", form.preExistCond.data)
    print("Age:", form.age.data)
    print("Gender:", form.gender.data)
    print("Health Insurance:", form.healthInsurance.data)
    return render_template('addPatient.html', title="Admit Patient", form=form)
    #elif Patient.query.get(form.patientID.data):
    #print("This patient already exists as", form.name.data)
    #return render_template('addPatient.html', title="Admit Patient", form=form, error="EXISTING PATIENT ID ERROR")

    return render_template("index.html", title="Home")
Beispiel #32
0
#!flask/bin/python
from config import SQLALCHEMY_DATABASE_URI
from app.models import Patient, Appointment, PhoneCalls
from app import db
import os.path
db.create_all()

# Patient.generate_fake();
# Appointment.generate_fake();
# PhoneCalls.generate_fake();

Patient.add_patient();
Appointment.add_appointment();
PhoneCalls.add_call();