var inventory_form = {
    settings: {
        branch_autocomplete_url: null,
        location_autocomplete_url: null,
        item_autocomplete_url: null
    },
    init: function() {
        inventory_form.bindAutocomplete();
    },
    bindAutocomplete: function() {
        global.autocomplete.bind(inventory_form.settings.branch_autocomplete_url, '#inventory_form_branch_description', '#inventory_form_healthFacility', {
            onSelect: function (d) {
                jQ('#inventory_location_description').devbridgeAutocomplete('setOptions', {params: {branchId: btoa(d.id)}});
            }
        });
        global.autocomplete.bind(inventory_form.settings.location_autocomplete_url, '#inventory_form_location_description', '#inventory_form_location', {
            onSelect: function(d){
                jQ('#inventory_branch_description').val(d.branch_description);
                jQ('#inventory_branch_id').val(d.branch_id);
            }
        });

        global.autocomplete.bind(inventory_form.settings.item_autocomplete_url, '#inventory_form_item_description', '#inventory_form_item');
    }
};