diff --git a/backend/src/middlewares/auth.js b/backend/src/middlewares/auth.js index b8d71ea2..90cccfb9 100644 --- a/backend/src/middlewares/auth.js +++ b/backend/src/middlewares/auth.js @@ -4,6 +4,7 @@ import { createClient } from "@supabase/supabase-js"; const auth = async (req, res, next) => { try { const token = req.header("Authorization")?.split(" ")[1]; + console.log(token) const supabaseSecret = process.env.SUPABASE_JWT_SECRET; if (token) { jwt.verify(token, supabaseSecret); diff --git a/backend/src/routes/logbooks-route.js b/backend/src/routes/logbooks-route.js index b86a059e..a846f795 100644 --- a/backend/src/routes/logbooks-route.js +++ b/backend/src/routes/logbooks-route.js @@ -4,12 +4,12 @@ import { createLogbook, getUserLogbooks, getLogbook, createLog, getLogbookLogs, const router = express.Router(); -router.post("/", auth, async (req, res) => { +router.post("", auth, async (req, res) => { const logbook = await createLogbook(req); res.status(201).json({ data: logbook }); }); -router.get("/", auth, async (req, res) => { +router.get("", auth, async (req, res) => { const userLogbooks = await getUserLogbooks(req); res.status(200).json({ data: userLogbooks }); }); @@ -24,7 +24,7 @@ router.post("/:logbookID/logs", auth, async (req, res) => { res.status(201).json({ data: log }); }); -router.get("/:logbookID/logs/", auth, async (req, res) => { +router.get("/:logbookID/logs", auth, async (req, res) => { const logbookLogs = await getLogbookLogs(req); res.status(200).json({ data: logbookLogs }); }); @@ -34,4 +34,4 @@ router.get("/:logbookID/logs/:logID", auth, async (req, res) => { res.status(200).json({ data: log }); }); -export default router; +export default router; \ No newline at end of file diff --git a/backend/src/services/logbooks-service.js b/backend/src/services/logbooks-service.js index 0acb7772..cdcba939 100644 --- a/backend/src/services/logbooks-service.js +++ b/backend/src/services/logbooks-service.js @@ -73,14 +73,120 @@ export async function createLog(req) { async function createAdultCardiacLog(req, supabase) { const { logbookID } = req.params; - const { caseNo } = req.body; + const { + type, + caseNo, + paitentID, + surgeon, + age, + gender, + orDate, + reason, + hpi, + socialEtOH, + socialDrugs, + socialSmoking, + socialMeds, + socialAllergies, + phmxHTN, + phmxDMII, + phmxDLP, + phmxCVA, + examWeight, + examHeight, + examBMI, + examVeins, + examAllenTest, + examPulsesSixtyTwo, + examPulsesSixtyFive, + examPulsesSixtyEight, + examPulsesSeventy, + cathLink, + invxEchoEF, + invxEchoRVFx, + invxWMA, + invxAorta, + invxValves, + invxCXR, + invxHb, + invxW, + invxPit, + invxCr, + ctLink, + surgicalPlan, + surgicalPlanFirstOperator, + surgicalPlanIssueOR, + surgicalPlanIssuePost, + surgicalPlanaFlagForFU, + operativeNotesCPBh, + operativeNotesCPBm, + operativeNotesXCh, + operativeNotesXCm, + operativeNotesCAh, + operativeNotesCAm, + myRole, + postOperativeCourse, + learningPointsKeyLessons, + } = req.body; const { data, error } = await supabase .from("adult_cardiac_logs") .insert({ logbook_id: logbookID, - case_no: Number(caseNo), + type: type, + case_no: caseNo, + paitent_id: paitentID, + surgeon: surgeon, + age: age, + gender: gender, + or_date: orDate, + reason: reason, + hpi: hpi, + social_etoh: socialEtOH, + social_drugs: socialDrugs, + social_smoking: socialSmoking, + social_meds: socialMeds, + social_allergies: socialAllergies, + pmhx_htn: phmxHTN, + pmhx_dmii: phmxDMII, + pmhx_dlp: phmxDLP, + pmhx_cva: phmxCVA, + exam_weight: examWeight, + exam_height: examHeight, + exam_bmi: examBMI, + exam_veins: examVeins, + exam_allen_test: examAllenTest, + exam_pulses_sixtytwo: examPulsesSixtyTwo, + exam_pulses_sixtyfive: examPulsesSixtyFive, + exam_pulses_sixtyeight: examPulsesSixtyEight, + exam_pulses_seventy: examPulsesSeventy, + cath: cathLink, + invx_echo_ef: invxEchoEF, + invx_echo_rvfx: invxEchoRVFx, + invx_wma: invxWMA, + invx_aorta: invxAorta, + invx_valves: invxValves, + invx_cxr: invxCXR, + invx_hb: invxHb, + invx_w: invxW, + invx_pit: invxPit, + invx_cr: invxCr, + ct: ctLink, + surgical_plan: surgicalPlan, + surgical_plan_first_operator: surgicalPlanFirstOperator, + surgical_plan_issue_or: surgicalPlanIssueOR, + surgical_plan_issue_post: surgicalPlanIssuePost, + surgical_plan_flag_for_fu: surgicalPlanaFlagForFU, + operative_notes_cpb_h: operativeNotesCPBh, + operative_notes_cpb_m: operativeNotesCPBm, + operative_notes_xc_h: operativeNotesXCh, + operative_notes_xc_m: operativeNotesXCm, + operative_notes_ca_h: operativeNotesCAh, + operative_notes_ca_m: operativeNotesCAm, + my_role: myRole, + post_operative_course: postOperativeCourse, + learning_points_key_lessons: learningPointsKeyLessons, }) - .select(); + .select(); if (error) { throw new Error(error.message); } @@ -123,4 +229,4 @@ export async function getLog(req) { } catch (error) { throw new Error(error.message); } -} \ No newline at end of file +}