2 //our api for 3rd party developers
3 require_once(dirname(__FILE__) . "/../interface/globals.php");
4 require_once("{$GLOBALS['srcdir']}/billing.inc");
6 $GLOBALS['form_exit_url'] = "$rootdir/patient_file/encounter/encounter_top.php";
8 function formHeader($title = "My Form")
13 <?php html_header_show();?>
14 <link rel=stylesheet href="<?php echo $GLOBALS['css_header']?>" type="text/css">
15 <title><?php echo $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 $sql = "insert into " . escape_table_name($tableName) . " set " . $attendant_type . "='".add_escape_custom($_SESSION['pid'])."',groupname='".add_escape_custom($_SESSION['authProvider'])."',user='".add_escape_custom($_SESSION['authUser'])."',authorized='".add_escape_custom($authorized)."',activity=1, date = NOW(),";
34 foreach ($values as $key => $value) {
35 if (strpos($key, "openemr_net_cpt") === 0) {
36 //code to auto add cpt code
38 $code_array = explode(" ", $value, 2);
40 addBilling(date("Ymd"), 'CPT4', $code_array[0], $code_array[1], $_SESSION['pid'], $authorized, $_SESSION['authUserID']);
42 } //case where key looks like "[a-zA-Z]*diagnosis[0-9]" which is special, it is used to auto add ICD codes
44 elseif (strpos($key, "diagnosis") == (strlen($key) -10) && !(strpos($key, "diagnosis")=== false )) {
45 //icd auto add ICD9-CM
47 $code_array = explode(" ", $value, 2);
48 addBilling(date("Ymd"), 'ICD9-M', $code_array[0], $code_array[1], $_SESSION['pid'], $authorized, $_SESSION['authUserID']);
51 $sql .= " " . escape_sql_column_name($key, array($tableName)) . " = '" . add_escape_custom($value) . "',";
55 $sql = substr($sql, 0, -1);
56 return sqlInsert($sql);
60 function formUpdate($tableName, $values, $id, $authorized = "0")
62 $sql = "update " . escape_table_name($tableName) . " set pid ='".add_escape_custom($_SESSION['pid'])."',groupname='".add_escape_custom($_SESSION['authProvider'])."',user='".add_escape_custom($_SESSION['authUser'])."',authorized='".add_escape_custom($authorized)."',activity=1, date = NOW(),";
63 foreach ($values as $key => $value) {
64 $sql .= " " . escape_sql_column_name($key, array($tableName)) . " = '" . add_escape_custom($value) . "',";
67 $sql = substr($sql, 0, -1);
68 $sql .= " where id='".add_escape_custom($id)."'";
70 return sqlInsert($sql);
74 function formJump($address = "0")
76 $returnurl = 'encounter_top.php';
77 if ($address == "0") {
78 $address = "{$GLOBALS['rootdir']}/patient_file/encounter/$returnurl";
80 echo "\n<script language='Javascript'>top.restoreSession();window.location='$address';</script>\n";
84 function formFetch($tableName, $id, $cols = "*", $activity = "1")
86 // Run through escape_table_name() function to support dynamic form names in addition to mitigate sql table casing issues.
87 return sqlQuery("select $cols from `" . escape_table_name($tableName) . "` where id=? and pid = ? and activity like ? order by date DESC LIMIT 0,1", array($id,$GLOBALS['pid'],$activity)) ;
90 function formGetIds($tableName, $cols = "*", $limit = 'all', $start = 0, $activity = "1")
92 if ($limit == "all") {
93 // Run through escape_table_name() function to support dynamic form names in addition to mitigate sql table casing issues.
94 $sql = "select $cols from `" . escape_table_name($tableName) . "` where pid like '$pid' ";
95 if ($activity != "all") {
96 $sql .= "and activity like '$activity' ";
99 $sql .= "order by date DESC";
101 $sql = "select $cols from pnotes where pid like '$pid' ";
102 $sql .= " AND deleted != 1 "; // exclude ALL deleted notes
103 if ($activity != "all") {
104 $sql .= "and activity like '$activity' ";
107 $sql .= "order by date DESC LIMIT $start, $limit";
110 $res = sqlStatement($sql);
112 for ($iter = 0; $row = sqlFetchArray($res); $iter++) {
119 function formDisappear($tableName, $id)
121 // Run through escape_table_name() function to support dynamic form names in addition to mitigate sql table casing issues.
122 if (sqlStatement("update `" . escape_table_name($tableName) . "` set activity = '0' where id='$id' and pid='$pid'")) {
129 function formReappear($tableName, $id)
131 // Run through escape_table_name() function to support dynamic form names in addition to mitigate sql table casing issues.
132 if (sqlStatement("update `" . escape_table_name($tableName) . "` set activity = '1' where id='$id' and pid='$pid'")) {