Huge Bootstrap 4 Classes Fix (#2807)
[openemr.git] / interface / patient_file / education.php
blob6437d2370d3a2d85da5090c0fdccec692bc8d8c2
1 <?php
2 /**
3 * This is called as a pop-up to display patient education materials.
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author Rod Roark <rod@sunsetsystems.com>
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2014 Rod Roark <rod@sunsetsystems.com>
10 * @copyright Copyright (c) 2017-2018 Brady Miller <brady.g.miller@gmail.com>
11 * @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 ($_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 // http://www.nlm.nih.gov/medlineplus/connect/application.html
38 $url = 'http://apps.nlm.nih.gov/medlineplus/services/mpconnect.cfm';
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 } else if ('ICD10' == $codetype) {
44 $url .= '2.16.840.1.113883.6.90' ;
45 } else if ('SNOMED' == $codetype) {
46 $url .= '2.16.840.1.113883.6.96' ;
47 } else if ('RXCUI' == $codetype) {
48 $url .= '2.16.840.1.113883.6.88' ;
49 } else if ('NDC' == $codetype) {
50 $url .= '2.16.840.1.113883.6.69' ;
51 } else if ('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 language='JavaScript'>\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 class="body_top">
115 <div class="container">
116 <div class="row">
117 <div class="col-12">
118 <div class="page-header">
119 <h3>
120 <?php
121 echo xlt('Educational materials for');
122 echo ' ' . text($codetype) . ' ';
123 echo xlt('code');
124 echo ' "' . text($codevalue) . '"';
125 if ($language) {
126 echo ' ' . xlt('with preferred language') . ' ' .
127 text(getListItemTitle('language', $_REQUEST['language']));
130 </h3>
131 <?php
132 if ($errmsg) {
133 echo "<p style='color:red'>" . text($errmsg) . "</p>\n";
136 </div>
137 </div>
138 </div>
139 <div class='row'>
140 <div class='col-12'>
141 <form method='post' action='education.php' onsubmit='return top.restoreSession()'>
142 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
143 <input type='hidden' name='type' value='<?php echo attr($codetype); ?>' />
144 <input type='hidden' name='code' value='<?php echo attr($codevalue); ?>' />
145 <input type='hidden' name='language' value='<?php echo attr($language); ?>' />
146 <div class='form-group'>
147 <label for="source"><?php echo xlt('Select source'); ?></label>
148 <select name='source' id='source' class='form-control'>
149 <option value='MLP' ><?php echo xlt('MedlinePlus Connect'); ?></option>
150 <option value='Local'><?php echo xlt('Local Content'); ?></option>
151 </select>
152 </div>
153 <div class='form-group'>
154 <div class='btn-group' role='group'>
155 <button type='submit' class='btn btn-secondary btn-search' name='bn_submit' value='bn_submit'>
156 <?php echo xlt('Submit'); ?>
157 </button>
158 <button type='button' class='btn btn-link btn-cancel' onclick='window.close()'>
159 <?php echo xlt('Cancel'); ?>
160 </button>
161 </div>
162 </div>
163 </form>
164 </div>
165 </div>
166 </div>
167 </body>
168 </html>