5 * @link http://www.open-emr.org
6 * @author Brady Miller
<brady.g.miller@gmail.com
>
7 * @copyright Copyright (c)
2017-
2018 Brady Miller
<brady.g.miller@gmail.com
>
8 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License
3
14 {headerTemplate assets='datetime-picker|select2'}
19 function my_process_lookup(drug
, rxcode
= '') {
21 let newOption
= new Option(drug
, drug
, true, true);
22 $("#rxnorm_drugcode").val(rxcode
);
23 $('#drug').append(newOption
).trigger('change');
24 $('#hiddendiv').hide();
25 $("#hiddendiv").html( " " );
33 // This holds all the default drug attributes.
34 // This was html escaped previously
36 var drugopts
= [{if !empty($DRUG_ATTRIBUTES
)}{$DRUG_ATTRIBUTES
}{/if}];
39 // Helper to choose an option from its value.
40 function selchoose(sel
, value
) {
42 for (let i
= 0; i
< o
.length
; ++i
) {
43 o
[i
].selected
= (o
[i
].value
== value
);
47 // Fill in default values when a drop-down drug is selected.
48 function drugselected(sel
) {
49 var f
= document
.forms
[0];
50 var i
= f
.drug_id
.selectedIndex
- 1;
53 var newOption
= new Option(d
[0], d
[0], true, true);
54 $('#drug').append(newOption
).trigger('change');
55 selchoose(f
.form
, d
[1]);
56 f
.dosage
.value
= d
[2];
58 f
.rxnorm_drugcode
.value
= d
[11];
59 selchoose(f
.unit
, d
[4]);
60 selchoose(f
.route
, d
[5]);
61 selchoose(f
.interval
, d
[6]);
62 selchoose(f
.substitute
, d
[7]);
63 f
.quantity
.value
= d
[8];
64 f
.disp_quantity
.value
= d
[8];
65 selchoose(f
.refills
, d
[9]);
66 f
.per_refill
.value
= d
[10];
70 // Invoke the popup to dispense a drug.
72 var f
= document
.forms
[0];
73 dlgopen('interface/drugs/dispense_drug.php' +
74 '?drug_id=' + {$prescription
->get_drug_id()|js_url
} +
75 '&prescription=' + encodeURIComponent(f
.id
.value
) +
76 '&quantity=' + encodeURIComponent(f
.disp_quantity
.value
) +
77 '&fee=' + encodeURIComponent(f
.disp_fee
.value
),
81 function quantityChanged() {
82 var f
= document
.forms
[0];
83 f
.per_refill
.value
= f
.quantity
.value
;
84 if (f
.disp_quantity
) {
85 f
.disp_quantity
.value
= f
.quantity
.value
;
92 <body id=
"prescription_edit">
93 <div class=
"container">
94 <form name=
"prescribe" id=
"prescribe" method=
"post" action=
"{$FORM_ACTION}" >
97 <td class=
"title font-weight-bold">{xlt t='Add'}/{xlt t='Edit'}
</td>
99 <a id=
"save" href=#
onclick=
"submitfun();" class=
"btn btn-primary btn-sm btn-save">{xlt t='Save'}
</a>
100 {if !empty($DRUG_ARRAY_VALUES)}
101
102 {if $prescription-
>get_refills()
>= $prescription-
>get_dispensation_count()}
103 <input type=
"submit" name=
"disp_button"class='btn btn-primary btn-sm my-
0 mr-
1 ml-
1'
value=
"{xla t='Save and Dispense'}" />
104 <input class=
"input-sm" type=
"text" name=
"disp_quantity" size=
"2" maxlength=
"10" value=
"{$DISP_QUANTITY|attr}" />
105 units, {$GBL_CURRENCY_SYMBOL|text}
106 <input class=
"input-sm" type=
"text" name=
"disp_fee" size=
"5" maxlength=
"10" value=
"{$DISP_FEE|attr}" />
108 {xlt t='prescription has reached its limit of'} {$prescription-
>get_refills()|text} {xlt t='refills'}.
111 <a id=
"back" class='btn btn-secondary btn-sm btn-back'
href=
"controller.php?prescription&list&id={$prescription->patient->id|attr_url}">{xlt t='Back'}
</a>
116 {if $GLOBALS.enable_amc_prompting}
117 <div class='float-right border mr-
5'
>
118 <div class='float-left m-
1'
>
119 {amcCollect amc_id='e_prescribe_amc' patient_id=$prescription-
>patient-
>id object_category='prescriptions' object_id=$prescription-
>id}
120 {if not $amcCollectReturn}
121 <input type=
"checkbox" id=
"escribe_flag" name=
"escribe_flag" />
123 <input type=
"checkbox" id=
"escribe_flag" name=
"escribe_flag" checked=
"checked" />
125 <span class=
"text">{xlt t='E-Prescription?'}
</span><br />
127 {amcCollect amc_id='e_prescribe_chk_formulary_amc' patient_id=$prescription-
>patient-
>id object_category='prescriptions' object_id=$prescription-
>id}
128 {if not $amcCollectReturn}
129 <input type=
"checkbox" id=
"checked_formulary_flag" name=
"checked_formulary_flag" />
131 <input type=
"checkbox" id=
"checked_formulary_flag" name=
"checked_formulary_flag" checked=
"checked" />
133 <span class=
"text">{xlt t='Checked Drug Formulary?'}
</span><br />
135 {amcCollect amc_id='e_prescribe_cont_subst_amc' patient_id=$prescription-
>patient-
>id object_category='prescriptions' object_id=$prescription-
>id}
136 {if not $amcCollectReturn}
137 <input type=
"checkbox" id=
"controlled_substance_flag" name=
"controlled_substance_flag" />
139 <input type=
"checkbox" id=
"controlled_substance_flag" name=
"controlled_substance_flag" checked=
"checked" />
141 <span class=
"text">{xlt t='Controlled Substance?'}
</span><br />
146 <div class=
"form-group mt-3">
147 <label>{xlt t='Currently Active'}
</label>
148 <input class=
"input-sm" type=
"checkbox" name=
"active" value=
"1"{if $prescription-
>get_active()
> 0} checked{/if}
/>
150 <div class=
"form-group mt-3">
151 <label>{xlt t='Starting Date'}
</label>
152 <input type=
"text" size=
"10" class=
"datepicker form-control" name=
"start_date" id=
"start_date" value=
"{$prescription->start_date|oeFormatShortDate|attr}" />
154 <div class=
"form-group mt-3">
155 <label>{xlt t='Provider'}
</label>
156 {html_options
class=
"input-sm form-control" name=
"provider_id" options=$prescription-
>provider-
>utility_provider_array() selected=$prescription-
>provider-
>get_id()}
157 <input type=
"hidden" name=
"patient_id" value=
"{$prescription->patient->id|attr}" />
159 <div class=
"form-group mt-3">
160 <label class=
"mr-2">{xlt t='Drug'}
</label>
161 <div class=
"form-check-inline">
162 <label class=
"form-check-label" title=
"{xlt t='Search from native inventory drugs table'}">
163 <input type=
"radio" class=
"form-check-input" name=
"rxcui_select" checked
/>{xlt t='Use Default'}
166 <div class=
"form-check-inline">
167 <label class=
"form-check-label" title=
"{xlt t='Search from external RxNorm table. Vocabulary RXNORM'}">
168 <input type=
"radio" class=
"form-check-input" name=
"rxcui_select" {if empty($RXNORMS_AVAILABLE)} disabled{else} checked{/if}
/>{xlt t='Use RxNorm'}
171 <div class=
"form-check-inline">
172 <label class=
"form-check-label" title=
"{xlt t='Search from native loaded RxCUI table.'}">
173 <input type=
"radio" class=
"form-check-input" name=
"rxcui_select" {if empty($RXCUI_AVAILABLE)}disabled{else} checked{/if}
/>{xlt t='Use RxCUI'}
176 <select class=
"input-sm form-control" type=
"input" name=
"drug" id=
"drug"></select>
177 <a href=
"javascript:;" id=
"druglookup" class=
"small" name=
"B4" onclick=
"$('#hiddendiv').show(); document.getElementById('hiddendiv').innerHTML='<iframe src="controller.php?prescription&lookup&drug=" width="100%"height="75" scrolling="no" frameborder="no"></iframe>'">
178 ({xlt t='Search Web API'})
180 <div class=
"jumbotron jumbotron-fluid" id=
"hiddendiv" style=
"display: none"> </div>
182 {if !empty($DRUG_ARRAY_VALUES)}
183 <div class=
"form-group mt-3">
184 <label> {xlt t='in-house'}
</label>
185 <select class=
"input-sm form-control" name=
"drug_id" onchange=
"drugselected(this)">
186 {html_options values=$DRUG_ARRAY_VALUES output=$DRUG_ARRAY_OUTPUT selected=$prescription-
>get_drug_id()}
188 <input type=
"hidden" name=
"rxnorm_drugcode" value=
"{$prescription->rxnorm_drugcode|attr}">
191 <div class=
"form-group mt-3">
192 <label>{xlt t='Quantity'}
</label>
193 <input class=
"input-sm form-control" type=
"text" name=
"quantity" id=
"quantity" size=
"10" maxlength=
"31"
194 value=
"{$prescription->quantity|attr}" onchange=
"quantityChanged()" />
196 {if $SIMPLIFIED_PRESCRIPTIONS && !$prescription-
>size}
197 <div class=
"form-group row mt-3 d-none">
199 <div class=
"form-group row mt-3">
202 <label>{xlt t='Medicine Units'}
</label>
205 <input class=
"input-sm form-control" type=
"text" name=
"size" id=
"size" size=
"11" maxlength=
"10" value=
"{$prescription->size|attr}"/>
208 <select class=
"input-sm form-control" name=
"unit" id=
"unit">{html_options options=$prescription-
>unit_array selected=$prescription-
>unit}
</select>
211 <div class=
"form-group row mt-3">
213 <label>{xlt t='Directions'}
</label>
215 {if $SIMPLIFIED_PRESCRIPTIONS && !$prescription-
>form && !$prescription-
>route && !$prescription-
>interval}
216 <input class=
"input-sm form-control" type=
"text" name=
"dosage" id=
"dosage" size=
"30" maxlength=
"100" value=
"{$prescription->dosage|attr}" />
217 <input type=
"hidden" name=
"form" id=
"form" value=
"0" />
218 <input type=
"hidden" name=
"route" id=
"route" value=
"0" />
219 <input type=
"hidden" name=
"interval" id=
"interval" value=
"0" />
222 <input class=
"input-sm form-control" type=
"text" name=
"dosage" id=
"dosage" size=
"2" maxlength=
"10" value=
"{$prescription->dosage|attr}"/>
228 <select class=
"input-sm form-control" name=
"form" id=
"form">{html_options options=$prescription-
>form_array selected=$prescription-
>form}
</select>
231 <select class=
"input-sm form-control" name=
"route" id=
"route">{html_options options=$prescription-
>route_array selected=$prescription-
>route}
</select>
234 <select class=
"input-sm form-control" name=
"interval" id=
"interval">{html_options options=$prescription-
>interval_array selected=$prescription-
>interval}
</select>
238 <div class=
"form-group row mt-3">
240 <label>{xlt t='Refills'}
</label>
243 {html_options
name=
"refills" class=
"form-control" options=$prescription-
>refills_array selected=$prescription-
>refills}
245 {if $SIMPLIFIED_PRESCRIPTIONS}
246 <input type=
"hidden" id=
"per_refill" name=
"per_refill" value=
"{$prescription->per_refill|attr}" />
249 # {xlt t='of tablets'}:
252 <input class=
"input-sm form-control" type=
"text" id=
"per_refill" name=
"per_refill" size=
"2" maxlength=
"9" value=
"{$prescription->per_refill|attr}" />
256 <div class=
"form-group mt-3">
257 <label>{xlt t='Notes'}
</label>
258 <textarea class=
"form-control" name=
"note" cols=
"30" rows=
"1" wrap=
"virtual">{$prescription-
>note|text}
</textarea>
260 <div class=
"form-group row mt-3">
261 {if $WEIGHT_LOSS_CLINIC}
262 <label>{xlt t='Substitution'}
</label>
263 {html_options
name=
"substitute" class=
"form-control" options=$prescription-
>substitute_array selected=$prescription-
>substitute}
266 <label>{xlt t='Add to Medication List'}
</label>
269 {html_radios
class=
"input-sm" name=
"medication" options=$prescription-
>medication_array selected=$prescription-
>medication}
272 {html_options
class=
"input-sm form-control" name=
"substitute" options=$prescription-
>substitute_array selected=$prescription-
>substitute}
277 <input type=
"hidden" name=
"id" value=
"{$prescription->id|attr}" />
278 <input type=
"hidden" name=
"process" value=
"{$PROCESS|attr}" />
279 <input type=
"hidden" id=
"rxnorm_drugcode" name=
"rxnorm_drugcode" value=
"{$prescription->rxnorm_drugcode|attr}" />
282 {if !empty($ENDING_JAVASCRIPT
)}{$ENDING_JAVASCRIPT
}{/if}
287 <!-- for the fancy jQuery stuff -->
290 function submitfun() {
291 top
.restoreSession();
292 if (CheckForErrors(this)) {
293 document
.forms
["prescribe"].submit();
300 function iframetopardiv(string
){
302 document
.getElementById('drug').value
=name
;
303 $("#hiddendiv").html( " " );
304 $('#hiddendiv').hide();
307 function cancelParlookup () {
308 $('#hiddendiv').hide();
309 $("#hiddendiv").html( " " );
314 $("#save,#back").on("click",function(){
315 $("#clearButton",window
.parent
.document
).css("display", "none");
316 $("#backButton",window
.parent
.document
).css("display", "none");
317 $("#addButton",window
.parent
.document
).css("display", "");
321 {if $GLOBALS
.weno_rx_enable
}
325 url
: "library/ajax/drug_autocomplete/search.php",
327 data: function(params
) {
329 csrf_token_form
: {$CSRF_TOKEN_FORM
|js_escape
},
334 processResults: function(data
) {
336 results
: $.map(data
, function(item
, index
) {
347 minimumInputLength
: 3
354 url
: "library/ajax/prescription_drugname_lookup.php",
356 data: function(params
) {
358 csrf_token_form
: {$CSRF_TOKEN_FORM
|js_escape
},
361 use_rxnorm
: document
.prescribe
.rxcui_select
[1].checked
,
362 use_rxcui
: document
.prescribe
.rxcui_select
[2].checked
365 processResults: function(data
) {
367 results
: $.map(data
, function(item
, index
) {
369 text
: item
['display_name'],
371 value
: item
['display_name']
380 minimumInputLength
: 3
383 {if $prescription
->drug
}
385 // Show the current drug name in the select
386 var newOption
= new Option({$prescription
->drug
|js_escape
}, {$prescription
->drug
|js_escape
}, true, true);
387 $('#drug').append(newOption
).trigger('change');
392 $("#prescribe").submit(function() { return CheckForErrors(this) });
395 // check the form for required fields before submitting
396 var CheckForErrors = function(eObj
) {
398 if (CheckRequired('drug') == false) { return false; }
399 if (CheckRequired('quantity') == false) { return false; }
400 //if (CheckRequired('unit') == false) { return false; }
401 //if (CheckRequired('size') == false) { return false; }
402 if (CheckRequired('dosage') == false) { return false; }
403 //if (CheckRequired('form') == false) { return false; }
404 //if (CheckRequired('route') == false) { return false; }
405 //if (CheckRequired('interval') == false) { return false; }
407 return top
.restoreSession();
410 function CheckRequired(objID
) {
413 if ($('#'+objID
).is('input')) {
414 if ($('#'+objID
).val() == "") {
415 alert({xlj t
='Missing a required field and will be highlighted'});
416 $('#'+objID
).css("backgroundColor", "pink");
422 if ($('#'+objID
).is('select')) {
423 if ($('#'+objID
).val() == "0") {
424 alert({xlj t
='Missing a required field'});
425 $('#'+objID
).css("backgroundColor", "pink");
433 $(document
).on('select2:select', 'select#drug', function(e
) {
434 let idx
= this.selectedIndex
;
439 let optionText
= document
.getElementById("drug").options
[idx
].text
;
440 let rxcode
= (optionText
.split('(RxCUI:').pop().split(')')[0]).trim();
441 $("#rxnorm_drugcode").val(rxcode
);
445 {datetimepickerSupport input
='format'}