4 * This will print a blank form, and if "patientid" is specified then
5 * any existing data for the specified patient is included.
8 * @link http://www.open-emr.org
9 * @author Rod Roark <rod@sunsetsystems.com>
10 * @author Brady Miller <brady.g.miller@gmail.com>
11 * @copyright Copyright (c) 2009-2015 Rod Roark <rod@sunsetsystems.com>
12 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
13 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
16 require_once("../../globals.php");
18 // Option to substitute a custom version of this script.
20 !empty($GLOBALS['gbl_rapid_workflow']) &&
21 $GLOBALS['gbl_rapid_workflow'] == 'LBFmsivd' &&
22 file_exists('../../../custom/demographics_print.php')
24 include('../../../custom/demographics_print.php');
28 require_once("$srcdir/options.inc.php");
29 require_once("$srcdir/patient.inc.php");
32 use OpenEMR\Common\Acl\AclMain
;
33 use OpenEMR\Pdf\Config_Mpdf
;
35 $patientid = empty($_REQUEST['patientid']) ?
0 : 0 +
$_REQUEST['patientid'];
37 $patientid = (int) $pid; // -1 means current pid
40 // True if to display as a form to complete, false to display as information.
41 $isform = empty($_REQUEST['isform']) ?
0 : 1;
43 $PDF_OUTPUT = ($patientid && $isform) ?
false : true;
46 $config_mpdf = Config_Mpdf
::getConfigMpdf();
47 $pdf = new mPDF($config_mpdf);
48 if ($_SESSION['language_direction'] == 'rtl') {
49 $pdf->SetDirectionality('rtl');
54 $CPR = 4; // cells per row
61 $prow = getPatientData($pid, "*, DATE_FORMAT(DOB,'%Y-%m-%d') as DOB_YMD");
62 $erow = getEmployerData($pid);
63 // Check authorization.
64 $thisauth = AclMain
::aclCheckCore('patients', 'demo');
66 die(xlt('Demographics not authorized'));
68 if ($prow['squad'] && ! AclMain
::aclCheckCore('squads', $prow['squad'])) {
69 die(xlt('You are not authorized to access this squad'));
71 // $irow = getInsuranceProviders(); // needed?
74 // Load array of properties for this layout and its groups.
76 getLayoutProperties('DEM', $grparr);
78 $fres = sqlStatement("SELECT * FROM layout_options " .
79 "WHERE form_id = 'DEM' AND uor > 0 " .
80 "ORDER BY group_id, seq");
83 <?php
if (!$PDF_OUTPUT) { ?
>
90 <?php
if ($PDF_OUTPUT) { ?
>
98 font
-family
: Arial
, Helvetica
, sans
-serif
;
103 padding
: 5pt
5pt
5pt
5pt
;
117 // html2pdf screws up the div borders when a div overflows to a second page.
118 // Our temporary solution is to turn off the borders in the case where this
119 // is likely to happen (i.e. where all form options are listed).
120 // TODO - now use mPDF, so should test if still need this fix
125 border
-color
: #000000;
132 div
.section td
.stuff
{
133 vertical
-align
: bottom
;
137 td
.lcols1
{ width
: 20%
; }
138 td
.lcols2
{ width
: 50%
; }
139 td
.lcols3
{ width
: 70%
; }
140 td
.dcols1
{ width
: 30%
; }
141 td
.dcols2
{ width
: 50%
; }
142 td
.dcols3
{ width
: 80%
; }
152 border
-width
: 0 0 1px
0;
153 border
-color
: #999999;
184 <body bgcolor
='#ffffff'>
188 // Generate header with optional logo.
190 $ma_logo_path = "sites/" . $_SESSION['site_id'] . "/images/ma_logo.png";
191 if (is_file("$webserver_root/$ma_logo_path")) {
192 $logo = "$web_root/$ma_logo_path";
195 echo genFacilityTitle(xl('Registration Form'), -1, $logo);
199 global $item_count, $cell_count;
200 if ($item_count > 0) {
208 global $cell_count, $CPR;
210 if ($cell_count > 0) {
211 for (; $cell_count < $CPR; ++
$cell_count) {
223 if (strlen($last_group) > 0) {
230 function getContent()
232 $content = ob_get_clean();
240 while ($frow = sqlFetchArray($fres)) {
241 $this_group = $frow['group_id'];
242 $titlecols = $frow['titlecols'];
243 $datacols = $frow['datacols'];
244 $data_type = $frow['data_type'];
245 $field_id = $frow['field_id'];
246 $list_id = $frow['list_id'];
249 if (strpos($field_id, 'em_') === 0) {
250 $tmp = substr($field_id, 3);
251 if (isset($erow[$tmp])) {
252 $currvalue = $erow[$tmp];
255 if (isset($prow[$field_id])) {
256 $currvalue = $prow[$field_id];
260 // Handle a data category (group) change.
261 if (strcmp($this_group, $last_group) != 0) {
264 // if (strlen($last_group) > 0) echo "<br />\n";
266 // This replaces the above statement and is an attempt to work around a
267 // nasty html2pdf bug. When a table overflows to the next page, vertical
268 // positioning for whatever follows it is off and can cause overlap.
269 // TODO - now use mPDF, so should test if still need this fix
270 if (strlen($last_group) > 0) {
271 echo "</nobreak><br /><div><table><tr><td> </td></tr></table></div><br />\n";
274 // This is also for html2pdf. Telling it that the following stuff should
275 // start on a new page if there is not otherwise room for it on this page.
276 // TODO - now use mPDF, so should test if still need this fix
277 echo "<nobreak>\n"; // grasping
279 $group_name = $grparr[$this_group]['grp_title'];
280 $last_group = $this_group;
281 echo "<p class='grpheader'>" . text(xl_layout_label($group_name)) . "</p>\n";
282 echo "<div class='section'>\n";
283 echo " <table border='0' cellpadding='0'>\n";
284 echo " <tr><td class='lcols1'></td><td class='dcols1'></td><td class='lcols1'></td><td class='dcols1'></td></tr>\n";
287 // Handle starting of a new row.
288 if (($titlecols > 0 && $cell_count >= $CPR) ||
$cell_count == 0) {
293 if ($item_count == 0 && $titlecols == 0) {
297 // Handle starting of a new label cell.
298 if ($titlecols > 0) {
300 echo "<td colspan='" . attr($titlecols) . "' ";
301 echo "class='lcols" . attr($titlecols) . " stuff " . (($frow['uor'] == 2) ?
"required'" : "bold'");
302 if ($cell_count == 2) {
303 echo " style='padding-left:10pt'";
306 $cell_count +
= $titlecols;
313 if ($frow['title']) {
314 echo text((xl_layout_label($frow['title'])) . ":");
321 // Handle starting of a new data cell.
324 echo "<td colspan='" . attr($datacols) . "' class='dcols" . attr($datacols) . " stuff under'";
325 /*****************************************************************
326 // Underline is wanted only for fill-in-the-blank data types.
327 if ($data_type < 21 && $data_type != 1 && $data_type != 3) {
328 echo " class='under'";
330 *****************************************************************/
331 if ($cell_count > 0) {
332 echo " style='padding-left:5pt;'";
335 $cell_count +
= $datacols;
341 generate_print_field($frow, $currvalue);
343 $s = generate_display_field($frow, $currvalue);
353 // Ending the last nobreak section for html2pdf.
354 // TODO - now use mPDF, so should test if still need this fix
355 if (strlen($last_group) > 0) {
364 $content = getContent();
365 $pdf->writeHTML($content);
366 $pdf->Output('Demographics_form.pdf', 'D'); // D = Download, I = Inline
369 <!-- This should really be in the onload handler but that seems to be unreliable
and can crash Firefox
3. -->
371 opener
.top
.printLogPrint(window
);