CoolFace
Apppublic

NTV-Media/codecracker-belgium

sourceHugging Faceupdated 10mo agoView on Hugging Face
0likes
script.js77 linesDownload Raw Back to root
1// Main application functionality2document.addEventListener('DOMContentLoaded', function() {3    // Initialize tooltips4    const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));5    tooltipTriggerList.map(function (tooltipTriggerEl) {6        return new bootstrap.Tooltip(tooltipTriggerEl);7    });8 9    // Search functionality10    const searchInput = document.querySelector('input[type="text"]');11    const searchButton = document.querySelector('button[type="button"]');12    13    searchButton.addEventListener('click', function() {14        const code = searchInput.value.trim();15        if (code) {16            alert(`Searching for code: ${code}\nThis would connect to the Belgium healthcare API in a real implementation.`);17            // In a real app, this would fetch from the API and display results18        }19    });20 21    // Allow search on Enter key22    searchInput.addEventListener('keypress', function(e) {23        if (e.key === 'Enter') {24            searchButton.click();25        }26    });27});28// Toggle reimbursement display29const reimbursementToggle = document.getElementById('reimbursement-toggle');30const priceCells = document.querySelectorAll('tbody td:nth-child(3)');31 32reimbursementToggle.addEventListener('change', function() {33    const isReimbursementOn = this.checked;34    priceCells.forEach(cell => {35        if (isReimbursementOn) {36            const originalPrice = parseFloat(cell.textContent.replace('€', ''));37            // Example: 75% reimbursement rate for demonstration38            const reimbursedPrice = (originalPrice * 0.25).toFixed(2);39            cell.textContent = `€${reimbursedPrice}`;40            cell.classList.add('price-with-reimbursement');41        } else {42            // Return to original prices (stored in data attribute)43            const originalPrice = cell.getAttribute('data-original-price') || cell.textContent;44            cell.textContent = originalPrice;45            cell.classList.remove('price-with-reimbursement');46        }47    });48});49 50// Store original prices in data attributes51document.addEventListener('DOMContentLoaded', function() {52    document.querySelectorAll('tbody td:nth-child(3)').forEach(cell => {53        cell.setAttribute('data-original-price', cell.textContent);54    });55});56 57// Connect to RIZIV/INAMI API58async function fetchCodeDetails(code) {59    try {60        const response = await fetch(`https://webappsa.riziv-inami.fgov.be/Nomen/nl/search?searchString=${code}`);61        if (!response.ok) {62            throw new Error('Network response was not ok');63        }64        const data = await response.json();65        return {66            description: data.nomenclatureItemName || 'Description not found',67            price: data.reimbursementAmount ? `€${data.reimbursementAmount}` : 'Price not available'68        };69    } catch (error) {70        console.error('Error fetching from RIZIV/INAMI API:', error);71        return { 72            description: 'Error fetching data', 73            price: 'N/A' 74        };75    }76}77