|
@@ -317,12 +317,14 @@
|
|
|
$(elem).attr('ac-initialized', 1);
|
|
|
});
|
|
|
$('[rx-section] input[type="text"][name="contentText"]:not([ac-initialized])').each(function() {
|
|
|
- var elem = this,
|
|
|
- dynID = 'rx-' + Math.ceil(Math.random() * 1000000);
|
|
|
+ let elem = this,
|
|
|
+ randPart = Math.ceil(Math.random() * 1000000),
|
|
|
+ dynID = 'rx-' + randPart;
|
|
|
$(elem).attr('id', dynID);
|
|
|
var strengthElem = $(elem).closest('form').find('[name="strength"]')[0],
|
|
|
- dynStrengthsID = 'rx-' + Math.ceil(Math.random() * 1000000) + '-strengths';
|
|
|
+ dynStrengthsID = 'rx-' + randPart + '-strengths';
|
|
|
$(strengthElem).attr('id', dynStrengthsID);
|
|
|
+ $(strengthElem).attr('rx-id', dynID);
|
|
|
new window.Def.Autocompleter.Prefetch(dynStrengthsID, []);
|
|
|
new window.Def.Autocompleter.Search(dynID,
|
|
|
'https://clinicaltables.nlm.nih.gov/api/rxterms/v3/search?ef=STRENGTHS_AND_FORMS');
|
|
@@ -335,6 +337,23 @@
|
|
|
});
|
|
|
$(elem).attr('ac-initialized', 1);
|
|
|
});
|
|
|
+ window.rxEditMoeOpened = function() { // note "this" is the "form"
|
|
|
+ let form = $(this),
|
|
|
+ rxElem = form.find('input[type="text"][name="contentText"]').first(),
|
|
|
+ strengthElem = form.find('input[type="text"][name="strength"]').first(),
|
|
|
+ q = $.trim(rxElem.val());
|
|
|
+ if(q !== '') {
|
|
|
+ $.get('https://clinicaltables.nlm.nih.gov/api/rxterms/v3/search?' +
|
|
|
+ 'authenticity_token=' + (window._token || '') + '&' +
|
|
|
+ 'maxList=100&' +
|
|
|
+ 'terms=' + encodeURIComponent(q) + '&' +
|
|
|
+ 'ef=STRENGTHS_AND_FORMS', function(_data) {
|
|
|
+ if(Array.isArray(_data) && _data.length >= 3 && Array.isArray(_data[2]['STRENGTHS_AND_FORMS']) && Array.isArray(_data[2]['STRENGTHS_AND_FORMS'][0])) {
|
|
|
+ strengthElem[0].autocomp.setListAndField(_data[2]['STRENGTHS_AND_FORMS'][0], '', true);
|
|
|
+ }
|
|
|
+ }, 'json');
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
addMCInitializer('patient-single', window.initAutoRxAndICDComplete);
|
|
|
})();
|