2 //our api for 3rd party developers
3 require_once(dirname(__FILE__) . "/../interface/globals.php");
5 use OpenEMR\Billing\BillingUtilities;
7 $GLOBALS['form_exit_url'] = "javascript:parent.closeTab(window.name, false)";
9 function formHeader($title = "My Form")
14 <link rel=stylesheet href="<?php echo $GLOBALS['css_header']?>" type="text/css">
15 <title><?php echo text($title); ?></title>
17 <body background="<?php echo $GLOBALS['backpic']?>" topmargin=0 rightmargin=0 leftmargin=2 bottommargin=0 marginwidth=2 marginheight=0>
29 function formSubmit($tableName, $values, $id, $authorized = "0")
31 global $attendant_type;
33 $sqlBindingArray = [$_SESSION['pid'], $_SESSION['authProvider'], $_SESSION['authUser'], $authorized];
34 $sql = "insert into " . escape_table_name($tableName) . " set " . escape_sql_column_name($attendant_type, array($tableName)) . "=?, groupname=?, user=?, authorized=?, activity=1, date = NOW(),";
35 foreach ($values as $key => $value) {
36 if ($key == "csrf_token_form") {
39 if (strpos($key, "openemr_net_cpt") === 0) {
40 //code to auto add cpt code
42 $code_array = explode(" ", $value, 2);
44 BillingUtilities::addBilling(date("Ymd"), 'CPT4', $code_array[0], $code_array[1], $_SESSION['pid'], $authorized, $_SESSION['authUserID']);
46 } //case where key looks like "[a-zA-Z]*diagnosis[0-9]" which is special, it is used to auto add ICD codes
48 elseif (strpos($key, "diagnosis") == (strlen($key) -10) && !(strpos($key, "diagnosis")=== false )) {
49 //icd auto add ICD9-CM
51 $code_array = explode(" ", $value, 2);
52 BillingUtilities::addBilling(date("Ymd"), 'ICD9-M', $code_array[0], $code_array[1], $_SESSION['pid'], $authorized, $_SESSION['authUserID']);
55 $sql .= " " . escape_sql_column_name($key, array($tableName)) . " = ?,";
56 $sqlBindingArray[] = $value;
60 $sql = substr($sql, 0, -1);
61 return sqlInsert($sql, $sqlBindingArray);
65 function formUpdate($tableName, $values, $id, $authorized = "0")
67 $sqlBindingArray = [$_SESSION['pid'], $_SESSION['authProvider'], $_SESSION['authUser'], $authorized];
68 $sql = "update " . escape_table_name($tableName) . " set pid =?, groupname=?, user=? ,authorized=?, activity=1, date = NOW(),";
69 foreach ($values as $key => $value) {
70 if ($key == "csrf_token_form") {
73 $sql .= " " . escape_sql_column_name($key, array($tableName)) . " = ?,";
74 $sqlBindingArray[] = $value;
77 $sql = substr($sql, 0, -1);
78 $sql .= " where id=?";
79 $sqlBindingArray[] = $id;
81 return sqlInsert($sql, $sqlBindingArray);
84 function formJump($address = '')
88 echo "top.restoreSession();\n";
89 echo "location.href = " . js_escape($address) . ";\n";
91 echo "parent.closeTab(window.name, true);\n";
94 // TBD: Exit seems wrong here, but that's how it has been forever.
98 function formFetch($tableName, $id, $cols = "*", $activity = "1")
100 // Run through escape_table_name() function to support dynamic form names in addition to mitigate sql table casing issues.
101 return sqlQuery("select " . escape_sql_column_name(process_cols_escape($cols), array($tableName)) . " from `" . escape_table_name($tableName) . "` where id=? and pid = ? and activity like ? order by date DESC LIMIT 0,1", array($id,$GLOBALS['pid'],$activity)) ;
105 function formDisappear($tableName, $id)
107 // Run through escape_table_name() function to support dynamic form names in addition to mitigate sql table casing issues.
108 if (sqlStatement("update `" . escape_table_name($tableName) . "` set activity = '0' where id=? and pid=?", [$id, $pid])) {
115 function formReappear($tableName, $id)
117 // Run through escape_table_name() function to support dynamic form names in addition to mitigate sql table casing issues.
118 if (sqlStatement("update `" . escape_table_name($tableName) . "` set activity = '1' where id=? and pid=?", [$id, $pid])) {