public function createStore() { $this->load->dbforge(); $this->load->helper('file_helper'); $this->load->helper('Mobile_Detect_helper'); $this->load->helper('create_db_helper'); $detect = new Mobile_Detect(); $deviceName = ""; if ($detect->isMobile()) { $deviceName = "mobile"; } else { if ($detect->isTablet()) { $deviceName = "tablet"; } else { $deviceName = "pc"; } } $post = $this->input->post(); $clientInfo = $post["clientInfo"]; $userId = $this->session->userdata("userid"); $databaseObj = $this->template->getTemplateName($post["key"]); $resultObj = $databaseObj->result()[0]; $projectName = $resultObj->TemplateProjectName; $projectImage = $resultObj->TemplateImage; recursive_copy("assets/template/" . $projectName, "../" . $post["domainName"]); copy("assets/images/screen-shot/" . $projectImage, "assets/images/screen-shot/" . $post["domainName"] . ".jpg"); $databaseObj->next_result(); $databaseObj = $this->template->createStore($post["storeName"], $post["domainName"], $userId, $post["key"], $clientInfo["appCodeName"], $clientInfo["appVersion"], $this->input->ip_address(), $deviceName, $clientInfo["platform"]); $newStore = $databaseObj->result()[0]; $databaseObj->next_result(); execSql($newStore->TemplateType, $post["domainName"], get_instance()); }
function dummyAgents($db, $count = 10) { for ($i = 1; $i <= $count; $i++) { execSql($db, "INSERT INTO agent (id) VALUES ({$i})", "add dummy agent {$i}"); } }
loadSchema('acl'); include_once dirname(__FILE__) . '/../lib/org/freemedsoftware/module/ACL.class.php'; $a = new ACL(); $q = "SELECT username, id FROM user WHERE id > 0"; $r = $GLOBALS['sql']->queryAll($q); foreach ($r as $user) { print " - Adding ACL record for user " . $user['username'] . " (" . $user['id'] . ") \n"; $a->UserAdd($r['id']); } printHeader("Create 'healthy system' status"); `touch ./data/cache/healthy`; printHeader("Rebuild differently organized tables"); // -- Allergies execSql("INSERT INTO allergies ( patient ) SELECT DISTINCT patient FROM allergies_old;"); execSql("CREATE TEMPORARY TABLE allergies_atomic_temp SELECT * FROM allergies_atomic;"); execSql("INSERT INTO allergies_atomic_temp ( aid, allergy, severity, patient ) SELECT a.id, o.allergy, o.severity, a.patient FROM allergies_old o LEFT OUTER JOIN allergies a ON o.patient = a.patient;"); execSql("INSERT INTO allergies_atomic SELECT * FROM allergies_atomic_temp;"); execSql("DROP TEMPORARY TABLE allergies_atomic_temp;"); // -- Medications execSql("INSERT INTO medications ( mpatient, mdate ) SELECT DISTINCT mpatient, mdate FROM medications_old;"); execSql("CREATE TEMPORARY TABLE medications_atomic_temp SELECT * FROM medications_atomic;"); execSql("INSERT INTO medications_atomic_temp ( mid, mdrug, mdosage, mroute, mdate, mpatient ) SELECT m.id, o.mdrug, o.mdosage, o.mroute, m.mdate, m.mpatient FROM medications_old o LEFT OUTER JOIN medications m ON o.mpatient = m.mpatient;"); execSql("INSERT INTO medications_atomic SELECT * FROM medications_atomic_temp;"); execSql("DROP TEMPORARY TABLE medications_atomic_temp;"); // -- Practice records execSql("INSERT INTO practice ( pracname, ein, addr1a, addr2a, citya, statea, zipa, phonea, faxa, addr1b, addr2b, cityb, stateb, zipb, phoneb, faxb, email, cellular, pager, id ) SELECT phypracname, phypracein, phyaddr1a, phyaddr2a, phycitya, phystatea, phyzipa, phyphonea, phyfaxa, phyaddr1b, phyaddr2b, phycityb, phystateb, phyzipb, phyphoneb, phyfaxb, phyemail, phycellular, phypager, id FROM physician;"); execSql("ALTER IGNORE TABLE physician ADD COLUMN phypractice INT UNSIGNED NOT NULL DEFAULT 0 AFTER phytitle;"); execSql("UPDATE physician SET phypractice = id;"); // -- Templates, if they exist execSql("INSERT INTO pnotes_templates SELECT pntname, pntphy, pntS, pntO, pntA, pntP, pntI, pntE, pntR, NOW(), NULL FROM pntemplate;");