3 * This will print a blank form, and if "patientid" is specified then
4 * any existing data for the specified patient is included.
7 * @link http://www.open-emr.org
8 * @author Rod Roark <rod@sunsetsystems.com>
9 * @copyright Copyright (c) 2009-2015 Rod Roark <rod@sunsetsystems.com>
10 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 require_once("../../globals.php");
15 // Option to substitute a custom version of this script.
16 if (!empty($GLOBALS['gbl_rapid_workflow']) &&
17 $GLOBALS['gbl_rapid_workflow'] == 'LBFmsivd' &&
18 file_exists('../../../custom/demographics_print.php')) {
19 include('../../../custom/demographics_print.php');
23 require_once("$srcdir/acl.inc");
24 require_once("$srcdir/options.inc.php");
25 require_once("$srcdir/patient.inc");
27 $patientid = empty($_REQUEST['patientid']) ?
0 : 0 +
$_REQUEST['patientid'];
29 $patientid = 0 +
$pid; // -1 means current pid
32 // True if to display as a form to complete, false to display as information.
33 $isform = empty($_REQUEST['isform']) ?
0 : 1;
35 // Html2pdf fails to generate checked checkboxes properly, so write plain HTML
36 // if we are doing a patient-specific complete form.
37 $PDF_OUTPUT = ($patientid && $isform) ?
false : true;
40 require_once("$srcdir/html2pdf/vendor/autoload.php");
41 $pdf = new HTML2PDF('P', 'Letter', 'en');
42 $pdf->setTestTdInOnePage(false); // Turn off error message for TD contents too big.
43 $pdf->pdf
->SetDisplayMode('real');
47 $CPR = 4; // cells per row
54 $prow = getPatientData($pid, "*, DATE_FORMAT(DOB,'%Y-%m-%d') as DOB_YMD");
55 $erow = getEmployerData($pid);
56 // Check authorization.
57 $thisauth = acl_check('patients', 'demo');
59 die(xl('Demographics not authorized'));
61 if ($prow['squad'] && ! acl_check('squads', $prow['squad'])) {
62 die(xl('You are not authorized to access this squad'));
64 // $irow = getInsuranceProviders(); // needed?
67 // Load array of properties for this layout and its groups.
69 getLayoutProperties('DEM', $grparr);
71 $fres = sqlStatement("SELECT * FROM layout_options " .
72 "WHERE form_id = 'DEM' AND uor > 0 " .
73 "ORDER BY group_id, seq");
76 <?php
if (!$PDF_OUTPUT) { ?
>
79 <?php
html_header_show();?
>
84 <?php
if ($PDF_OUTPUT) { ?
>
92 font
-family
: Arial
, Helvetica
, sans
-serif
;
97 padding
: 5pt
5pt
5pt
5pt
;
111 // html2pdf screws up the div borders when a div overflows to a second page.
112 // Our temporary solution is to turn off the borders in the case where this
113 // is likely to happen (i.e. where all form options are listed).
118 border
-color
: #000000;
125 div
.section td
.stuff
{
126 vertical
-align
: bottom
;
130 td
.lcols1
{ width
: 20%
; }
131 td
.lcols2
{ width
: 50%
; }
132 td
.lcols3
{ width
: 70%
; }
133 td
.dcols1
{ width
: 30%
; }
134 td
.dcols2
{ width
: 50%
; }
135 td
.dcols3
{ width
: 80%
; }
145 border
-width
: 0 0 1px
0;
146 border
-color
: #999999;
177 <body bgcolor
='#ffffff'>
181 // Generate header with optional logo.
183 $ma_logo_path = "sites/" . $_SESSION['site_id'] . "/images/ma_logo.png";
184 if (is_file("$webserver_root/$ma_logo_path")) {
185 $logo = "<img src='$web_root/$ma_logo_path' style='height:" . round(9 * 5.14) . "pt' />";
187 $logo = "<!-- '$ma_logo_path' does not exist. -->";
189 echo genFacilityTitle(xl('Registration Form'), -1, $logo);
193 global $item_count, $cell_count;
194 if ($item_count > 0) {
202 global $cell_count, $CPR;
204 if ($cell_count > 0) {
205 for (; $cell_count < $CPR;
218 if (strlen($last_group) > 0) {
225 function getContent()
227 global $web_root, $webserver_root;
228 $content = ob_get_clean();
229 // Fix a nasty html2pdf bug - it ignores document root!
231 $wrlen = strlen($web_root);
232 $wsrlen = strlen($webserver_root);
234 $i = stripos($content, " src='/", $i +
1);
238 if (substr($content, $i+
6, $wrlen) === $web_root &&
239 substr($content, $i+
6, $wsrlen) !== $webserver_root) {
240 $content = substr($content, 0, $i +
6) . $webserver_root . substr($content, $i +
6 +
$wrlen);
250 while ($frow = sqlFetchArray($fres)) {
251 $this_group = $frow['group_id'];
252 $titlecols = $frow['titlecols'];
253 $datacols = $frow['datacols'];
254 $data_type = $frow['data_type'];
255 $field_id = $frow['field_id'];
256 $list_id = $frow['list_id'];
259 if (strpos($field_id, 'em_') === 0) {
260 $tmp = substr($field_id, 3);
261 if (isset($erow[$tmp])) {
262 $currvalue = $erow[$tmp];
265 if (isset($prow[$field_id])) {
266 $currvalue = $prow[$field_id];
270 // Handle a data category (group) change.
271 if (strcmp($this_group, $last_group) != 0) {
274 // if (strlen($last_group) > 0) echo "<br />\n";
276 // This replaces the above statement and is an attempt to work around a
277 // nasty html2pdf bug. When a table overflows to the next page, vertical
278 // positioning for whatever follows it is off and can cause overlap.
279 if (strlen($last_group) > 0) {
280 echo "</nobreak><br /><div><table><tr><td> </td></tr></table></div><br />\n";
283 // This is also for html2pdf. Telling it that the following stuff should
284 // start on a new page if there is not otherwise room for it on this page.
285 echo "<nobreak>\n"; // grasping
287 $group_name = $grparr[$this_group]['grp_title'];
288 $last_group = $this_group;
289 echo "<p class='grpheader'>" . xl_layout_label($group_name) . "</p>\n";
290 echo "<div class='section'>\n";
291 echo " <table border='0' cellpadding='0'>\n";
292 echo " <tr><td class='lcols1'></td><td class='dcols1'></td><td class='lcols1'></td><td class='dcols1'></td></tr>\n";
295 // Handle starting of a new row.
296 if (($titlecols > 0 && $cell_count >= $CPR) ||
$cell_count == 0) {
301 if ($item_count == 0 && $titlecols == 0) {
305 // Handle starting of a new label cell.
306 if ($titlecols > 0) {
308 echo "<td colspan='$titlecols' ";
309 echo "class='lcols$titlecols stuff " . (($frow['uor'] == 2) ?
"required'" : "bold'");
310 if ($cell_count == 2) {
311 echo " style='padding-left:10pt'";
314 $cell_count +
= $titlecols;
321 if ($frow['title']) {
322 echo (xl_layout_label($frow['title']) . ":");
329 // Handle starting of a new data cell.
332 echo "<td colspan='$datacols' class='dcols$datacols stuff under'";
333 /*****************************************************************
334 // Underline is wanted only for fill-in-the-blank data types.
335 if ($data_type < 21 && $data_type != 1 && $data_type != 3) {
336 echo " class='under'";
338 *****************************************************************/
339 if ($cell_count > 0) {
340 echo " style='padding-left:5pt;'";
343 $cell_count +
= $datacols;
349 generate_print_field($frow, $currvalue);
351 $s = generate_display_field($frow, $currvalue);
361 // Ending the last nobreak section for html2pdf.
362 if (strlen($last_group) > 0) {
371 $content = getContent();
372 // $pdf->setDefaultFont('Arial');
373 $pdf->writeHTML($content, false);
374 $pdf->Output('Demographics_form.pdf', 'D'); // D = Download, I = Inline
377 <!-- This should really be in the onload handler but that seems to be unreliable
and can crash Firefox
3. -->
378 <script language
='JavaScript'>
379 opener
.top
.printLogPrint(window
);