PageRenderTime 76ms CodeModel.GetById 37ms RepoModel.GetById 0ms app.codeStats 0ms

/include/imgcreator/gd_test_request_baclabor.php

https://github.com/timschofield/2.8
PHP | 982 lines | 707 code | 204 blank | 71 comment | 81 complexity | d5673824f423a0490c99d191c7e60b2e MD5 | raw file
Possible License(s): LGPL-2.1, BSD-3-Clause, GPL-2.0
  1. <?php
  2. /*------begin------ This protection code was suggested by Luki R. luki@karet.org ---- */
  3. if (stristr($PHP_SELF, 'inc_test_request_gd_baclabor.php')) die("<meta http-equiv='refresh' content='0; url=../'>");
  4. /*------end------*/
  5. /**
  6. * CARE2X Integrated Hospital Information System
  7. * GNU General Public License
  8. * Copyright 2002 Elpidio Latorilla
  9. * elpidio@care2x.org,
  10. *
  11. * See the file "copy_notice.txt" for the licence notice
  12. */
  13. /**
  14. * This script works only with the barcode_label_single_large.php
  15. */
  16. /* Load the variables elements */
  17. require_once(CARE_BASE .'modules/laboratory/includes/inc_test_request_vars_baclabor.php');
  18. /* Load additional language table */
  19. if(file_exists(CARE_BASE .'language/'.$lang.'/lang_'.$lang.'_konsil_'.$subtarget.'.php')) include_once(CARE_BASE .'language/'.$lang.'/lang_'.$lang.'_konsil_'.$subtarget.'.php');
  20. else include_once(CARE_BASE .'language/'.LANG_DEFAULT.'/lang_'.LANG_DEFAULT.'_konsil_'.$subtarget.'.php');
  21. function doBlock()
  22. {
  23. global $sx, $sy, $im, $pink, $black, $top_border, $mark_v_offset,$ewhite;
  24. $width=10;
  25. $height=5;
  26. $ex=$sx+$width;
  27. $ey=$sy+$height+$mark_v_offset;
  28. ImageRectangle($im,$sx,($sy+$mark_v_offset),$ex,($ey),$pink);
  29. ImageFilledRectangle($im,($sx+1),(($sy+$mark_v_offset)+1),($ex-1),($ey-1),$ewhite);
  30. }
  31. function doFilledBlock()
  32. {
  33. global $sx, $sy, $im, $pink, $black, $mark_v_offset;
  34. $width=10;
  35. $height=5;
  36. $ex=$sx+$width;
  37. $ey=$sy+$height+$mark_v_offset;
  38. ImageRectangle($im,$sx,($sy+$mark_v_offset),$ex,($ey),$pink);
  39. ImageFilledRectangle($im,($sx+1),(($sy+$mark_v_offset)+1),($ex-1),($ey-1),$black);
  40. }
  41. function doSyncBlocks()
  42. {
  43. global $w, $h, $hdiv, $vdiv, $im, $black, $top_border;
  44. $width=14;
  45. $height=7;
  46. $x1=$w-($width+1);
  47. $x2=$w-1;
  48. for($i=0,$y1=$top_border; $i<67; $i++, $y1=$y1+$vdiv)
  49. {
  50. ImageFilledRectangle($im,$x1,$y1,$x2,($y1+$height),$black);
  51. }
  52. }
  53. function doTitel($titel,$len=6)
  54. {
  55. global $sx, $sy, $hdiv, $vdiv, $im, $pink, $black, $left_border, $top_border, $mark_v_offset,$ewhite, $dark_pink;
  56. ImageFilledRectangle($im,($sx-$left_border),($sy-3),($sx+($hdiv*$len)-8),($sy+10),$dark_pink);
  57. ImageString($im,2,($sx),($sy-3),$titel,$ewhite);
  58. }
  59. function doWrite($item)
  60. {
  61. global $sx, $sy, $im, $dark_pink;
  62. ImageString($im,1,($sx+14),($sy),$item,$dark_pink);
  63. }
  64. function doWriteLeft($item)
  65. {
  66. global $sx, $sy, $im, $dark_pink;
  67. ImageString($im,1,($sx-16),($sy),$item,$dark_pink);
  68. }
  69. function doWriteTop($item)
  70. {
  71. global $sx, $sy, $im, $dark_pink;
  72. ImageString($im,1,($sx),($sy-7),$item,$dark_pink);
  73. }
  74. function doBgColor($len=6)
  75. {
  76. global $sx, $sy, $hdiv, $im, $pink, $left_border, $bgcolor;
  77. ImageFilledRectangle($im,($sx-$left_border),($sy-2),($sx+($hdiv*$len)-8),($sy+10),$bgcolor);
  78. ImageLine($im,($sx-$left_border),($sy+10),($sx+($hdiv*$len)-8),($sy+10),$pink);
  79. }
  80. function showphone()
  81. {
  82. global $sx, $sy, $hdiv, $vdiv, $im, $v_phone;
  83. if($v_phone) ImageCopy($im,$v_phone,($sx-5),($sy-1),0,0,14,10);
  84. }
  85. /**
  86. * Initializations
  87. * Create the image $im and allocate colors
  88. */
  89. $left_border=4; /* The left border for drawing of blocks */
  90. $top_border=24; /* The top border for drawing of blocks */
  91. $mark_v_offset=1; /* Vertical offset of the marking blocks */
  92. /* Load the batch nr barcode */
  93. if(file_exists('../cache/barcodes/form_'.$batch_nr.'.png'))
  94. {
  95. $fbc = ImageCreateFrompng('../cache/barcodes/form_'.$batch_nr.'.png');
  96. }
  97. /* Set dimensions of the form */
  98. $w=745;
  99. $h=1080;
  100. $im=@ ImageCreate($w,$h);
  101. /* Allocate colors used for the form */
  102. $white = ImageColorAllocate ($im, 255,255,255); //white bkgrnd
  103. $blue=ImageColorAllocate($im, 0, 127, 255);
  104. $purple=ImageColorAllocate($im, 186, 124, 237);
  105. $light_violet=ImageColorAllocate($im, 243, 241, 254);
  106. $black = ImageColorAllocate ($im, 000, 0000, 000);
  107. $pink=ImageColorAllocate ($im, 255, 206, 206);
  108. $light_pink=ImageColorAllocate ($im, 255, 243, 243);
  109. $dark_pink=ImageColorAllocate ($im, 238, 102, 102);
  110. /*calculate the divisions */
  111. $hdiv=(int)$w/41;
  112. $vdiv=(int)$h/69;
  113. /* fill the form with color */
  114. ImageFillToBorder($im,2,2,$blue, $light_pink);
  115. /* Top horizontal title bar */
  116. ImageFilledRectangle($im,$left_border,1,($w-($hdiv*2)),($top_border-4),$pink);
  117. /* Write the info part */
  118. ImageString($im,5,$hdiv,3,($LDHospitalName.' '.$LDCentralLab),$dark_pink);
  119. /* second top horizontal bar */
  120. ImageFilledRectangle($im,$left_border,($top_border-3),($left_border+($hdiv*26)),($top_border+8),$dark_pink);
  121. ImageString($im,2,($left_border+4),($top_border-4),strtoupper($LDMaterial),$white);
  122. ImageString($im,2,($left_border+($hdiv*5)),($top_border-4),strtoupper($LDRequestedTest),$white);
  123. $lab_x1=(int)($w-($label_w))/2;
  124. $lab_y1=(int)($label_h+1);
  125. /* Create the background rectangle for the label */
  126. ImageFilledRectangle($im,($lab_x1-7-$hdiv),($top_border-3),($lab_x1+$label_w+14-$hdiv),($lab_y1+14+$top_border),$dark_pink);
  127. /* Copy the patient label into the form */
  128. ImageCopy($im,$label,($lab_x1+4-$hdiv),($top_border+8),0,0,$label_w,$label_h);
  129. /* Create the synchronizing blocks on the right edge of the form */
  130. doSyncBlocks();
  131. /* Create initialization markers */
  132. $sy=$top_border+$vdiv;
  133. $sx=$left_border+($hdiv*29);
  134. doBlock();
  135. $sx=$left_border+($hdiv*32);
  136. doFilledBlock();
  137. $sx=$left_border+($hdiv*33);
  138. doFilledBlock();
  139. $sx=$left_border+($hdiv*38);
  140. doFilledBlock();
  141. $sx=$left_border+($hdiv*39);
  142. doFilledBlock();
  143. /* Create the case number markers */
  144. $sy=$top_border+$vdiv;
  145. for($n=0;$n<8;$n++)
  146. {
  147. $sy+=$vdiv;
  148. for($i=0,$sx=($left_border+($hdiv*29));$i<10;$i++,$sx=$sx+$hdiv)
  149. {
  150. ImageString($im,1,($sx+3),($sy-6),$i,$dark_pink);
  151. if(substr($fen,$n,1)==$i) doFilledBlock();
  152. else doBlock();
  153. }
  154. }
  155. /* Place the form batch nr barcode */
  156. $sx=$left_border+($hdiv*32);
  157. $sy=$top_border+($vdiv*10)-6;
  158. /* Copy the batch nr barcode into the form */
  159. if($fbc) ImageCopy($im,$fbc,$sx,$sy,6,7,139,28);
  160. /* Create the material elements */
  161. $sy=($top_border+($vdiv*2));
  162. while(list($x,$v)=each($LDBacLabMaterialType))
  163. {
  164. $sx=$left_border;
  165. if($stored_material[$x])
  166. {
  167. doFilledBlock();
  168. }
  169. else
  170. {
  171. doBlock();
  172. }
  173. doWriteTop($v);
  174. $sx+=($hdiv*2);
  175. list($x,$v)=each($LDBacLabMaterialType);
  176. if($stored_material[$x])
  177. {
  178. doFilledBlock();
  179. }
  180. else
  181. {
  182. doBlock();
  183. }
  184. doWriteTop($v);
  185. $sy+=$vdiv;
  186. }
  187. /* Create the test type elements */
  188. $sy=($top_border+($vdiv*2));
  189. while(list($x,$v)=each($LDBacLabTestType))
  190. {
  191. $sx=$left_border+($hdiv*5);
  192. if($stored_test_type[$x])
  193. {
  194. doFilledBlock();
  195. }
  196. else
  197. {
  198. doBlock();
  199. }
  200. doWriteTop($v);
  201. $sx+=($hdiv*3);
  202. list($x,$v)=each($LDBacLabTestType);
  203. if($stored_test_type[$x])
  204. {
  205. doFilledBlock();
  206. }
  207. else
  208. {
  209. doBlock();
  210. }
  211. doWriteTop($v);
  212. $sy+=$vdiv;
  213. }
  214. /* Create the date code*/
  215. $day_tens=0;
  216. $day_ones=0;
  217. if($edit_form || $read_form )
  218. {
  219. /* Process the sampling date, isolate the elements from the DATE format */
  220. list($yearval,$monval,$dayval) = explode("-",$stored_request['sample_date']);
  221. }
  222. else
  223. {
  224. /* If fresh form, assume today */
  225. $yearval=(int)date('Y');
  226. $dayval=(int)date('d');
  227. $monval=(int)date('m');
  228. }
  229. /* Process the day of the week, separate the 10's from ones */
  230. if($dayval>29)
  231. {
  232. $day_tens=30;
  233. $day_ones=$dayval-$day_tens;
  234. }
  235. elseif($dayval>19)
  236. {
  237. $day_tens=20;
  238. $day_ones=$dayval-$day_tens;
  239. }
  240. elseif($dayval>10)
  241. {
  242. $day_tens=10;
  243. $day_ones=$dayval-$day_tens;
  244. }
  245. else
  246. {
  247. $day_ones=$dayval;
  248. }
  249. /* Set the row and column */
  250. $sx=$left_border+($hdiv*28);
  251. $sy=$top_border+($vdiv*12);
  252. //echo $day_ones." ".$day_tens;
  253. for($i=1;$i<10;$i++)
  254. {
  255. if($day_ones==$i) doFilledBlock();
  256. else doBlock();
  257. doWriteTop($i);
  258. $sx+=$hdiv;
  259. }
  260. /* For the 10's */
  261. if($day_tens==10) echo doFilledBlock();
  262. else doBlock();
  263. doWriteTop(10);
  264. $sx+=$hdiv; /* advance to the right */
  265. /* For the 20's */
  266. if($day_tens==20) echo doFilledBlock();
  267. else doBlock();
  268. doWriteTop(20);
  269. $sx+=$hdiv; /* advance to the right */
  270. /* For the 30's */
  271. if($day_tens==30) echo doFilledBlock();
  272. else doBlock();
  273. doWriteTop(30);
  274. $sx+=$hdiv; /* advance to the right */
  275. $sx=$left_border+($hdiv*28);
  276. $sy+=$vdiv; /* Move down one column */
  277. /* Create the month code */
  278. for($i=1;$i<13;$i++)
  279. {
  280. if($monval==$i) echo doFilledBlock();
  281. else doBlock();
  282. doWriteTop($LDShortMonth[$i]);
  283. $sx+=$hdiv; /* advance to the right */
  284. }
  285. /* Create the batch nr code */
  286. $sy=$top_border+($vdiv*14);
  287. $sx=$left_border;
  288. for($i=0,$sx=($left_border+($hdiv*10));$i<30; $i++, $sx=$sx+$hdiv)
  289. {
  290. doBlock();
  291. }
  292. $sy+=$vdiv;
  293. /* horizontal bar under the label */
  294. ImageFilledRectangle($im,$left_border,($sy-3),($left_border+($hdiv*40)-4),($sy+8),$dark_pink);
  295. ImageString($im,1,($left_border+($hdiv*10)),($sy-2),$LDBatchNumber,$white);
  296. ImageString($im,2,($left_border+($hdiv*14)),($sy-4),$stored_request['batch_nr'],$black);
  297. ImageString($im,1,($left_border+($hdiv*18)),($sy-2),$LDInitFindings,$white);
  298. ImageString($im,1,($left_border+($hdiv*24)),($sy-2),$LDCurrentFindings,$white);
  299. ImageString($im,1,($left_border+($hdiv*30)),($sy-2),$LDFinalFindings,$white);
  300. ImageString($im,1,($left_border+($hdiv*33)),($sy-2),$LDResistanceTestAnaerob,$white);
  301. /* Create the findings status code*/
  302. $sy+=$vdiv;
  303. $sx=$left_border+($hdiv*19);
  304. if($stored_findings['findings_init']) echo doFilledBlock();
  305. else doBlock();
  306. $sx+=($hdiv*6); /* advance to the right */
  307. if($stored_findings['findings_current']) echo doFilledBlock();
  308. else doBlock();
  309. $sx+=($hdiv*6); /* advance to the right */
  310. if($stored_findings['findings_final']) echo doFilledBlock();
  311. else doBlock();
  312. /* Convert any possible html special chars to normal chars and print the text */
  313. $translation_table= array_flip(get_html_translation_table(HTML_SPECIALCHARS));
  314. /* Write some text */
  315. ImageString($im,5,($left_border),($sy),$LDMaterial.':',$dark_pink);
  316. $sx=$left_border+($hdiv*5);
  317. ImageString($im,2,$sx,($sy),strtr($stored_request['material_note'],$translation_table),$purple); // Material
  318. $sy+=$vdiv;
  319. ImageString($im,5,($left_border),($sy),$LDDiagnosis,$dark_pink);
  320. $sx=$left_border+($hdiv*5);
  321. ImageString($im,2,$sx,($sy),strtr($stored_request['diagnosis_note'],$translation_table),$purple); // Diagnosis
  322. $sy+=($vdiv*2);
  323. ImageString($im,1,($left_border),($sy),$LDImmuneSupp,$dark_pink);
  324. /* Imunne suppression Yes/No*/
  325. $sx=$left_border+($hdiv*5);
  326. if($stored_request['immune_supp']) echo doFilledBlock();
  327. else doBlock();
  328. doWrite($LDYes);
  329. $sx+=($hdiv*3); /* advance to the right */
  330. if(!$stored_request['immune_supp']) echo doFilledBlock();
  331. else doBlock();
  332. doWrite($LDNo);
  333. /* Write some more text */
  334. $sx=$left_border;
  335. $sy+=$vdiv;
  336. ImageString($im,3,($left_border),($sy-6),$LDFillLabOnly.'!',$dark_pink); // Fill lab only
  337. $sy+=$vdiv;
  338. doWriteTop($LDLEN); // LEN
  339. $sx=$left_border+($hdiv*2);
  340. ImageString($im,2,$sx,($sy-9),$stored_findings['entry_nr'],$purple); // LEN
  341. $sx=$left_border+($hdiv*9);
  342. doWriteTop($LDDate); // Date
  343. $sx=$left_border+($hdiv*11);
  344. if($stored_findings['rec_date'] && $stored_findings['rec_date']!=DBF_NODATE){
  345. ImageString($im,2,$sx,($sy-9),formatDate2Local($stored_findings['rec_date'],$date_format),$purple); // Date
  346. }
  347. /* Create test type elements */
  348. $tr_tracker=0;
  349. $sx=$left_border;
  350. $sy+=$vdiv;
  351. while(list($x,$v)=each($lab_TestType))
  352. {
  353. if($parsed_type[$x])
  354. {
  355. doFilledBlock();
  356. }
  357. else
  358. {
  359. doBlock();
  360. }
  361. doWriteTop($v);
  362. $tr_tracker++;
  363. $sy+=$vdiv;
  364. if($tr_tracker>9)
  365. {
  366. $tr_tracker=0;
  367. $sy-=($vdiv*10);
  368. $sx+=($hdiv*2);
  369. }
  370. }
  371. /* Free text field */
  372. $sx=$left_border+($hdiv*19);
  373. $sy=$top_border+($vdiv*17);
  374. doWriteTop($LDFillLabOnly.':');
  375. $stored_findings['notes']=strtr($stored_findings['notes'],$translation_table);
  376. /* Chunk split the notes */
  377. $chunks=explode('~',chunk_split($stored_findings['notes'],35,'~'));
  378. for($i=0;$i<sizeof($chunks);$i++)
  379. {
  380. $sy+=$vdiv;
  381. ImageString($im,2,$sx,$sy,trim($chunks[$i]),$purple);
  382. }
  383. $sx=$left_border+($hdiv*33);
  384. $sy=$top_border+($vdiv*16);
  385. doWrite($LDBac_1);
  386. $sx+=($hdiv*2);
  387. doWrite($LDBac_2);
  388. $sx+=($hdiv*2);
  389. doWrite($LDBac_3);
  390. /* Create Resistance test anaerobes */
  391. $sy+=$vdiv;
  392. $sx=$left_border+($hdiv*34);
  393. doWriteTop('S');
  394. $sx+=$hdiv;
  395. doWriteTop('R');
  396. /* First column - anaerobes */
  397. while(list($x,$v)=each($lab_ResistANaerobAcro))
  398. {
  399. $sx=$left_border+($hdiv*34);
  400. doWriteLeft($v);
  401. for($n=0;$n<2;$n++)
  402. {
  403. list($x2,$v2)=each($lab_ResistANaerob_1);
  404. if($parsed_resist_anaerob[$v2])
  405. {
  406. doFilledBlock();
  407. }
  408. else
  409. {
  410. doBlock();
  411. }
  412. $sx+=$hdiv;
  413. }
  414. $sy+=$vdiv;
  415. }
  416. reset($lab_ResistANaerobAcro);
  417. /* 2nd column - anaerobes */
  418. $sy-=($vdiv*15);
  419. $sx=$left_border+($hdiv*36);
  420. doWriteTop('S');
  421. $sx+=$hdiv;
  422. doWriteTop('R');
  423. while(list($x,$v)=each($lab_ResistANaerobAcro))
  424. {
  425. $sx=$left_border+($hdiv*36);
  426. for($n=0;$n<2;$n++)
  427. {
  428. list($x2,$v2)=each($lab_ResistANaerob_2);
  429. if($parsed_resist_anaerob[$v2])
  430. {
  431. doFilledBlock();
  432. }
  433. else
  434. {
  435. doBlock();
  436. }
  437. $sx+=$hdiv;
  438. }
  439. $sy+=$vdiv;
  440. }
  441. reset($lab_ResistANaerobAcro);
  442. /* 3rd column - anaerobes */
  443. $sy-=($vdiv*15);
  444. $sx=$left_border+($hdiv*38);
  445. doWriteTop('S');
  446. $sx+=$hdiv;
  447. doWriteTop('R');
  448. while(list($x,$v)=each($lab_ResistANaerobAcro))
  449. {
  450. $sx=$left_border+($hdiv*38);
  451. for($n=0;$n<2;$n++)
  452. {
  453. list($x2,$v2)=each($lab_ResistANaerob_3);
  454. if($parsed_resist_anaerob[$v2])
  455. {
  456. doFilledBlock();
  457. }
  458. else
  459. {
  460. doBlock();
  461. }
  462. $sx+=$hdiv;
  463. }
  464. $sy+=$vdiv;
  465. }
  466. reset($lab_ResistANaerobAcro);
  467. /* horizontal bar under the label */
  468. $sy=$top_border+($vdiv*32);
  469. ImageFilledRectangle($im,$left_border,($sy-3),($left_border+($hdiv*40)-4),($sy+8),$dark_pink);
  470. ImageString($im,2,($left_border+4),($sy-5),$LDTestFindings,$white);
  471. ImageString($im,2,($left_border+($hdiv*26)),($sy-5),$LDResistanceTestAerob,$white);
  472. /* Bac I,II,III*/
  473. $sx=$left_border+($hdiv*27);
  474. $sy+=$vdiv;
  475. if($parsed_resist_aerob['_rx_pathogen_1_'])
  476. {
  477. doFilledBlock();
  478. }
  479. else
  480. {
  481. doBlock();
  482. }
  483. doWrite($LDBac_I);
  484. $sx+=$hdiv*3;
  485. if($parsed_resist_aerob['_rx_pathogen_2_'])
  486. {
  487. doFilledBlock();
  488. }
  489. else
  490. {
  491. doBlock();
  492. }
  493. doWrite($LDBac_II);
  494. $sx+=$hdiv*3;
  495. if($parsed_resist_aerob['_rx_pathogen_3_'])
  496. {
  497. doFilledBlock();
  498. }
  499. else
  500. {
  501. doBlock();
  502. }
  503. doWrite($LDBac_III);
  504. $sx+=$hdiv*4;
  505. if($parsed_resist_aerob['_rx_fungus_'])
  506. {
  507. doFilledBlock();
  508. }
  509. else
  510. {
  511. doBlock();
  512. }
  513. doWrite($LDFungi);
  514. /* Resistance test aerobes 1st column */
  515. $sx=$left_border+($hdiv*27);
  516. while(list($x,$v)=each($lab_ResistAerobAcro))
  517. {
  518. $sy+=$vdiv;
  519. doWriteLeft($v);
  520. for($n=0;$n<3;$n++)
  521. {
  522. list($x2,$v2)=each($lab_ResistAerob_1);
  523. if($parsed_resist_aerob[$v2])
  524. {
  525. doFilledBlock();
  526. }
  527. else
  528. {
  529. doBlock();
  530. }
  531. doWriteTop($LDSMR[$n]);
  532. $sx+=$hdiv; /* Advance to the right */
  533. }
  534. $sx=$left_border+($hdiv*27);
  535. }
  536. reset($lab_ResistAerobAcro);
  537. /* 2nd column*/
  538. $sx=$left_border+($hdiv*30);
  539. $sy-=($vdiv*32);
  540. while(list($x,$v)=each($lab_ResistAerobAcro))
  541. {
  542. $sy+=$vdiv;
  543. for($n=0;$n<3;$n++)
  544. {
  545. list($x2,$v2)=each($lab_ResistAerob_2);
  546. if($parsed_resist_aerob[$v2])
  547. {
  548. doFilledBlock();
  549. }
  550. else
  551. {
  552. doBlock();
  553. }
  554. doWriteTop($LDSMR[$n]);
  555. $sx+=$hdiv; /* Advance to the right */
  556. }
  557. $sx=$left_border+($hdiv*30);
  558. }
  559. reset($lab_ResistAerobAcro);
  560. /* 3rd column*/
  561. $sx=$left_border+($hdiv*33);
  562. $sy-=($vdiv*32);
  563. while(list($x,$v)=each($lab_ResistAerobAcro))
  564. {
  565. $sy+=$vdiv;
  566. for($n=0;$n<3;$n++)
  567. {
  568. list($x2,$v2)=each($lab_ResistAerob_3);
  569. if($parsed_resist_aerob[$v2])
  570. {
  571. doFilledBlock();
  572. }
  573. else
  574. {
  575. doBlock();
  576. }
  577. doWriteTop($LDSMR[$n]);
  578. $sx+=$hdiv; /* Advance to the right */
  579. }
  580. $sx=$left_border+($hdiv*33);
  581. }
  582. reset($lab_ResistAerobAcro);
  583. /* The 4th column group of resistance test aerobes*/
  584. $sy-=($vdiv*32);
  585. $tr_tracker=0;
  586. $rx_tracker=0;
  587. while(list($x,$v)=each($lab_ResistAerobExtra))
  588. {
  589. $sx=$left_border+($hdiv*37);
  590. $sy+=$vdiv;
  591. doWriteLeft($v);
  592. if($tr_tracker==6)
  593. {
  594. doWriteTop($LDEye);
  595. if($parsed_resist_aerob['_rx_eye_'.$rx_tracker])
  596. {
  597. doFilledBlock();
  598. }
  599. else
  600. {
  601. doBlock();
  602. }
  603. $tr_tracker++;
  604. }
  605. elseif($tr_tracker==7)
  606. {
  607. doWriteTop($LDBAC[$rx_tracker]);
  608. if($parsed_resist_aerob['_rx_bac_'.$rx_tracker])
  609. {
  610. doFilledBlock();
  611. }
  612. else
  613. {
  614. doBlock();
  615. }
  616. $tr_tracker=0;
  617. $rx_tracker++;
  618. }
  619. else
  620. {
  621. for($n=0;$n<3;$n++)
  622. {
  623. list($x2,$v2)=each($lab_ResistAerobExtra_1);
  624. if($parsed_resist_aerob[$v2])
  625. {
  626. doFilledBlock();
  627. }
  628. else
  629. {
  630. doBlock();
  631. }
  632. doWriteTop($LDSMR[$n]);
  633. $sx+=$hdiv;
  634. }
  635. $tr_tracker++;
  636. }
  637. }
  638. reset($lab_ResistAerobExtra);
  639. /* Initial test findings elements */
  640. $sy=$top_border+($vdiv*33);
  641. $sx=$left_border+($hdiv*12);
  642. if($parsed_findings['_tr_blocker_neg']) // blocker negative
  643. {
  644. doFilledBlock();
  645. }
  646. else
  647. {
  648. doBlock();
  649. }
  650. doWrite($LDBlockerNeg);
  651. $sx+=($hdiv*6);
  652. if($parsed_findings['_tr_blocker_pos']) // blocker positive
  653. {
  654. doFilledBlock();
  655. }
  656. else
  657. {
  658. doBlock();
  659. }
  660. doWrite($LDBlockerPos);
  661. $sy+=$vdiv;
  662. $sx=$left_border;
  663. if($parsed_findings['_tr_mark_streptococcus']) // mark streptococcus
  664. {
  665. doFilledBlock();
  666. }
  667. else
  668. {
  669. doBlock();
  670. }
  671. doWrite($LDMarkStreptocResistance);
  672. $sx=$left_border+($hdiv*12);;
  673. if($parsed_findings['_tr_pathogenless']) // pathogen count <10^5
  674. {
  675. doFilledBlock();
  676. }
  677. else
  678. {
  679. doBlock();
  680. }
  681. doWrite($LDBacNr_LT);
  682. $sx+=($hdiv*5);;
  683. if($parsed_findings['_tr_pathogenmore']) // pathogen count >10^5
  684. {
  685. doFilledBlock();
  686. }
  687. else
  688. {
  689. doBlock();
  690. }
  691. doWrite($LDBacNr_GT);
  692. $sx+=($hdiv*5);;
  693. if($parsed_findings['_tr_patho_neg']) // pathogen count negative
  694. {
  695. doFilledBlock();
  696. }
  697. else
  698. {
  699. doBlock();
  700. }
  701. doWrite($LDBacNrNeg);
  702. /* Column markers for findings group */
  703. $sy+=($vdiv*2);
  704. $sx=$left_border;
  705. for($i=0;$i<3;$i++)
  706. {
  707. doWriteTop('I');
  708. $sx+=$hdiv;
  709. doWriteTop('II');
  710. $sx+=$hdiv;
  711. doWriteTop('III');
  712. $sx+=($hdiv*7);
  713. }
  714. /* First group of findings */
  715. $sx=$left_border;
  716. $tr_tracker=0;
  717. while(list($x,$v)=each($lab_TestResultId_1))
  718. {
  719. for($n=0;$n<3;$n++)
  720. {
  721. list($x2,$v2)=each($lab_TestResult_1);
  722. if($parsed_findings[$v2])
  723. {
  724. doFilledBlock();
  725. }
  726. else
  727. {
  728. doBlock();
  729. }
  730. if($n==2)
  731. {
  732. doWrite($v);
  733. $sx+=($hdiv*7);
  734. }
  735. else
  736. {
  737. $sx+=$hdiv;
  738. }
  739. }
  740. if($tr_tracker>1)
  741. {
  742. $tr_tracker=0;
  743. $sy+=$vdiv;
  744. $sx=$left_border;
  745. }
  746. else $tr_tracker++;
  747. }
  748. /* Second group of findings */
  749. $sy+=$vdiv;
  750. $sx=$left_border;
  751. while(list($x,$v)=each($lab_TestResultId_2))
  752. {
  753. list($x2,$v2)=each($lab_TestResult_2);
  754. if($parsed_findings[$v2])
  755. {
  756. doFilledBlock();
  757. }
  758. else
  759. {
  760. doBlock();
  761. }
  762. doWrite($v);
  763. if($tr_tracker>1)
  764. {
  765. $tr_tracker=0;
  766. $sx=$left_border;
  767. $sy+=$vdiv;
  768. }
  769. else
  770. {
  771. $tr_tracker++;
  772. $sx+=($hdiv*9);
  773. }
  774. }
  775. /* Output the image form */
  776. Imagepng($im);
  777. ImageDestroy($im);
  778. ?>