Example #1
0
def inventories():
    response = {
        'status': Repository.readAllStatus(),
        'inventories': Repository.readInventories(),
        'current_date': datetime.now()
    }
    return render_template('admin/inventories.html', data=response)
Example #2
0
def patient_notification(id):
    Repository.updateNotification(id)
    response = {
        'notifications': Repository.readAllNotifications(),
        'notification': Repository.readNotification(id)
    }
    return render_template('patient/notification.html', data=response)
Example #3
0
def dashboard():
    response = {
        'accounts': Repository.readRegisteredAccounts(),
        'records': Repository.readRecords(),
        'appointments': Repository.readAppointments()
    }
    return render_template('admin/dashboard.html', data=response)
Example #4
0
def patient_dashboard():
    response = {
        'notifications': Repository.readAllNotifications(),
        'accounts': Repository.readAccounts(),
        'records': Repository.readRecords(),
        'appointments': Repository.readAppointments()
    }
    return render_template('patient/dashboard.html', data=response)
Example #5
0
def patient_appointment_request():
    response = {
        'status': Repository.readAllStatus(),
        'services': Repository.readServices(),
        'appointments': Repository.readAppointments(),
        'schedules': Repository.readSchedules(),
        'current_date': datetime.now()
    }
    return render_template('patient/appointment_request.html', data=response)
Example #6
0
def search_residents():
    if request.method == 'POST':
        account_id = int(request.form['account_id'])
        if account_id == -1:
            return redirect(url_for('residents'))

        response = {
            'result': [Repository.readAccount(account_id)],
            'accounts': Repository.readResidentAccounts()
        }
        return render_template('admin/residents.html', data=response)
Example #7
0
def search_inventories():
    if request.method == 'POST':
        category = int(request.form['category'])
        if category == -1:
            return redirect(url_for('inventories'))

        response = {
            'status': Repository.readAllStatus(),
            'inventories': [Repository.readInventory(category)],
            'current_date': datetime.now()
        }
        return render_template('admin/inventories.html', data=response)
Example #8
0
def register():
    if request.method == 'POST':
        name = request.form['name']
        email = request.form['email']
        return Repository.register(name, email)

    return {'success': False}
Example #9
0
def upsert_appointment():

    validator = CreateAppointmentSchema(unknown='EXCLUDE')
    errors = validator.validate(request.form)

    if errors:
        return jsonify({'success': False, 'errors': errors})

    if Repository.upsertAppointment(request.form):
        return {'success': True}
    return {'success': False}
Example #10
0
def login():
    if request.method == 'POST':
        data = Repository.loginAccount(request.form)
        if data is not None and data is not False:
            if data.role_id is not None:
                if data.role_id < 3 and data.occupation != 'Barangay Lupon':
                    return redirect(url_for('dashboard'))
            return redirect(url_for('patient_dashboard'))
        else:
            flash('Invalid credentials.')
    return render_template('common/login.html')
Example #11
0
def upsert_record():

    validator = CreateRecordSchema(unknown='EXCLUDE')
    errors = validator.validate(request.form)

    if errors:
        return jsonify({'success': False, 'errors': errors})

    if Repository.upsertRecord(request.form):
        return {'success': True}
    return {'success': False}
Example #12
0
def upsert_inventory_items():

    validator = AddItemsSchema(unknown='EXCLUDE')
    errors = validator.validate(request.form)

    if errors:
        return jsonify({'success': False, 'errors': errors})

    if Repository.upsertItems(request.form):
        return {'success': True}
    return {'success': False}
Example #13
0
def search_records():
    if request.method == 'POST':
        date = request.form['start_date']
        response = {
            'roles': Repository.readRoles(),
            'status': Repository.readAllStatus(),
            'services': Repository.readServices(),
            'accounts': Repository.readAccounts(),
            'residents': Repository.readResidentAccounts(),
            'records': Repository.readRecords(),
            'appointments': Repository.searchAppointments(request.form),
            'inventories': Repository.readInventories(),
            'current_date': datetime.strptime(date, '%m/%d/%Y'),
            'form': request.form
        }
        return render_template('admin/records.html', data=response)
Example #14
0
def patient_appointments():
    response = {
        'notifications': Repository.readAllNotifications(),
        'roles': Repository.readRoles(),
        'status': Repository.readAllStatus(),
        'accounts': Repository.readAccounts(),
        'records': Repository.readRecords(),
        'appointments': Repository.readAppointments()
    }
    return render_template('patient/appointments.html', data=response)
Example #15
0
def upsert_account():

    if int(request.form['id']) == -1:
        validator = CreateAccountSchema(unknown='EXCLUDE')
        errors = validator.validate(request.form)
        if errors:
            return jsonify({'success': False, 'errors': errors})
    else:
        validator = UpdateAccountSchema(unknown='EXCLUDE')
        errors = validator.validate(request.form)
        if errors:
            return jsonify({'success': False, 'errors': errors})

    if Repository.upsertAccount(request.form):
        return {'success': True}
    return {'success': True}
Example #16
0
def register():
    if request.method == 'POST':

        validator = RegisterAccountSchema(unknown='EXCLUDE')
        errors = validator.validate(request.form)

        if errors:
            return render_template('common/register.html',
                                   data={
                                       'errors': errors,
                                       'input': request.form
                                   })

        if Repository.registerAccount(request.form):
            return redirect(url_for('login'))

    return render_template('common/register.html',
                           data={
                               'errors': [],
                               'input': []
                           })
Example #17
0
def appointments():
    response = {
        'roles':
        Repository.readRoles(),
        'status':
        Repository.readAllStatus(),
        'services':
        Repository.readServices(),
        'accounts':
        Repository.readAccounts(),
        'residents':
        Repository.readResidentAccounts(),
        'records':
        Repository.readRecords(),
        'appointments':
        Repository.readDailyAppointments(datetime.now().strftime('%m/%d/%Y')),
        'inventories':
        Repository.readInventories(),
        'current_date':
        datetime.now(),
        'form':
        None
    }
    return render_template('admin/appointments.html', data=response)
Example #18
0
def get_daily_appointments():
    return jsonify(Repository.readInventoriesGroupByItem())
    return jsonify(
        [data.serialize() for data in Repository.readInventoriesGroupByItem()])
Example #19
0
def get_appointment(id):
    return jsonify(Repository.readAppointment(id).serialize())
Example #20
0
def delete_record():
    if Repository.deleteRecord(request.form):
        return {'success': True}
    return {'success': False}
Example #21
0
def get_all_records():
    return jsonify([data.serialize() for data in Repository.readRecords()])
Example #22
0
def get_record(id):
    return jsonify(Repository.readRecord(id).serialize())
Example #23
0
def delete_account():
    if Repository.deleteAccount(request.form):
        return {'success': True}
    return {'success': False}
Example #24
0
def tester():
    return jsonify(Repository.readSchedules())
Example #25
0
def populate():
    Repository.populate()
    return {'success': True}
Example #26
0
def update_notification(id):
    if Repository.updateNotification(id):
        return {'success': True}
    return {'success': False}
Example #27
0
def get_notification(id):
    return jsonify(Repository.readNotification(id).serialize())
Example #28
0
def get_account_notifications(id):
    return jsonify(
        [data.serialize() for data in Repository.readAccountNotifications(id)])
Example #29
0
def get_all_notifications():
    return jsonify(
        [data.serialize() for data in Repository.readAllNotifications()])
Example #30
0
def send_sms():
    response = Repository.sendSMS()
    return jsonify(response)