Skip to content

Commit

Permalink
added remaining keys to adult cardiac logs request
Browse files Browse the repository at this point in the history
  • Loading branch information
parkrafael committed Nov 26, 2024
1 parent 7de87c5 commit c27acf2
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 8 deletions.
1 change: 1 addition & 0 deletions backend/src/middlewares/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions backend/src/routes/logbooks-route.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
});
Expand All @@ -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 });
});
Expand All @@ -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;
114 changes: 110 additions & 4 deletions backend/src/services/logbooks-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -123,4 +229,4 @@ export async function getLog(req) {
} catch (error) {
throw new Error(error.message);
}
}
}

0 comments on commit c27acf2

Please sign in to comment.