Initial commit: DMH Patient Registration Flask app

This commit is contained in:
Ayush
2026-11-27 17:07:03 +05:30
commit 6c03977aab
34 changed files with 5445 additions and 0 deletions
+70
View File
@@ -0,0 +1,70 @@
/* Minimal DOM helper compatible with the registration form's jQuery usage */
(function(global) {
function selectElements(sel) {
if (!sel) return [];
if (typeof sel === "function") {
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", sel);
} else {
sel();
}
return [];
}
if (typeof sel === "string") {
return Array.prototype.slice.call(document.querySelectorAll(sel));
}
if (sel === document || sel === window || sel.nodeType) {
return [sel];
}
return [];
}
function MiniQuery(sel) {
if (!(this instanceof MiniQuery)) return new MiniQuery(sel);
this.els = selectElements(sel);
}
MiniQuery.prototype.ready = function(fn) {
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", fn);
} else {
fn();
}
return this;
};
MiniQuery.prototype.show = function() {
this.els.forEach(function(el) { el.style.display = ""; });
return this;
};
MiniQuery.prototype.hide = function() {
this.els.forEach(function(el) { el.style.display = "none"; });
return this;
};
MiniQuery.prototype.html = function(val) {
if (val === undefined) return this.els[0] ? this.els[0].innerHTML : "";
this.els.forEach(function(el) { el.innerHTML = val; });
return this;
};
MiniQuery.prototype.append = function(htmlStr) {
this.els.forEach(function(el) { el.insertAdjacentHTML("beforeend", htmlStr); });
return this;
};
MiniQuery.prototype.bind = function(events, fn) {
var evList = events.split(/\s+/);
this.els.forEach(function(el) {
evList.forEach(function(ev) { el.addEventListener(ev, fn); });
});
return this;
};
MiniQuery.prototype.keydown = function(fn) {
return this.bind("keydown", fn);
};
MiniQuery.noConflict = function() {
return MiniQuery;
};
MiniQuery.fn = MiniQuery.prototype;
global.$ = MiniQuery;
global.jQuery = MiniQuery;
})(window);
+32
View File
@@ -0,0 +1,32 @@
.dmh-datepicker-popup {
position: absolute;
z-index: 9999;
background: #fff;
border: 1px solid #ccc;
border-radius: 4px;
padding: 8px;
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
width: 240px;
}
.dmh-dp-header {
display: flex;
justify-content: space-between;
margin-bottom: 6px;
gap: 6px;
}
.dmh-dp-header select { flex: 1; padding: 2px; }
.dmh-dp-grid {
display: grid;
grid-template-columns: repeat(7, 1fr);
gap: 3px;
}
.dmh-dp-grid button {
border: 1px solid #e0e0e0;
background: #f8f9fa;
padding: 4px 0;
cursor: pointer;
border-radius: 2px;
font-size: 12px;
}
.dmh-dp-grid button:hover:not(:disabled) { background: #007bff; color: #fff; }
.dmh-dp-grid button:disabled { opacity: 0.4; cursor: not-allowed; }
+100
View File
@@ -0,0 +1,100 @@
/* Lightweight dd/mm/yyyy datepicker compatible with $(selector).datepicker(opts) */
(function($) {
if (!$ || !$.fn) return;
function pad(n) { return n < 10 ? "0" + n : "" + n; }
$.fn.datepicker = function(opts) {
opts = opts || {};
this.els.forEach(function(input) {
var popup = null;
function closePopup() {
if (popup && popup.parentNode) {
popup.parentNode.removeChild(popup);
popup = null;
}
}
function renderCalendar(year, month) {
closePopup();
popup = document.createElement("div");
popup.className = "dmh-datepicker-popup";
var rect = input.getBoundingClientRect();
popup.style.top = (window.scrollY + rect.bottom + 2) + "px";
popup.style.left = (window.scrollX + rect.left) + "px";
var header = document.createElement("div");
header.className = "dmh-dp-header";
var monthSel = document.createElement("select");
var months = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
months.forEach(function(m, idx) {
var o = document.createElement("option");
o.value = idx;
o.textContent = m;
if (idx === month) o.selected = true;
monthSel.appendChild(o);
});
var yearSel = document.createElement("select");
var curYear = new Date().getFullYear();
for (var y = curYear; y >= curYear - 100; y--) {
var oy = document.createElement("option");
oy.value = y;
oy.textContent = y;
if (y === year) oy.selected = true;
yearSel.appendChild(oy);
}
monthSel.onchange = function() { renderCalendar(parseInt(yearSel.value, 10), parseInt(monthSel.value, 10)); };
yearSel.onchange = function() { renderCalendar(parseInt(yearSel.value, 10), parseInt(monthSel.value, 10)); };
header.appendChild(monthSel);
header.appendChild(yearSel);
popup.appendChild(header);
var grid = document.createElement("div");
grid.className = "dmh-dp-grid";
var daysInMonth = new Date(year, month + 1, 0).getDate();
var today = new Date();
today.setHours(0, 0, 0, 0);
for (var d = 1; d <= daysInMonth; d++) {
(function(dayNum) {
var btn = document.createElement("button");
btn.type = "button";
btn.textContent = dayNum;
var candidate = new Date(year, month, dayNum);
if (opts.maxDate === "0" && candidate > today) {
btn.disabled = true;
}
btn.onclick = function() {
var formatted = pad(dayNum) + "/" + pad(month + 1) + "/" + year;
input.value = formatted;
closePopup();
if (typeof opts.onSelect === "function") {
opts.onSelect(formatted);
}
};
grid.appendChild(btn);
})(d);
}
popup.appendChild(grid);
document.body.appendChild(popup);
}
input.addEventListener("click", function() {
if (input.readOnly) return;
var now = new Date();
renderCalendar(now.getFullYear(), now.getMonth());
});
document.addEventListener("click", function(ev) {
if (popup && ev.target !== input && !popup.contains(ev.target)) {
closePopup();
}
});
});
return this;
};
})(window.$);
+1
View File
@@ -0,0 +1 @@
/* Calendar touch style placeholder */