-
Notifications
You must be signed in to change notification settings - Fork 9
/
dictate_show_preview_report_pdf.php
232 lines (207 loc) · 5.93 KB
/
dictate_show_preview_report_pdf.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
<?php
############################################
# ThaiRIS (Thai Radiology Information System)
# Version: 1.0
# File last modified: 8 Nov 2016
# File name:
# Description :
# http://www.thairis.net
# Email : [email protected]
############################################
while (ob_get_level())
ob_end_clean();
header("Content-Encoding: None", true);
include ("./pdf/fpdf.php");
include ("connectdb.php");
$ACCESSION = $_GET[ACCESSION];
$sql = "SELECT * FROM xray_request_detail
LEFT JOIN xray_request ON xray_request.REQUEST_NO = xray_request_detail.REQUEST_NO
LEFT JOIN xray_patient_info ON xray_patient_info.MRN = xray_request.MRN
WHERE xray_request_detail.ACCESSION ='$ACCESSION'";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)){
$acc = ": ".$row[ACCESSION];
$ptname = ": ".$row[NAME];
$ptlastname = ": ".$row[LASTNAME];
$report = $row[TEMP_REPORT];
$MRN= ": ".$row[MRN];
$procedure = ": ".$row[DESCRIPTION];
}
$report= preg_replace('#<div\s*/?>#i', '', $report); // Replace <br > with new line \n
$report= preg_replace('#</div\s*/?>#i', '<br />', $report); // Replace <br > with new line \n
$report = str_replace(" ", " ", $report);
$report = str_replace("&", "&", $report);
$report = str_replace("<", "<", $report);
$report = str_replace(">", ">", $report);
$report = str_replace(""", "\"", $report);
$report = str_replace("</p>", "<br />", $report);
class PDF extends FPDF
{
var $B;
var $I;
var $U;
var $HREF;
//Page header
function Header()
{
//Logo
$this->Image('image/banner-report.jpg',30,5,150);
//Arial bold 15
$this->SetFont('Arial','B',15);
//Move to the right
$this->Cell(80);
//Title
//$this->Cell(30,10,'RIS DEMO',1,0,'C');
//Line break
$this->Ln(10);
// $this->Ln(5);
}
//Page footer
function Footer()
{
//Position at 1.5 cm from bottom
$this->SetY(-15);
//Arial italic 8
$this->SetFont('Arial','I',8);
//Page number
$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}
function PDF($orientation='P',$unit='mm',$format='A4')
//function PDF($orientation='L',$unit='mm',$format='A5')
{
//Call parent constructor
$this->FPDF($orientation,$unit,$format);
//Initialization
$this->B=0;
$this->I=0;
$this->U=0;
$this->HREF='';
}
function WriteHTML($html)
{
//HTML parser
$html=str_replace("\n",' ',$html);
$a=preg_split('/<(.*)>/U',$html,-1,PREG_SPLIT_DELIM_CAPTURE);
foreach($a as $i=>$e)
{
if($i%2==0)
{
//Text
if($this->HREF)
$this->PutLink($this->HREF,$e);
else
$this->Write(5,$e);
}
else
{
//Tag
if($e[0]=='/')
$this->CloseTag(strtoupper(substr($e,1)));
else
{
//Extract attributes
$a2=explode(' ',$e);
$tag=strtoupper(array_shift($a2));
$attr=array();
foreach($a2 as $v)
{
if(preg_match('/([^=]*)=["\']?([^"\']*)/',$v,$a3))
$attr[strtoupper($a3[1])]=$a3[2];
}
$this->OpenTag($tag,$attr);
}
}
}
}
function OpenTag($tag,$attr)
{
//Opening tag
if($tag=='B' || $tag=='I' || $tag=='U')
$this->SetStyle($tag,true);
if($tag=='A')
$this->HREF=$attr['HREF'];
if($tag=='BR')
$this->Ln(5);
}
function CloseTag($tag)
{
//Closing tag
if($tag=='B' || $tag=='I' || $tag=='U')
$this->SetStyle($tag,false);
if($tag=='A')
$this->HREF='';
}
function SetStyle($tag,$enable)
{
//Modify style and select corresponding font
$this->$tag+=($enable ? 1 : -1);
$style='';
foreach(array('B','I','U') as $s)
{
if($this->$s>0)
$style.=$s;
}
$this->SetFont('',$style);
}
function PutLink($URL,$txt)
{
//Put a hyperlink
$this->SetTextColor(0,0,255);
$this->SetStyle('U',true);
$this->Write(5,$txt,$URL);
$this->SetStyle('U',false);
$this->SetTextColor(0);
}
function conv($string) {
return iconv('UTF-8', 'TIS-620', $string);
}
}
//Instanciation of inherited class
$pdf=new PDF();
$pdf->AddFont('AngsanaNew','','angsa.php');
$pdf->AddFont('AngsanaNew','B','angsab.php');
$pdf->AddFont('AngsanaNew','I','angsai.php');
$pdf->AddFont('AngsanaNew','BI','angsai.php');
$pdf->AddPage();
$pdf->SetFont('AngsanaNew','B',16);
$pdf->SetLeftMargin(20);
$pdf->AliasNbPages();
//$pdf->AddPage();
//$pdf->SetFont('Arial','',12);
$pdf->Ln(5);
$pdf->Cell(15,6,'Name',0,0,'L');
$pdf->Cell(65,6,iconv('UTF-8','TIS-620',$ptname),0,0,'L');
$pdf->Cell(20,6,'Report Time ',0,0,'L');
$pdf->Cell(50,6,iconv('UTF-8','TIS-620',$reporttime),0,0,'L');
$pdf->Ln(5);
$pdf->Cell(15,6,'Age ',0,0,'L');
$pdf->Cell(65,6,iconv('UTF-8','TIS-620',$dob),0,0,'L');
$pdf->Cell(20,6,'Exam Time ',0,0,'L');
$pdf->Cell(50,6,iconv('UTF-8','TIS-620',$requesttime),0,0,'L');
$pdf->Ln(5);
$pdf->Cell(15,6,'HN ',0,0,'L');
$pdf->Cell(65,6,$MRN,0,0,'L');
$pdf->Cell(20,6,'Order ',0,0,'L');
$pdf->Cell(50,6,$procedure,0,0,'L');
$pdf->Ln(5);
$pdf->Cell(15,6,'ACC ',0,0,'L');
$pdf->Cell(65,6,iconv('UTF-8','TIS-620',$acc),0,0,'L');
$pdf->Cell(20,6,'Department ',0,0,'L');
$pdf->Cell(50,6,iconv('UTF-8','TIS-620',$department),0,0,'L');
$pdf->Ln(5);
$pdf->SetDrawColor(0, 0, 0);
$pdf->SetLineWidth(0.2);
$pdf->Line(20, 48, 196, 48);
$pdf->SetFont('AngsanaNew','',16);
$pdf->Ln(5);
$pdf->WriteHTML($report);
$pdf->Ln(5);
$txt ="Preview Report";
$txt = $pdf->conv($txt);
//$pdf->Cell(0, 0, $txt, 0, 1, 'C');
$pdf->Ln(5);
//$pdf->Write(5,$txt);
$pdf->Ln(3); //New Line
//$pdf->Write(5,'....................................................Preview Report Not Approve Yet.!...............................................................');
$pdf->Output();
?>