Intake FR

Intkae inladen voor FR

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==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);
})();