complete a9 (#4976)
[openemr.git] / interface / patient_file / education.php
blob58dcb5901665e00f7dc792ed9a0d43f8789cb2f8
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\Csrf\CsrfUtils;
19 use OpenEMR\Core\Header;
21 $educationdir = "$OE_SITE_DIR/documents/education";
23 $codetype = empty($_REQUEST['type' ]) ? '' : $_REQUEST['type' ];
24 $codevalue = empty($_REQUEST['code' ]) ? '' : $_REQUEST['code' ];
25 $language = empty($_REQUEST['language']) ? '' : strtolower($_REQUEST['language']);
26 $source = empty($_REQUEST['source' ]) ? '' : $_REQUEST['source' ];
28 $errmsg = '';
30 if (!empty($_POST['bn_submit'])) {
31 if (!CsrfUtils::verifyCsrfToken($_POST["csrf_token_form"])) {
32 CsrfUtils::csrfNotVerified();
35 if ($source == 'MLP') {
36 // MedlinePlus Connect Web Application. See:
37 // https://www.nlm.nih.gov/medlineplus/connect/application.html
38 $url = 'https://connect.medlineplus.gov/application';
39 // Set code type in URL.
40 $url .= '?mainSearchCriteria.v.cs=';
41 if ('ICD9' == $codetype) {
42 $url .= '2.16.840.1.113883.6.103';
43 } elseif ('ICD10' == $codetype) {
44 $url .= '2.16.840.1.113883.6.90' ;
45 } elseif ('SNOMED' == $codetype) {
46 $url .= '2.16.840.1.113883.6.96' ;
47 } elseif ('RXCUI' == $codetype) {
48 $url .= '2.16.840.1.113883.6.88' ;
49 } elseif ('NDC' == $codetype) {
50 $url .= '2.16.840.1.113883.6.69' ;
51 } elseif ('LOINC' == $codetype) {
52 $url .= '2.16.840.1.113883.6.1' ;
53 } else {
54 die(xlt('Code type not recognized') . ': ' . text($codetype));
57 // Set code value in URL.
58 $url .= '&mainSearchCriteria.v.c=' . urlencode($codevalue);
59 // Set language in URL if relevant. MedlinePlus supports only English or Spanish.
60 if ($language == 'es' || $language == 'spanish') {
61 $url .= '&informationRecipient.languageCode.c=es';
64 // There are 2 different ways to get the data: have the server do it, or
65 // have the browser do it.
66 if (false) {
67 $data = file_get_contents($url);
68 echo text($data);
69 } else { // Removed opener because this is not a dialog. sjp 12/14/17
70 echo "<html><body>"
71 //."<script type=\"text/javascript\" src=\"". $webroot ."/interface/main/tabs/js/include_opener.js\"></script>"
72 . "<script>\n";
73 echo "document.location.href = " . js_escape($url) . ";\n";
74 echo "</script></body></html>\n";
77 exit();
78 } else {
79 $lang = 'en';
80 if ($language == 'es' || $language == 'spanish') {
81 $lang = 'es';
84 $filename = strtolower("{$codetype}_{$codevalue}_{$lang}.pdf");
85 $filepath = "$educationdir/$filename";
86 if (is_file($filepath)) {
87 header('Content-Description: File Transfer');
88 header('Content-Transfer-Encoding: binary');
89 header('Expires: 0');
90 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
91 header('Pragma: public');
92 // attachment, not inline
93 header("Content-Disposition: attachment; filename=\"$filename\"");
94 header("Content-Type: application/pdf");
95 header("Content-Length: " . filesize($filepath));
96 ob_clean();
97 flush();
98 readfile($filepath);
99 exit();
100 } else {
101 $errmsg = xl('There is no local content for this topic.');
106 <html>
107 <head>
109 <title><?php echo xlt('Education'); ?></title>
111 <?php Header::setupHeader(); ?>
113 </head>
114 <body>
115 <div class="container mt-3">
116 <div class="row">
117 <div class="col-12">
118 <h3>
119 <?php
120 echo xlt('Educational materials for');
121 echo ' ' . text($codetype) . ' ';
122 echo xlt('code');
123 echo ' "' . text($codevalue) . '"';
124 if ($language) {
125 echo ' ' . xlt('with preferred language') . ' ' .
126 text(getListItemTitle('language', $_REQUEST['language']));
129 </h3>
130 <?php
131 if ($errmsg) {
132 echo "<p class='text-danger'>" . text($errmsg) . "</p>\n";
135 </div>
136 </div>
137 <div class='row'>
138 <div class='col-12'>
139 <form method='post' action='education.php' onsubmit='return top.restoreSession()'>
140 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
141 <input type='hidden' name='type' value='<?php echo attr($codetype); ?>' />
142 <input type='hidden' name='code' value='<?php echo attr($codevalue); ?>' />
143 <input type='hidden' name='language' value='<?php echo attr($language); ?>' />
144 <div class='form-group'>
145 <label for="source"><?php echo xlt('Select source'); ?></label>
146 <select name='source' id='source' class='form-control'>
147 <option value='MLP'><?php echo xlt('MedlinePlus Connect'); ?></option>
148 <option value='Local'><?php echo xlt('Local Content'); ?></option>
149 </select>
150 </div>
151 <div class='form-group'>
152 <div class='btn-group' role='group'>
153 <button type='submit' class='btn btn-primary btn-search' name='bn_submit' value='bn_submit'>
154 <?php echo xlt('Submit'); ?>
155 </button>
156 <button type='button' class='btn btn-secondary btn-cancel' onclick='window.close()'>
157 <?php echo xlt('Cancel'); ?>
158 </button>
159 </div>
160 </div>
161 </form>
162 </div>
163 </div>
164 </div>
165 </body>
166 </html>