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>;.
21 * @author (Mac) Kevin McAloon <mcaloon@patienthealthcareanalytics.com>
22 * @author Rohit Kumar <pandit.rohit@netsity.com>
23 * @author Brady Miller <brady@sparmy.com>
24 * @link http://www.open-emr.org
28 //SANITIZE ALL ESCAPES
29 $sanitize_all_escapes=true;
32 //STOP FAKE REGISTER GLOBALS
33 $fake_register_globals=false;
36 require_once("../../interface/globals.php");
37 require_once("$srcdir/acl.inc");
38 require_once("$srcdir/standard_tables_capture.inc");
40 // Ensure script doesn't time out and has enough memory
42 ini_set('memory_limit', '150M');
45 if (!acl_check('admin', 'super')) {
46 echo xlt('Not Authorized');
50 $db = isset($_GET['db']) ?
$_GET['db'] : '0';
51 $version = isset($_GET['version']) ?
$_GET['version'] : '0';
52 $file_revision_date = isset($_GET['file_revision_date']) ?
$_GET['file_revision_date'] : '0';
53 $file_checksum = isset($_GET['file_checksum']) ?
$_GET['file_checksum'] : '0';
54 $newInstall = isset($_GET['newInstall']) ?
$_GET['newInstall'] : '0';
55 $mainPATH = $GLOBALS['fileroot']."/contrib/".strtolower($db);
57 $files_array = scandir($mainPATH);
58 array_shift($files_array); // get rid of "."
59 array_shift($files_array); // get rid of ".."
61 foreach ($files_array as $file) {
62 $this_file = $mainPATH."/".$file;
63 if (strpos($file, ".zip") === false) {
66 if (is_file($this_file)) {
67 handle_zip_file($db, $this_file);
72 if ($db == 'RXNORM') {
73 if (!rxnorm_import(IS_WINDOWS
)) {
74 echo htmlspecialchars( xl('ERROR: Unable to load the file into the database.'), ENT_NOQUOTES
)."<br>";
75 temp_dir_cleanup($db);
78 } else if ( $db == 'SNOMED') {
79 if ($version == "US Extension") {
80 if (!snomed_import(TRUE)) {
81 echo htmlspecialchars( xl('ERROR: Unable to load the file into the database.'), ENT_NOQUOTES
)."<br>";
82 temp_dir_cleanup($db);
86 else { //$version is not "US Extension"
87 if (!snomed_import(FALSE)) {
88 echo htmlspecialchars( xl('ERROR: Unable to load the file into the database.'), ENT_NOQUOTES
)."<br>";
89 temp_dir_cleanup($db);
95 if (!icd_import($db)) {
96 echo htmlspecialchars( xl('ERROR: Unable to load the file into the database.'), ENT_NOQUOTES
)."<br>";
97 temp_dir_cleanup($db);
102 // set the revision version in the database
103 if (!update_tracker_table($db, $file_revision_date, $version, $file_checksum)) {
104 echo htmlspecialchars( xl('ERROR: Unable to set the version number.'), ENT_NOQUOTES
)."<br>";
105 temp_dir_cleanup($db);
109 // done, so clean up the temp directory
110 if ($newInstall === "1") {
112 <div
><?php
echo xlt("Successfully installed the following database") . ": " . text($db); ?
></div
>
116 <div
><?php
echo xlt("Successfully upgraded the following database") . ": " . text($db); ?
></div
>
119 temp_dir_cleanup($db);