Moved recent v5.0.0 statement fix to current master.
[openemr.git] / interface / code_systems / standard_tables_manage.php
blob610a5ddd1730f8fee08e00bb1febf1091d78fe8f
1 <?php
2 /**
3 * This file implements the database load processing when loading external
4 * database files into openEMR
6 * Copyright (C) 2012 Patient Healthcare Analytics, Inc.
7 * Copyright (C) 2011 Phyaura, LLC <info@phyaura.com>
9 * LICENSE: This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
20 * @package OpenEMR
21 * @author (Mac) Kevin McAloon <mcaloon@patienthealthcareanalytics.com>
22 * @author Rohit Kumar <pandit.rohit@netsity.com>
23 * @author Brady Miller <brady.g.miller@gmail.com>
24 * @link http://www.open-emr.org
30 require_once("../../interface/globals.php");
31 require_once("$srcdir/acl.inc");
32 require_once("$srcdir/standard_tables_capture.inc");
34 // Ensure script doesn't time out and has enough memory
35 set_time_limit(0);
36 ini_set('memory_limit', '150M');
38 // Control access
39 if (!acl_check('admin', 'super')) {
40 echo xlt('Not Authorized');
41 exit;
44 $db = isset($_GET['db']) ? $_GET['db'] : '0';
45 $version = isset($_GET['version']) ? $_GET['version'] : '0';
46 $file_revision_date = isset($_GET['file_revision_date']) ? $_GET['file_revision_date'] : '0';
47 $file_checksum = isset($_GET['file_checksum']) ? $_GET['file_checksum'] : '0';
48 $newInstall = isset($_GET['newInstall']) ? $_GET['newInstall'] : '0';
49 $mainPATH = $GLOBALS['fileroot']."/contrib/".strtolower($db);
51 $files_array = scandir($mainPATH);
52 array_shift($files_array); // get rid of "."
53 array_shift($files_array); // get rid of ".."
55 foreach ($files_array as $file) {
56 $this_file = $mainPATH."/".$file;
57 if (strpos($file, ".zip") === false) {
58 continue;
61 if (is_file($this_file)) {
62 handle_zip_file($db, $this_file);
66 // load the database
67 if ($db == 'RXNORM') {
68 if (!rxnorm_import(IS_WINDOWS)) {
69 echo htmlspecialchars(xl('ERROR: Unable to load the file into the database.'), ENT_NOQUOTES)."<br>";
70 temp_dir_cleanup($db);
71 exit;
73 } else if ($db == 'SNOMED') {
74 if ($version == "US Extension") {
75 if (!snomed_import(true)) {
76 echo htmlspecialchars(xl('ERROR: Unable to load the file into the database.'), ENT_NOQUOTES)."<br>";
77 temp_dir_cleanup($db);
78 exit;
80 } else { //$version is not "US Extension"
81 if (!snomed_import(false)) {
82 echo htmlspecialchars(xl('ERROR: Unable to load the file into the database.'), ENT_NOQUOTES)."<br>";
83 temp_dir_cleanup($db);
84 exit;
87 } else if ($db == 'CQM_VALUESET') {
88 if (!valueset_import($db)) {
89 echo htmlspecialchars(xl('ERROR: Unable to load the file into the database.'), ENT_NOQUOTES)."<br>";
90 temp_dir_cleanup($db);
91 exit;
93 } else { //$db == 'ICD'
94 if (!icd_import($db)) {
95 echo htmlspecialchars(xl('ERROR: Unable to load the file into the database.'), ENT_NOQUOTES)."<br>";
96 temp_dir_cleanup($db);
97 exit;
101 // set the revision version in the database
102 if (!update_tracker_table($db, $file_revision_date, $version, $file_checksum)) {
103 echo htmlspecialchars(xl('ERROR: Unable to set the version number.'), ENT_NOQUOTES)."<br>";
104 temp_dir_cleanup($db);
105 exit;
108 // done, so clean up the temp directory
109 if ($newInstall === "1") {
111 <div><?php echo xlt("Successfully installed the following database") . ": " . text($db); ?></div>
112 <?php
113 } else {
115 <div><?php echo xlt("Successfully upgraded the following database") . ": " . text($db); ?></div>
116 <?php
119 temp_dir_cleanup($db);