private function resolve_module_to_table($module) { $cache = freemed::module_cache(); foreach ($cache as $v) { if (strtolower($v['MODULE_CLASS']) == strtolower($module)) { return $v['META_INFORMATION']['table_name']; } } trigger_error(__("Could not resolve table name!"), E_USER_ERROR); }
public function lookupPatient($module, $id) { $cache = freemed::module_cache(); foreach ($cache as $v) { if ($t = $v['META_INFORMATION']['table_name']) { $tables[strtolower($v['MODULE_CLASS'])] = $t; $pfield[strtolower($v['MODULE_CLASS'])] = $v['META_INFORMATION']['patient_field']; } } if ($pfield[strtolower($module)] and $tables[strtolower($module)]) { $r = $GLOBALS['sql']->get_link($tables[strtolower($module)], $id); return $r[$pfield[strtolower($module)]]; } else { return 0; } }
function _GetAssociations() { $index = freemed::module_cache(); $associations = array(); foreach ($index as $module) { $a = $module['META_INFORMATION']['__associations']; foreach ($a as $_k => $_v) { if (strtolower($_k) == strtolower($this->MODULE_CLASS)) { $associations[] = $_v; } } } return $associations; }
// (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. if (!$_SERVER['argc']) { die("cannot be called via web"); } ini_set('include_path', dirname(dirname(__FILE__)) . ':' . ini_get('include_path')); include_once 'lib/freemed.php'; $cache = freemed::module_cache(); print "ACL Rebuild Tool\n"; print "(c) 2006 FreeMED Software Foundation\n\n"; $tables = array('acl_acl', 'acl_acl_sections', 'acl_acl_seq', 'acl_aco', 'acl_aco_map', 'acl_aco_sections', 'acl_aro', 'acl_aro_groups', 'acl_aro_groups_map', 'acl_aro_map', 'acl_aro_sections', 'acl_aro_seq', 'acl_axo', 'acl_axo_groups', 'acl_axo_groups_map', 'acl_axo_map', 'acl_axo_sections', 'acl_axo_seq', 'acl_groups_aro_map', 'acl_groups_axo_map', 'acl_phpgacl'); print " - Dropping tables ... "; foreach ($tables as $table) { $GLOBALS['sql']->query('DROP TABLE ' . $table); } print "[done]\n"; // Reinitialize db print " - Reinitializing ACL tables ... "; $GLOBALS['sql']->query("CREATE TABLE IF NOT EXISTS acl ( id SERIAL );"); module_function('acl', '_setup', array()); print "[done]\n"; // Reimport users print " - Reimporting users ... \n";
#!/usr/bin/env php <?php // $Id$ // // Authors: // Jeff Buchbinder <*****@*****.**> // // FreeMED Electronic Medical Record and Practice Management System // Copyright (C) 1999-2012 FreeMED Software Foundation // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. include_once dirname(__FILE__) . '/bootstrap.test.php'; if ($argc < 3) { die("syntax: {$argv['0']} moduleclass id [tex|pdf]\n"); } $module = $argv[1]; $id = $argv[2]; $modules = freemed::module_cache(); print module_function($module, 'RenderToPDF', array($id, strtolower($argv[3]) == 'tex'));
function ProcessData($data) { $cache = freemed::module_cache(); // Handle "module:" prefix if (substr($data['table'], 0, 7) == 'object:') { $objectname = substr($data['table'], -(strlen($data['table']) - 7)); $params = explode(':', $data['field']); if ($params[0] == 'patient') { $obj = CreateObject('org.freemedsoftware.core.' . $objectname, $this->patient->local_record[$params[1]]); $method = $params[2] ? $params[2] : 'to_text'; $raw = $obj->{${method}}(); } else { syslog(LOG_INFO, get_class($this) . "| could not process {$data['table']}, {$data['field']}"); return ''; } } elseif (substr($data['table'], 0, 7) == 'module:') { $modulename = substr($data['table'], -(strlen($data['table']) - 7)); // Deal with method: prefix on data if (substr($data['field'], 0, 7) == 'method:') { $params = explode(':', $data['field']); $raw = module_function($modulename, $params[1], array($params[2] ? $params[2] : $this->patient->id)); } else { // Load information from module include_once resolve_module($modulename); $m = new $modulename(); // Run SQL query $query = "SELECT *" . (count($m->summary_query) > 0 ? "," . join(",", $m->summary_query) . " " : " ") . "FROM " . $m->table_name . " " . "WHERE " . $m->patient_field . "='" . addslashes($this->patient->id) . "' " . ($m->summary_conditional ? 'AND ' . $m->summary_conditional . ' ' : '') . "ORDER BY id DESC LIMIT 1"; $result = $GLOBALS['sql']->query($query); if ($GLOBALS['sql']->num_rows($result) != 1) { syslog(LOG_INFO, get_class($this) . "| could not retrieve rows for {$data['table']}, {$data['field']}"); return ""; } $r = $GLOBALS['sql']->fetch_array($result); return $r[$data['field']]; } } else { // Deal with straight abbreviations for data switch ($data['table']) { case 'patient': if (strpos($data['field'], ':') === false) { $raw = $this->patient->local_record[$data['field']]; } else { list($desc, $field) = explode(':', $data['field']); switch ($desc) { case 'method': $raw = $this->patient->{${field}}(); break; // end method // end method default: syslog(LOG_INFO, get_class($this) . "| could not figure out syntax for {$data['table']}, {$data['field']}"); $raw = ""; break; // end default } // end switch desc } break; case 'control': $raw = $this->FetchDataElement($data['field']); break; case 'static': $raw = $data['field']; break; default: break; } // end switch } // Deal with output formatting switch ($data['type']) { case 'link': if (!$data['value']) { syslog(LOG_INFO, get_class($this) . "| could not process {$data['table']}, {$data['field']}, {$data['value']}"); return ''; } if (strpos($data['value'], ':') !== false) { $params = explode(':', $data['value']); return module_function($params[0], 'get_field', array($raw, $params[1])); } else { return module_function($data['value'], 'to_text', array($raw)); } break; case 'ssn': return substr($raw, 0, 3) . '-' . substr($raw, 3, 2) . '-' . substr($raw, 5, 4); break; case 'conditional': // Handle "static" type if ($data['table'] == 'static') { return 'X'; } // Handle "multiple" type if ($data['table'] == 'control') { if (!isset($this->controls)) { $this->controls = $this->GetControls(); } if ($this->controls[$data['field']]['type'] == 'multiple') { foreach (explode(',', $raw) as $value) { if ($data['value'] == $value) { return 'X'; } } return ''; } } // Handle everything else if ($data['value'] == $raw) { return 'X'; } else { return ''; } break; case 'phone': return freemed::phone_display($raw); break; case 'date': if (!$raw) { return ''; } $_date = explode('-', $raw); switch (freemed::config_value('dtfmt')) { case 'ymd': return $raw; break; case 'mdy': default: return "{$_date[1]}/{$_date[2]}/{$_date[0]}"; break; } // Should never get here return $raw; break; case 'string': default: return $raw; break; } // end data type }
public static function module_version($module) { static $cache; // cache all modules if (!is_array($cache)) { $mcache = freemed::module_cache(); foreach ($mcache as $r) { $_config[$r['module_name']] = $r['module_version']; } // end of while results } // end caching modules config // check in cache for version return $cache["{$module}"]; }
public function CreateForm($report) { $form = CreateObject('net.php.pear.HTML_QuickForm', 'form', 'get'); freemed::quickform_i18n(&$form); $form->addElement('hidden', 'report', $report); $form->addElement('hidden', 'action', 'view'); $form->setDefaults(array('action' => 'view')); // Make sure module cache is loaded, just in case $_cache = freemed::module_cache(); // Get meta-information from the report $this->api->setReportPath(FREEMED_DIR . '/data/report/' . $report . '.report'); $report = $this->api->getReport(); // Display the header if one exists if ($report['Report']['Properties']['Description']) { $form->addElement('header', '', $report['Report']['Properties']['Description']); } $merged = $this->DetermineMergedFormat($report); //if (!is_array($report['Report']['Parameters'])) { return NULL; } foreach ($report['Report']['Parameters'] as $k => $v) { if ($k == 'module') { next; } list($desc, $type, $detail) = explode(':', $v['value']); switch ($type) { case 'date': $form->addElement('static', $k, $desc, fm_date_entry($k)); break; // date // date case 'module': $form->addElement('static', $k, $desc, module_function($detail, 'widget', $k)); break; // module // module case 'select': $form->addElement('select', $k, $desc, explode(',', $detail)); break; // select // select case 'text': $form->addElement('text', $k, $desc); break; // text // text default: break; } } // Show format selection if (!$merged) { $form->addElement('select', 'format', __("Report Format"), array('csv' => 'CSV', 'html' => 'HTML', 'pdf' => 'PDF', 'ps' => 'Postscript', 'txt' => 'Plain Text')); } else { $form->addElement('select', 'format', __("Report Format"), array('pdf' => 'PDF')); } $submit_group[] =& HTML_QuickForm::createElement('submit', 'submit_action', __("Generate")); $submit_group[] =& HTML_QuickForm::createElement('submit', 'submit_action', __("Cancel")); $form->addGroup($submit_group, null, null, ' '); return $form; }