Help file for patient_select.php
[openemr.git] / library / api.inc
blob96772141e9a37d9f9e7bc6d58a055716edbd39c1
1 <?php
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")
13         ?>
14         <html>
15         <head>
16         <link rel=stylesheet href="<?=$GLOBALS['css_header']?>" type="text/css">
17         <title><?=$title?></title>
18         </head>
19         <body background="<?=$GLOBALS['backpic']?>" topmargin=0 rightmargin=0 leftmargin=2 bottommargin=0 marginwidth=2 marginheight=0>
20         <?php
23 function formFooter ()
25         ?>
26         </body>
27         </form>
28         <?php
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
37                         if (!empty($value)) {
38                                 $code_array = split(" ",$value,2);
39                                 
40                                 addBilling(date("Ymd"), 'CPT4', $code_array[0], $code_array[1], $_SESSION['pid'], $authorized, $_SESSION['authUserID']);
41                         }
42                                         
43                 }
44                 //case where key looks like "[a-zA-Z]*diagnosis[0-9]" which is special, it is used to auto add ICD codes
45                 
46                 elseif (strpos($key,"diagnosis") == (strlen($key) -10) && !(strpos($key,"diagnosis")=== false )) {
47                         //icd auto add ICD9-CM
48                         if (!empty($value)) {
49                                 $code_array = split(" ",$value,2);
50                                 addBilling(date("Ymd"), 'ICD9-M', $code_array[0], $code_array[1], $_SESSION['pid'], $authorized, $_SESSION['authUserID']);
51                         }
52                 }
53                 else {
54                         $sql .= " $key = '$value',";
55                 }
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";
68         
69         return sqlInsert($sql);
73 function formJump ($address = "0")
75         $returnurl = $GLOBALS['concurrent_layout'] ? 'encounter_top.php' : 'patient_encounter.php';
76         if ($address == "0")
77                 $address = "{$GLOBALS['rootdir']}/patient_file/encounter/$returnurl";
78         echo "\n<script language='Javascript'>top.restoreSession();window.location='$address';</script>\n";
79         exit;
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")
89         if($limit == "all")
90         {
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";
96         }
97         else
98         {
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";
103         }
105         $res = sqlStatement($sql);
106         
107         for ($iter = 0;$row = sqlFetchArray($res);$iter++)
108                 $all[$iter] = $row;
109         return $all;
112 function formDisappear ($tableName, $id)
114         if (sqlStatement("update `$tableName` set activity = '0' where id='$id' and pid='$pid'")) return true;
115         return false;
118 function formReappear ($tableName, $id)
120         if (sqlStatement("update `$tableName` set activity = '1' where id='$id' and pid='$pid'")) return true;
121         return false;