forked from timschofield/care2x
-
Notifications
You must be signed in to change notification settings - Fork 0
/
discharge.php
executable file
·43 lines (34 loc) · 1.43 KB
/
discharge.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/php
<?php
include ('./include/inc_init_main.php');
if ( $argc != 3 ) {
echo "Usage of this script:\n ./discharge.php ecnounter_class c2x-username\n";
echo "encouter_class=1 for Inpatient, 2 for Outpatient";
die();
}
$encounter_class = $argv[1];
$username = $argv[2];
echo "Are you shure, you want to discharge ALL patients with\n";
echo "encounter_class $encounter_class and username $username?\n";
echo "Enter YES for procedeing:";
echo "\n";
if ($fp=fopen("php://stdin","r")) {
$line = fgets($fp,4096);
}
fclose($fp);
if ($line != "YES\n") {
die ("Not saying YES: Not discharging patients.\n");
}
$db = mysql_connect($dbhost,$dbusername,$dbpassword) or die ("No connection: " . mysql_error());
mysql_select_db($dbname,$db) or die ("Wrong database: " . mysql_error());
$sql="UPDATE care_encounter SET is_discharged = '1',
status='discharged',
discharge_date = '".date('Y-m-d')."',
discharge_time = '".date('H:i:s')."',
history ='"."Update (discharged): " .date('Y-m-d H:i:s'). " ". $username ."',
modify_id='" . $username . "'
WHERE is_discharged='0' AND encounter_class_nr='".$encounter_class."'";
mysql_query($sql) or die ("SQL Error: " . mysql_error());
echo "I am just pleased as punch to inform you that ".mysql_affected_rows($db)." Patients have been discharged.\n";
die();
?>