-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrug_samples.emr.module.php
135 lines (117 loc) · 3.42 KB
/
drug_samples.emr.module.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
// $Id$
// $Author$
LoadObjectDependency('_FreeMED.EMRModule');
class DrugSamples extends EMRModule {
var $MODULE_NAME = "Drug Samples";
var $MODULE_VERSION = "0.1.1";
var $MODULE_AUTHOR = "jeff b ([email protected])";
var $MODULE_FILE = __FILE__;
var $PACKAGE_MINIMUM_VERSION = '0.7.0';
var $record_name = "Drug Samples";
var $table_name = "drugsamples";
var $patient_field = "patientid";
var $order_field = "drugsampleid";
function DrugSamples ( ) {
$this->summary_vars = array (
__("Lot") => 'drugsampleid:drugsampleinv:lot',
__("Drug") => 'drugsampleid:drugsampleinv:drugformal',
__("Amount") => 'amount'
);
$this->table_definition = array (
"drugsampleid" => SQL__INT_UNSIGNED(0),
"patientid" => SQL__INT_UNSIGNED(0),
"prescriber" => SQL__INT_UNSIGNED(0),
"deliveryform" => SQL__VARCHAR(50),
"amount" => SQL__INT_UNSIGNED(0),
"instructions" => SQL__TEXT,
"id" => SQL__SERIAL
);
$this->variables = array (
'drugsampleid',
'patientid' => $_REQUEST['patient'],
'prescriber',
'deliveryform' => html_form::combo_assemble('deliveryform'),
'amount',
'instructions'
);
$this->EMRModule(); // won't work without this line
} // end constructor
function add ( $_param = NULL ) {
$this->_add($_param);
} // end method add
function _preadd ( $_param = NULL ) {
// Deduct appropriate amount from sample inventory
module_function (
'DrugSampleInventory',
'deduct',
array(
$_REQUEST['drugsampleid'], $_REQUEST['amount']
)
);
} // end method _preadd
function form_table ( ) {
return array (
__("Drug Sample Lot") => module_function(
'DrugSampleInventory',
'widget',
array ('drugsampleid')
),
__("Prescriber") => module_function(
'ProviderModule',
'widget',
array ('prescriber')
),
__("Delivery Form") => html_form::combo_widget(
'deliveryform',
$GLOBALS['sql']->distinct_values(
$this->table_name,
'deliveryform'
)
),
__("Amount (numeric)") => html_form::text_widget(
'amount'
),
__("Instructions") => html_form::text_area('instructions')
);
} // end method form
function view () {
global $display_buffer;
global $patient, $action;
foreach ($GLOBALS AS $k => $v) { global ${$k}; }
// Check for "view" action (actually display)
if ($action=="view") {
$this->display();
return NULL;
}
$display_buffer .= freemed_display_itemlist(
$sql->query(
"SELECT * FROM ".$this->table_name." ".
"WHERE (".$this->patient_field."='".addslashes($patient)."') ".
freemed::itemlist_conditions(false)." ".
( $condition ? 'AND '.$condition : '' )." ".
"ORDER BY ".$this->order_field
),
$this->page_name,
array (
__("Lot") => 'drugsampleid',
__("Drug") => 'drugsampleid',
__("Amount") => 'amount'
),
array (
"",
"",
""
),
array (
"drugsampleinv" => 'lot',
"drugsampleinv " => 'drugformal',
""
),
NULL,
ITEMLIST_MOD | ITEMLIST_DEL
);
} // end method view
} // end class DrugSamples
register_module("DrugSamples");
?>