Various changes and fixes (#7424)
[openemr.git] / interface / patient_file / education.php
blobc61f6b07bcdbe53721085de4ae018e0ba7998508
1 <?php
3 /**
4 * This is called as a pop-up to display patient education materials.
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Rod Roark <rod@sunsetsystems.com>
9 * @author Brady Miller <brady.g.miller@gmail.com>
10 * @copyright Copyright (c) 2014 Rod Roark <rod@sunsetsystems.com>
11 * @copyright Copyright (c) 2017-2018 Brady Miller <brady.g.miller@gmail.com>
12 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 require_once("../globals.php");
16 require_once("$srcdir/options.inc.php");
18 use OpenEMR\Common\Crypto\CryptoGen;
19 use OpenEMR\Common\Csrf\CsrfUtils;
20 use OpenEMR\Core\Header;
22 $educationdir = "$OE_SITE_DIR/documents/education";
24 $codetype = empty($_REQUEST['type' ]) ? '' : $_REQUEST['type' ];
25 $codevalue = empty($_REQUEST['code' ]) ? '' : $_REQUEST['code' ];
26 $language = empty($_REQUEST['language']) ? '' : strtolower($_REQUEST['language']);
27 $source = empty($_REQUEST['source' ]) ? '' : $_REQUEST['source' ];
29 $errmsg = '';
31 if (!empty($_POST['bn_submit'])) {
32 if (!CsrfUtils::verifyCsrfToken($_POST["csrf_token_form"])) {
33 CsrfUtils::csrfNotVerified();
36 if ($source == 'MLP') {
37 // MedlinePlus Connect Web Application. See:
38 // https://www.nlm.nih.gov/medlineplus/connect/application.html
39 $url = 'https://connect.medlineplus.gov/application';
40 // Set code type in URL.
41 $url .= '?mainSearchCriteria.v.cs=';
42 if ('ICD9' == $codetype) {
43 $url .= '2.16.840.1.113883.6.103';
44 } elseif ('ICD10' == $codetype) {
45 $url .= '2.16.840.1.113883.6.90' ;
46 } elseif ('SNOMED' == $codetype) {
47 $url .= '2.16.840.1.113883.6.96' ;
48 } elseif ('RXCUI' == $codetype) {
49 $url .= '2.16.840.1.113883.6.88' ;
50 } elseif ('NDC' == $codetype) {
51 $url .= '2.16.840.1.113883.6.69' ;
52 } elseif ('LOINC' == $codetype) {
53 $url .= '2.16.840.1.113883.6.1' ;
54 } else {
55 die(xlt('Code type not recognized') . ': ' . text($codetype));
58 // Set code value in URL.
59 $url .= '&mainSearchCriteria.v.c=' . urlencode($codevalue);
60 // Set language in URL if relevant. MedlinePlus supports only English or Spanish.
61 if ($language == 'es' || $language == 'spanish') {
62 $url .= '&informationRecipient.languageCode.c=es';
65 echo "<html><body>"
66 //."<script type=\"text/javascript\" src=\"". $webroot ."/interface/main/tabs/js/include_opener.js\"></script>"
67 . "<script>\n";
68 echo "document.location.href = " . js_escape($url) . ";\n";
69 echo "</script></body></html>\n";
71 exit();
72 } else {
73 $lang = 'en';
74 if ($language == 'es' || $language == 'spanish') {
75 $lang = 'es';
77 $filename = strtolower("{$codetype}_{$codevalue}_{$lang}.pdf");
78 check_file_dir_name($filename);
79 $filepath = "$educationdir/$filename";
81 if (is_file($filepath)) {
82 $fileData = file_get_contents($filepath);
84 // Decrypt file, if applicable.
85 $cryptoGen = new CryptoGen();
86 if ($cryptoGen->cryptCheckStandard($fileData)) {
87 $fileData = $cryptoGen->decryptStandard($fileData, null, 'database');
90 header('Content-Description: File Transfer');
91 header('Content-Transfer-Encoding: binary');
92 header('Expires: 0');
93 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
94 header('Pragma: public');
95 // attachment, not inline
96 header("Content-Disposition: attachment; filename=\"$filename\"");
97 header("Content-Type: application/pdf");
98 header("Content-Length: " . strlen($fileData));
99 ob_clean();
100 flush();
101 echo $fileData;
102 exit();
103 } else {
104 $errmsg = xl('There is no local content for this topic.');
109 <html>
110 <head>
112 <title><?php echo xlt('Education'); ?></title>
114 <?php Header::setupHeader(); ?>
116 </head>
117 <body>
118 <div class="container mt-3">
119 <div class="row">
120 <div class="col-12">
121 <h3>
122 <?php
123 echo xlt('Educational materials for');
124 echo ' ' . text($codetype) . ' ';
125 echo xlt('code');
126 echo ' "' . text($codevalue) . '"';
127 if ($language) {
128 echo ' ' . xlt('with preferred language') . ' ' .
129 text(getListItemTitle('language', $_REQUEST['language']));
132 </h3>
133 <?php
134 if ($errmsg) {
135 echo "<p class='text-danger'>" . text($errmsg) . "</p>\n";
138 </div>
139 </div>
140 <div class='row'>
141 <div class='col-12'>
142 <form method='post' action='education.php' onsubmit='return top.restoreSession()'>
143 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
144 <input type='hidden' name='type' value='<?php echo attr($codetype); ?>' />
145 <input type='hidden' name='code' value='<?php echo attr($codevalue); ?>' />
146 <input type='hidden' name='language' value='<?php echo attr($language); ?>' />
147 <div class='form-group'>
148 <label for="source"><?php echo xlt('Select source'); ?></label>
149 <select name='source' id='source' class='form-control'>
150 <option value='MLP'><?php echo xlt('MedlinePlus Connect'); ?></option>
151 <option value='Local'><?php echo xlt('Local Content'); ?></option>
152 </select>
153 </div>
154 <div class='form-group'>
155 <div class='btn-group' role='group'>
156 <button type='submit' class='btn btn-primary btn-search' name='bn_submit' value='bn_submit'>
157 <?php echo xlt('Submit'); ?>
158 </button>
159 <button type='button' class='btn btn-secondary btn-cancel' onclick='window.close()'>
160 <?php echo xlt('Cancel'); ?>
161 </button>
162 </div>
163 </div>
164 </form>
165 </div>
166 </div>
167 </div>
168 </body>
169 </html>