4 * Print postcards for patients currently in the $_SESSION['pidList'] variable.
7 * @link http://www.MedExBank.com
8 * @author MedEx <support@MedExBank.com>
9 * @copyright Copyright (c) 2017 MedEx <support@MedExBank.com>
10 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 require_once("../../globals.php");
16 $pid_list = $_SESSION['pidList'];
18 $pdf = new FPDF('L', 'mm', array(148, 105));
20 $pdf->SetFont('Arial', '', 14);
22 $sql = "SELECT * FROM facility ORDER BY billing_location DESC LIMIT 1";
23 $facility = sqlQuery($sql);
25 $sql = "SELECT * FROM medex_prefs";
26 $prefs = sqlQuery($sql);
27 if ($prefs['postcard_top']) {
28 $postcard_top = $prefs['postcard_top'];
33 $postcard_message = $postcard_top . "\n" . xl('Please call our office to schedule') . "\n" . xl('your next appointment at') . " " . $facility['phone'] . ".
34 \n\n" . $facility['street'] . "\n
35 " . $facility['city'] . ", " . $facility['state'] . " " . $facility['postal_code'];
36 $postcard_message = "\n\n" . $postcard_message . "\n\n";
38 foreach ($pid_list as $pid) {
40 $patdata = sqlQuery("SELECT " .
41 "p.fname, p.mname, p.lname, p.pubpid, p.DOB, " .
42 "p.street, p.city, p.state, p.postal_code, p.pid " .
43 "FROM patient_data AS p " .
44 "WHERE p.pid = ? LIMIT 1", array($pid));
45 $prov = sqlQuery("SELECT * FROM users WHERE id IN (SELECT r_provider FROM `medex_recalls` WHERE `r_pid`=?)", array($pid));
46 if (isset($prov['fname']) && isset($prov['lname'])) {
47 $prov_name = ": " . $prov['fname'] . " " . $prov['lname'];
48 if (isset($prov['suffix'])) {
49 $prov_name .= ", " . $prov['suffix'];
52 $pdf->SetFont('Arial', '', 9);
53 $pdf->Cell(74, 30, $facility['name'] . $prov_name, 1, 1, 'C');
54 $pdf->MultiCell(74, 4, $postcard_message, 'LRTB', 'C', 0);// [, boolean fill]]])
55 $pdf->Text(100, 50, $patdata['fname'] . " " . $patdata['lname']);
56 $pdf->Text(100, 55, $patdata['street']);
57 $pdf->Text(100, 60, $patdata['city'] . " " . $patdata['state'] . " " . $patdata['postal_code']);
59 $pdf->Output('postcards.pdf', 'D');
60 //D forces the file download instead of showing it in browser
61 //isn't there an openEMR global for this?