Giter VIP home page Giter VIP logo

switchboard's Introduction

NOTE: Archived on 11-27-2023. No longer in use.

Exploring the idea of a REDCap record switchboard for the SFS kit unboxing team.

Aggregates minimal data from REDCap into a SQLite database. The SQLite database is served by Datasette to provide a lightweight off-the-shelf data browsing and querying interface. A Datasette custom page uses the Datasette JSON web API to provide a "barcode dialer" that jumps you to the associated REDCap record, regardless of which SFS project it is in.

Installation

Requires:

  • Python 3.6
  • SQLite CLI (sqlite3)

Install the Python deps with:

make venv

and the SQLite CLI with:

apt install sqlite3   # on Ubuntu/Debian
brew install sqlite3  # on macOS with Homebrew

Activate the virtualenv to run any of the commands below:

source .venv/bin/activate

(Or alternatively, run the commands below via ./bin/venv-run.)

Building the data

You can build the data/sfs-redcap.sqlite database with:

make

Data will be exported from REDCap the first time make is run. Subsequent times will rebuild the SQLite database but not re-fetch from REDCap unless you pass the -B / --always-make option (or delete data/record-barcodes.csv).

You'll need to provide several environment variables with REDCap API credentials:

REDCAP_API_TOKEN_hct.redcap.rit.uw.edu_148

These are the same variables used in the backoffice/id3c-production/env.d/redcap/ envdir.

Serving the data

You can serve the database with Datasette with:

./bin/serve

and then browse the tables and views at http://localhost:3002.

There's a "canned query" for looking up barcodes at http://localhost:3002/sfs-redcap/lookup-barcode. The corresponding JSON web API is http://localhost:3002/sfs-redcap/lookup-barcode.json?barcode=โ€ฆ.

The "barcode dialer" is at http://localhost:3002/dial.

Development

Adding or updating a Python dependency

Python dependencies are managed with pip-tools.

Edit requirements.in to modify our top-level Python dependency declarations.

Then, regenerate the fully-specified requirements.txt using pip-compile with:

make requirements.txt

Finally, re-create your virtualenv from scratch with:

make venv

Or alternatively, apply the changes to your virtualenv in-place with:

pip-sync

Once you're satisfied, make sure to commit your changes to both requirements.in and requirements.txt.

Troubleshooting

On MacOS, if you see this error message:

./bin/serve: line 6: realpath: command not found

You can install realpath as part of coreutils, using Homebrew:

brew install coreutils

database is locked error

SQLite handles concurrency differently than a client-server database system does.
In SQLite, a write operation can lock the entire database and prevent readers
from accessing it, for example. This is good resource for learning about
locks in SQLite: https://sqlite.org/lockingv3.html

switchboard's People

Contributors

bencap avatar davereinhart avatar dependabot[bot] avatar kairstenfay avatar kschwabefry avatar seidelma avatar truong97 avatar tsibley avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

switchboard's Issues

Rethink optional barcode logic

The new SCAN IRB Kiosk project does not contain all the same barcode fields that we expected in the SCAN IRB (non-kiosk) projects.

Some hasty deployment on a tight deadline meant that we overlooked some of these missing barcode fields in the new REDCap project and accidentally broke the Switchboard data export in deployment.

We wrote a quick hack, #15, where @jccraft-uw mentions in a comment the decision we made at that point in time to make barcode fields optional.

We probably want to be more specific about which barcode fields are optional or add some conditional logic that depends on barcode availability by project purview (e.g. "scan" vs. "scan-kiosk").

Deployed front-end doesn't reload to include latest data

It's unclear at this point whether this is a deployment configuration issue (and thus should be filed at seattleflu/backoffice) or something that can be fixed in this repo.

In the past couple of days, the deployed app at backoffice.seattleflu.org/switchboard has failed to update the front-end with the latest data in the sqlite database.

See this Slack thread for the steps I took to debug, as I'm unsure how much barcode/REDCap link sharing I should be doing in a public setting.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.