-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_data_for_delta_check.php
303 lines (245 loc) · 9.35 KB
/
get_data_for_delta_check.php
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
<?php
$GLOBALS['Collection_Date']=1015;
$GLOBALS['Collection_Time']=1016;
$GLOBALS['Received_on']=1017;
$GLOBALS['Receipt_time']=1018;
$GLOBALS['remark']=5098;
$GLOBALS['patient_name']=1002;
if(isset($GLOBALS['library'])){goto only_functions;}
//$GLOBALS['nojunk']='';
require_once 'project_common.php';
require_once 'base/verify_login.php';
////////User code below/////////////////////
//echo '<pre>';print_r($_POST);echo '</pre>';
echo ' <link rel="stylesheet" href="project_common.css">
<script src="project_common.js"></script>';
$link=get_link($GLOBALS['main_user'],$GLOBALS['main_pass']);
main_menu($link);
echo '<div id=response></div>';
if(isset($_POST['one_by_one_sample_id']))
{
if(ctype_digit($_POST['one_by_one_sample_id']))
{
$one_by_one_sample_id=$_POST['one_by_one_sample_id'];
}
else
{
$one_by_one_sample_id=0;
}
}
else
{
$one_by_one_sample_id=0;
}
if(isset($_POST['get_data']))
{
if($_POST['get_data']=='one_by_one')
{
$one_by_one_sample_id=$one_by_one_sample_id;
}
if($_POST['get_data']=='one_by_one_plus')
{
$one_by_one_sample_id=$one_by_one_sample_id+1;
}
if($_POST['get_data']=='one_by_one_minus')
{
$one_by_one_sample_id=$one_by_one_sample_id-1;
}
}
echo '<h2>QC</h2>';
echo '<form method=post>
<input type=hidden name=session_name value=\''.$_POST['session_name'].'\'>
<div class="d-inline border border-success rounded p-2" >
<input type=number name=one_by_one_sample_id value=\''.$one_by_one_sample_id.'\' placeholder="for 1-by-1">
<button class="btn btn-info btn-sm" type=submit name=get_data value=one_by_one_plus>+1</button>
<button class="btn btn-info btn-sm" type=submit name=get_data value=one_by_one>OnebyOne</button>
<button class="btn btn-info btn-sm" type=submit name=get_data value=one_by_one_minus>-1</button>
</div>
</form>';
if(isset($_POST['get_data']))
{
if( $_POST['get_data']=='one_by_one' || $_POST['get_data']=='one_by_one_plus' || $_POST['get_data']=='one_by_one_minus')
{
echo '<button class="btn btn-warning btn-sm" onclick="toggle_display(\'compact\')">extra</button><br>';
echo '<div class="d-inline-block border rounded p-2 border-primary">';
show_delta_for_single_sample($link,$one_by_one_sample_id);
echo '</div>';
}
}
//////////////user code ends////////////////
tail();
//////////////data//////
//////////////Functions///////////////////////
only_functions:
function get_lj_display_parameter_sample_id($link,$qc_levels)
{
echo '<form method=post>';
echo '<input type=hidden name=session_name value=\''.$_POST['session_name'].'\'>';
//read_checkbox($qc_levels);
echo '<input type=text name=qc_mrd placeholder="QC MRD" value=\'QC/\'">';
echo '<input type=text name=qc_equipment placeholder="QC Equipment">';
echo '<input type=number name=from_sample_id placeholder="from sample_id">';
echo '<input type=number name=to_sample_id placeholder="to sample_id">';
//echo '<input type=checkbox name=compact>';
//get_examination_names($link);
get_examination_data($link);
echo '<button type=submit class="btn btn-primary" name=show_lj value="show_lj_sample_id">Show LJ</button>';
echo '<button type=submit class="btn btn-primary" name=show_lj formaction=export_lj.php formtarget=blank value="export_lj_sample">Export</button>';
echo '<button type=submit class="btn btn-primary" name=show_lj formaction=chart_lj.php formtarget=blank value="chart_lj_sample">Chart</button>';
//echo '<button type=submit class="btn btn-primary" name=show_lj formaction=export_lj.php formtarget=blank value="export_lj_date">Export</button>';
echo '</form>';
}
function get_lj_display_parameter_date($link)
{
echo '<form method=post>';
echo '<input type=hidden name=session_name value=\''.$_POST['session_name'].'\'>';
echo '<input type=text name=qc_mrd placeholder="QC MRD" value=\'QC/\'">';
echo '<input type=text name=qc_equipment placeholder="QC Equipment">';
echo '<input type=date name=from_date>';
echo '<input type=date name=to_date>';
get_examination_data($link);
echo '<button type=submit class="btn btn-primary" name=show_lj value="show_lj_date">Show LJ</button>';
echo '<button type=submit class="btn btn-primary" name=show_lj formaction=export_lj.php formtarget=blank value="export_lj_date">Export</button>';
echo '<button type=submit class="btn btn-primary" name=show_lj formaction=chart_lj.php formtarget=blank value="chart_lj_date">Chart</button>';
echo '</form>';
}
function get_lj_display_parameter_today($link)
{
echo '<form method=post>';
echo '<input type=hidden name=session_name value=\''.$_POST['session_name'].'\'>';
echo '<button type=submit class="btn btn-primary" name=show_lj value="show_lj_today">Show Today\'s LJ</button>';
echo '</form>';
}
function read_checkbox($ar)
{
foreach ($ar as $v)
{
echo '<input type="checkbox" id=\'chk_'.$v.'\' name=\'chk_'.$v.'\'>
<label for=\'chk_'.$v.'\'>'.$v.'</label>';
}
}
function show_lj_for_sample($link,$sample_id_array,$ex_requested=array())
{
echo '<table class="table table-sm" id=qc_table>';
echo '<tr>
<td>MRD</td>
<td>Name</td>
<td><button type=button class="btn btn-sm btn-info" onclick="my_sort(this,2,\'qc_table\')" data-sorting=1>Sample_ID</button></td>
<td><button type=button class="btn btn-sm btn-info" onclick="my_sort(this,3,\'qc_table\')" data-sorting=1>Examination</button></td>
<td>Result</td>
<!-- <td><button type=button class="btn btn-sm btn-info" onclick="my_sort(this,5,\'qc_table\')" data-sorting=1>Analysis Time</button></td>-->
<td class="compact collapse">Receipt Date</td>
<td class="compact collapse">Receipt Time</td>
<td class="compact collapse">Sample Type</td>
';
echo '</tr>';
foreach($sample_id_array as $sample_id)
{
display_one_qc($link,$sample_id,$ex_requested);
}
echo '</table>';
}
function show_delta_for_single_sample($link,$sample_id,$ex_requested=array())
{
//Never use $mrd, it is a global
$this_mrd=get_one_ex_result($link,$sample_id,$GLOBALS['mrd']);
$sql='select sample_id from result
where
examination_id=\''.$GLOBALS['mrd'].'\'
and
result=\''.$this_mrd.'\'';
$result=run_query($link,$GLOBALS['database'],$sql);
$sample_id_array=array();
while($ar=get_single_row($result))
{
$sample_id_array[]=$ar['sample_id'];
}
//echo '<pre>';print_r($sample_id_array);echo '</pre>';
show_lj_for_sample($link,$sample_id_array);
}
function show_lj($link,$parameters)
{
$sample_id_array=get_qc_sample_id_from_parameters($link,$parameters);
//echo '<pre>';print_r($sample_id_array);echo '</pre>';
$ex_requested=explode(',',$parameters['list_of_selected_examination']);
show_lj_for_sample($link,$sample_id_array,$ex_requested);
}
function show_lj_today($link)
{
$sample_id_array=get_today_sample_id($link);
//echo '<pre>';print_r($sample_id_array);echo '</pre>';
show_lj_for_sample($link,$sample_id_array);
}
function show_lj_date_range($link,$from_date,$to_date,$parameters)
{
$sample_id_array=get_date_range_sample_id($link,$from_date,$to_date,$parameters);
//echo '<pre>';print_r($sample_id_array);echo '</pre>';
$ex_requested=explode(',',$parameters['list_of_selected_examination']);
show_lj_for_sample($link,$sample_id_array,$ex_requested);
}
function display_one_qc($link,$sample_id,$ex_requested)
{
$mrd_num=get_one_ex_result($link,$sample_id,$GLOBALS['mrd']);
$sample_requirement=get_one_ex_result($link,$sample_id,$GLOBALS['sample_requirement']);
$date=get_one_ex_result($link,$sample_id,$GLOBALS['Received_on']);
$time=get_one_ex_result($link,$sample_id,$GLOBALS['Receipt_time']);
$patient_name_local=get_one_ex_result($link,$sample_id,$GLOBALS['patient_name']);
//never give $name, it is global
//$sql='select * from primary_result where sample_id=\''.$sample_id.'\' order by uniq';
$sql='select * from result where sample_id=\''.$sample_id.'\'';
$result=run_query($link,$GLOBALS['database'],$sql);
$current_ex_id=0;
while($ar=get_single_row($result))
{
//echo '<pre>';print_r($ar);
$ex_requested=array_filter($ex_requested);
if(in_array($ar['examination_id'],$ex_requested) || count($ex_requested)==0)
{
if($sample_id%2==0){$sample_class='text-danger';}
else{$sample_class='text-info';}
if($current_ex_id==$ar['examination_id'])
{
$border='border border-top-0 border-bottom-0';
}
else
{
$border='border border-top-0 border-bottom-0';
$current_ex_id=$ar['examination_id'];
}
$tr_class_list=array(
'text-primary',
'text-secondary',
'text-success',
'text-info',
'text-danger',
'text-info',
'text-primary',
'text-secondary',
'text-muted',
'text-success'
);
$tr_class=$tr_class_list[$ar['examination_id']%10].' '.$border;
//compact allow toggle of display from .js file, collapse allow hide on loading
echo '<tr class=\''.$tr_class.'\'>';
echo '<td>'.$mrd_num.'</td>';
echo '<td>'.$patient_name_local.'</td>';
echo '<td class=\''.$sample_class.'\'>'.$sample_id.'</td>';
echo '<td>'.$ar['examination_id'].'-'.get_name_of_ex_id($link,$ar['examination_id']).'</td>';
echo '<td>'.$ar['result'].'</td>';
//echo '<td>'.$ar['uniq'].'</td>';
//echo '<td></td>';
if(strftime("%Y-%m-%d")==$date)
{
echo '<td class="border border-dark compact collapse">'.$date.'</td>';
}
else
{
echo '<td class="compact collapse" >'.$date.'</td>';
}
echo '<td class="compact collapse">'.$time.'</td>';
echo '<td class="compact collapse" >'.$sample_requirement.'</td>';
echo '</tr>';
}
}
}
?>