plokmii commited on
Commit
a6b011b
·
verified ·
1 Parent(s): b046626

Upload templates/dsa_history.html with huggingface_hub

Browse files
Files changed (1) hide show
  1. templates/dsa_history.html +110 -0
templates/dsa_history.html ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="zh-TW">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>DSA History</title>
7
+ <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
8
+ </head>
9
+ <body>
10
+ <div class="container py-4" style="max-width: 1200px;">
11
+ <div class="d-flex justify-content-between align-items-center mb-3">
12
+ <h2 class="mb-0">DSA 歷史紀錄</h2>
13
+ <div>
14
+ <a href="/" class="btn btn-dark btn-sm me-1">首頁</a>
15
+ <a href="/dsa/new" class="btn btn-outline-primary btn-sm me-1">新增資料</a>
16
+ <a href="/dsa/analysis" class="btn btn-outline-secondary btn-sm">統計分析</a>
17
+ </div>
18
+ </div>
19
+ <div class="small text-muted mb-2">目前共 {{ db_stats.patients }} 位病患、{{ db_stats.reports }} 筆 DSA 報告</div>
20
+
21
+ {% if error %}<div class="alert alert-danger">{{ error }}</div>{% endif %}
22
+
23
+ <form class="row g-2 mb-3" method="get" action="/dsa/history">
24
+ <div class="col">
25
+ <input type="text" class="form-control" name="q" placeholder="搜尋姓名或病歷號" value="{{ request.args.get('q','') }}">
26
+ </div>
27
+ <div class="col-auto d-flex align-items-center">
28
+ <span class="me-1 text-muted small">日期範圍</span>
29
+ <input type="date" class="form-control form-control-sm" name="from" value="{{ request.args.get('from','') }}" style="width:150px;">
30
+ <span class="mx-1">–</span>
31
+ <input type="date" class="form-control form-control-sm" name="to" value="{{ request.args.get('to','') }}" style="width:150px;">
32
+ </div>
33
+ <div class="col-auto"><button class="btn btn-secondary">搜尋</button></div>
34
+ </form>
35
+
36
+ <table class="table table-bordered table-hover bg-white" style="font-size:.9rem;">
37
+ <thead class="table-light">
38
+ <tr>
39
+ <th>病患姓名</th><th>病歷號</th><th>報告日期</th><th>Class</th>
40
+ <th>%SA</th><th>Overall</th><th>Antibodies</th><th>填表人</th><th></th>
41
+ </tr>
42
+ </thead>
43
+ <tbody>
44
+ {% set q = request.args.get('q','').lower() %}
45
+ {% set date_from = request.args.get('from','') %}
46
+ {% set date_to = request.args.get('to','') %}
47
+ {% for r in reports %}
48
+ {% set rd = r.report_date | replace('/','-') %}
49
+ {% if (not q or q in r.chart_no.lower() or q in r.patient_name.lower())
50
+ and (not date_from or rd >= date_from)
51
+ and (not date_to or rd <= date_to) %}
52
+ <tr>
53
+ <td>{{ r.patient_name }}</td>
54
+ <td>{{ r.chart_no }}</td>
55
+ <td>{{ r.report_date }}</td>
56
+ <td>{{ r.dsa_class }}</td>
57
+ <td class="fw-bold">{{ r.pct_sa }}%</td>
58
+ <td><span class="badge {{ 'bg-danger' if r.overall == 'Positive' else 'bg-success' }}">{{ r.overall }}</span></td>
59
+ <td class="small spec-cell" style="max-width:240px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;"
60
+ title="{{ r.specificity or '' }}">
61
+ {{ r.specificity if r.specificity and r.specificity != '(-)' else '(-)' }}
62
+ </td>
63
+ <td class="small">{{ r.submitted_by or '' }}</td>
64
+ <td class="text-nowrap">
65
+ <a href="/dsa/history/{{ r.chart_no }}" class="btn btn-sm btn-outline-primary me-1">View</a>
66
+ <a href="/dsa/analysis?chart_no={{ r.chart_no }}" class="btn btn-sm btn-outline-success me-1">Analyze</a>
67
+ <button class="btn btn-sm btn-outline-danger" onclick="deleteDsaReport({{ r.id }}, this)">Del</button>
68
+ </td>
69
+ </tr>
70
+ {% endif %}
71
+ {% endfor %}
72
+ </tbody>
73
+ </table>
74
+
75
+ {% if not reports %}<div class="text-center text-muted py-5">尚無紀錄</div>{% endif %}
76
+ </div>
77
+ <script>
78
+ window.addEventListener('DOMContentLoaded', function() {
79
+ document.querySelectorAll('.spec-cell').forEach(td => {
80
+ const orig = td.textContent.trim();
81
+ if (!orig || orig === '(-)') return;
82
+ const tokens = orig.match(/\S+?\([^)]*\)|\S+/g) || [];
83
+ td.innerHTML = tokens.map(seg => {
84
+ const m = seg.match(/^([^(]+)(\([^)]*\))?$/);
85
+ if (!m) return seg;
86
+ const sero = m[1];
87
+ const paren = m[2] || '';
88
+ const seroHtml = '<span style="color:#1E40AF;font-weight:bold;">' + sero + '</span>';
89
+ if (!paren) return seroHtml;
90
+ const inner = paren.slice(1, -1);
91
+ const alleleHtml = inner.split(/\s+/).map(a =>
92
+ a ? '<span style="color:#374151;">' + a + '</span>' : a
93
+ ).join(' ');
94
+ return seroHtml + '(' + alleleHtml + ')';
95
+ }).join(' ');
96
+ });
97
+ });
98
+
99
+ function deleteDsaReport(id, btn) {
100
+ if (!confirm('確定刪除此筆 DSA 報告?')) return;
101
+ fetch('/dsa/delete_report/' + id, { method: 'POST' })
102
+ .then(r => r.json())
103
+ .then(d => {
104
+ if (d.ok) location.reload();
105
+ else alert('刪除失敗: ' + (d.error || ''));
106
+ });
107
+ }
108
+ </script>
109
+ </body>
110
+ </html>