-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrequest_report.php
145 lines (118 loc) · 3.1 KB
/
request_report.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
<?php
session_start();
echo '<html>';
echo '<head>';
echo '</head>';
echo '<body>';
/*
echo '<pre>';
print_r($GLOBALS);
echo '</pre>';
*/
include 'common.php';
function read_from_to()
{
echo '<table border=1>
<form target=_blank method=post>';
echo '<tr>';
echo '<td>from</td>';
echo '<td><input type=text name=from ></td>';
echo '<td><input type=text name=to ></td>';
echo '</tr>';
echo '<tr><td colspan=4 align=center><button type=submit name=action>Request Report</button></td></tr>';
echo '</form></table>';
}
function get_all_ex($sample_id)
{
$link=start_nchsls();
$sql='select code,note from examination where sample_id=\''.$sample_id.'\'';
$result=mysql_query($sql,$link);
$ex_str='';
$note_str='';
while($ex=mysql_fetch_assoc($result))
{
$ex_str=$ex_str.','.$ex['code'];
$note_str=$note_str.$ex['note'];
}
return array($ex_str,$note_str);
}
function prepare_report($from,$to)
{
$link=start_nchsls();
$sql='select * from sample
where
request_id between \''.$from.'\' and \''.$to.'\'
and
sample_id between 1 and 999999
order by
section,request_id,sample_id';
$result=mysql_query($sql,$link);
$section='';
$prev_section='';
$start='yes';
while($sample_array=mysql_fetch_assoc($result))
{
$section=$sample_array['section'];
if($section!=$prev_section && $start=='no')
{
echo '</table>';
echo '<h2 style="page-break-before: always;"></h2>';
echo '<table border=1 style="border-collapse:collapse;">';
echo '<th colspan=10>'.$section.'</th>';
echo '<tr> <th>section</th>
<th>request_id</th>
<th>sample_id</th>
<th>name</th>
<th>mrd</th>
<th>d/u/l</th>
<th>examinations</th>
<th>extra</th>
</tr>';
}
if($start=='yes')
{
$start='no';
echo '<h2 style="page-break-before: always;"></h2>';
echo '<table border=1 style="border-collapse:collapse;">';
echo '<th colspan=10>'.$section.'</th>';
echo '<tr> <th>section</th>
<th>request_id</th>
<th>sample_id</th>
<th>name</th>
<th>mrd</th>
<th>d/u/l</th>
<th>examinations</th>
<th>extra</th>
</tr>'; }
$all_ex=get_all_ex($sample_array['sample_id']);
echo '<tr>
<td>'.$sample_array['section'].'</td>
<td>'.$sample_array['request_id'].'</td>
<td>'.$sample_array['sample_id'].'</td>
<td>'.$sample_array['patient_name'].'</td>
<td>'.$sample_array['patient_id'].'</td>
<td>'.$sample_array['clinician'].'/'.$sample_array['unit'].'/'.$sample_array['location'].'</td>
<td>'.$all_ex[0].'</td>
<td><pre>'.$sample_array['extra'].'</pre>
<td><pre>'.$all_ex[1].'</pre>
</td>
</tr>';
$prev_section=$section;
}
echo '</table>';
}
if(!login_varify())
{
exit();
}
if(!isset($_POST['from']) || !isset($_POST['to']))
{
main_menu();
read_from_to();
}
else
{
//echo 'preparing to print requests from '.$_POST['from'].' to '.$_POST['to'];
prepare_report($_POST['from'],$_POST['to']);
}
?>