2 // Copyright (C) 2010 Rod Roark <rod@sunsetsystems.com>
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 require_once("../../globals.php");
10 require_once("$srcdir/api.inc");
11 require_once("$srcdir/forms.inc");
12 require_once("$srcdir/options.inc.php");
13 require_once("$srcdir/formdata.inc.php");
14 require_once("$srcdir/formatting.inc.php");
16 // Defaults for new orders.
18 'provider_id' => $_SESSION['authUserID'],
19 'date_ordered' => date('Y-m-d'),
20 'date_collected' => date('Y-m-d H:i'),
23 if (! $encounter) { // comes from globals.php
24 die("Internal error: we do not seem to be in an encounter!");
27 function cbvalue($cbname) {
28 return $_POST[$cbname] ?
'1' : '0';
31 function cbinput($name, $colname) {
33 $ret = "<input type='checkbox' name='$name' value='1'";
34 if ($row[$colname]) $ret .= " checked";
39 function cbcell($name, $desc, $colname) {
40 return "<td width='25%' nowrap>" . cbinput($name, $colname) . "$desc</td>\n";
43 function QuotedOrNull($fld) {
44 if (empty($fld)) return "NULL";
48 $formid = formData('id', 'G') +
0;
50 // If Save was clicked, save the info.
52 if ($_POST['bn_save']) {
55 "procedure_type_id = " . (formData('form_proc_type') +
0) . ", " .
56 "date_ordered = " . QuotedOrNull(formData('form_date_ordered')) . ", " .
57 "provider_id = " . (formData('form_provider_id') +
0) . ", " .
58 "date_collected = " . QuotedOrNull(formData('form_date_collected')) . ", " .
59 "order_priority = '" . formData('form_order_priority') . "', " .
60 "order_status = '" . formData('form_order_status') . "', " .
61 "patient_instructions = '" . formData('form_patient_instructions') . "', " .
62 "patient_id = '" . $pid . "', " .
63 "encounter_id = '" . $encounter . "'";
65 // If updating an existing form...
68 $query = "UPDATE procedure_order SET $sets " .
69 "WHERE procedure_order_id = '$formid'";
73 // If adding a new form...
76 $query = "INSERT INTO procedure_order SET $sets";
77 $newid = sqlInsert($query);
78 addForm($encounter, "Procedure Order", $newid, "procedure_order", $pid, $userauthorized);
81 formHeader("Redirecting....");
88 $row = sqlQuery ("SELECT * FROM procedure_order WHERE " .
89 "procedure_order_id = '$formid' AND activity = '1'") ;
92 $enrow = sqlQuery("SELECT p.fname, p.mname, p.lname, fe.date FROM " .
93 "form_encounter AS fe, forms AS f, patient_data AS p WHERE " .
94 "p.pid = '$pid' AND f.pid = '$pid' AND f.encounter = '$encounter' AND " .
95 "f.formdir = 'newpatient' AND f.deleted = 0 AND " .
96 "fe.id = f.form_id LIMIT 1");
100 <?php
html_header_show(); ?
>
101 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css" />
116 <style type
="text/css">@import
url(<?php
echo $GLOBALS['webroot'] ?
>/library
/dynarch_calendar
.css
);</style
>
117 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar.js"></script
>
118 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
119 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar_setup.js"></script
>
121 <script type
="text/javascript" src
="../../../library/dialog.js"></script
>
122 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/textformat.js"></script
>
124 <script language
='JavaScript'>
126 // This invokes the find-procedure-type popup.
128 function sel_proc_type(varname
) {
129 var f
= document
.forms
[0];
130 if (typeof varname
== 'undefined') varname
= 'form_proc_type';
132 dlgopen('../../orders/types.php?popup=1&order=' + f
[ptvarname
].value
, '_blank', 800, 500);
135 // This is for callback by the find-procedure-type popup.
136 // Sets both the selected type ID and its descriptive name.
137 function set_proc_type(typeid
, typename
) {
138 var f
= document
.forms
[0];
139 f
[ptvarname
].value
= typeid
;
140 f
[ptvarname +
'_desc'].value
= typename
;
147 <body
class="body_top">
149 <form method
="post" action
="<?php echo $rootdir ?>/forms/procedure_order/new.php?id=<?php echo $formid ?>" onsubmit
="return top.restoreSession()">
151 <p
class='title' style
='margin-top:8px;margin-bottom:8px;text-align:center'>
153 echo xl('Procedure Order for') . ' ';
154 echo $enrow['fname'] . ' ' . $enrow['mname'] . ' ' . $enrow['lname'];
155 echo ' ' . xl('on') . ' ' . oeFormatShortDate(substr($enrow['date'], 0, 10));
162 <table border
='1' width
='95%'>
165 $ptid = -1; // -1 means no order is selected yet
166 $ptrow = array('name' => '');
167 if (!empty($row['procedure_type_id'])) {
168 $ptid = $row['procedure_type_id'];
169 $ptrow = sqlQuery("SELECT name FROM procedure_type WHERE " .
170 "procedure_type_id = '$ptid'");
174 <td width
='1%' nowrap
><b
><?php
xl('Order Type','e'); ?
>:</b
></td
>
176 <input type
='text' size
='50' name
='form_proc_type_desc'
177 value
='<?php echo addslashes($ptrow['name
']) ?>'
178 onclick
='sel_proc_type()' onfocus
='this.blur()'
179 title
='<?php xl('Click to select the desired procedure
','e
'); ?>'
180 style
='width:100%;cursor:pointer;cursor:hand' readonly
/>
181 <input type
='hidden' name
='form_proc_type' value
='<?php echo $ptid ?>' />
186 <td width
='1%' nowrap
><b
><?php
xl('Ordering Provider','e'); ?
>:</b
></td
>
189 generate_form_field(array('data_type'=>10,'field_id'=>'provider_id'),
190 $row['provider_id']);
196 <td width
='1%' nowrap
><b
><?php
xl('Date Ordered','e'); ?
>:</b
></td
>
199 echo "<input type='text' size='10' name='form_date_ordered' id='form_date_ordered'" .
200 " value='" . $row['date_ordered'] . "'" .
201 " title='" . xl('Date of this order') . "'" .
202 " onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'" .
204 "<img src='$rootdir/pic/show_calendar.gif' align='absbottom' width='24' height='22'" .
205 " id='img_date_ordered' border='0' alt='[?]' style='cursor:pointer'" .
206 " title='" . xl('Click here to choose a date') . "' />";
212 <td width
='1%' nowrap
><b
><?php
xl('Internal Time Collected','e'); ?
>:</b
></td
>
215 echo "<input type='text' size='16' name='form_date_collected' id='form_date_collected'" .
216 " value='" . $row['date_collected'] . "'" .
217 " title='" . xl('Date and time that the sample was collected') . "'" .
218 // " onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'" .
220 "<img src='$rootdir/pic/show_calendar.gif' align='absbottom' width='24' height='22'" .
221 " id='img_date_collected' border='0' alt='[?]' style='cursor:pointer'" .
222 " title='" . xl('Click here to choose a date and time') . "' />";
228 <td width
='1%' nowrap
><b
><?php
xl('Priority','e'); ?
>:</b
></td
>
231 generate_form_field(array('data_type'=>1,'field_id'=>'order_priority',
232 'list_id'=>'ord_priority'), $row['order_priority']);
238 <td width
='1%' nowrap
><b
><?php
xl('Status','e'); ?
>:</b
></td
>
241 generate_form_field(array('data_type'=>1,'field_id'=>'order_status',
242 'list_id'=>'ord_status'), $row['order_status']);
248 <td width
='1%' nowrap
><b
><?php
xl('Patient Instructions','e'); ?
>:</b
></td
>
250 <textarea rows
='3' cols
='40' name
='form_patient_instructions' style
='width:100%'
251 wrap
='virtual' class='inputtext' /><?php
echo $row['patient_instructions'] ?
></textarea
>
258 <input type
='submit' name
='bn_save' value
='<?php xl('Save
','e
'); ?>' />
260 <input type
='button' value
='<?php xl('Cancel
','e
'); ?>' onclick
="top.restoreSession();location='<?php echo $GLOBALS['form_exit_url']; ?>'" />
265 <script language
='JavaScript'>
266 Calendar
.setup({inputField
:'form_date_ordered', ifFormat
:'%Y-%m-%d',
267 button
:'img_date_ordered'});
268 Calendar
.setup({inputField
:'form_date_collected', ifFormat
:'%Y-%m-%d %H:%M',
269 button
:'img_date_collected', showsTime
:true});