Intake FR

Intkae inladen voor FR

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

You will need to install an extension such as Tampermonkey to install this script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         Intake FR
// @namespace    http://tampermonkey.net/
// @version      1.3.0
// @description  Intkae inladen voor FR
// @match        *://*/*
// @grant        none

// ==/UserScript==

// ⚠️ VEROUDERD: Dit script is verouderd en wordt niet meer onderhouden.
// De API-koppeling (whisper.anzwerz.ai) is verwijderd; gebruik een nieuwere versie indien beschikbaar.

(function() {
    'use strict';
    window.addEventListener('load', function() {

    function getPatientName() {

        // Pak de derde frame (index 2) uit het frameset
        const h3 = document.querySelector('h3.patient-card__name');
        if (h3){
            const patientName = h3.textContent;

            if (patientName) {
                console.log(patientName)
                return patientName.split(",")[0]
            }
        }

        return null
    }


    function storeConsultDate(){
        const datumEl = document.getElementById('frm_input_indication_date_datepicker');
        if (datumEl){
            console.log("element gevonden");
            const delen = datumEl.value.split(/[-/]/);
            const [dag, maand, jaar] = delen;
            const nieuweDatum = `${jaar}-${maand}-${dag}`;
            
            sessionStorage.setItem('consultDate', nieuweDatum);

        }
    }
    
    const patientName = getPatientName();
    storeConsultDate()
    const dateConsult = sessionStorage.getItem('consultDate');


    if (patientName === null){
        console.log("kan patiëntnaam niet vinden");
    } else if (dateConsult == null) {
        console.log("kan datum niet vinden");
        
    } else {
        console.log("haal data op");
        // Fetches naar whisper.anzwerz.ai verwijderd
    }

    function checkveld (el, input, checkboxValue=null) {
        if (!el) return { status: 'element niet gevonden', succes: false };

        if (el.tagName === 'TEXTAREA'){
            if (el.innerHTML){
                if (el.innerHTML.trim().replace(/\s+/g, '')  !== input.trim().replace(/\s+/g, '') ) return {
                    status: 'niet goed ingevuld', 
                    succes: false,
                    ingevuld: el.innerHTML.trim().replace(/\s+/g, ''),
                    opgehaald: input.trim().replace(/\s+/g, '')
                }
        }
        } else if (el.tagName === 'INPUT' && el.type === 'checkbox'){
            if (input) { 
                if (el.checked !== (input.toLowerCase() === checkboxValue.toLowerCase())) return {
                    status: 'niet goed ingevuld', 
                    succes: false,
                    ingevuld: el.checked,
                    opgehaald: input.toLowerCase(),
                    checkbox_waarde: checkboxValue.toLowerCase()
                }
            }
        } else if (el.tagName === 'INPUT' && el.type === 'date'){
            if (el.value && el.value !== input) return {
                status: 'niet goed ingevuld', 
                succes: false,
                ingevuld: el.value,
                opgehaald: input
            }
        } else if (el.tagName === 'INPUT' && el.type === 'text'){
            if (el.getAttribute('data-slider') === 'true') {
                if (el !== input) return {
                    status: 'niet goed ingevuld', 
                    succes: false,
                    ingevuld: el,
                    opgehaald: input
                }
            } else {
                if (el.value !== input) return {
                    status: 'niet goed ingevuld', 
                    succes: false,
                    ingevuld: el.value,
                    opgehaald: input
                }
            }
        } else if (el.tagName === 'SELECT') {
            if (el.value && el.value !== input) return { 
                status: 'niet goed ingevuld', 
                succes: false,
                ingevuld: el.value,
                opgehaald: input
            };
        } else if (el.tagName === 'INPUT' && el.type === 'radio') {

            if (input) { 
                if (el.checked !== (input.toLowerCase() === checkboxValue.toLowerCase())) return {
                    status: 'niet goed ingevuld', 
                    succes: false,
                    ingevuld: el.checked,
                    opgehaald: input.toLowerCase(),
                    checkbox_waarde: checkboxValue.toLowerCase()
                }
            }
        }

        return {status: 'ok', succes: true}
        
    }

    function sendReport(rapport, title){
        const allesOK = Object.values(rapport).every(v => v.status === 'ok' && v.succes === true);
        console.log(allesOK);
        console.log(new Date().toISOString());
        console.log(allesOK ? 'succes' : 'fouten');
        console.log(rapport);
        console.log(patientName);
        // Feedback-fetch naar whisper.anzwerz.ai verwijderd
    }

    function sendError(err){
        console.error("❌ Fout bij ophalen of verwerken van data:", err);
        // Error-log fetch naar whisper.anzwerz.ai verwijderd
    }

}, false);
})();