def add_clinic(clinic):
    update_language_string(clinic.name)
    with get_connection() as conn:
        with conn.cursor() as cur:
            cur.execute(
                'INSERT INTO clinics (id, name, edited_at) VALUES (%s, %s, %s)',
                [clinic.id, to_id(clinic.name), clinic.edited_at])
def add_user(user):
    update_language_string(user.name)
    with get_connection() as conn:
        with conn.cursor() as cur:
            query = '''
            INSERT INTO users (id, name, role, email, hashed_password, edited_at) VALUES (%s, %s, %s, %s, %s, %s);
            '''
            cur.execute(query, [
                user.id, user.name.id, user.role, user.email,
                user.hashed_password,
                datetime.now()
            ])
Exemple #3
0
def add_patient(patient: Patient):
    update_language_string(patient.given_name)
    update_language_string(patient.surname)
    update_language_string(patient.country)
    update_language_string(patient.hometown)
    with get_connection() as conn:
        with conn.cursor() as cur:
            cur.execute(
                'INSERT INTO patients (id, given_name, surname, date_of_birth, sex, country, hometown, phone, edited_at) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)',
                [
                    patient.id,
                    to_id(patient.given_name),
                    to_id(patient.surname), patient.date_of_birth, patient.sex,
                    to_id(patient.country),
                    to_id(patient.hometown), patient.phone, patient.edited_at
                ])