Skip to content

Commit

Permalink
Feature/task management and label crud routes (#29)
Browse files Browse the repository at this point in the history
* Added mock data

* feat: get tasks by gid/uid/status/type/date

* style: formatting

* fix: Remove commitizen branch

* test: fix task tests

* style: quick reformat

* feat: assign user(s) to a task CRUD and test

* style: quick style

* refactor: abstract queries, enable multiple

* refactor: abstract filter query/arg building logic

* crud routes for create new task, delete task, and update task info

* Feat: generic card and popup modal (#20)

* Intial card/button

* Basic card and modal

Basic card and modal skeleton

* fixed card and popup to have the requirments

fixed card and popup to have the requirments

* wip for passing medication data into Card component

* trying to get stuff workin

* trying to get comps workin

* stuff

* Final Working Card + Popup

---------

Co-authored-by: AdharshKan42 <[email protected]>

* fix: go formatting stuff werent running through entire directory (#23)

* feat: add a user context provider to the app (#24)

* feat: userContext stuff idk man

* refactor: general all around fixes (removing unused imports, fixing navigation errors)

* refactor: all over the place with this commit, but added swagger docs for file upload

* refactor: make context more general

* refactor: utilize card and popup in the medlist FE

* backend hot reload

* feat: added hot reloading for backend code

* refactor: abstract queries, enable multiple

* refactor: routes are updated

* feat: new route backend

* feat: add a new label crud and test

* feat: delete label crud and test

* refactor: FE  remove extra card file

* test: fix typo in db, tests passing locally

* refactor: modify task filter to bind to query

* feat: update task name and color route and test

* docs: fix swaggo comment style for task assignment and deletion

* docs: same swagger changes for label routes

* refactor: implement inclusive data range filter

* refactor: keep consistency between route groups

* docs: fix a swagger doc return type

---------

Co-authored-by: bedrockdude10 <[email protected]>
Co-authored-by: haleymartin-6 <[email protected]>
Co-authored-by: CaitlinFlynn <[email protected]>
Co-authored-by: AdharshKan42 <[email protected]>
Co-authored-by: Matt McCoy <[email protected]>
Co-authored-by: Matt McCoy <[email protected]>
  • Loading branch information
7 people authored Feb 17, 2024
1 parent 084cf9e commit 4c2985b
Show file tree
Hide file tree
Showing 24 changed files with 2,937 additions and 31 deletions.
2 changes: 0 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,3 @@ repos:
rev: v3.13.0
hooks:
- id: commitizen
- id: commitizen-branch
stages: [push]
90 changes: 73 additions & 17 deletions backend/db/migrations/init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ DROP TABLE IF EXISTS label;
DROP TABLE IF EXISTS task_labels;
DROP TABLE IF EXISTS files;


CREATE TYPE role AS ENUM ('PATIENT', 'PRIMARY', 'SECONDARY');
CREATE TYPE task_assignment_status AS ENUM ('ACCEPTED', 'DECLINED', 'NOTIFIED');
CREATE TYPE task_status AS ENUM ('INCOMPLETE', 'COMPLETE', 'PARTIAL');
Expand Down Expand Up @@ -58,7 +57,7 @@ CREATE TABLE IF NOT EXISTS task (
start_date timestamp,
end_date timestamp,
notes varchar,
repeating BOOLEAN,
repeating BOOLEAN DEFAULT FALSE,
repeating_interval varchar,
repeating_end_date timestamp,
task_status task_status NOT NULL,
Expand Down Expand Up @@ -95,8 +94,8 @@ CREATE TABLE IF NOT EXISTS task_assignees (
group_id integer NOT NULL,
label_name varchar NOT NULL,
PRIMARY KEY (task_id, label_name),
FOREIGN KEY (task_id) REFERENCES task (task_id),
FOREIGN KEY (group_id, label_name) REFERENCES label (group_id, label_name) -- NOTE: unsure about label/task_labels table constraints, uncommenting this line is err
FOREIGN KEY (task_id) REFERENCES task (task_id) ON UPDATE CASCADE,
FOREIGN KEY (group_id, label_name) REFERENCES label (group_id, label_name) ON UPDATE CASCADE -- NOTE: unsure about label/task_labels table constraints, uncommenting this line is err
);

CREATE TABLE IF NOT EXISTS files (
Expand All @@ -113,6 +112,7 @@ CREATE TABLE IF NOT EXISTS files (
FOREIGN KEY (task_id) REFERENCES task (task_id)
);

----------------- SAMPLE DATA :) -----------------------

-- Insert sample data into "medication" table
INSERT INTO medication (medication_id, medication_name)
Expand All @@ -121,19 +121,75 @@ VALUES
(2, 'Medication B'),
(3, 'Medication C'),
(4, 'Medication D'),
(5, 'Medication E');
(5, 'Medication E')
;

-- Insert sample data into "users" table
INSERT INTO users (user_id, first_name, last_name, email, phone, address, pfp_s3_url, device_id, push_notification_enabled) VALUES
('user123', 'John', 'Doe', '[email protected]', '123-456-7890', '123 Main St, Anytown, USA', 'https://example.com/pfp/user123.jpg', 'device123', TRUE),
('user456', 'Jane', 'Smith', '[email protected]', '987-654-3210', '456 Elm St, Anytown, USA', 'https://example.com/pfp/user456.jpg', 'device456', TRUE);

-- Insert sample data into "care_group" table
INSERT INTO care_group (group_name, date_created)
VALUES ('Sample Care Group', CURRENT_TIMESTAMP),
('Care-Wallet Group', NOW());
VALUES
('Smith Family', NOW()),
('Johnson Support Network', NOW()),
('Williams Care Team', NOW()),
('Brown Medical Group', NOW()),
('Care-Wallet Group', NOW())
;

INSERT INTO users (user_id, first_name, last_name, email, phone, address)
VALUES
('user1', 'John', 'Smith', '[email protected]', '123-456-7890', '123 Main St'),
('user2', 'Jane', 'Doe', '[email protected]', '987-654-3210', '456 Elm St'),
('user3', 'Bob', 'Johnson', '[email protected]', NULL, NULL),
('user4', 'Emily', 'Garcia', '[email protected]', '555-1212', '789 Oak Ave'),
('fIoFY26mJnYWH8sNdfuVoxpnVnr1', 'Matt', 'McCoy', '', '', '')
;

INSERT INTO group_roles (group_id, user_id, role)
VALUES
(1, 'user1', 'PATIENT'),
(1, 'user2', 'PRIMARY'),
(2, 'user3', 'PRIMARY'),
(2, 'user4', 'SECONDARY'),
(3, 'user4', 'PATIENT'),
(4, 'user1', 'SECONDARY'),
(4, 'user3', 'SECONDARY'),
(5, 'fIoFY26mJnYWH8sNdfuVoxpnVnr1', 'PRIMARY')
;

INSERT INTO task (group_id, created_by, created_date, start_date, end_date, notes, task_status, task_type)
VALUES
(1, 'user2', '2024-02-03 10:45:00', '2024-02-05 10:00:00', '2024-02-05 11:00:00', 'Pick up medication from pharmacy', 'INCOMPLETE', 'med_mgmt'),
(2, 'user3', '2024-02-20 23:59:59', '2024-02-10 14:30:00', NULL, 'Schedule doctor appointment', 'INCOMPLETE', 'other'),
(3, 'user4', '2020-02-05 11:00:00', NULL, '2024-02-20 23:59:59', 'Submit insurance claim', 'PARTIAL', 'financial'),
(4, 'user1', '2006-01-02 15:04:05', NULL, NULL, 'Refill water pitcher', 'COMPLETE', 'other')
;

-- Insert sample data into "group_roles" table
INSERT INTO group_roles (group_id, user_id, role) VALUES
(1, 'user123', 'PATIENT'),
(1, 'user456', 'PRIMARY');
INSERT INTO task_assignees (task_id, user_id, assignment_status, assigned_by, assigned_date)
VALUES
(1, 'user1', 'ACCEPTED', 'user2', NOW()),
(2, 'user3', 'NOTIFIED', 'user3', NOW()),
(3, 'user4', 'DECLINED', 'user4', NOW()),
(4, 'user2', 'DECLINED', 'user1', NOW())
;

INSERT INTO label (group_id, label_name, label_color)
VALUES
(1, 'Medication', 'blue'),
(2, 'Appointments', 'green'),
(3, 'Financial', 'orange'),
(4, 'Household', 'purple'),
(1, 'Household', 'purple')
;

INSERT INTO task_labels (task_id, group_id, label_name)
VALUES
(1, 1, 'Medication'),
(2, 2, 'Appointments'),
(3, 3, 'Financial'),
(4, 4, 'Household')
;

INSERT INTO files (file_id, file_name, group_id, upload_by, upload_date, file_size, task_id)
VALUES
(1, 'Medication list.pdf', 1, 'user2', NOW(), 123456, 1),
(2, 'Insurance form.docx', 3, 'user4', NOW(), 456789, 3),
(3, 'Water pitcher instructions.txt', 4, 'user1', NOW(), 1234, 4)
;
Loading

0 comments on commit 4c2985b

Please sign in to comment.