Prescriptions Fix up. (#1328)
[openemr.git] / templates / prescription / general_edit.html
blobc4f555b37036c9126c3b679cdcafd80fa1bcf9a0
1 {**
2 * Prescription edit
4 * @package OpenEMR
5 * @link http://www.open-emr.org
6 * @author Brady Miller <brady.g.miller@gmail.com>
7 * @copyright Copyright (c) 2017 Brady Miller <brady.g.miller@gmail.com>
8 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
9 *}
10 <!DOCTYPE html>
11 <html>
12 <head>
14 {headerTemplate assets='jquery-ui'}
15 <link rel="stylesheet" href="{$GLOBALS.assets_static_relative}/jquery-ui-1-12-1/themes/base/jquery-ui.min.css" type="text/css" />
17 {literal}
18 <style type="text/css">
21 input{
22 margin: 5px;
24 select{
25 margin: 5px;
27 </style>
28 {/literal}
29 <script language="Javascript">
31 {literal}
32 function my_process () {
33 // Pass the variable
34 opener.document.prescribe.drug.value = document.lookup.drug.value;
35 // Close the window
36 window.self.close();
38 {/literal}
39 </script>
40 <!---Gen Look up-->
41 {literal}
42 <script language='JavaScript'>
44 // This holds all the default drug attributes.
45 // This was html escaped previously
46 {/literal}
47 var drugopts = [{$DRUG_ATTRIBUTES}];
48 {literal}
50 // Helper to choose an option from its value.
51 function selchoose(sel, value) {
52 var o = sel.options;
53 for (i = 0; i < o.length; ++i) {
54 o[i].selected = (o[i].value == value);
58 // Fill in default values when a drop-down drug is selected.
59 function drugselected(sel) {
60 var f = document.forms[0];
61 var i = f.drug_id.selectedIndex - 1;
62 if (i >= 0) {
63 var d = drugopts[i];
64 f.drug.value = d[0];
65 selchoose(f.form, d[1]);
66 f.dosage.value = d[2];
67 f.size.value = d[3];
68 f.rxnorm_drugcode.value = d[11];
69 selchoose(f.unit, d[4]);
70 selchoose(f.route, d[5]);
71 selchoose(f.interval, d[6]);
72 selchoose(f.substitute, d[7]);
73 f.quantity.value = d[8];
74 f.disp_quantity.value = d[8];
75 selchoose(f.refills, d[9]);
76 f.per_refill.value = d[10];
80 // Invoke the popup to dispense a drug.
81 function dispense() {
82 var f = document.forms[0];
83 dlgopen('interface/drugs/dispense_drug.php' +
84 {/literal}'?drug_id={$prescription->get_drug_id()}' +{literal}
85 '&prescription=' + f.id.value +
86 '&quantity=' + f.disp_quantity.value +
87 '&fee=' + f.disp_fee.value,
88 '_blank', 400, 200);
91 function quantityChanged() {
92 var f = document.forms[0];
93 f.per_refill.value = f.quantity.value;
94 if (f.disp_quantity) {
95 f.disp_quantity.value = f.quantity.value;
99 </script>
100 {/literal}
101 </head>
102 <body class="body_top">
104 <form name="prescribe" id="prescribe" method="post" action="{$FORM_ACTION}" >
105 <table>
106 <tr><td class="title"><font><b>{xl t='Add'|escape:'html'}/{xl t='Edit'|escape:'html'}</b></font>&nbsp;</td>
107 <td><a href=# onclick="submitfun();" class="css_button_small"><span>{xl t='Save'|escape:'html'}</span></a>
108 {if $DRUG_ARRAY_VALUES}
109 &nbsp; &nbsp; &nbsp; &nbsp;
110 {if $prescription->get_refills() >= $prescription->get_dispensation_count()}
111 <input type="submit" name="disp_button"class='css_button_small' style="margin:0 5px 0 2px;" value="{xl t='Save and Dispense'|escape:'html'}" />
112 <input class="input-sm" type="text" name="disp_quantity" size="2" maxlength="10" value="{$DISP_QUANTITY|escape:'html'}" />
113 units, $
114 <input class="input-sm" type="text" name="disp_fee" size="5" maxlength="10" value="{$DISP_FEE|escape:'html'}" />
115 {else}&nbsp;
116 {xl t='prescription has reached its limit of'|escape:'html'} {$prescription->get_refills()|escape:'html'} {xl t='refills'|escape:'html'}.
117 {/if}
118 {/if}
119 <a class='css_button_small' href="controller.php?prescription&list&id={$prescription->patient->id|escape:'html'}"><span>{xl t='Back'|escape:'html'}</span></a>
120 </td></tr>
121 </table>
123 {if $GLOBALS.enable_amc_prompting}
124 <div style='float:right;margin-right:25px;border-style:solid;border-width:1px;'>
125 <div style='float:left;margin:5px 5px 5px 5px;'>
126 {amcCollect amc_id='e_prescribe_amc' patient_id=$prescription->patient->id object_category='prescriptions' object_id=$prescription->id}
127 {if not $amcCollectReturn}
128 <input type="checkbox" id="escribe_flag" name="escribe_flag">
129 {else}
130 <input type="checkbox" id="escribe_flag" name="escribe_flag" checked>
131 {/if}
132 <span class="text">{xl t='E-Prescription?'|escape:'html'}</span><br>
134 {amcCollect amc_id='e_prescribe_chk_formulary_amc' patient_id=$prescription->patient->id object_category='prescriptions' object_id=$prescription->id}
135 {if not $amcCollectReturn}
136 <input type="checkbox" id="checked_formulary_flag" name="checked_formulary_flag">
137 {else}
138 <input type="checkbox" id="checked_formulary_flag" name="checked_formulary_flag" checked>
139 {/if}
140 <span class="text">{xl t='Checked Drug Formulary?'|escape:'html'}</span><br>
142 {amcCollect amc_id='e_prescribe_cont_subst_amc' patient_id=$prescription->patient->id object_category='prescriptions' object_id=$prescription->id}
143 {if not $amcCollectReturn}
144 <input type="checkbox" id="controlled_substance_flag" name="controlled_substance_flag">
145 {else}
146 <input type="checkbox" id="controlled_substance_flag" name="controlled_substance_flag" checked>
147 {/if}
148 <span class="text">{xl t='Controlled Substance?'|escape:'html'}</span><br>
150 </div>
151 </div>
152 {/if}
154 <table CELLSPACING="0" CELLPADDING="3" BORDER="0">
155 <tr>
156 <td COLSPAN="1" class="text input-sm" ALIGN="right" VALIGN="MIDDLE" >{xl t='Currently Active'|escape:'html'}</td>
157 <td COLSPAN="2" ALIGN="LEFT" VALIGN="MIDDLE" >
158 <input class="input-sm"type="checkbox" name="active" value="1"{if $prescription->get_active() > 0} checked{/if} />
159 </td>
160 </tr>
161 <tr>
162 <td COLSPAN="1" class="text" ALIGN="right" VALIGN="MIDDLE" >{xl t='Starting Date'|escape:'html'}</td>
163 <td COLSPAN="2" ALIGN="LEFT" VALIGN="MIDDLE" >
164 {html_select_date class="input-sm" start_year="-10" end_year="+5" time=$prescription->start_date prefix="start_date_"}
165 <input type="hidden" name="start_date" value="{$prescription->start_date|escape:'html'}">
166 </td>
167 </tr>
168 <tr>
169 <td COLSPAN="1" class="text" ALIGN="right" VALIGN="MIDDLE" >{xl t='Provider'|escape:'html'}</td>
170 <td COLSPAN="2" ALIGN="LEFT" VALIGN="MIDDLE" >
171 {html_options class="input-sm" name="provider_id" options=$prescription->provider->utility_provider_array() selected=$prescription->provider->get_id()}
172 <input type="hidden" name="patient_id" value="{$prescription->patient->id|escape:'html'}" />
173 </td>
174 </tr>
176 <tr>
177 <td COLSPAN="1" class="text" ALIGN="right" VALIGN="MIDDLE" >{xl t='Drug'|escape:'html'}</td>
178 <td COLSPAN="2" ALIGN="LEFT" VALIGN="MIDDLE" >
179 <input class="input-sm" type="input" size="35" name="drug" id="drug" value="{$prescription->drug|escape:'html'}"/>
180 <a href="javascript:;" id="druglookup" class="small" name="B4" onclick="$('#hiddendiv').show(); document.getElementById('hiddendiv').innerHTML='&lt;iframe src=&quot;controller.php?prescription&amp;lookup&amp;drug=&quot; width=&quot;100%&quot;height=&quot;75&quot; scrolling=&quot;no&quot; frameborder=&quot;no&quot;&gt;&lt;/iframe&gt;'">
181 ({xl t='click here to search'|escape:'html'})</a>
182 <div class="well well-sm" id="hiddendiv" style="display:none">&nbsp;</div>
183 </td>
184 </tr>
185 {if $DRUG_ARRAY_VALUES}
186 <tr>
187 <td COLSPAN="1" class="text" ALIGN="right" VALIGN="MIDDLE" >&nbsp; {xl t='in-house'|escape:'html'}</td>
188 <td COLSPAN="2" ALIGN="LEFT" VALIGN="MIDDLE" >
189 <select class="input-sm" name="drug_id" onchange="drugselected(this)">
190 {html_options values=$DRUG_ARRAY_VALUES output=$DRUG_ARRAY_OUTPUT selected=$prescription->get_drug_id()}
191 </select>
192 <input type="hidden" name="rxnorm_drugcode" value="{$prescription->rxnorm_drugcode|escape:'html'}">
193 </td>
194 </tr>
195 {/if}
196 <tr>
197 <td COLSPAN="1" class="text" ALIGN="right" VALIGN="MIDDLE" >{xl t='Quantity'|escape:'html'}</td>
198 <td COLSPAN="2" ALIGN="LEFT" VALIGN="MIDDLE" >
199 <input class="input-sm" TYPE="TEXT" NAME="quantity" id="quantity" SIZE="10" MAXLENGTH="31"
200 VALUE="{$prescription->quantity|escape:'html'}"
201 onchange="quantityChanged()" />
202 </td>
203 </tr>
204 {if $SIMPLIFIED_PRESCRIPTIONS && !$prescription->size}
205 <tr style='display:none;'>
206 {else}
207 <tr>
208 {/if}
209 <td COLSPAN="1" class="text" ALIGN="right" VALIGN="MIDDLE" >{xl t='Medicine Units'|escape:'html'}</td>
210 <td COLSPAN="2" ALIGN="LEFT" VALIGN="MIDDLE" >
211 <input class="input-sm" TYPE="TEXT" NAME="size" id="size" SIZE="11" MAXLENGTH="10" VALUE="{$prescription->size|escape:'html'}"/>
212 <select class="input-sm" name="unit" id="unit">{html_options options=$prescription->unit_array selected=$prescription->unit}</select>
213 </td>
214 </tr>
215 <tr>
216 <td COLSPAN="1" class="text" ALIGN="right" VALIGN="MIDDLE" >{xl t='Directions'|escape:'html'}</td>
217 <td COLSPAN="2" class="text" ALIGN="LEFT" VALIGN="MIDDLE" >
218 {if $SIMPLIFIED_PRESCRIPTIONS && !$prescription->form && !$prescription->route && !$prescription->interval}
219 <input class="input-sm" TYPE="text" NAME="dosage" id="dosage" SIZE="30" MAXLENGTH="100" VALUE="{$prescription->dosage|escape:'html'}" />
220 <input type="hidden" name="form" id="form" value="0" />
221 <input type="hidden" name="route" id="route" value="0" />
222 <input type="hidden" name="interval" id="interval" value="0" />
223 {else}
224 <input class="input-sm" TYPE="TEXT" NAME="dosage" id="dosage" SIZE="2" MAXLENGTH="10" VALUE="{$prescription->dosage|escape:'html'}"/> {xl t='in'|escape:'html'}
225 <select class="input-sm" name="form" id="form">{html_options options=$prescription->form_array selected=$prescription->form}</select>
226 <select class="input-sm" name="route" id="route">{html_options options=$prescription->route_array selected=$prescription->route}</select>
227 <select class="input-sm" name="interval" id="interval">{html_options options=$prescription->interval_array selected=$prescription->interval}</select>
228 {/if}
229 </td>
230 </tr>
231 <tr>
232 <td COLSPAN="1" class="text" ALIGN="right" VALIGN="MIDDLE" >{xl t='Refills'|escape:'html'}</td>
233 <td COLSPAN="2" class="text" ALIGN="LEFT" VALIGN="MIDDLE" >
234 {html_options name="refills" options=$prescription->refills_array selected=$prescription->refills}
235 {if $SIMPLIFIED_PRESCRIPTIONS}
236 <input TYPE="hidden" ID="per_refill" NAME="per_refill" VALUE="{$prescription->per_refill|escape:'html'}" />
237 {else}
238 &nbsp; &nbsp; # {xl t='of tablets'}:
239 <input class="input-sm" TYPE="TEXT" ID="per_refill" NAME="per_refill" SIZE="2" MAXLENGTH="10" VALUE="{$prescription->per_refill|escape:'html'}" />
240 {/if}
241 </td>
242 </tr>
243 <tr>
244 <td COLSPAN="1" class="text" ALIGN="right" VALIGN="MIDDLE" >{xl t='Notes'|escape:'html'}</td>
245 <td COLSPAN="2" class="text" ALIGN="LEFT" VALIGN="MIDDLE" >
246 <textarea class="form-control" name="note" cols="30" rows="1" wrap="virtual">{$prescription->note|escape:'html'}</textarea>
247 </td>
248 </tr>
249 <tr>
250 {if $WEIGHT_LOSS_CLINIC}
251 <td COLSPAN="1" class="text" ALIGN="right" VALIGN="MIDDLE" >{xl t='Substitution'|escape:'html'}</td>
252 <td COLSPAN="2" ALIGN="LEFT" VALIGN="MIDDLE" >
253 {html_options name="substitute" options=$prescription->substitute_array selected=$prescription->substitute}
254 </td>
255 {else}
256 <td COLSPAN="1" class="text input-sm" ALIGN="right" VALIGN="MIDDLE" >{xl t='Add to Medication List'|escape:'html'}</td>
257 <td COLSPAN="2" class="text input-sm" ALIGN="LEFT" VALIGN="MIDDLE" >
258 {html_radios class="input-sm" name="medication" options=$prescription->medication_array selected=$prescription->medication}
259 &nbsp; &nbsp;
260 {html_options class="input-sm" name="substitute" options=$prescription->substitute_array selected=$prescription->substitute}
261 </td>
262 {/if}
263 </tr>
264 </table>
265 <input type="hidden" name="id" value="{$prescription->id|escape:'html'}" />
266 <input type="hidden" name="process" value="{$PROCESS|escape:'html'}" />
267 <script language='JavaScript'>
268 {$ENDING_JAVASCRIPT}
269 </script>
270 </form>
272 {literal}
273 <!-- for the fancy jQuery stuff -->
274 <script type="text/javascript">
276 function submitfun() {
277 top.restoreSession();
278 if (CheckForErrors(this)) {
279 document.forms["prescribe"].submit();
281 else {
282 return false;
286 function iframetopardiv(string){
287 var name=string
288 document.getElementById('drug').value=name;
289 $("#hiddendiv").html( "&nbsp;" );
290 $('#hiddendiv').hide();
293 function cancelParlookup () {
294 $('#hiddendiv').hide();
295 $("#hiddendiv").html( "&nbsp;" );
298 $().ready(function() {
300 {/literal}
301 {if $GLOBALS.weno_rx_enable}
302 {literal}
303 $('#drug').autocomplete({
304 source: 'library/ajax/drug_autocomplete/search.php',
305 minLength: 3
307 {/literal}
308 {else}
309 {literal}
310 $('#drug').autocomplete({
311 source: 'library/ajax/prescription_drugname_lookup.php',
312 minLength: 1
314 {/literal}
315 {/if}
316 {literal}
318 $("#drug").focus();
319 $("#prescribe").submit(function() { return CheckForErrors(this) });
322 // check the form for required fields before submitting
323 var CheckForErrors = function(eObj) {
324 // REQUIRED FIELDS
325 if (CheckRequired('drug') == false) { return false; }
326 if (CheckRequired('quantity') == false) { return false; }
327 //if (CheckRequired('unit') == false) { return false; }
328 //if (CheckRequired('size') == false) { return false; }
329 if (CheckRequired('dosage') == false) { return false; }
330 //if (CheckRequired('form') == false) { return false; }
331 //if (CheckRequired('route') == false) { return false; }
332 //if (CheckRequired('interval') == false) { return false; }
334 return top.restoreSession();
337 function CheckRequired(objID) {
339 // for text boxes
340 if ($('#'+objID).is('input')) {
341 if ($('#'+objID).val() == "") {
342 alert("{/literal}{xl t='Missing a required field and will be highlighted'}{literal}");
343 $('#'+objID).css("backgroundColor", "pink");
344 return false;
348 // for select boxes
349 if ($('#'+objID).is('select')) {
350 if ($('#'+objID).val() == "0") {
351 alert("{/literal}{xl t='Missing a required field'}{literal}");
352 $('#'+objID).css("backgroundColor", "pink");
353 return false;
357 return true;
360 </script>
361 {/literal}
363 </html>