more organization of autoloaded files (#424)
[openemr.git] / interface / patient_file / education.php
blobfbb62b1df7d65cdc73128581cedf4a053691e2bd
1 <?php
2 /**
3 * This is called as a pop-up to display patient education materials.
5 * Copyright (C) 2014 Rod Roark <rod@sunsetsystems.com>
7 * LICENSE: This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>.
18 * @package OpenEMR
19 * @author Rod Roark <rod@sunsetsystems.com>
22 $sanitize_all_escapes = true;
23 $fake_register_globals = false;
25 require_once("../globals.php");
26 require_once("$srcdir/options.inc.php");
28 $educationdir = "$OE_SITE_DIR/documents/education";
30 $codetype = empty($_REQUEST['type' ]) ? '' : $_REQUEST['type' ];
31 $codevalue = empty($_REQUEST['code' ]) ? '' : $_REQUEST['code' ];
32 $language = empty($_REQUEST['language']) ? '' : strtolower($_REQUEST['language']);
33 $source = empty($_REQUEST['source' ]) ? '' : $_REQUEST['source' ];
35 $errmsg = '';
37 if ($_POST['bn_submit']) {
38 if ($source == 'MLP') {
39 // MedlinePlus Connect Web Application. See:
40 // http://www.nlm.nih.gov/medlineplus/connect/application.html
41 $url = 'http://apps.nlm.nih.gov/medlineplus/services/mpconnect.cfm';
42 // Set code type in URL.
43 $url .= '?mainSearchCriteria.v.cs=';
44 if ('ICD9' == $codetype) $url .= '2.16.840.1.113883.6.103'; else
45 if ('ICD10' == $codetype) $url .= '2.16.840.1.113883.6.90' ; else
46 if ('SNOMED' == $codetype) $url .= '2.16.840.1.113883.6.96' ; else
47 if ('RXCUI' == $codetype) $url .= '2.16.840.1.113883.6.88' ; else
48 if ('NDC' == $codetype) $url .= '2.16.840.1.113883.6.69' ; else
49 if ('LOINC' == $codetype) $url .= '2.16.840.1.113883.6.1' ; else
50 die(xlt('Code type not recognized') . ': ' . text($codetype));
51 // Set code value in URL.
52 $url .= '&mainSearchCriteria.v.c=' . urlencode($codevalue);
53 // Set language in URL if relevant. MedlinePlus supports only English or Spanish.
54 if ($language == 'es' || $language == 'spanish') {
55 $url .= '&informationRecipient.languageCode.c=es';
57 // There are 2 different ways to get the data: have the server do it, or
58 // have the browser do it.
59 if (false) {
60 $data = file_get_contents($url);
61 echo $data;
63 else {
64 echo "<html><body>"
65 ."<script type=\"text/javascript\" src=\"". $webroot ."/interface/main/tabs/js/include_opener.js\"></script>"
66 . "<script language='JavaScript'>\n";
67 echo "document.location.href = '$url';\n";
68 echo "</script></body></html>\n";
70 exit();
72 else {
73 $lang = 'en';
74 if ($language == 'es' || $language == 'spanish') $lang = 'es';
75 $filename = strtolower("{$codetype}_{$codevalue}_{$lang}.pdf");
76 $filepath = "$educationdir/$filename";
77 if (is_file($filepath)) {
78 header('Content-Description: File Transfer');
79 header('Content-Transfer-Encoding: binary');
80 header('Expires: 0');
81 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
82 header('Pragma: public');
83 // attachment, not inline
84 header("Content-Disposition: attachment; filename=\"$filename\"");
85 header("Content-Type: application/pdf");
86 header("Content-Length: " . filesize($filepath));
87 ob_clean();
88 flush();
89 readfile($filepath);
90 exit();
92 else {
93 $errmsg = xl('There is no local content for this topic.');
98 <html>
99 <head>
100 <?php html_header_show(); ?>
101 <!-- There is a problem with cross site scripting with iframes -->
102 <script type="text/javascript" src="<?php echo $webroot ?>/interface/main/tabs/js/include_opener.js"></script>
103 <link rel=stylesheet href="<?php echo $css_header; ?>" type="text/css">
105 <style type="text/css">@import url(../../library/dynarch_calendar.css);</style>
106 <style>
108 tr.head { font-size:10pt; background-color:#cccccc; text-align:center; }
109 tr.detail { font-size:10pt; background-color:#ddddff; }
110 td input { background-color:transparent; }
112 </style>
114 <script type="text/javascript" src="../../library/textformat.js"></script>
115 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-2-2/index.js"></script>
117 <script language="JavaScript">
119 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
121 </script>
122 </head>
124 <body class="body_top">
125 <center>
127 <h2>
128 <?php
129 echo xlt('Educational materials for');
130 echo ' ' . text($codetype) . ' ';
131 echo xlt('code');
132 echo ' "' . text($codevalue) . '"';
133 if ($language) {
134 echo ' ' . xlt('with preferred language') . ' ' .
135 text(getListItemTitle('language', $_REQUEST['language']));
138 </h2>
140 <?php
141 if ($errmsg) echo "<p style='color:red'>" . text($errmsg) . "</p>\n";
144 <form method='post' action='education.php'>
146 <input type='hidden' name='type' value='<?php echo attr($codetype ); ?>' />
147 <input type='hidden' name='code' value='<?php echo attr($codevalue); ?>' />
148 <input type='hidden' name='language' value='<?php echo attr($language ); ?>' />
150 <p class='bold'>
151 <?php echo xlt('Select source'); ?>:
152 <select name='source'>
153 <option value='MLP' ><?php echo xlt('MedlinePlus Connect'); ?></option>
154 <option value='Local'><?php echo xlt('Local Content' ); ?></option>
155 </select>
156 </p>
159 <input type='submit' name='bn_submit' value='<?php echo xla('Submit'); ?>' />
160 &nbsp;
161 <input type='button' value='<?php echo xla('Cancel'); ?>' onclick="window.close()" />
162 </p>
164 </form>
165 </center>
166 </body>
167 </html>