2 //our api for 3rd party developers
3 include_once("../../globals.php");
4 include_once("{$GLOBALS['srcdir']}/sql.inc");
5 include_once("{$GLOBALS['srcdir']}/billing.inc");
7 $GLOBALS['form_exit_url'] = $GLOBALS['concurrent_layout'] ?
8 "$rootdir/patient_file/encounter/encounter_top.php" :
9 "$rootdir/patient_file/encounter/patient_encounter.php";
11 function formHeader ($title = "My Form")
16 <? html_header_show();?>
17 <link rel=stylesheet href="<?=$GLOBALS['css_header']?>" type="text/css">
18 <title><?=$title?></title>
20 <body background="<?=$GLOBALS['backpic']?>" topmargin=0 rightmargin=0 leftmargin=2 bottommargin=0 marginwidth=2 marginheight=0>
24 function formFooter ()
32 function formSubmit ($tableName, $values, $id, $authorized = "0")
34 $sql = "insert into $tableName set pid = {$_SESSION['pid']},groupname='".$_SESSION['authProvider']."',user='".$_SESSION['authUser']."',authorized=$authorized,activity=1, date = NOW(),";
35 foreach ($values as $key => $value)
36 if (strpos($key,"openemr_net_cpt") === 0) {
37 //code to auto add cpt code
39 $code_array = split(" ",$value,2);
41 addBilling(date("Ymd"), 'CPT4', $code_array[0], $code_array[1], $_SESSION['pid'], $authorized, $_SESSION['authUserID']);
45 //case where key looks like "[a-zA-Z]*diagnosis[0-9]" which is special, it is used to auto add ICD codes
47 elseif (strpos($key,"diagnosis") == (strlen($key) -10) && !(strpos($key,"diagnosis")=== false )) {
48 //icd auto add ICD9-CM
50 $code_array = split(" ",$value,2);
51 addBilling(date("Ymd"), 'ICD9-M', $code_array[0], $code_array[1], $_SESSION['pid'], $authorized, $_SESSION['authUserID']);
55 $sql .= " $key = '$value',";
57 $sql = substr($sql, 0, -1);
58 return sqlInsert($sql);
62 function formUpdate ($tableName, $values, $id, $authorized = "0")
64 $sql = "update $tableName set pid = {$_SESSION['pid']},groupname='".$_SESSION['authProvider']."',user='".$_SESSION['authUser']."',authorized=$authorized,activity=1, date = NOW(),";
65 foreach ($values as $key => $value)
66 $sql .= " $key = '$value',";
67 $sql = substr($sql, 0, -1);
68 $sql .= " where id=$id";
70 return sqlInsert($sql);
74 function formJump ($address = "0")
76 $returnurl = $GLOBALS['concurrent_layout'] ? 'encounter_top.php' : 'patient_encounter.php';
78 $address = "{$GLOBALS['rootdir']}/patient_file/encounter/$returnurl";
79 echo "\n<script language='Javascript'>top.restoreSession();window.location='$address';</script>\n";
83 function formFetch ($tableName, $id, $cols="*", $activity="1")
85 return sqlQuery ( "select $cols from `$tableName` where id='$id' and pid = '{$GLOBALS['pid']}' and activity like '$activity' order by date DESC LIMIT 0,1" ) ;
88 function formGetIds ($tableName, $cols = "*", $limit='all', $start=0, $activity = "1")
93 $sql = "select $cols from `$tableName` where pid like '$pid' ";
94 if ($activity != "all")
95 $sql .= "and activity like '$activity' ";
96 $sql .= "order by date DESC";
100 $sql = "select $cols from pnotes where pid like '$pid' ";
101 $sql .= " AND deleted != 1 "; // exclude ALL deleted notes
102 if ($activity != "all")
103 $sql .= "and activity like '$activity' ";
104 $sql .= "order by date DESC LIMIT $start, $limit";
107 $res = sqlStatement($sql);
109 for ($iter = 0;$row = sqlFetchArray($res);$iter++)
114 function formDisappear ($tableName, $id)
116 if (sqlStatement("update `$tableName` set activity = '0' where id='$id' and pid='$pid'")) return true;
120 function formReappear ($tableName, $id)
122 if (sqlStatement("update `$tableName` set activity = '1' where id='$id' and pid='$pid'")) return true;