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