diff --git a/controllers/patient.controller.js b/controllers/patient.controller.js index f99bd7c..d15be6a 100644 --- a/controllers/patient.controller.js +++ b/controllers/patient.controller.js @@ -33,12 +33,12 @@ async function listPatients(req, res) { const params = []; if (firstname) { - sql += " AND firstname LIKE ?"; + sql += " AND LOWER(firstname) LIKE LOWER(?)"; params.push(`%${firstname}%`); } if (lastname) { - sql += " AND lastname LIKE ?"; + sql += " AND LOWER(lastname) LIKE LOWER(?)"; params.push(`%${lastname}%`); } @@ -79,7 +79,7 @@ async function listPatients(req, res) { // ✅ Sidebar dynamisch sidebarPartial: selectedPatient - ? "partials/patient-sidebar" + ? "partials/patient_sidebar" : "partials/sidebar", // ✅ Active dynamisch @@ -114,7 +114,7 @@ function showEditPatient(req, res) { res.render("patient_edit", { title: "Patient bearbeiten", - sidebarPartial: "partials/patient-sidebar", + sidebarPartial: "partials/patient_sidebar", active: "patient_edit", patient: results[0], @@ -538,7 +538,7 @@ function showMedicationPlan(req, res) { res.render("patient_plan", { title: "Medikationsplan", - sidebarPartial: "partials/patient-sidebar", + sidebarPartial: "partials/patient_sidebar", active: "patient_plan", patient: patients[0], @@ -675,7 +675,7 @@ async function showPatientOverviewDashborad(req, res) { res.render("patient_overview_dashboard", { title: "Patient Dashboard", - sidebarPartial: "partials/patient-sidebar", + sidebarPartial: "partials/patient_sidebar", active: "patient_dashboard", patient, diff --git a/controllers/service.controller.js b/controllers/service.controller.js index e274daa..948a0c2 100644 --- a/controllers/service.controller.js +++ b/controllers/service.controller.js @@ -287,7 +287,7 @@ async function listOpenServices(req, res, next) { res.render("open_services", { title: "Offene Leistungen", - sidebarPartial: "partials/sidebar-empty", + sidebarPartial: "partials/patient_sidebar", active: "services", rows, diff --git a/public/js/patients_sidebar.js b/public/js/patients_sidebar.js index 0b63905..e06d9e7 100644 --- a/public/js/patients_sidebar.js +++ b/public/js/patients_sidebar.js @@ -40,7 +40,7 @@ document.addEventListener("DOMContentLoaded", () => { radios.forEach((radio) => { radio.addEventListener("change", () => { - const id = radio.dataset.id; + const id = radio.value; const firstname = radio.dataset.firstname; const lastname = radio.dataset.lastname; diff --git a/views/layout.ejs b/views/layout.ejs index 5e4b5ab..486ec33 100644 --- a/views/layout.ejs +++ b/views/layout.ejs @@ -42,5 +42,6 @@ + diff --git a/views/partials/patient-sidebar.ejs b/views/partials/patient-sidebar.ejs_old similarity index 96% rename from views/partials/patient-sidebar.ejs rename to views/partials/patient-sidebar.ejs_old index 8f47ec7..da0cc3b 100644 --- a/views/partials/patient-sidebar.ejs +++ b/views/partials/patient-sidebar.ejs_old @@ -1,140 +1,140 @@ -<% - // ========================= - // BASISDATEN - // ========================= - const role = user?.role || null; - - // Arzt + Mitarbeiter dürfen Patienten bedienen - const canPatientArea = role === "arzt" || role === "mitarbeiter"; - - const pid = patient && patient.id ? patient.id : null; - const isActive = patient && patient.active ? true : false; - const isWaiting = patient && patient.waiting_room ? true : false; - - const canUsePatient = canPatientArea && !!pid; - - function lockClass(allowed) { - return allowed ? "" : "locked"; - } - - function hrefIfAllowed(allowed, href) { - return allowed ? href : "#"; - } -%> - - +<% + // ========================= + // BASISDATEN + // ========================= + const role = user?.role || null; + + // Arzt + Mitarbeiter dürfen Patienten bedienen + const canPatientArea = role === "arzt" || role === "mitarbeiter"; + + const pid = patient && patient.id ? patient.id : null; + const isActive = patient && patient.active ? true : false; + const isWaiting = patient && patient.waiting_room ? true : false; + + const canUsePatient = canPatientArea && !!pid; + + function lockClass(allowed) { + return allowed ? "" : "locked"; + } + + function hrefIfAllowed(allowed, href) { + return allowed ? href : "#"; + } +%> + + diff --git a/views/partials/patient_sidebar.ejs b/views/partials/patient_sidebar.ejs index ca38e7e..4d78ca5 100644 --- a/views/partials/patient_sidebar.ejs +++ b/views/partials/patient_sidebar.ejs @@ -1,177 +1,181 @@ +<% + // ========================= + // BASISDATEN + // ========================= + const role = user?.role || null; + + // Arzt + Mitarbeiter dürfen Patienten bedienen + const canPatientArea = role === "arzt" || role === "mitarbeiter"; + + const pid = patient && patient.id ? patient.id : null; + const isActive = patient && patient.active ? true : false; + const isWaiting = patient && patient.waiting_room ? true : false; + + const canUsePatient = canPatientArea && !!pid; + + function lockClass(allowed) { + return allowed ? "" : "locked"; + } + + function hrefIfAllowed(allowed, href) { + return allowed ? href : "#"; + } +%> + +
- + - <%=t.global.reset2%> + <%= t.global.reset2 %>
- -
- - - - - - - - - - - - - - - - - - - - + + - - <% if (patients.length === 0) { %> + + + + + +
+
ID<%=t.global.name%>N.I.E. / DNI<%=t.global.gender%><%=t.global.birthday%><%=t.global.email%><%=t.global.phone%><%=t.global.address%><%=t.global.country%><%=t.global.status%><%=t.global.notice%><%=t.global.create%><%=t.global.change%><%=t.global.action%>
+ + - + + + + + + + + + + + + + + - <% } %> + - <% patients.forEach(p => { %> - + + <% if (patients.length === 0) { %> + + + + <% } %> - - + + - - + - + + - - + - + + + - + - - + - + - + + + + + <% }) %> + - - - - - - - - - - - <% }) %> - - -
- <%=t.patientoverview.nopatientfound%> - ID<%= t.global.name %>DNI<%= t.global.gender %><%= t.global.birthday %><%= t.global.email %><%= t.global.phone %><%= t.global.address %><%= t.global.country %><%= t.global.status %><%= t.global.notice %><%= t.global.create %><%= t.global.change %>
+ <%= t.patientoverview.nopatientfound %> +
- - - - - + <% patients.forEach(p => { %> +
+ onchange="this.form.submit()" /> + <%= p.id %><%= p.id %><%= p.firstname %> <%= p.lastname %><%= p.dni || "-" %><%= p.firstname %> <%= p.lastname %><%= p.dni || "-" %> + <%= p.gender === 'm' ? 'm' : + p.gender === 'w' ? 'w' : + p.gender === 'd' ? 'd' : '-' %> + - <% if (p.gender === 'm') { %> - m - <% } else if (p.gender === 'w') { %> - w - <% } else if (p.gender === 'd') { %> - d - <% } else { %> - - - <% } %> - <%= new Date(p.birthdate).toLocaleDateString("de-DE") %><%= p.email || "-" %><%= p.phone || "-" %> - <%= new Date(p.birthdate).toLocaleDateString("de-DE") %> - + <%= p.street || "" %> <%= p.house_number || "" %>
+ <%= p.postal_code || "" %> <%= p.city || "" %> +
<%= p.email || "-" %><%= p.phone || "-" %><%= p.country || "-" %> - <%= p.street || "" %> <%= p.house_number || "" %>
- <%= p.postal_code || "" %> <%= p.city || "" %> -
+ <% if (p.active) { %> + Aktiv + <% } else { %> + Inaktiv + <% } %> + <%= p.country || "-" %><%= p.notes ? p.notes.substring(0, 80) : "-" %><%= new Date(p.created_at).toLocaleString("de-DE") %><%= new Date(p.updated_at).toLocaleString("de-DE") %>
- <% if (p.active) { %> - Aktiv - <% } else { %> - Inaktiv - <% } %> - - <%= p.notes ? p.notes.substring(0, 80) : "-" %> - <%= new Date(p.created_at).toLocaleString("de-DE") %><%= new Date(p.updated_at).toLocaleString("de-DE") %> - -
-
+ + + - diff --git a/views/services.ejs b/views/services.ejs index 32de462..834c117 100644 --- a/views/services.ejs +++ b/views/services.ejs @@ -1,35 +1,13 @@ - - - - - Leistungen - - ✔ erlaubt - - - - - +<%- include("partials/page-header", { + user, + title: t.patienteoverview.patienttitle, + subtitle: "", + showUserName: true +}) %>
- + <%- include("partials/flash") %>

Leistungen