Harm Reduction

Project phases

Published: August 22, 2023

Last Updated: 1 year ago.

View All Projects

The UBC Cloud Innovation Center (CIC) supported the Hein Lab in developing a prototype to track and view substance composition to better inform decision-making. This convenient and anonymous web application uses the AWS cloud to aid in harm reduction. Students can enter a public database of substance composition and access its relevant details, alternatively, they are given the choice to get notified to speed up the process of tracking drugs.

The Hein Lab aims to provide UBC people the opportunity to have their recreational drugs tested, to inform their decision-making. In order to encourage participation, the application is completely anonymous. They are not identified, tracked, or compelled to disclose their identity.

Approach

The prototype solution provides an interface for users and the general public, as well as for the Hein Lab administrators.

In order to build awareness of harm reduction, drug testing results are available on a publicly accessible website. Students submit drug samples to the Hein Lab anonymously, via a dropbox system. The sample is processed using a robotic device developed by the Hein Lab. The resulting data is transmitted to the database. In the event that manual testing is required, an alert is sent to the lab. Authorized Lab administrators can make notes, verify and manually adjust results. Once satisfied that they are correct, the results become publicly available.

Users can opt-in to receive push notifications by text or email when the results are available, but that data is retained only as long as needed for this purpose. Alternatively, users can fetch the results using a Sample ID provided at drop-off.

Supporting Artifacts

Architecture Diagram

Architecture diagram depicting the backend of the Harm Reduction process.

Screenshots of UI

The About Us page is where both the users and admins land on for home

Common pages of the student

Common pages of the lab admin

Technical Details

Key components of the Harm Reduction prototype are React, Amplify, Cognito, and AWS for the user interface. For the backend, API gateways to receive requests from the user and admin, SNS and SES to manipulate optional contact information, Lambdas to send updates to the user and admin and handle requests from the admin, and DynamoDB to store drug sample data and temporary (optional) user data. 

Frontend

When a user enters the web app, they land on the home page featuring the lab. The user can search by sample id, and see layout of details involving tracking progress and date received, as well, the user can opt-in to receive updates via email/sms and/or provide more information about the sample (e.g., was it used?). If the results are already out, the user also sees a table of drug composition and percentage by mass below this layout. Alternatively, the user can search for another sample by entering the id on the right-hand side. Each completed result is publicly published onto the table of all samples.

Backend

Expand the below tabs for more information.

Optional notification system

When a user chooses to enter their contact information to get push notifications when their sample is ready, their private data goes through the OTP API that determines whether to send or verify an OTP. Next, the OTP API Handler handles the subsequent request in either sending a 6-digit code or verifying the code inputted by the user. For the latter, the OTP Info matches the stored code with the user’s code. If the user opts-in for their phone, then SNS activates and sends a text to their phone about OTP. If the user opts-in for their email, then SES activates and sends an email. Whenever the user’s sample updates in progress, a notification is pushed through the described way.

Database storage and access

When the Hein Lab robot finishes testing the drug sample, the composition is sent through the API Gateway to handle changes to the user and samples table. The Lambda handles the request from the robot’s automatic additions and admin’s manual changes, and returns a response, exits, or times out depending on what the admin does. After, DynamoDB for sample information stores the drug sample information, while if the user provided contact information, another DynamoDB for user information stores, retrieves, and eventually purges this information.

Walkthrough of the architecture diagram

1. React App is the web application that the user interacts with to view results or to input optional additional drug and contact information. The admin interacts with this via unlisted pages, and can view more comprehensive drug sample data and manually adjust testing data. 

2. Amplify is the front end of the web application hosted using AWS Amplify. 

3. Cognito allocates information for admins. The admin uses their credentials to log into the admin page. The account must be manually set up by the system administrator through the AWS Console

4. API Gateway (OTP) receives only POST requests with a specific parameter ‘action’ that dictates whether the request will ‘send’ or ‘verify’ an OTP.

5. Lambda (OTP API Handler) handles requests received through the API Gateway for OTP. Requests are labeled with an action of either ‘send’ or ‘verify. ‘Send’ generates a 6-digit code along with a session id as an OTP, which is then stored as OTP Info in DynamoDB. ‘Verify’ queries the DynamoDB table and checks the OTP and session code against the ones entered by the user, and returns a boolean value representing the validity of the OTP entered by the user. 

6. DynamoDB (OTP Info) saves OTP Info from the Lambda that sends OTP with a session id, then gives the OTP Info to determine match between the user input of their OTP with the stored OTP.  

7. SNS (Text) sends texts to users that opt in for SMS notifications. Users verify their phone number via OTP, and receive a text notifying when the sample they submitted has been tested

8. SES (Email) integrates into any application for bulk email sending. The Lambda for sending OTP passes the OTP to the user-provided email. 

9. API Gateway supports GET, POST, PUT, and DELETE operations on either the user or samples table.

10. Lab is the Python client installed on the laptop in the lab. This client makes a call to the API Gateway in order to update the sample database with new information when a sample has been tested

11. Lambda (Handle Request) processes events from the admin through the API Gateway. Returns a response, exits, or times out depending on Admin input. 

12. DynamoDB (User Info) stores and retrieves sensitive user info, including contact information. Data is purged if there is no further need to store this info.

13. DynamoDB (Sample Info) stores and retrieves sample information, particularly the drug composition. 

14. Lambda (Send Update) sends notifications via SNS or SES  to users when the status of their sample is updated in the Samples Table. The admin also receives a notification when a sample requires further manual testing.

Link to solution on GitHub: https://github.com/UBC-CIC/ubc-harm-reduction

Student and Lab Interaction

The student interaction process of Harm Reduction. The student collects a kit first and obtains a code and vial. The student then puts their drug sample into the vial and envelop, then anonymously drops the sample off at the designated secure receptacle. The student can choose to get notified via email or text, or remain anonymous and check the public table. If the student opted-in for notifications, once their sample is ready, they get notified of the drug sample results.
The lab admin logs into the site and gains access to view all submitted and tested/in testing drug samples. The admin can choose to note the sample or manually adjust it. Samples that are flagged get noted. Once testing is finished, results are published onto the public table.

Demo Video

Acknowledgements

Photo by the Hein Lab

About the University of British Columbia Cloud Innovation Centre (UBC CIC)

The UBC CIC is a public-private collaboration between UBC and Amazon Web Services (AWS). A CIC identifies digital transformation challenges, the problems or opportunities that matter to the community, and provides subject matter expertise and CIC leadership.

Using Amazon’s innovation methodology, dedicated UBC and AWS CIC staff work with students, staff and faculty, as well as community, government or not-for-profit organizations to define challenges, to engage with subject matter experts, to identify a solution, and to build a Proof of Concept (PoC). Through co-op and work-integrated learning, students also have an opportunity to learn new skills which they will later be able to apply in the workforce.