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");
6 function formHeader ($title = "My Form")
11 <link rel=stylesheet href="<?=$GLOBALS['css_header']?>" type="text/css">
12 <title><?=$title?></title>
14 <body background="<?=$GLOBALS['backpic']?>" topmargin=0 rightmargin=0 leftmargin=2 bottommargin=0 marginwidth=2 marginheight=0>
18 function formFooter ()
26 function formSubmit ($tableName, $values, $id, $authorized = "0")
28 $sql = "insert into $tableName set pid = {$_SESSION['pid']},groupname='".$_SESSION['authProvider']."',user='".$_SESSION['authUser']."',authorized=$authorized,activity=1, date = NOW(),";
29 while(list($key, $value) = each($values))
30 if (strpos($key,"openemr_net_cpt") === 0) {
31 //code to auto add cpt code
33 $code_array = split(" ",$value,2);
35 addBilling(date("Ymd"), 'CPT4', $code_array[0], $code_array[1], $_SESSION['pid'], $authorized, $_SESSION['authUserID']);
39 //case where key looks like "[a-zA-Z]*diagnosis[0-9]" which is special, it is used to auto add ICD codes
41 elseif (strpos($key,"diagnosis") == (strlen($key) -10) && !(strpos($key,"diagnosis")=== false )) {
42 //icd auto add ICD9-CM
44 $code_array = split(" ",$value,2);
45 addBilling(date("Ymd"), 'ICD9-M', $code_array[0], $code_array[1], $_SESSION['pid'], $authorized, $_SESSION['authUserID']);
49 $sql .= " $key = '$value',";
51 $sql = substr($sql, 0, -1);
52 return sqlInsert($sql);
56 function formUpdate ($tableName, $values, $id, $authorized = "0")
58 $sql = "update $tableName set pid = {$_SESSION['pid']},groupname='".$_SESSION['authProvider']."',user='".$_SESSION['authUser']."',authorized=$authorized,activity=1, date = NOW(),";
59 while(list($key, $value) = each($values))
60 $sql .= " $key = '$value',";
61 $sql = substr($sql, 0, -1);
62 $sql .= " where id=$id";
64 return sqlInsert($sql);
68 function formJump ($address = "0")
71 $address = "{$GLOBALS['rootdir']}/patient_file/encounter/patient_encounter.php";
73 echo "\n<script language='Javascript'>window.location='$address';</script>\n";
77 function formFetch ($tableName, $id, $cols="*", $activity="1")
79 return sqlQuery ( "select $cols from `$tableName` where id='$id' and pid = '{$GLOBALS['pid']}' and activity like '$activity' order by date DESC LIMIT 0,1" ) ;
82 function formGetIds ($tableName, $cols = "*", $limit='all', $start=0, $activity = "1")
87 $sql = "select $cols from `$tableName` where pid like '$pid' ";
88 if ($activity != "all")
89 $sql .= "and activity like '$activity' ";
90 $sql .= "order by date DESC";
94 $sql = "select $cols from pnotes where pid like '$pid' ";
95 if ($activity != "all")
96 $sql .= "and activity like '$activity' ";
97 $sql .= "order by date DESC LIMIT $start, $limit";
100 $res = sqlStatement($sql);
102 for ($iter = 0;$row = sqlFetchArray($res);$iter++)
107 function formDisappear ($tableName, $id)
109 if (sqlStatement("update `$tableName` set activity = '0' where id='$id' and pid='$pid'")) return true;
113 function formReappear ($tableName, $id)
115 if (sqlStatement("update `$tableName` set activity = '1' where id='$id' and pid='$pid'")) return true;