improvements for blank forms
[openemr.git] / interface / patient_file / summary / demographics_print.php
blobd151f0f9acabc03dcb0fbbcf94dde1ba722c26da
1 <?php
2 // Copyright (C) 2009 Rod Roark <rod@sunsetsystems.com>
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 // Currently this will print only a blank form, but some code was
10 // preserved here and in options.inc.php to ease future support for
11 // data for a specified patient.
13 require_once("../../globals.php");
14 require_once("$srcdir/acl.inc");
15 require_once("$srcdir/options.inc.php");
16 require_once("$srcdir/patient.inc");
18 $CPR = 4; // cells per row
20 /*********************************************************************
21 $result = getPatientData($pid, "*, DATE_FORMAT(DOB,'%Y-%m-%d') as DOB_YMD");
22 $result2 = getEmployerData($pid);
23 // Check authorization.
24 $thisauth = acl_check('patients', 'demo');
25 if ($pid) {
26 if (!$thisauth != 'write')
27 die(xl('Demographics not authorized.'));
28 if ($result['squad'] && ! acl_check('squads', $result['squad']))
29 die(xl('You are not authorized to access this squad.'));
31 $insurancei = getInsuranceProviders();
32 *********************************************************************/
34 $fres = sqlStatement("SELECT * FROM layout_options " .
35 "WHERE form_id = 'DEM' AND uor > 0 " .
36 "ORDER BY group_name, seq");
38 <html>
39 <head>
40 <?php html_header_show();?>
42 <style>
43 body, td {
44 font-family: Arial, Helvetica, sans-serif;
45 font-weight: normal;
46 font-size: 9pt;
49 body {
50 padding: 5pt 5pt 5pt 5pt;
53 div.section {
54 border-style: solid;
55 border-width: 1px;
56 border-color: #000000;
57 margin: 0 0 0 10pt;
58 padding: 5pt;
61 .mainhead {
62 font-weight: bold;
63 font-size: 14pt;
64 text-align: center;
67 .under {
68 border-style: solid;
69 border-width: 0 0 1px 0;
70 border-color: #999999;
72 </style>
73 </head>
75 <body bgcolor='#ffffff'>
76 <form>
78 <p class='mainhead'><?php xl('Registration Form','e'); ?></p>
80 <?php
82 function end_cell() {
83 global $item_count, $cell_count;
84 if ($item_count > 0) {
85 echo "</td>";
86 $item_count = 0;
90 function end_row() {
91 global $cell_count, $CPR;
92 end_cell();
93 if ($cell_count > 0) {
94 for (; $cell_count < $CPR; ++$cell_count) echo "<td></td>";
95 echo "</tr>\n";
96 $cell_count = 0;
100 function end_group() {
101 global $last_group;
102 if (strlen($last_group) > 0) {
103 end_row();
104 echo " </table>\n";
105 echo "</div>\n";
109 $last_group = '';
110 $cell_count = 0;
111 $item_count = 0;
113 while ($frow = sqlFetchArray($fres)) {
114 $this_group = $frow['group_name'];
115 $titlecols = $frow['titlecols'];
116 $datacols = $frow['datacols'];
117 $data_type = $frow['data_type'];
118 $field_id = $frow['field_id'];
119 $list_id = $frow['list_id'];
120 $currvalue = '';
122 if (strpos($field_id, 'em_') === 0) {
123 $tmp = substr($field_id, 3);
124 // if (isset($result2[$tmp])) $currvalue = $result2[$tmp];
126 else {
127 // if (isset($result[$field_id])) $currvalue = $result[$field_id];
130 // Handle a data category (group) change.
131 if (strcmp($this_group, $last_group) != 0) {
132 end_group();
133 if (strlen($last_group) > 0) echo "<br />\n";
134 $group_name = substr($this_group, 1);
135 $last_group = $this_group;
136 echo "<b>" . xl_layout_label($group_name) . "</b>\n";
138 echo "<div class='section'>\n";
139 echo " <table border='0' cellpadding='0'>\n";
142 // Handle starting of a new row.
143 if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
144 end_row();
145 echo " <tr style='height:30pt'>";
148 if ($item_count == 0 && $titlecols == 0) $titlecols = 1;
150 // Handle starting of a new label cell.
151 if ($titlecols > 0) {
152 end_cell();
153 echo "<td colspan='$titlecols' width='10%'";
154 echo ($frow['uor'] == 2) ? " class='required'" : " class='bold'";
155 if ($cell_count == 2) echo " style='padding-left:10pt'";
156 echo ">";
157 $cell_count += $titlecols;
159 ++$item_count;
161 echo "<b>";
163 if ($frow['title']) echo (xl_layout_label($frow['title']) . ":"); else echo "&nbsp;";
165 echo "</b>";
167 // Handle starting of a new data cell.
168 if ($datacols > 0) {
169 end_cell();
170 echo "<td colspan='$datacols' width='40%' class='under'";
171 if ($cell_count > 0) echo " style='padding-left:5pt;'";
172 echo ">";
173 $cell_count += $datacols;
176 ++$item_count;
177 generate_print_field($frow, $currvalue);
180 end_group();
183 </form>
185 <!-- This should really be in the onload handler but that seems to be unreliable and can crash Firefox 3. -->
186 <script language='JavaScript'>
187 window.print();
188 </script>
190 </body>
191 </html>