@extends ('layouts/template')

@section('content')

    <style>
      .fdb-suggestions-container .suggestions-outer {
        right: auto;
        left: 0;
      }
    </style>

    <div class="p-0 mcp-theme-1" id="fdb-pg">
        <div class="px-3 py-2 bg-light border-bottom d-flex align-items-center font-weight-bold font-size-14">FDB Playground</div>
        <div class="p-3 bg-light">
            <div class="row mb-3">
                <div class="col-6">
                    <div class="bg-white p-3 border">
                        <div class="d-flex align-items-baseline mb-2">
                            <span class="font-size-14 font-weight-bold">Allergies</span>
                            <a href="#" v-on:click.prevent="addAllergy()" class="ml-3">+ Add</a>
                        </div>
                        <table class="table table-sm table-striped table-bordered m-0">
                        <thead>
                        <tr>
                            <th class="border-bottom-0 text-secondary">Allergy</th>
                            <th class="border-bottom-0 width-100px"></th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr v-for="(item, index) in allergies">
                            <td class="p-0 position-relative">
                                <input type="text" class="rounded-0 border-0 form-control form-control-sm min-width-unset"
                                       fdb-allergy-suggest-search :fdb-suggest-group="index">
                            </td>
                            <td class="text-center">
                                <a href="#" v-on:click.prevent="allergies.splice(index, 1); showDrugAllergyNotes();"><i class="fa fa-trash-alt text-danger"></i></a>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                    </div>
                </div>
                <div class="col-6 pl-0">
                    <div class="bg-white p-3 border">
                        <div class="d-flex align-items-baseline mb-2">
                            <span class="font-size-14 font-weight-bold">Current Problems</span>
                            <a href="#" v-on:click.prevent="addDx()" class="ml-3">+ Add</a>
                        </div>
                        <table class="table table-sm table-striped table-bordered m-0">
                        <thead>
                        <tr>
                            <th class="border-bottom-0 text-secondary">Problem</th>
                            <th class="border-bottom-0 width-100px"></th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr v-for="(item, index) in dx">
                            <td class="p-0 position-relative">
                                <input type="text" class="rounded-0 border-0 form-control form-control-sm min-width-unset"
                                       fdb-dx-suggest-search :fdb-suggest-group="index">
                            </td>
                            <td class="text-center">
                                <a href="#" v-on:click.prevent="dx.splice(index, 1)"><i class="fa fa-trash-alt text-danger"></i></a>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                    </div>
                </div>
            </div>
            <div class="bg-white p-3 mb-3 border">
                <div class="d-flex align-items-baseline mb-2">
                    <span class="font-size-14 font-weight-bold">Medications</span>
                    <a href="#" v-on:click.prevent="addRx()" class="ml-3">+ Add</a>
                </div>
                <table class="table table-sm table-bordered m-0" style="table-layout: fixed">
                <thead>
                <tr>
                    <th class="border-bottom-0 text-secondary">Medication</th>
                    <th class="border-bottom-0 text-secondary">Route</th>
                    <th class="border-bottom-0 text-secondary">Dosage</th>
                    <th class="border-bottom-0 text-secondary">Strength</th>
                    <th class="border-bottom-0 text-secondary">Side Effects</th>
                    <th class="border-bottom-0 text-secondary">Ger. Precautions</th>
                    <th class="border-bottom-0 text-secondary">Indications</th>
                    <th class="border-bottom-0 text-secondary">Contraindications</th>
                    <th class="border-bottom-0 width-100px"></th>
                </tr>
                </thead>
                <tbody>
                <tr v-for="(item, index) in rx">
                    <td class="p-0 position-relative">
                        <input type="text" class="rounded-0 border-0 form-control form-control-sm min-width-unset"
                               fdb-med-suggest-search :fdb-suggest-group="index">
                    </td>
                    <td class="p-0 position-relative">
                        <select class="rounded-0 border-0 form-control form-control-sm min-width-unset"
                                fdb-med-suggest-route :fdb-suggest-group="index" v-model="item.routed_med_id"
                                disabled>
                        </select>
                    </td>
                    <td class="p-0 position-relative">
                        <select class="rounded-0 border-0 form-control form-control-sm min-width-unset"
                                fdb-med-suggest-dosage :fdb-suggest-group="index" v-model="item.routed_dosage_form_med_id"
                                disabled>
                        </select>
                    </td>
                    <td class="p-0 position-relative">
                        <select class="rounded-0 border-0 form-control form-control-sm min-width-unset"
                                fdb-med-suggest-strength :fdb-suggest-group="index" v-model="item.gcn_seqno"
                                disabled>
                        </select>
                    </td>

                    <td class="p-0 overflow-auto side-effects" :fdb-suggest-group="index">

                    </td>
                    <td class="p-0 overflow-auto geriatric-precautions" :fdb-suggest-group="index">

                    </td>
                    <td class="p-0 overflow-auto indications" :fdb-suggest-group="index">

                    </td>
                    <td class="p-0 overflow-auto contraindications" :fdb-suggest-group="index">

                    </td>
                    <td class="text-center">
                        <a href="#" v-on:click.prevent="rx.splice(index, 1); showDrugAllergyNotes(); showDrugCoadministrationNotes(); showDuplicateTherapyNotes()"><i class="fa fa-trash-alt text-danger"></i></a>
                    </td>
                </tr>
                </tbody>
            </table>
            </div>
            <div class="row">
                <div class="col-3">
                    <div class="bg-white p-3 border">
                        <div class="d-flex align-items-baseline mb-2">
                            <span class="font-size-14 font-weight-bold">Drug Allergy Notes</span>
                        </div>
                        <div class="drug-allergies"></div>
                    </div>
                </div>
                <div class="col-3 pl-0">
                    <div class="bg-white p-3 border">
                        <div class="d-flex align-items-baseline mb-2">
                            <span class="font-size-14 font-weight-bold">Drug Drug Interaction Notes</span>
                        </div>
                        <div class="drug-drug-interaction"></div>
                    </div>
                </div>
                <div class="col-3 pl-0">
                    <div class="bg-white p-3 border">
                        <div class="d-flex align-items-baseline mb-2">
                            <span class="font-size-14 font-weight-bold">Duplicate Therapy Notes</span>
                        </div>
                        <div class="duplicate-therapy"></div>
                    </div>
                </div>
                <div class="col-3 pl-0">
                    <div class="bg-white p-3 border">
                        <div class="d-flex align-items-baseline mb-2">
                            <span class="font-size-14 font-weight-bold">Coadministration Notes</span>
                        </div>
                        <div class="drug-coadministration"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        (function() {

            let suggestionsOuter = null;

            const debounce = (func, wait) => {
                let timeout;
                return function executedFunction(...args) {
                    const later = () => {
                        clearTimeout(timeout);
                        func(...args);
                    };
                    clearTimeout(timeout);
                    timeout = setTimeout(later, wait);
                };
            };

            var lastTerm = '';
            var returnedFunction = debounce(function (elem) {
                let term = elem.val();
                if (!!term && lastTerm !== term) {
                    let ep = false;
                    if($(elem).is('[fdb-med-suggest-search]')) {
                        ep = '/fdb-med-suggest';
                    }
                    else if($(elem).is('[fdb-dx-suggest-search]')) {
                        ep = '/fdb-dx-suggest';
                    }
                    else if($(elem).is('[fdb-allergy-suggest-search]')) {
                        ep = '/fdb-allergy-suggest';
                    }
                    $.get(ep + '?term=' + $.trim(term), function (_data) {
                        suggestionsOuter.html(_data).removeClass('d-none');
                    });
                    lastTerm = term;
                } else {
                    suggestionsOuter.addClass('d-none');
                }
            }, 250);

            function handleKeydown(elem, e) {
                let term = $.trim(elem.val());
                let activeItem = suggestionsOuter.find('.suggest-item.active');
                switch (e.which) {
                    case 27:
                        suggestionsOuter.addClass('d-none');
                        return false;
                    case 38:
                        if (activeItem.prev().length) {
                            activeItem.prev()
                                .addClass('active')
                                .siblings().removeClass('active');
                            activeItem = suggestionsOuter.find('.suggest-item.active');
                            if (activeItem.length) {
                                activeItem[0].scrollIntoView();
                            }
                        }
                        return false;
                    case 40:
                        if (activeItem.next().length) {
                            activeItem.next()
                                .addClass('active')
                                .siblings().removeClass('active');
                            activeItem = suggestionsOuter.find('.suggest-item.active');
                            if (activeItem.length) {
                                activeItem[0].scrollIntoView();
                            }
                        }
                        return false;
                    case 13:
                        if (activeItem.length) {
                            activeItem.first().click();
                        }
                        return false;
                    default:
                        if (!!term) {
                            suggestionsOuter
                                .html('<span class="d-block no-suggest-items">Searching...</span>')
                                .removeClass('d-none');
                            returnedFunction(elem);
                        } else {
                            suggestionsOuter.addClass('d-none');
                        }
                        break;
                }
            }

            function handleKeypress(elem, e) {
                var term = $.trim(elem.val());
                if (!!term) {
                    suggestionsOuter
                        .html('<span class="d-block no-suggest-items">Searching...</span>')
                        .removeClass('d-none');
                    returnedFunction(elem);
                } else {
                    suggestionsOuter.addClass('d-none');
                }
            }

            function fillSideEffects(_group, _gcn_seqno) {
                let container = $('.side-effects[fdb-suggest-group=' + _group + ']');
                container.empty();
                $.get('/fdb-side-effects?gcn-seq-no=' + _gcn_seqno, _data => {
                    container.html(_data);
                });
            }

            function fillGeriatricPrecautions(_group, _gcn_seqno) {
                let container = $('.geriatric-precautions[fdb-suggest-group=' + _group + ']');
                container.empty();
                $.get('/fdb-geriatric-precautions?gcn-seq-no=' + _gcn_seqno, _data => {
                    container.html(_data);
                });
            }

            function fillIndications(_group, _gcn_seqno) {
                let container = $('.indications[fdb-suggest-group=' + _group + ']');
                container.empty();
                $.get('/fdb-indications?gcn-seq-no=' + _gcn_seqno, _data => {
                    container.html(_data);
                });
            }

            function fillContraindications(_group, _gcn_seqno) {
                let container = $('.contraindications[fdb-suggest-group=' + _group + ']');
                container.empty();
                $.get('/fdb-contraindications?routed-med-id=' + _gcn_seqno, _data => {
                    container.html(_data);
                });
            }

            addMCInitializer('fdb-pg', function() {

                window.fdbPGApp = new Vue({
                    el: '#fdb-pg',
                    delimiters: ['@{{', '}}'],
                    data: {
                        allergies: [{

                        }],
                        dx: [{

                        }],
                        rx: [{

                        }],
                    },
                    methods: {
                        addRx: function() {
                            this.rx.push({});
                            Vue.nextTick(() => {
                                this.initFDBRxSuggest();
                                $('[fdb-med-suggest-search]').last().focus();
                            });
                        },
                        addDx: function() {
                            this.dx.push({});
                            Vue.nextTick(() => {
                                this.initFDBDxSuggest();
                                $('[fdb-dx-suggest-search]').last().focus();
                            });
                        },
                        addAllergy: function() {
                            this.allergies.push({});
                            Vue.nextTick(() => {
                                this.initFDBAllergySuggest();
                                $('[fdb-allergy-suggest-search]').last().focus();
                            });
                        },
                        showDrugAllergyNotes: function() {
                            $('.drug-allergies').html('');
                            if(this.allergies && this.allergies.length && this.rx && this.rx.length) {
                                $.get('/fdb-drug-allergies', {
                                    data: JSON.stringify({
                                        allergies: this.allergies,
                                        rx: this.rx
                                    })
                                }, _data => {
                                    $('.drug-allergies').html(_data);
                                });
                            }
                        },
                        showDrugDrugInteractionNotes: function() {
                            $('.drug-drug-interaction').html('');
                            if(this.rx && this.rx.length > 1) {
                                $.get('/fdb-drug-drug-interaction', {
                                    data: JSON.stringify({
                                        rx: this.rx
                                    })
                                }, _data => {
                                    $('.drug-drug-interaction').html(_data);
                                });
                            }
                        },
                        showDrugCoadministrationNotes: function() {
                            $('.drug-coadministration').html('');
                            if(this.rx && this.rx.length > 1) {
                                let gcnSeqNos = [];
                                for (let i = 0; i < this.rx.length; i++) {
                                    gcnSeqNos.push(this.rx[i].gcn_seqno);
                                }
                                gcnSeqNos = gcnSeqNos.join(",");
                                $.get('/fdb-drug-coadministration', {
                                    'gcn-seqnos': gcnSeqNos
                                }, _data => {
                                    $('.drug-coadministration').html(_data);
                                });
                            }
                        },
                        showDuplicateTherapyNotes: function() {
                            $('.duplicate-therapy').html('');
                            if(this.rx && this.rx.length > 1) {
                                $.get('/fdb-duplicate-therapy', {
                                    data: JSON.stringify({
                                        rx: this.rx
                                    })
                                }, _data => {
                                    $('.duplicate-therapy').html(_data);
                                });
                            }
                        },
                        initFDBRxSuggest: function() {
                            $('[fdb-med-suggest-search]:not([fdb-suggest-initialized])').each(function() {
                                let elem = $(this);
                                elem.next('.fdb-suggestions-container').remove();
                                $('<div class="fdb-suggestions-container position-relative" fdb-suggest-group="' + elem.attr('fdb-suggest-group') + '">' +
                                    '<div class="suggestions-outer fdb-suggestions position-absolute d-none"></div>' +
                                    '</div>').insertAfter(elem);

                                elem
                                    .off('keydown.fdb-suggest')
                                    .on('keydown.fdb-suggest', function (e) {
                                        suggestionsOuter = $(this).next('.fdb-suggestions-container').find('>.suggestions-outer');
                                        return handleKeydown($(this), e);
                                    })
                                    .off('keypress.fdb-suggest')
                                    .on('keypress.fdb-suggest', function (e) {
                                        suggestionsOuter = $(this).next('.fdb-suggestions-container').find('>.suggestions-outer');
                                        return handleKeypress($(this), e);
                                    });

                                $(this).attr('fdb-suggest-initialized', 1);
                            });
                        },
                        initFDBDxSuggest: function() {
                            $('[fdb-dx-suggest-search]:not([fdb-suggest-initialized])').each(function() {
                                let elem = $(this);
                                elem.next('.fdb-suggestions-container').remove();
                                $('<div class="fdb-suggestions-container position-relative" fdb-suggest-group="' + elem.attr('fdb-suggest-group') + '">' +
                                    '<div class="suggestions-outer fdb-suggestions position-absolute d-none"></div>' +
                                    '</div>').insertAfter(elem);

                                elem
                                    .off('keydown.fdb-suggest')
                                    .on('keydown.fdb-suggest', function (e) {
                                        suggestionsOuter = $(this).next('.fdb-suggestions-container').find('>.suggestions-outer');
                                        return handleKeydown($(this), e);
                                    })
                                    .off('keypress.fdb-suggest')
                                    .on('keypress.fdb-suggest', function (e) {
                                        suggestionsOuter = $(this).next('.fdb-suggestions-container').find('>.suggestions-outer');
                                        return handleKeypress($(this), e);
                                    });

                                $(this).attr('fdb-suggest-initialized', 1);
                            });
                        },
                        initFDBAllergySuggest: function() {
                            $('[fdb-allergy-suggest-search]:not([fdb-suggest-initialized])').each(function() {
                                let elem = $(this);
                                elem.next('.fdb-suggestions-container').remove();
                                $('<div class="fdb-suggestions-container position-relative" fdb-suggest-group="' + elem.attr('fdb-suggest-group') + '">' +
                                    '<div class="suggestions-outer fdb-suggestions position-absolute d-none"></div>' +
                                    '</div>').insertAfter(elem);

                                elem
                                    .off('keydown.fdb-suggest')
                                    .on('keydown.fdb-suggest', function (e) {
                                        suggestionsOuter = $(this).next('.fdb-suggestions-container').find('>.suggestions-outer');
                                        return handleKeydown($(this), e);
                                    })
                                    .off('keypress.fdb-suggest')
                                    .on('keypress.fdb-suggest', function (e) {
                                        suggestionsOuter = $(this).next('.fdb-suggestions-container').find('>.suggestions-outer');
                                        return handleKeypress($(this), e);
                                    });

                                $(this).attr('fdb-suggest-initialized', 1);
                            });
                        }
                    },
                    mounted: function() {

                        let vueApp = this;

                        // on auto-suggest med selection
                        $(document).off('click', '.suggest-item.fdb-suggest[data-med-name-id]');
                        $(document).on('click', '.suggest-item.fdb-suggest[data-med-name-id]', function () {

                            $('.suggestions-outer.fdb-suggestions').addClass('d-none');

                            let medNameID = $(this).attr('data-med-name-id'),
                                label = $.trim($(this).text()),
                                group = $(this).closest('.fdb-suggestions-container').attr('fdb-suggest-group');

                            // set value
                            let input = $(this).closest('.position-relative').prev('[fdb-med-suggest-search]');
                            input.val(label);
                            input.attr('data-med-name-id', medNameID);
                            input.trigger('input');
                            input.trigger('change');

                            // vue value
                            vueApp.rx[group].rx = label;
                            vueApp.rx[group].med_name_id = medNameID;

                            $(document).trigger('fdb-med-changed', [group]);

                            return false;
                        });

                        // on auto-suggest dx selection
                        $(document).off('click', '.suggest-item.fdb-suggest[data-dx-id]');
                        $(document).on('click', '.suggest-item.fdb-suggest[data-dx-id]', function () {

                            $('.suggestions-outer.fdb-suggestions').addClass('d-none');

                            let dxID = $(this).attr('data-dx-id'),
                                label = $.trim($(this).text()),
                                group = $(this).closest('.fdb-suggestions-container').attr('fdb-suggest-group');

                            // set value
                            let input = $(this).closest('.position-relative').prev('[fdb-dx-suggest-search]');
                            input.val(label);
                            input.attr('data-dx-id', dxID);
                            input.trigger('input');
                            input.trigger('change');

                            // vue value
                            vueApp.dx[group].problem = label;
                            vueApp.dx[group].dxid = dxID;

                            $(document).trigger('fdb-dx-changed', [group]);

                            return false;
                        });

                        // on auto-suggest allergy selection
                        $(document).off('click', '.suggest-item.fdb-suggest[data-dam-concept-id]');
                        $(document).on('click', '.suggest-item.fdb-suggest[data-dam-concept-id]', function () {

                            $('.suggestions-outer.fdb-suggestions').addClass('d-none');

                            let damConceptID = $(this).attr('data-dam-concept-id'),
                                damConceptIDTyp = $(this).attr('data-dam-concept-id-typ'),
                                label = $.trim($(this).text()),
                                group = $(this).closest('.fdb-suggestions-container').attr('fdb-suggest-group');

                            // set value
                            let input = $(this).closest('.position-relative').prev('[fdb-allergy-suggest-search]');
                            input.val(label);
                            input.attr('data-dam-concept-id', damConceptID);
                            input.attr('data-dam-concept-id-type', damConceptIDTyp);
                            input.trigger('input');
                            input.trigger('change');

                            // vue value
                            vueApp.allergies[group].allergen = label;
                            vueApp.allergies[group].dam_concept_id = damConceptID;
                            vueApp.allergies[group].dam_concept_id_typ = damConceptIDTyp;

                            $(document).trigger('fdb-allergy-changed', [group]);

                            vueApp.showDrugAllergyNotes();

                            return false;
                        });

                        // med changed, update routes
                        $(document).off('fdb-med-changed');
                        $(document).on('fdb-med-changed', function(e, group) {

                            // clear vue values
                            vueApp.rx[group].routed_med_id = null;
                            vueApp.rx[group].routed_dosage_form_med_id = null;
                            vueApp.rx[group].medid = null;
                            vueApp.rx[group].gcn_seqno = null;

                            let routeSelect = $('[fdb-med-suggest-route][fdb-suggest-group='+group+']').empty().prop('disabled', true);
                            let dosageSelect = $('[fdb-med-suggest-dosage][fdb-suggest-group='+group+']').empty().prop('disabled', true);
                            let strengthSelect = $('[fdb-med-suggest-strength][fdb-suggest-group='+group+']').empty().prop('disabled', true);
                            let medNameID = $('[fdb-med-suggest-search][fdb-suggest-group='+group+']').attr('data-med-name-id');
                            $.get('/fdb-routed-meds?med-name-id=' + medNameID, _data => {
                                routeSelect
                                    .empty()
                                    .append('<option value="">-- select --</option>');
                                for (let i = 0; i < _data.length; i++) {
                                    routeSelect.append('<option value="' + _data[i].routed_med_id + '">' + _data[i].med_routed_med_id_desc + '</option>')
                                }
                                routeSelect.prop('disabled', false);
                                if(_data.length === 1) {
                                    vueApp.rx[group].routed_med_id = _data[0].routed_med_id;
                                    routeSelect.val(_data[0].routed_med_id).trigger('change');
                                }
                            }, 'json');
                            routeSelect.prop('disabled', false);
                        });

                        // on route selection
                        $(document).off('change', '[fdb-med-suggest-route]');
                        $(document).on('change', '[fdb-med-suggest-route]', function () {
                            let group = $(this).attr('fdb-suggest-group');

                            // clear vue values
                            vueApp.rx[group].routed_dosage_form_med_id = null;
                            vueApp.rx[group].medid = null;
                            vueApp.rx[group].gcn_seqno = null;

                            let dosageSelect = $('[fdb-med-suggest-dosage][fdb-suggest-group='+group+']').empty().prop('disabled', true);
                            let strengthSelect = $('[fdb-med-suggest-strength][fdb-suggest-group='+group+']').empty().prop('disabled', true);
                            let routedMedID = $('[fdb-med-suggest-route][fdb-suggest-group='+$(this).attr('fdb-suggest-group')+']').val();
                            $.get('/fdb-routed-dosages?routed-med-id=' + routedMedID, _data => {
                                dosageSelect
                                    .empty()
                                    .append('<option value="">-- select --</option>');
                                for (let i = 0; i < _data.length; i++) {
                                    dosageSelect.append('<option value="' + _data[i].routed_dosage_form_med_id + '">' + _data[i].med_routed_df_med_id_desc + '</option>')
                                }
                                dosageSelect.prop('disabled', false);
                                if(_data.length === 1) {
                                    vueApp.rx[group].routed_dosage_form_med_id = _data[0].routed_dosage_form_med_id;
                                    dosageSelect.val(_data[0].routed_dosage_form_med_id).trigger('change');
                                }
                            }, 'json');
                        });

                        // on dosage selection
                        $(document).off('change', '[fdb-med-suggest-dosage]');
                        $(document).on('change', '[fdb-med-suggest-dosage]', function () {
                            let group = $(this).attr('fdb-suggest-group');

                            vueApp.rx[group].medid = null;
                            vueApp.rx[group].gcn_seqno = null;

                            let strengthSelect = $('[fdb-med-suggest-strength][fdb-suggest-group='+group+']').empty().prop('disabled', true);
                            let dosageFormMedID = $('[fdb-med-suggest-dosage][fdb-suggest-group='+$(this).attr('fdb-suggest-group')+']').val();
                            $.get('/fdb-meds?dosage-form-med-id=' + dosageFormMedID, _data => {
                                strengthSelect
                                    .empty()
                                    .append('<option value="">-- select --</option>');
                                for (let i = 0; i < _data.length; i++) {
                                    strengthSelect.append('<option data-medid="' + _data[i].medid + '" value="' + _data[i].gcn_seqno + '">' + _data[i].med_medid_desc + '</option>')
                                }
                                strengthSelect.prop('disabled', false);
                                if(_data.length === 1) {
                                    vueApp.rx[group].medid = _data[0].medid;
                                    vueApp.rx[group].gcn_seqno = _data[0].gcn_seqno;
                                    strengthSelect.val(_data[0].gcn_seqno).trigger('change');
                                }
                            }, 'json');
                        });

                        // on strength (medid) selection
                        $(document).off('change', '[fdb-med-suggest-strength]');
                        $(document).on('change', '[fdb-med-suggest-strength]', function () {

                            let group = $(this).attr('fdb-suggest-group');
                            vueApp.rx[group].medid = $(this).find('option:selected').attr('data-medid');

                            fillSideEffects($(this).attr('fdb-suggest-group'), $(this).val());
                            fillGeriatricPrecautions($(this).attr('fdb-suggest-group'), $(this).val());
                            fillIndications($(this).attr('fdb-suggest-group'), $(this).val());

                            let routedMedID = $('[fdb-med-suggest-route][fdb-suggest-group='+$(this).attr('fdb-suggest-group')+']').val();
                            fillContraindications($(this).attr('fdb-suggest-group'), routedMedID);

                            vueApp.showDrugAllergyNotes();
                            vueApp.showDrugDrugInteractionNotes();
                            vueApp.showDuplicateTherapyNotes();
                            vueApp.showDrugCoadministrationNotes();
                        });

                        Vue.nextTick(() => {
                            this.initFDBAllergySuggest();
                            this.initFDBDxSuggest();
                            this.initFDBRxSuggest();
                            $('[fdb-allergy-suggest-search]').first().focus();
                        });

                    }
                })

            }, '#fdb-pg');
        }).call(window);
    </script>

@endsection
