4 * old api for 3rd parties
7 * @link https://www.open-emr.org
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2017-2021 Brady Miller <brady.g.miller@gmail.com>
10 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 use OpenEMR\Billing\BillingUtilities
;
14 use OpenEMR\Core\Header
;
16 $GLOBALS['form_exit_url'] = "javascript:parent.closeTab(window.name, false)";
18 function formHeader($title = "My Form")
23 <?php Header
::setupHeader(); ?
>
24 <title
><?php
echo text($title); ?
></title
>
26 <body background
="<?php echo $GLOBALS['backpic']?>" topmargin
=0 rightmargin
=0 leftmargin
=2 bottommargin
=0 marginwidth
=2 marginheight
=0>
38 function formSubmit($tableName, $values, $id, $authorized = "0")
40 global $attendant_type;
42 $sqlBindingArray = [$_SESSION['pid'], $_SESSION['authProvider'], $_SESSION['authUser'], $authorized];
43 $sql = "insert into " . escape_table_name($tableName) . " set " . escape_sql_column_name($attendant_type, array($tableName)) . "=?, groupname=?, user=?, authorized=?, activity=1, date = NOW(),";
44 foreach ($values as $key => $value) {
45 if ($key == "csrf_token_form") {
48 if (strpos($key, "openemr_net_cpt") === 0) {
49 //code to auto add cpt code
51 $code_array = explode(" ", $value, 2);
53 BillingUtilities
::addBilling(date("Ymd"), 'CPT4', $code_array[0], $code_array[1], $_SESSION['pid'], $authorized, $_SESSION['authUserID']);
55 } elseif (strpos($key, "diagnosis") == (strlen($key) - 10) && !(strpos($key, "diagnosis") === false )) {
56 //case where key looks like "[a-zA-Z]*diagnosis[0-9]" which is special, it is used to auto add ICD codes
57 //icd auto add ICD9-CM
59 $code_array = explode(" ", $value, 2);
60 BillingUtilities
::addBilling(date("Ymd"), 'ICD9-M', $code_array[0], $code_array[1], $_SESSION['pid'], $authorized, $_SESSION['authUserID']);
63 $sql .= " " . escape_sql_column_name($key, array($tableName)) . " = ?,";
64 $sqlBindingArray[] = $value;
68 $sql = substr($sql, 0, -1);
69 return sqlInsert($sql, $sqlBindingArray);
73 function formUpdate($tableName, $values, $id, $authorized = "0")
75 $sqlBindingArray = [$_SESSION['pid'], $_SESSION['authProvider'], $_SESSION['authUser'], $authorized];
76 $sql = "update " . escape_table_name($tableName) . " set pid =?, groupname=?, user=? ,authorized=?, activity=1, date = NOW(),";
77 foreach ($values as $key => $value) {
78 if ($key == "csrf_token_form") {
81 $sql .= " " . escape_sql_column_name($key, array($tableName)) . " = ?,";
82 $sqlBindingArray[] = $value;
85 $sql = substr($sql, 0, -1);
86 $sql .= " where id=?";
87 $sqlBindingArray[] = $id;
89 return sqlInsert($sql, $sqlBindingArray);
92 function formJump($address = '')
96 echo "top.restoreSession();\n";
97 echo "location.href = " . js_escape($address) . ";\n";
99 echo "parent.closeTab(window.name, true);\n";
102 // TBD: Exit seems wrong here, but that's how it has been forever.
106 function formFetch($tableName, $id, $cols = "*", $activity = "1")
108 // Run through escape_table_name() function to support dynamic form names in addition to mitigate sql table casing issues.
109 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)) ;
112 function formDisappear($tableName, $id)
114 // Run through escape_table_name() function to support dynamic form names in addition to mitigate sql table casing issues.
115 if (sqlStatement("update `" . escape_table_name($tableName) . "` set activity = '0' where id=? and pid=?", [$id, $pid])) {
122 function formReappear($tableName, $id)
124 // Run through escape_table_name() function to support dynamic form names in addition to mitigate sql table casing issues.
125 if (sqlStatement("update `" . escape_table_name($tableName) . "` set activity = '1' where id=? and pid=?", [$id, $pid])) {