Feature to add drug-drug interaction checking for the
[openemr.git] / interface / weno / drug-drug.php
blobd763b9c049333b0bd15f97ad6a88a5d2a8d6dd83
1 <?php
3 /** Copyright (C) 2016 Sherwin Gaddis <sherwingaddis@gmail.com>
5 * LICENSE: This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
16 * @package OpenEMR
17 * @author Sherwin Gaddis <sherwingaddis@gmail.com>
18 * @link http://www.open-emr.org
21 $fake_register_globals=false;
22 $sanitize_all_escapes=true;
23 require_once("../globals.php");
26 * check to see if RxNorm installed
28 $rxn = sqlQuery("SELECT table_name FROM information_schema.tables WHERE table_name = 'RXNCONSO' OR table_name = 'rxnconso'");
29 if($rxn == false){
30 die(xlt("Could not find RxNorm Table! Please install."));
33 * Grab medication list from prescriptions list
34 * load into array
36 $medList = sqlStatement("SELECT drug FROM prescriptions WHERE active = 1 AND patient_id = ?", array($pid));
37 $nameList = array();
38 while($name = sqlFetchArray($medList)){
39 $drug = explode(" ", $name['drug']);
40 $rXn = sqlQuery("SELECT `rxcui` FROM `" . mitigateSqlTableUpperCase('RXNCONSO') . "` WHERE `str` LIKE ?", array("%" . $drug[0] . "%"));
41 $nameList[] = $rXn['rxcui'];
44 * make sure there are drugs to compare
46 if (count($nameList) < 2) {
47 echo xlt("Need more than one drug.");
48 exit;
52 * If there are drugs to compare, collect the data
55 $rxcui_list = implode("+",$nameList);
56 $data = file_get_contents("https://rxnav.nlm.nih.gov/REST/interaction/list.json?rxcuis=".$rxcui_list);
59 * Content from NLM returned
62 $json = json_decode($data, true);
65 <html>
66 <head>
67 <?php html_header_show();?>
68 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
69 </head>
70 <body class="body_top">
71 <span class="title"><?php echo xlt('Drug - Drug Interaction'); ?></span>
72 <br><br>
73 <?php
76 * Display the drug interactions if any
79 if(!empty($json['fullInteractionTypeGroup'][0]['fullInteractionType'])){
80 foreach($json['fullInteractionTypeGroup'][0]['fullInteractionType'] as $item){
81 print xlt('Comment').":".text($item['comment'])."</br>";
82 print xlt('Drug1 Name{{Drug1 Interaction}}').":".text($item['minConcept'][0]['name'])."</br>";
83 print xlt('Drug2 Name{{Drug2 Interaction}}').":".text($item['minConcept'][1]['name'])."</br>";
84 print xlt('Severity').":". text($item['interactionPair'][0]['severity'])."</br>";
85 print xlt('Description').":". text($item['interactionPair'][0]['description'])."</br></br>";
87 } else {
88 echo xlt('No interactions found');
91 </body>
92 </html>