Initialize drug list correctly for weno.
[openemr.git] / templates / prescription / general_edit.html
blobed569231f86e093fd69a53cf552c2eff3e8c1a69
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 <html>
11 <head>
13 {headerShow}
15 <link rel="stylesheet" href="{$GLOBALS.css_header}" type="text/css">
16 <link rel="stylesheet" href="{$GLOBALS.assets_static_relative}/jquery-ui-1-12-1/themes/base/jquery-ui.min.css" type="text/css" />
18 {literal}
19 <style type="text/css">
22 input{
23 margin: 5px;
25 select{
26 margin: 5px;
28 </style>
29 {/literal}
30 <script language="Javascript">
32 {literal}
33 function my_process () {
34 // Pass the variable
35 opener.document.prescribe.drug.value = document.lookup.drug.value;
36 // Close the window
37 window.self.close();
39 {/literal}
40 </script>
41 {literal}
42 {/literal}
43 <!---Gen Look up-->
44 <script type="text/javascript" src="{$GLOBALS.assets_static_relative}/jquery-min-3-1-1/index.js"></script>
45 <script type="text/javascript" src="{$GLOBALS.webroot}/library/dialog.js?v={$GLOBALS.v_js_includes}"></script>
46 <script type="text/javascript" src="{$GLOBALS.assets_static_relative}/jquery-ui-1-12-1/jquery-ui.js"></script>
48 {literal}
49 <script language='JavaScript'>
51 // This holds all the default drug attributes.
52 // This was html escaped previously
53 {/literal}
54 var drugopts = [{$DRUG_ATTRIBUTES}];
55 {literal}
57 // Helper to choose an option from its value.
58 function selchoose(sel, value) {
59 var o = sel.options;
60 for (i = 0; i < o.length; ++i) {
61 o[i].selected = (o[i].value == value);
65 // Fill in default values when a drop-down drug is selected.
66 function drugselected(sel) {
67 var f = document.forms[0];
68 var i = f.drug_id.selectedIndex - 1;
69 if (i >= 0) {
70 var d = drugopts[i];
71 f.drug.value = d[0];
72 selchoose(f.form, d[1]);
73 f.dosage.value = d[2];
74 f.size.value = d[3];
75 f.rxnorm_drugcode.value = d[11];
76 selchoose(f.unit, d[4]);
77 selchoose(f.route, d[5]);
78 selchoose(f.interval, d[6]);
79 selchoose(f.substitute, d[7]);
80 f.quantity.value = d[8];
81 f.disp_quantity.value = d[8];
82 selchoose(f.refills, d[9]);
83 f.per_refill.value = d[10];
87 // Invoke the popup to dispense a drug.
88 function dispense() {
89 var f = document.forms[0];
90 dlgopen('interface/drugs/dispense_drug.php' +
91 {/literal}'?drug_id={$prescription->get_drug_id()}' +{literal}
92 '&prescription=' + f.id.value +
93 '&quantity=' + f.disp_quantity.value +
94 '&fee=' + f.disp_fee.value,
95 '_blank', 400, 200);
98 function quantityChanged() {
99 var f = document.forms[0];
100 f.per_refill.value = f.quantity.value;
101 if (f.disp_quantity) {
102 f.disp_quantity.value = f.quantity.value;
106 </script>
107 {/literal}
108 </head>
109 <body class="body_top">
111 <form name="prescribe" id="prescribe" method="post" action="{$FORM_ACTION}" >
112 <table>
113 <tr><td class="title"><font><b>{xl t='Add'|escape:'html'}/{xl t='Edit'|escape:'html'}</b></font>&nbsp;</td>
114 <td><a href=# onclick="submitfun();" class="css_button_small"><span>{xl t='Save'|escape:'html'}</span></a>
115 {if $DRUG_ARRAY_VALUES}
116 &nbsp; &nbsp; &nbsp; &nbsp;
117 {if $prescription->get_refills() >= $prescription->get_dispensation_count()}
118 <input type="submit" name="disp_button" value="{xl t='Save and Dispense'|escape:'html'}" />
119 <input type="text" name="disp_quantity" size="2" maxlength="10" value="{$DISP_QUANTITY|escape:'html'}" />
120 units, $
121 <input type="text" name="disp_fee" size="5" maxlength="10" value="{$DISP_FEE|escape:'html'}" />
122 {else}&nbsp;
123 {xl t='prescription has reached its limit of'|escape:'html'} {$prescription->get_refills()|escape:'html'} {xl t='refills'|escape:'html'}.
124 {/if}
125 {/if}
126 <a class='css_button_small' href="controller.php?prescription&list&id={$prescription->patient->id|escape:'html'}"><span>{xl t='Back'|escape:'html'}</span></a>
127 </td></tr>
128 </table>
130 {if $GLOBALS.enable_amc_prompting}
131 <div style='float:right;margin-right:25px;border-style:solid;border-width:1px;'>
132 <div style='float:left;margin:5px 5px 5px 5px;'>
133 {amcCollect amc_id='e_prescribe_amc' patient_id=$prescription->patient->id object_category='prescriptions' object_id=$prescription->id}
134 {if not $amcCollectReturn}
135 <input type="checkbox" id="escribe_flag" name="escribe_flag">
136 {else}
137 <input type="checkbox" id="escribe_flag" name="escribe_flag" checked>
138 {/if}
139 <span class="text">{xl t='E-Prescription?'|escape:'html'}</span><br>
141 {amcCollect amc_id='e_prescribe_chk_formulary_amc' patient_id=$prescription->patient->id object_category='prescriptions' object_id=$prescription->id}
142 {if not $amcCollectReturn}
143 <input type="checkbox" id="checked_formulary_flag" name="checked_formulary_flag">
144 {else}
145 <input type="checkbox" id="checked_formulary_flag" name="checked_formulary_flag" checked>
146 {/if}
147 <span class="text">{xl t='Checked Drug Formulary?'|escape:'html'}</span><br>
149 {amcCollect amc_id='e_prescribe_cont_subst_amc' patient_id=$prescription->patient->id object_category='prescriptions' object_id=$prescription->id}
150 {if not $amcCollectReturn}
151 <input type="checkbox" id="controlled_substance_flag" name="controlled_substance_flag">
152 {else}
153 <input type="checkbox" id="controlled_substance_flag" name="controlled_substance_flag" checked>
154 {/if}
155 <span class="text">{xl t='Controlled Substance?'|escape:'html'}</span><br>
157 </div>
158 </div>
159 {/if}
161 <table CELLSPACING="0" CELLPADDING="3" BORDER="0">
162 <tr>
163 <td COLSPAN="1" class="text" ALIGN="right" VALIGN="MIDDLE" >{xl t='Currently Active'|escape:'html'}</td>
164 <td COLSPAN="2" ALIGN="LEFT" VALIGN="MIDDLE" >
165 <input type="checkbox" name="active" value="1"{if $prescription->get_active() > 0} checked{/if} />
166 </td>
167 </tr>
168 <tr>
169 <td COLSPAN="1" class="text" ALIGN="right" VALIGN="MIDDLE" >{xl t='Starting Date'|escape:'html'}</td>
170 <td COLSPAN="2" ALIGN="LEFT" VALIGN="MIDDLE" >
171 {html_select_date start_year="-10" end_year="+5" time=$prescription->start_date prefix="start_date_"}
172 <input type="hidden" name="start_date" value="{$prescription->start_date|escape:'html'}">
173 </td>
174 </tr>
175 <tr>
176 <td COLSPAN="1" class="text" ALIGN="right" VALIGN="MIDDLE" >{xl t='Provider'|escape:'html'}</td>
177 <td COLSPAN="2" ALIGN="LEFT" VALIGN="MIDDLE" >
178 {html_options name="provider_id" options=$prescription->provider->utility_provider_array() selected=$prescription->provider->get_id()}
179 <input type="hidden" name="patient_id" value="{$prescription->patient->id|escape:'html'}" />
180 </td>
181 </tr>
183 <tr>
184 <td COLSPAN="1" class="text" ALIGN="right" VALIGN="MIDDLE" >{xl t='Drug'|escape:'html'}</td>
185 <td COLSPAN="2" ALIGN="LEFT" VALIGN="MIDDLE" >
186 <input type="input" size="20" name="drug" id="drug" value="{$prescription->drug|escape:'html'}"/>
187 <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;52&quot; scrolling=&quot;no&quot; frameborder=&quot;no&quot;&gt;&lt;/iframe&gt;'">
188 ({xl t='click here to search'|escape:'html'})</a>
189 <div id=hiddendiv style="display:none">&nbsp;</div>
190 </td>
191 </tr>
192 {if $DRUG_ARRAY_VALUES}
193 <tr>
194 <td COLSPAN="1" class="text" ALIGN="right" VALIGN="MIDDLE" >&nbsp; {xl t='in-house'|escape:'html'}</td>
195 <td COLSPAN="2" ALIGN="LEFT" VALIGN="MIDDLE" >
196 <select name="drug_id" onchange="drugselected(this)">
197 {html_options values=$DRUG_ARRAY_VALUES output=$DRUG_ARRAY_OUTPUT selected=$prescription->get_drug_id()}
198 </select>
199 <input type="hidden" name="rxnorm_drugcode" value="{$prescription->rxnorm_drugcode|escape:'html'}">
200 </td>
201 </tr>
202 {/if}
203 <tr>
204 <td COLSPAN="1" class="text" ALIGN="right" VALIGN="MIDDLE" >{xl t='Quantity'|escape:'html'}</td>
205 <td COLSPAN="2" ALIGN="LEFT" VALIGN="MIDDLE" >
206 <input TYPE="TEXT" NAME="quantity" id="quantity" SIZE="10" MAXLENGTH="31"
207 VALUE="{$prescription->quantity|escape:'html'}"
208 onchange="quantityChanged()" />
209 </td>
210 </tr>
211 {if $SIMPLIFIED_PRESCRIPTIONS && !$prescription->size}
212 <tr style='display:none;'>
213 {else}
214 <tr>
215 {/if}
216 <td COLSPAN="1" class="text" ALIGN="right" VALIGN="MIDDLE" >{xl t='Medicine Units'|escape:'html'}</td>
217 <td COLSPAN="2" ALIGN="LEFT" VALIGN="MIDDLE" >
218 <input TYPE="TEXT" NAME="size" id="size" SIZE="11" MAXLENGTH="10" VALUE="{$prescription->size|escape:'html'}"/>
219 <select name="unit" id="unit">{html_options options=$prescription->unit_array selected=$prescription->unit}</select>
220 </td>
221 </tr>
222 <tr>
223 <td COLSPAN="1" class="text" ALIGN="right" VALIGN="MIDDLE" >{xl t='Directions'|escape:'html'}</td>
224 <td COLSPAN="2" class="text" ALIGN="LEFT" VALIGN="MIDDLE" >
225 {if $SIMPLIFIED_PRESCRIPTIONS && !$prescription->form && !$prescription->route && !$prescription->interval}
226 <input TYPE="text" NAME="dosage" id="dosage" SIZE="30" MAXLENGTH="100" VALUE="{$prescription->dosage|escape:'html'}" />
227 <input type="hidden" name="form" id="form" value="0" />
228 <input type="hidden" name="route" id="route" value="0" />
229 <input type="hidden" name="interval" id="interval" value="0" />
230 {else}
231 <input TYPE="TEXT" NAME="dosage" id="dosage" SIZE="2" MAXLENGTH="10" VALUE="{$prescription->dosage|escape:'html'}"/> {xl t='in'|escape:'html'}
232 <select name="form" id="form">{html_options options=$prescription->form_array selected=$prescription->form}</select>
233 <select name="route" id="route">{html_options options=$prescription->route_array selected=$prescription->route}</select>
234 <select name="interval" id="interval">{html_options options=$prescription->interval_array selected=$prescription->interval}</select>
235 {/if}
236 </td>
237 </tr>
238 <tr>
239 <td COLSPAN="1" class="text" ALIGN="right" VALIGN="MIDDLE" >{xl t='Refills'|escape:'html'}</td>
240 <td COLSPAN="2" class="text" ALIGN="LEFT" VALIGN="MIDDLE" >
241 {html_options name="refills" options=$prescription->refills_array selected=$prescription->refills}
242 {if $SIMPLIFIED_PRESCRIPTIONS}
243 <input TYPE="hidden" ID="per_refill" NAME="per_refill" VALUE="{$prescription->per_refill|escape:'html'}" />
244 {else}
245 &nbsp; &nbsp; # {xl t='of tablets'}:
246 <input TYPE="TEXT" ID="per_refill" NAME="per_refill" SIZE="2" MAXLENGTH="10" VALUE="{$prescription->per_refill|escape:'html'}" />
247 {/if}
248 </td>
249 </tr>
250 <tr>
251 <td COLSPAN="1" class="text" ALIGN="right" VALIGN="MIDDLE" >{xl t='Notes'|escape:'html'}</td>
252 <td COLSPAN="2" class="text" ALIGN="LEFT" VALIGN="MIDDLE" >
253 <textarea name="note" cols="30" rows="2" wrap="virtual">{$prescription->note|escape:'html'}</textarea>
254 </td>
255 </tr>
256 <tr>
257 {if $WEIGHT_LOSS_CLINIC}
258 <td COLSPAN="1" class="text" ALIGN="right" VALIGN="MIDDLE" >{xl t='Substitution'|escape:'html'}</td>
259 <td COLSPAN="2" ALIGN="LEFT" VALIGN="MIDDLE" >
260 {html_options name="substitute" options=$prescription->substitute_array selected=$prescription->substitute}
261 </td>
262 {else}
263 <td COLSPAN="1" class="text" ALIGN="right" VALIGN="MIDDLE" >{xl t='Add to Medication List'|escape:'html'}</td>
264 <td COLSPAN="2" class="text" ALIGN="LEFT" VALIGN="MIDDLE" >
265 {html_radios name="medication" options=$prescription->medication_array selected=$prescription->medication}
266 &nbsp; &nbsp;
267 {html_options name="substitute" options=$prescription->substitute_array selected=$prescription->substitute}
268 </td>
269 {/if}
270 </tr>
271 </table>
272 <input type="hidden" name="id" value="{$prescription->id|escape:'html'}" />
273 <input type="hidden" name="process" value="{$PROCESS|escape:'html'}" />
274 <script language='JavaScript'>
275 {$ENDING_JAVASCRIPT}
276 </script>
277 </form>
279 {literal}
280 <!-- for the fancy jQuery stuff -->
281 <script type="text/javascript">
283 function submitfun() {
284 top.restoreSession();
285 if (CheckForErrors(this)) {
286 document.forms["prescribe"].submit();
288 else {
289 return false;
293 function iframetopardiv(string){
294 var name=string
295 document.getElementById('drug').value=name;
296 $("#hiddendiv").html( "&nbsp;" );
297 $('#hiddendiv').hide();
300 function cancelParlookup () {
301 $('#hiddendiv').hide();
302 $("#hiddendiv").html( "&nbsp;" );
305 $().ready(function() {
307 {/literal}
308 {if $GLOBALS.weno_rx_enable}
309 {literal}
310 $('#drug').autocomplete({
311 source: 'library/ajax/drug_autocomplete/search.php',
312 minLength: 3
314 {/literal}
315 {else}
316 {literal}
317 $('#drug').autocomplete({
318 source: 'library/ajax/prescription_drugname_lookup.php',
319 minLength: 1
321 {/literal}
322 {/if}
323 {literal}
325 $("#drug").focus();
326 $("#prescribe").submit(function() { return CheckForErrors(this) });
327 $("#druglookup").click(function() { DoDrugLookup(this) });
331 // pop up a drug lookup window with the value of the drug name, if we have one
332 function DoDrugLookup(eObj) {
333 drugname = "";
334 if ($('#drug').val() != "") { drugname = $('#drug').val(); }
335 $("#druglist").css('display','block');
336 document.lookup.action='controller.php?prescription&edit&id=&pid={/literal}{$prescription->patient->id}{literal}&drug=sss'+drugname;
337 drugPopup = window.open('controller.php?prescription&lookup&drug='+drugname, 'drugPopup', 'width=400,height=50,menubar=no,titlebar=no,left = 825,top = 400');
338 drugPopup.opener = self;
339 return true;
343 // check the form for required fields before submitting
344 var CheckForErrors = function(eObj) {
345 // REQUIRED FIELDS
346 if (CheckRequired('drug') == false) { return false; }
347 if (CheckRequired('quantity') == false) { return false; }
348 //if (CheckRequired('unit') == false) { return false; }
349 //if (CheckRequired('size') == false) { return false; }
350 if (CheckRequired('dosage') == false) { return false; }
351 //if (CheckRequired('form') == false) { return false; }
352 //if (CheckRequired('route') == false) { return false; }
353 //if (CheckRequired('interval') == false) { return false; }
355 return top.restoreSession();
358 function CheckRequired(objID) {
360 // for text boxes
361 if ($('#'+objID).is('input')) {
362 if ($('#'+objID).val() == "") {
363 alert("{/literal}{xl t='Missing a required field and will be highlighted'}{literal}");
364 $('#'+objID).css("backgroundColor", "pink");
365 return false;
369 // for select boxes
370 if ($('#'+objID).is('select')) {
371 if ($('#'+objID).val() == "0") {
372 alert("{/literal}{xl t='Missing a required field'}{literal}");
373 $('#'+objID).css("backgroundColor", "pink");
374 return false;
378 return true;
381 </script>
382 {/literal}
384 </html>