-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathchart.html
More file actions
207 lines (195 loc) · 7.92 KB
/
chart.html
File metadata and controls
207 lines (195 loc) · 7.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<!DOCTYPE html>
<html>
<title>Patient Chart</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="chart.css">
<script src="jquery-1.5.1.min.js"></script>
<script src="freezeheader.js"></script>
<script src="chart.js"></script>
<!-- Use double-quotes for HTML attributes; single-quotes for JS/Pebble strings. -->
<body>
<table id="tiles" cellspacing="0" cellpadding="0">
{% for tileRow in tileRows %}
<tr>
{% for tile in tileRow %}
{% set id = tile.item.conceptIds | first %}
{% set values = tile.points | values %}
{% set class = values | format_values(tile.item.cssClass) %}
{% set style = values | format_values(tile.item.cssStyle) %}
<td
id="tile-{{id}}"
class="tile concept-{{id}} {{class}}"
{% if tile.item.conceptUuids.size == 1 %}
onclick="od('{{tile.item.conceptUuids[0] }}','','');"
{% endif %}
style="{{style}}"
width="{{100.0 / tileRow.size}}%" >
<div class="heading">{{tile.item.label}}</div>
<div class="value">{{values | format_values(tile.item.format) | line_break_html | raw}}</div>
<div class="caption">{{values | format_values(tile.item.captionFormat) | line_break_html | raw}}</div>
</td>
{% endfor %}
</tr>
{% endfor %}
</table>
<div id="grid-scroller" style="width: 100%; overflow: scroll">
<table id="grid" cellspacing="0" cellpadding="0">
<thead>
<tr>
<th> </th>
{% set prevColumn = null %}
{% for column in columns %}
{% if prevColumn is not null and column.start != prevColumn.stop %}
<th class="gap" scope="col"> </th>
{% endif %}
<th class="{{column.start == nowColumnStart ? 'now' : ''}}" scope="col" onclick="od('','{{column.start.millis}}','{{column.stop.millis}}');">
{{column.headingHtml | raw}}
</th>
{% set prevColumn = column %}
{% endfor %}
</tr>
</thead>
<tbody>
<tr>
<th scope="rowgroup">
{{ string_resource("observations") }}
</th>
{% for column in columns %}
{% if prevColumn is not null and column.start != prevColumn.stop %}
<th scope="rowgroup" class="gap" rowspan={{rows.size + 1}}> </th>
{% endif %}
<th scope="rowgroup"></th>
{% set prevColumn = column %}
{% endfor %}
</tr>
{% for row in rows %}
{% set id = row.item.conceptIds | first %}
<tr class="obs concept-{{id}} {{ row.item.label | tosafechars }}">
<th scope="row" onclick="od('{{row.item.conceptUuids[0]}}','','');">
{{row.item.label}}
</th>
{% for column in columns %}
{% set points = get_all_points(row=row, column=column) %}
{% if points is empty %}
{% set summaryValue = null %}
{% elseif row.item.type == 'yes_no' %}
{% set summaryValue = points | values | max %}
{% else %}
{% set summaryValue = (points | last).value %}
{% endif %}
{% set class = summaryValue | format_values(row.item.cssClass) %}
{% set style = summaryValue | format_values(row.item.cssStyle) %}
<td id="cell-{{id}}-{{column.start.millis}}"
data-start="{{column.start.millis}}"
data-stop="{{column.stop.millis}}"
class="{{column.start == nowColumnStart ? 'now' : ''}} {{class}}"
style="{{style}}"
onclick="{% if points is not empty%}
{% if (row.item.type).string != 'text_icon' %}
od('{{row.item.conceptUuids[0]}}','{{column.start.millis}}','{{column.stop.millis}}');
{% endif %}
{% endif %}">
{% if points is not empty %}
{% if row.item.type == 'text_icon' %}
<div>📝</div>
{% else %}
{% set output = summaryValue | format_value(row.item.format) %}
{% if output is empty %}
{% set output = summaryValue | format_value(row.item.captionFormat) %}
{% endif %}
{{output}}
{% endif %}
{% endif %}
</td>
{% endfor %}
<script>
// Hides the row if not required and no observation is recorded.
if (!{{row.item.required}}) {
if (isRowEmpty(document.currentScript.parentNode)) {
document.currentScript.parentNode.style.display = 'none';
}
}
</script>
</tr>
{% endfor %}
</tbody>
<tbody>
<tr>
<th scope="rowgroup">
{{ string_resource("treatment_plan_title") }}
</th>
{% for column in columns %}
{% if prevColumn is not null and column.start != prevColumn.stop %}
<th scope="rowgroup" class="gap" rowspan={{orders.size + 1}}> </th>
{% endif %}
<th scope="rowgroup"></th>
{% set prevColumn = column %}
{% endfor %}
</tr>
{% for order in orders %}
<tr class="order">
<th scope="row" onclick="controller.onOrderHeadingPressed('{{order.uuid}}')">
<div class="medication">{{order.medication}}</div>
<!-- TODO: make string_resource take format strings and args so we don't need to manually concatenate like this. -->
<div>{{order.dosage}} {{order.frequency != null ? order.frequency + string_resource("times_daily") : ''}}</div>
</th>
{% set previousActive = false %}
{% set future = false %}
{% for column in columns %}
<td class="{{column.start == nowColumnStart ? 'now' : ''}}">
{% set active = intervals_overlap(order.interval, column.interval) %}
{% if order.stop == null and previousActive %}
<div class="future"> </div>
{% elseif order.stop != null and previousActive and not active %}
<div class="stop">Stop</div>
{% elseif active %}
{% if future %}
<div class="future active">●</div>
{% else %}
{% set count = get_order_execution_count(order_uuid=order.uuid, column=column) %}
<div class="past active"
onclick="controller.onOrderCellPressed('{{order.uuid}}', {{column.start.getMillis}})"
>{{count}}</div>
{% endif %}
{% endif %}
{% set previousActive = active %}
{% set future = future or column.start == nowColumnStart %}
</td>
{% endfor %}
</tr>
{% endfor %}
<tr>
<th scope="row" class="command" onclick="controller.onNewOrderPressed()">
{{ string_resource("treatment_add_new") }}
</th>
</tr>
</tbody>
</table>
</div>
<script>
var data = {{dataCellsByConceptId | raw}};
{% for tileRow in tileRows %}
{% for tile in tileRow %}
{% if tile.item.script is not empty %}
runTileScript(data, {{tile.item.conceptIds | join(',') | js | raw}}, {{tile.item.script | js | raw}});
{% endif %}
{% endfor %}
{% endfor %}
{% for row in rows %}
{% if row.item.script is not empty %}
runChartRowScript(data, {{row.item.conceptIds | join(',') | js | raw}}, {{row.item.script | js | raw}});
{% endif %}
{% endfor %}
$(document).ready(function() {
$('#grid').freezeHeader({top: true, left: true});
});
$( window ).unload(function() {
controller.onPageUnload($('#grid-scroller').scrollLeft(), $(window).scrollTop());
});
function od(concept_uuid, startmillis, stopmillis){
controller.onObsDialog(concept_uuid, startmillis, stopmillis);
}
</script>
</body>
</html>