{"id":59,"date":"2024-10-17T19:12:50","date_gmt":"2024-10-17T19:12:50","guid":{"rendered":"https:\/\/pdc.health\/?page_id=59"},"modified":"2024-10-17T19:12:51","modified_gmt":"2024-10-17T19:12:51","slug":"sdeva-3-3","status":"publish","type":"page","link":"https:\/\/pdc.health\/index.php\/sdeva-3-3","title":{"rendered":"SDEVA 3\/3"},"content":{"rendered":"        <div class=\"wp-sjs-plugin\" id=\"surveyContainer-9\">\n            <div id=\"surveyElement-9\">Survey is loading&#8230;<\/div>\n            <div id=\"surveyResult-9\"><\/div>\n        <\/div>\n        <script>\n            jQuery.ajax({\n                url:  \"https:\/\/pdc.health\/wp-admin\/admin-ajax.php?action=SurveyJS_GetSurveyJson\",\n                type: \"POST\",\n                data: { Id: 9, _wpnonce: 'ed6c76ef6d' },\n                success: function (data) {\n                    var json = {}\n                    let theme;\n                    if (data.json) {\n                        json = JSON.parse(data.json.replace(\/\\\\\\\"\/g, \"\\\"\").replace(\/\\\\\\\\\/g, \"\\\\\").replace(\/\\\\'\/g, \"'\"));\n                    }\n                    if (data.theme) {\n                        theme = JSON.parse(data.theme.replace(\/\\\\\\\"\/g, \"\\\"\").replace(\/\\\\\\\\\/g, \"\\\\\").replace(\/\\\\'\/g, \"'\"));\n                    } else {\n                        theme = null\n                    }\n                    jQuery(document).ready(()=>{\n                        initSurvey9(json, theme);\n                    });\n                }\n            });\n\n            function initSurvey9(json, theme) {\n                const survey9 = new Survey.Model(json);\n                if (!!theme) {\n                    survey9.applyTheme(theme);\n                }\n                window.survey9 = survey9; \n\n\/\/ ========== LOCAL STORAGE STATE MANAGEMENT ==========\nconst STORAGE_KEY = 'sjs_survey_' + 9;\n                \n                \/\/ Save state to localStorage on every change\n                survey9                    .onValueChanged\n                    .add((survey, options) => {\n                        if (debugVerbose) console.log(`The ${options.name} question value has changed to ${options.value}.`);\n\t\t\tlocalStorage.setItem(STORAGE_KEY, JSON.stringify({...survey.data, pageNo: survey.currentPageNo}));\n                    });\n                \n                \/\/ Save state on partial initialization (when user returns to page)\n                survey9                    .onPartialSend\n                    .add((survey, options) => {\n                        localStorage.setItem(STORAGE_KEY, JSON.stringify(survey.data));\n                    });\n                \n                \/\/ Restore state from localStorage on init\n                const savedState = localStorage.getItem(STORAGE_KEY);\n                if (savedState) {\n                    try {\n                        const savedData = JSON.parse(savedState);\n                        survey9.data = savedData;\n                        console.log('\u2705 Restored saved state from localStorage');\n\n\t\t\t\/\/ \ud83d\udc47 SET CURRENT PAGE (BETTER APPROACH) \ud83d\udc47\n        setTimeout(() => {\n            if (savedData && savedData.pageNo !== undefined) {\n                const pageIndex = Math.min(savedData.pageNo, survey9.pages.length - 1);\n                survey9.currentPageNo = pageIndex;\n                console.log(`\u23ed\ufe0f Jumped to saved page ${pageIndex}`);\n            } else if (survey9.pages.length > 1 && survey9.currentPageNo === 0) {\n                survey9.nextPage(); \/\/ Fallback to page 1\n                console.log('\u23ed\ufe0f Fallback: Skipped first page');\n            }\n        }, 200);\n        \/\/ \ud83d\udc46 END \ud83d\udc46\n\n                    } catch (e) {\n                        console.warn('\u26a0\ufe0f Could not restore saved state:', e);\n                    }\n                }\n                \n                \/\/ ========== INTERCEPT COMPLETION: save first, then navigate ==========\n                let _completing9 = false;\n                let _saving9 = false;\n\n                survey9.onCompleting.add(function(survey, options) {\n\n                    \/\/ If we're already in the save\/complete cycle, allow it through\n                    if (_completing9) { return; }\n\n                    if (_saving9) { options.allow = false; return; }\n\t\t    \/\/\n                    \/\/ Block navigation to completedHTML until save succeeds\n                    options.allow = false;\n                    _saving9 = true;\n\n \/\/ ADD THIS\n    const completeBtn9 = document.querySelector('#surveyElement-9 .sd-btn--action');\n    if (completeBtn9) {\n        completeBtn9.disabled = true;\n        completeBtn9.style.opacity = '0.5';\n        completeBtn9.style.cursor = 'wait';\n    }\n\/\/ ADD THIS \u2014 hourglass on the whole container too\n    const container9 = document.querySelector('#surveyElement-9');\n    if (container9) container9.style.cursor = 'wait';\n\n                    const plainData = survey.getPlainData({\n                        includeEmpty: false,\n                        includeCalculatedValues: true\n                    });\n\n                    if (debugVerbose) console.log('Table data:', JSON.stringify(plainData, null, 2));\n                    if (debugVerbose) console.table(plainData);\n\n                    let xformResult = null;\n                    let xformStatus = 'success';\n                    let xformError = '';\n\n                    try {\n                        console.log('\ud83d\udd04 Starting query transformation...');\n\n                        if (typeof query !== 'function') {\n                            throw new Error('query function is not defined. Make sure survey-transform.js is loaded.');\n                        }\n\n                        xformResult = query(survey.data);\n                        if (debugVerbose)\n                            console.log('\u2705 Query transformation successful:', xformResult);\n                        else\n                            console.log('\u2705 Query transformation successful');\n\n                    } catch (error) {\n                        console.error('\u274c Query transformation failed:', error);\n\n                        xformStatus = 'fail';\n                        xformError = new Date().toISOString() + ' - Transform Error: ' + error.message;\n\n                        if (error.stack) {\n                            xformError += '\\n' + error.stack;\n                        }\n\n                        console.error('Error details:', {\n                            message: error.message,\n                            stack: error.stack,\n                            surveyData: survey.data\n                        });\n                    }\n\n                    if (debugVerbose) console.log('Available keys:', Object.keys(survey.data));\n\n                    console.log('\ud83d\ude80 POST DATA:', {\n                        SurveyId: '9',\n                        SurveyType: 'OTHER',\n                        transformFile: ''\n                    });\n\n                    const respondentValue = (function() {\n                        const type = 'OTHER';\n                        if (!(['DEVA', 'DEVA-SPANISH', 'DEVA-TEST'].includes(type))) {\n                            return survey.data['noticeSigner'] || '';\n                        }\n                        return survey.data['agreementH14Signer'] || '';\n                    })();\n\n                    console.log('\ud83d\udd0d Resolved Respondent:', respondentValue);\n                    console.log('\ud83d\udd0d Type used:', 'OTHER');\n\n\t\t\t\t\tfunction restoreCompleteBtn9() {\n\t\t\t\t\t    if (completeBtn9) {\n\t\t\t\t\t        completeBtn9.disabled = false;\n\t\t\t\t\t        completeBtn9.style.opacity = '';\n\t\t\t\t\t        completeBtn9.style.cursor = '';\n\t\t\t\t\t    }\n\t\t\t\t\t    if (container9) container9.style.cursor = '';\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tlet userIP = '';\n\t\t\t\t\tconst ipTimeout9 = new Promise((_, reject) => setTimeout(() => reject('timeout'), 3000));\n\t\t\t\t\tconst ipFetch9   = fetch('https:\/\/api.ipify.org?format=json')\n\t\t\t\t\t                    .then(res => res.json())\n\t\t\t\t\t                    .then(data => { userIP = data.ip || ''; });\n\n\t\t\t\t\tPromise.race([ipFetch9, ipTimeout9])\n\t\t\t\t\t    .catch(() => { userIP = ''; })\n\t\t\t\t\t    .finally(() => {\n\t\t\t\t\t        doSurveySubmit9(userIP);\n\t\t\t\t\t    });\n\n\t\t\t\t\tfunction doSurveySubmit9(userIP) {\n\t\t\t\t\t    jQuery.ajax({\n\t\t\t\t\t        url:  \"https:\/\/pdc.health\/wp-admin\/admin-ajax.php?action=SurveyJS_SaveResult\",\n\t\t\t\t\t        type: \"POST\",\n                                                timeout: 20000,\n\t\t\t\t\t        data: { \n\t\t\t\t\t            SurveyId   : '9', \n\t\t\t\t\t            SurveyType : 'OTHER',\n\t\t\t\t\t            PatientID  : survey.data['PatientID'] || '',\n\t\t\t\t\t            PatientDOB : survey.data['PatientDOB'] || '',\n\t\t\t\t\t            Respondent : respondentValue,\n\t\t\t\t\t            Json       : JSON.stringify(survey.data, null, 2),\n\t\t\t\t\t            PlainText  : JSON.stringify(plainData, null, 2),\n\t\t\t\t\t            XformJson  : xformResult ? JSON.stringify(xformResult, null, 2) : '',\n\t\t\t\t\t            XformStatus: xformStatus,\n\t\t\t\t\t            XformError : xformError,\n\t\t\t\t\t            UserIP     : userIP,\n\t\t\t\t\t            _wpnonce   : '1e2954bfb4' \n\t\t\t\t\t        },\n\t\t\t\t\t        success: function(data) {\n\t\t\t\t\t            \/\/ WordPress nonce failure returns 200 with -1 or success:false\n\t\t\t\t\t            if (data === '-1' || data === -1 || (data && data.success === false)) {\n\t\t\t\t\t                console.warn('\u26a0\ufe0f Nonce validation failed');\n\t\t\t\t\t                _saving9 = false;\n\t\t\t\t\t                restoreCompleteBtn9();\n\t\t\t\t\t                alert('Session expired. Please refresh the page and try again.\\n\\nError: Nonce validation failed (-1)');\n\t\t\t\t\t                return;\n\t\t\t\t\t            }\n\t\t\t\t\t            console.log('\ud83d\udcbe Survey result saved successfully');\n\t\t\t\t\t            localStorage.removeItem(STORAGE_KEY);\n\t\t\t\t\t            if (debugVerbose) console.log('\ud83d\uddd1\ufe0f Cleared saved state from localStorage');\n\t\t\t\t\t            if (xformStatus === 'fail') {\n\t\t\t\t\t                console.warn('\u26a0\ufe0f Survey saved but transformation failed. Check database for error details.');\n\t\t\t\t\t            }\n\t\t\t\t\t            \/\/ \u2705 Set flag so the next onCompleting call passes through\n\t\t\t\t\t            _completing9 = true;\n\t\t\t\t\t            survey.doComplete();\n\t\t\t\t\t        },\n\t\t\t\t\t        error: function(xhr, status, error) {\n\t\t\t\t\t            console.error('\u274c Failed to save survey result:', error);\n\t\t\t\t\t            _saving9 = false;\n\t\t\t\t\t            restoreCompleteBtn9();\n\n\t\t\t\t\t            const isNetwork   = xhr.status === 0;\n\t\t\t\t\t            const isForbidden = xhr.status === 403;\n\n\t\t\t\t\t            let errorType;\n\t\t\t\t\t            if (isNetwork)        errorType = 'NETWORK ERROR (connection timed out)';\n\t\t\t\t\t            else if (isForbidden) errorType = 'ACCESS DENIED (403)';\n\t\t\t\t\t            else                  errorType = 'HTTP ' + xhr.status;\n\n\t\t\t\t\t            let serverMsg = '';\n\t\t\t\t\t            try {\n\t\t\t\t\t                const parsed = JSON.parse(xhr.responseText);\n\t\t\t\t\t                serverMsg = parsed.data || parsed.message || JSON.stringify(parsed).substring(0, 100);\n\t\t\t\t\t            } catch(e) {\n\t\t\t\t\t                serverMsg = xhr.responseText ? xhr.responseText.substring(0, 100) : '';\n\t\t\t\t\t            }\n\n\t\t\t\t\t            const diag = [\n\t\t\t\t\t\t\t'Time\/IP: ' + new Date().toISOString() + ' ' + (userIP || 'unavailable'),\n\t\t\t\t\t                'Error: ' + errorType + (serverMsg ? ' | ' + serverMsg : ''),\n\t\t\t\t\t                'Agent: ' + navigator.userAgent,\n\t\t\t\t\t            ].join('\\n');\n\n\t\t\t\t\t            alert(\n\t\t\t\t\t                'Error saving survey. Please try again. If the error persists, please take a screenshot, email to admin@pdcaz.com and call (480)462-3868.\\n\\n' + diag);\n\t\t\t\t\t        }\n\t\t\t\t\t    });\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t});\n                \/\/ ========== END COMPLETION HANDLER ==========\n\n                \n                survey9.onUploadFiles.add((_, options) => {\n                    const formData = new FormData();\n                    options.files.forEach((file) => {\n                        formData.append(file.name, file);\n                    });\n                formData.append(\"_wpnonce\", \"1eaba71d5c\");\n\n                    fetch(\"https:\/\/pdc.health\/wp-admin\/admin-ajax.php?action=SurveyJS_UploadFiles\", {\n                        method: \"POST\",\n                        body: formData\n                    })\n                        .then((response) => response.json())\n                        .then((data) => {\n                            options.callback(\n                                options.files.map((file) => {\n                                    return {\n                                        file: file,\n                                        content: data[file.name]\n                                    };\n                                })\n                            );\n                        })\n                        .catch((error) => {\n                            console.error(\"Error: \", error);\n                            options.callback([], [ 'An error occurred during file upload.' ]);\n                        });\n                });\n\n                function deleteFile(fileURL, options) {\n                    try {\n                        const deleteFileBaseUrl = \"https:\/\/pdc.health\/wp-admin\/admin-ajax.php?action=SurveyJS_DeleteFile&#038;_wpnonce=cfe3b01fcc\";\n                        const apiUrl = `${deleteFileBaseUrl}&name=${encodeURIComponent(fileURL)}`;\n                        fetch(apiUrl);\n                    } catch (error) {\n                        options.callback(\"error\");\n                    }\n                }\n\n                survey9.onClearFiles.add((_, options) => {\n                    if (!options.value || options.value.length === 0) {\n                        options.callback(\"success\");\n                        return;\n                    }\n\n                    if (!options.fileName && !!options.value) {\n                        for (const item of options.value) {\n                            deleteFile(item.content, options);\n                        }\n                    } else {\n                        const fileToRemove = options.value.find(\n                            (item) => item.name === options.fileName\n                        );\n                        if (fileToRemove) {\n                            deleteFile(fileToRemove.content, options);\n                        } else {\n                            console.error(`File with name ${options.fileName} is not found`);\n                        }\n                    }\n                    options.callback(\"success\");\n                });\n\n                jQuery(\"#surveyElement-9\").Survey({model: survey9\/*, css: customCss*\/});\n            }\n        <\/script>        \n        ","protected":false},"excerpt":{"rendered":"","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-59","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>SDEVA 3\/3 - HIPAA Wordpress<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/pdc.health\/index.php\/sdeva-3-3\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SDEVA 3\/3 - HIPAA Wordpress\" \/>\n<meta property=\"og:url\" content=\"https:\/\/pdc.health\/index.php\/sdeva-3-3\" \/>\n<meta property=\"og:site_name\" content=\"HIPAA Wordpress\" \/>\n<meta property=\"article:modified_time\" content=\"2024-10-17T19:12:51+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/pdc.health\/index.php\/sdeva-3-3\",\"url\":\"https:\/\/pdc.health\/index.php\/sdeva-3-3\",\"name\":\"SDEVA 3\/3 - HIPAA Wordpress\",\"isPartOf\":{\"@id\":\"https:\/\/pdc.health\/#website\"},\"datePublished\":\"2024-10-17T19:12:50+00:00\",\"dateModified\":\"2024-10-17T19:12:51+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/pdc.health\/index.php\/sdeva-3-3#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/pdc.health\/index.php\/sdeva-3-3\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/pdc.health\/index.php\/sdeva-3-3#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/pdc.health\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SDEVA 3\/3\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/pdc.health\/#website\",\"url\":\"https:\/\/pdc.health\/\",\"name\":\"HIPAA Wordpress\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/pdc.health\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SDEVA 3\/3 - HIPAA Wordpress","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/pdc.health\/index.php\/sdeva-3-3","og_locale":"en_US","og_type":"article","og_title":"SDEVA 3\/3 - HIPAA Wordpress","og_url":"https:\/\/pdc.health\/index.php\/sdeva-3-3","og_site_name":"HIPAA Wordpress","article_modified_time":"2024-10-17T19:12:51+00:00","twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/pdc.health\/index.php\/sdeva-3-3","url":"https:\/\/pdc.health\/index.php\/sdeva-3-3","name":"SDEVA 3\/3 - HIPAA Wordpress","isPartOf":{"@id":"https:\/\/pdc.health\/#website"},"datePublished":"2024-10-17T19:12:50+00:00","dateModified":"2024-10-17T19:12:51+00:00","breadcrumb":{"@id":"https:\/\/pdc.health\/index.php\/sdeva-3-3#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/pdc.health\/index.php\/sdeva-3-3"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/pdc.health\/index.php\/sdeva-3-3#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/pdc.health\/"},{"@type":"ListItem","position":2,"name":"SDEVA 3\/3"}]},{"@type":"WebSite","@id":"https:\/\/pdc.health\/#website","url":"https:\/\/pdc.health\/","name":"HIPAA Wordpress","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/pdc.health\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/pdc.health\/index.php\/wp-json\/wp\/v2\/pages\/59","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pdc.health\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/pdc.health\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/pdc.health\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/pdc.health\/index.php\/wp-json\/wp\/v2\/comments?post=59"}],"version-history":[{"count":1,"href":"https:\/\/pdc.health\/index.php\/wp-json\/wp\/v2\/pages\/59\/revisions"}],"predecessor-version":[{"id":60,"href":"https:\/\/pdc.health\/index.php\/wp-json\/wp\/v2\/pages\/59\/revisions\/60"}],"wp:attachment":[{"href":"https:\/\/pdc.health\/index.php\/wp-json\/wp\/v2\/media?parent=59"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}