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 <link rel=stylesheet href="<?=$GLOBALS['css_header']?>" type="text/css">
17 <title><?=$title?></title>
19 <body background="<?=$GLOBALS['backpic']?>" topmargin=0 rightmargin=0 leftmargin=2 bottommargin=0 marginwidth=2 marginheight=0>
23 function formFooter ()
31 function formSubmit ($tableName, $values, $id, $authorized = "0")
33 $sql = "insert into $tableName set pid = {$_SESSION['pid']},groupname='".$_SESSION['authProvider']."',user='".$_SESSION['authUser']."',authorized=$authorized,activity=1, date = NOW(),";
34 while(list($key, $value) = each($values))
35 if (strpos($key,"openemr_net_cpt") === 0) {
36 //code to auto add cpt code
38 $code_array = split(" ",$value,2);
40 addBilling(date("Ymd"), 'CPT4', $code_array[0], $code_array[1], $_SESSION['pid'], $authorized, $_SESSION['authUserID']);
44 //case where key looks like "[a-zA-Z]*diagnosis[0-9]" which is special, it is used to auto add ICD codes
46 elseif (strpos($key,"diagnosis") == (strlen($key) -10) && !(strpos($key,"diagnosis")=== false )) {
47 //icd auto add ICD9-CM
49 $code_array = split(" ",$value,2);
50 addBilling(date("Ymd"), 'ICD9-M', $code_array[0], $code_array[1], $_SESSION['pid'], $authorized, $_SESSION['authUserID']);
54 $sql .= " $key = '$value',";
56 $sql = substr($sql, 0, -1);
57 return sqlInsert($sql);
61 function formUpdate ($tableName, $values, $id, $authorized = "0")
63 $sql = "update $tableName set pid = {$_SESSION['pid']},groupname='".$_SESSION['authProvider']."',user='".$_SESSION['authUser']."',authorized=$authorized,activity=1, date = NOW(),";
64 while(list($key, $value) = each($values))
65 $sql .= " $key = '$value',";
66 $sql = substr($sql, 0, -1);
67 $sql .= " where id=$id";
69 return sqlInsert($sql);
73 function formJump ($address = "0")
75 $returnurl = $GLOBALS['concurrent_layout'] ? 'encounter_top.php' : 'patient_encounter.php';
77 $address = "{$GLOBALS['rootdir']}/patient_file/encounter/$returnurl";
78 echo "\n<script language='Javascript'>top.restoreSession();window.location='$address';</script>\n";
82 function formFetch ($tableName, $id, $cols="*", $activity="1")
84 return sqlQuery ( "select $cols from `$tableName` where id='$id' and pid = '{$GLOBALS['pid']}' and activity like '$activity' order by date DESC LIMIT 0,1" ) ;
87 function formGetIds ($tableName, $cols = "*", $limit='all', $start=0, $activity = "1")
92 $sql = "select $cols from `$tableName` where pid like '$pid' ";
93 if ($activity != "all")
94 $sql .= "and activity like '$activity' ";
95 $sql .= "order by date DESC";
99 $sql = "select $cols from pnotes where pid like '$pid' ";
100 if ($activity != "all")
101 $sql .= "and activity like '$activity' ";
102 $sql .= "order by date DESC LIMIT $start, $limit";
105 $res = sqlStatement($sql);
107 for ($iter = 0;$row = sqlFetchArray($res);$iter++)
112 function formDisappear ($tableName, $id)
114 if (sqlStatement("update `$tableName` set activity = '0' where id='$id' and pid='$pid'")) return true;
118 function formReappear ($tableName, $id)
120 if (sqlStatement("update `$tableName` set activity = '1' where id='$id' and pid='$pid'")) return true;