Exemplo n.º 1
0
 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
 }
Exemplo n.º 2
0
 function practicePhoneNumber()
 {
     return freemed::phone_display($this->local_record['phyphonea']);
 }
Exemplo n.º 3
0
 function phoneNumber()
 {
     if (!$this->local_record['pthphone']) {
         return __("No Phone Number");
     }
     return freemed::phone_display($this->local_record['pthphone']);
 }