-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from ubclaunchpad/rafael-backend-frontend
Integrated the frontend & backend for logbook page and log history page.
- Loading branch information
Showing
19 changed files
with
298 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Clinical Logging API Endpoints | ||
**Note:** You need to generate a token before you can access all endpoints either by logging in using the front-end interface or using the auth endpoint. | ||
|
||
## Auth | ||
### Generate token | ||
`POST` api/auth/token | ||
|
||
Query Params: | ||
| Name | Type | | ||
|------|------| | ||
| **email** | string | | ||
| **password** | string | | ||
|
||
## Logbooks | ||
### Create logbook | ||
`POST` api/logbooks/ | ||
|
||
Query Params: | ||
| Name | Type | | ||
|------|------| | ||
| **type** | string | | ||
| **title** | string | | ||
|
||
### Logbook details | ||
`GET` api/logbooks/{logbookID} | ||
|
||
Query Params: | ||
| Name | Type | | ||
|------|------| | ||
| **logbookID** | uuid | | ||
|
||
### User's logbooks | ||
`GET` api/logbooks/ | ||
|
||
Query Params: None | ||
|
||
## Logs | ||
### Create log | ||
`POST` api/logbooks/{logbookID}/logs | ||
|
||
Query Params: Params changes between log types. You can find example queries for each log type in the `examples` directory. | ||
|
||
### Logbook's logs | ||
`GET` api/logbooks/{logbookID}/logs | ||
|
||
Query Params: | ||
| Name | Type | | ||
|------|------| | ||
| **logbookID** | uuid | | ||
|
||
### Log details | ||
`GET` api/logbooks/{logbookID}/logs/{logID} | ||
|
||
Query Params: | ||
| Name | Type | | ||
|------|------| | ||
| **logbookID** | uuid | | ||
| **logID** | uuid | | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"case_no": 12345, | ||
"type": "adult_cardiac_logs", | ||
"patient_id": "P123456789", | ||
"age": 68, | ||
"surgeon": "Dr. Emily Thompson", | ||
"or_date": "2025-01-15T09:30:00+00:00", | ||
"reason_for_referral": "Severe angina, left main coronary artery disease", | ||
"hpi": "Patient presents with chronic angina, worsening over the past 3 months. Non-responsive to medical management.", | ||
"phmx": "Chronic obstructive pulmonary disease (COPD), hypertension, hyperlipidemia, previous myocardial infarction (2 years ago)", | ||
"gender": "Female", | ||
"social_etoh": "Retired, lives with spouse, occasional alcohol use, non-smoker", | ||
"social_smoking": "Never smoked", | ||
"social_drugs": "No history of illicit drug use", | ||
"social_allergies": "No known drug allergies", | ||
"medicine": "Aspirin 81mg, Metoprolol 25mg, Simvastatin 40mg, Isosorbide dinitrate 10mg", | ||
"exam_weight": 72.0, | ||
"exam_height": 160, | ||
"exam_bmi": 28.1, | ||
"exam_veins": "Veins are normal, no visible varicosities or thrombosis", | ||
"exam_allen_test": "Negative for both radial and ulnar patency", | ||
"exam_pulses_1": "Normal, 2+", | ||
"exam_pulses_2": "Normal, 2+", | ||
"exam_pulses_3": "Diminished, 1+", | ||
"exam_pulses_4": "Normal, 2+", | ||
"invx_echo": "Moderate left ventricular dysfunction, ejection fraction 40%, mild aortic stenosis", | ||
"invx_hb": 12.5, | ||
"invx_w": 5.4, | ||
"invx_plt": 220, | ||
"invx_cr_1": 1.1, | ||
"invx_cr_2": 1.0, | ||
"invx_cr_3": 1.2, | ||
"invx_cr_4": 1.1, | ||
"invx_cr_5": 1.0, | ||
"invx_cr_6": 1.0, | ||
"cath_image": "https://example.com/cath_image_left_main_stenosis.jpg", | ||
"cath_text": "Significant stenosis in the left main coronary artery (70%).", | ||
"cxr": "No acute lung pathology, cardiomegaly present.", | ||
"ct_image": "https://example.com/ct_image_coronary_calcification.jpg", | ||
"ct_text": "CT coronary angiography shows severe calcification in the proximal left anterior descending artery.", | ||
"surgical_plan": "Plan for coronary artery bypass grafting (CABG) involving left internal mammary artery (LIMA) to LAD and saphenous vein graft to RCA.", | ||
"first_operator_flag": "Yes", | ||
"or_flag": "Completed", | ||
"issue_flag": "Follow-up scheduled for 1 week", | ||
"fu_flag": "Follow-up readiness confirmed, no complications post-op", | ||
"op_notes_cpb": "CPB initiated with aortic cannulation and venous drainage via right atrium. Heparinization achieved with 300 units/kg.", | ||
"op_notes_xc": "Ascending aorta cross-clamped at 20 minutes into the procedure.", | ||
"op_notes_ca": "CABG performed, 2 grafts placed with good flow noted to both LAD and RCA.", | ||
"my_role": "Senior resident assisting in bypass graft placement and surgical closure", | ||
"post_op_course": "Stable in the ICU, extubated 6 hours post-op, no arrhythmias or complications.", | ||
"learning_points": "Close monitoring of hemodynamics during CPB; careful handling of the left internal mammary artery for grafting." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,36 @@ | ||
import express from "express"; | ||
import auth from "../middlewares/auth.js"; | ||
import dotenv from "dotenv"; | ||
import { createClient } from "@supabase/supabase-js"; | ||
|
||
dotenv.config(); | ||
|
||
const supabaseUrl = process.env.SUPABASE_URL; | ||
const supabaseKey = process.env.SUPABASE_ANON_KEY; | ||
|
||
const router = express.Router(); | ||
const supabase = createClient(supabaseUrl, supabaseKey); | ||
|
||
router.post("/check", auth, async (req, res) => { | ||
res.json({ message: "Auth Check Ok"}); | ||
// remove for production | ||
router.post("/token", async (req, res) => { | ||
try { | ||
const { email, password } = req.body; | ||
if (!email) { | ||
throw new Error("Email is missing"); | ||
} | ||
if (!password) { | ||
throw new Error("Password is missing"); | ||
} | ||
const { data, error } = await supabase.auth.signInWithPassword({ | ||
email: email, | ||
password: password, | ||
}); | ||
if (error) { | ||
throw new Error(error.message); | ||
} | ||
res.json({ data: data.session.access_token }) | ||
} catch (error) { | ||
res.json({ error: error.message }) | ||
} | ||
}) | ||
|
||
export default router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import express from "express"; | ||
import auth from "../middlewares/auth.js"; | ||
import { getUserLogs } from "../services/logs-service.js"; | ||
|
||
const router = express.Router(); | ||
|
||
router.get("", auth, async (req, res) => { | ||
const userLogs = await getUserLogs(req); | ||
if (userLogs.error) { | ||
res.status(500).json({ error: userLogs.error }); | ||
} else { | ||
res.status(200).json({ data: userLogs }); | ||
} | ||
}) | ||
|
||
export default router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import getTable from "../utils/get-table.js"; | ||
import { getUserLogbooks } from "./logbooks-service.js"; | ||
|
||
export async function getUserLogs(req) { | ||
try { | ||
const supabase = req.supabase; | ||
const userLogbooks = await getUserLogbooks(req); | ||
if (userLogbooks.error) { | ||
throw new Error(userLogbooks.error) | ||
} | ||
const logs = []; | ||
for (const logbook of userLogbooks) { | ||
const logbookLogs = await getTable(supabase, logbook.type, "logbook_id", logbook.id, "collection"); | ||
logs.push(...logbookLogs) | ||
} | ||
return logs; | ||
} catch (error) { | ||
return { error: error.message }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.