New dialog implementation-continued. (#1307)
[openemr.git] / interface / patient_file / education.php
blob8df06a9f40146fa272c507c9d1de343c6b8e42c5
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 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");
17 use OpenEMR\Core\Header;
19 $educationdir = "$OE_SITE_DIR/documents/education";
21 $codetype = empty($_REQUEST['type' ]) ? '' : $_REQUEST['type' ];
22 $codevalue = empty($_REQUEST['code' ]) ? '' : $_REQUEST['code' ];
23 $language = empty($_REQUEST['language']) ? '' : strtolower($_REQUEST['language']);
24 $source = empty($_REQUEST['source' ]) ? '' : $_REQUEST['source' ];
26 $errmsg = '';
28 if ($_POST['bn_submit']) {
29 if ($source == 'MLP') {
30 // MedlinePlus Connect Web Application. See:
31 // http://www.nlm.nih.gov/medlineplus/connect/application.html
32 $url = 'http://apps.nlm.nih.gov/medlineplus/services/mpconnect.cfm';
33 // Set code type in URL.
34 $url .= '?mainSearchCriteria.v.cs=';
35 if ('ICD9' == $codetype) {
36 $url .= '2.16.840.1.113883.6.103';
37 } else if ('ICD10' == $codetype) {
38 $url .= '2.16.840.1.113883.6.90' ;
39 } else if ('SNOMED' == $codetype) {
40 $url .= '2.16.840.1.113883.6.96' ;
41 } else if ('RXCUI' == $codetype) {
42 $url .= '2.16.840.1.113883.6.88' ;
43 } else if ('NDC' == $codetype) {
44 $url .= '2.16.840.1.113883.6.69' ;
45 } else if ('LOINC' == $codetype) {
46 $url .= '2.16.840.1.113883.6.1' ;
47 } else {
48 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';
58 // There are 2 different ways to get the data: have the server do it, or
59 // have the browser do it.
60 if (false) {
61 $data = file_get_contents($url);
62 echo $data;
63 } else { // Removed opener because this is not a dialog. sjp 12/14/17
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";
71 exit();
72 } else {
73 $lang = 'en';
74 if ($language == 'es' || $language == 'spanish') {
75 $lang = 'es';
78 $filename = strtolower("{$codetype}_{$codevalue}_{$lang}.pdf");
79 $filepath = "$educationdir/$filename";
80 if (is_file($filepath)) {
81 header('Content-Description: File Transfer');
82 header('Content-Transfer-Encoding: binary');
83 header('Expires: 0');
84 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
85 header('Pragma: public');
86 // attachment, not inline
87 header("Content-Disposition: attachment; filename=\"$filename\"");
88 header("Content-Type: application/pdf");
89 header("Content-Length: " . filesize($filepath));
90 ob_clean();
91 flush();
92 readfile($filepath);
93 exit();
94 } else {
95 $errmsg = xl('There is no local content for this topic.');
100 <html>
101 <head>
103 <title><?php echo xlt('Education'); ?></title>
105 <?php Header::setupHeader(); ?>
107 </head>
108 <body class="body_top">
109 <div class="container">
110 <div class="row">
111 <div class="col-xs-12">
112 <div class="page-header">
113 <h3>
114 <?php
115 echo xlt('Educational materials for');
116 echo ' ' . text($codetype) . ' ';
117 echo xlt('code');
118 echo ' "' . text($codevalue) . '"';
119 if ($language) {
120 echo ' ' . xlt('with preferred language') . ' ' .
121 text(getListItemTitle('language', $_REQUEST['language']));
124 </h3>
125 <?php
126 if ($errmsg) {
127 echo "<p style='color:red'>" . text($errmsg) . "</p>\n";
130 </div>
131 </div>
132 </div>
133 <div class='row'>
134 <div class='col-xs-12'>
135 <form method='post' action='education.php' onsubmit='return top.restoreSession()'>
136 <input type='hidden' name='type' value='<?php echo attr($codetype); ?>' />
137 <input type='hidden' name='code' value='<?php echo attr($codevalue); ?>' />
138 <input type='hidden' name='language' value='<?php echo attr($language); ?>' />
139 <div class='form-group'>
140 <label for="source"><?php echo xlt('Select source'); ?></label>
141 <select name='source' id='source' class='form-control'>
142 <option value='MLP' ><?php echo xlt('MedlinePlus Connect'); ?></option>
143 <option value='Local'><?php echo xlt('Local Content'); ?></option>
144 </select>
145 </div>
146 <div class='form-group'>
147 <div class='btn-group' role='group'>
148 <button type='submit' class='btn btn-default btn-search' name='bn_submit' value='bn_submit'>
149 <?php echo xlt('Submit'); ?>
150 </button>
151 <button type='button' class='btn btn-link btn-cancel' onclick='window.close()'>
152 <?php echo xlt('Cancel'); ?>
153 </button>
154 </div>
155 </div>
156 </form>
157 </div>
158 </div>
159 </div>
160 </body>
161 </html>