Highway to PSR2
[openemr.git] / library / encounter.inc
blob6d42f45a3437c8ef69109e75b169548be182a985
1 <?php
2 include_once("../../globals.php");
3 include_once("$srcdir/forms.inc");
5 //function called to set the global session variable for encounter number
6 function setencounter($enc)
8     
9     $return_val = 1;
10     global $encounter;
11     global $pid;
12     global $attendant_type;
14     $attendant_id = $attendant_type == 'pid' ? $pid : $_SESSION['therapy_group'];
15     if ($enc == "") {
16         $enc = date("Ymd");
17         if (getFormByEncounter($attendant_id, $enc)) {
18             //there is an encounter enterred for today
19         } else {
20             //addForm($enc, "New Patient Encounter", 0, $pid, 1);
21             $return_val = 0;
22         }
23     }
24     
25     $_SESSION['encounter']=$enc;
26     $encounter=$enc;
27     
28     
29     //returns 1 on successful global set, or 0 if there was no
30     //current encounter, signifying that the interface should load
31     //the screen for a new encounter
32     return $return_val;
36 //fetches encounter pc_catid by encounter number
37 function fetchCategoryIdByEncounter($encounter)
39     global $attendant_type;
40     $table = $attendant_type == 'pid' ? 'form_encounter' : 'form_groups_encounter';
41     $sql = "select pc_catid from $table where encounter=? limit 1";
42     $result = sqlQuery($sql, array($encounter));
43     return $result['pc_catid'];