def inventories(): response = { 'status': Repository.readAllStatus(), 'inventories': Repository.readInventories(), 'current_date': datetime.now() } return render_template('admin/inventories.html', data=response)
def patient_notification(id): Repository.updateNotification(id) response = { 'notifications': Repository.readAllNotifications(), 'notification': Repository.readNotification(id) } return render_template('patient/notification.html', data=response)
def dashboard(): response = { 'accounts': Repository.readRegisteredAccounts(), 'records': Repository.readRecords(), 'appointments': Repository.readAppointments() } return render_template('admin/dashboard.html', data=response)
def patient_dashboard(): response = { 'notifications': Repository.readAllNotifications(), 'accounts': Repository.readAccounts(), 'records': Repository.readRecords(), 'appointments': Repository.readAppointments() } return render_template('patient/dashboard.html', data=response)
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)
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)
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)
def register(): if request.method == 'POST': name = request.form['name'] email = request.form['email'] return Repository.register(name, email) return {'success': False}
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}
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')
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}
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}
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)
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)
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}
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': [] })
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)
def get_daily_appointments(): return jsonify(Repository.readInventoriesGroupByItem()) return jsonify( [data.serialize() for data in Repository.readInventoriesGroupByItem()])
def get_appointment(id): return jsonify(Repository.readAppointment(id).serialize())
def delete_record(): if Repository.deleteRecord(request.form): return {'success': True} return {'success': False}
def get_all_records(): return jsonify([data.serialize() for data in Repository.readRecords()])
def get_record(id): return jsonify(Repository.readRecord(id).serialize())
def delete_account(): if Repository.deleteAccount(request.form): return {'success': True} return {'success': False}
def tester(): return jsonify(Repository.readSchedules())
def populate(): Repository.populate() return {'success': True}
def update_notification(id): if Repository.updateNotification(id): return {'success': True} return {'success': False}
def get_notification(id): return jsonify(Repository.readNotification(id).serialize())
def get_account_notifications(id): return jsonify( [data.serialize() for data in Repository.readAccountNotifications(id)])
def get_all_notifications(): return jsonify( [data.serialize() for data in Repository.readAllNotifications()])
def send_sms(): response = Repository.sendSMS() return jsonify(response)