{"id":23878,"date":"2025-07-15T13:41:15","date_gmt":"2025-07-15T11:41:15","guid":{"rendered":"https:\/\/telemedi.com\/?page_id=23878"},"modified":"2025-07-15T13:41:50","modified_gmt":"2025-07-15T11:41:50","slug":"formularz-medycyny-pracy","status":"publish","type":"page","link":"https:\/\/telemedi.com\/pl\/formularz-medycyny-pracy\/","title":{"rendered":"Formularz Medycyny Pracy"},"content":{"rendered":"\n<div class=\"bg-gradient-to-br from-blue-50 to-indigo-100 min-h-screen py-8\">\n<div class=\"container mx-auto px-4\">\n\n    <!-- Komunikat dla wy\u0142\u0105czonego JavaScript -->\n    <div class=\"js-disabled-message max-w-2xl mx-auto\">\n        <div class=\"bg-yellow-50 border-l-4 border-yellow-400 p-6 rounded-r-lg shadow-lg\">\n            <div class=\"flex items-center\">\n                <div class=\"flex-shrink-0\">\n                    <svg class=\"h-8 w-8 text-yellow-400\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n                        <path fill-rule=\"evenodd\" d=\"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z\" clip-rule=\"evenodd\"><\/path>\n                    <\/svg>\n                <\/div>\n                <div class=\"ml-4\">\n                    <h3 class=\"text-lg font-medium text-yellow-800\">JavaScript jest wy\u0142\u0105czony<\/h3>\n                    <p class=\"mt-2 text-sm text-yellow-700\">\n                        Ten formularz wymaga w\u0142\u0105czonego JavaScript aby dzia\u0142a\u0107 poprawnie.\n                        Prosz\u0119 w\u0142\u0105czy\u0107 JavaScript w przegl\u0105darce i od\u015bwie\u017cy\u0107 stron\u0119.\n                    <\/p>\n                    <div class=\"mt-4\">\n                        <h4 class=\"text-sm font-medium text-yellow-800\">Jak w\u0142\u0105czy\u0107 JavaScript:<\/h4>\n                        <ul class=\"mt-2 text-sm text-yellow-700 list-disc list-inside space-y-1\">\n                            <li><strong>Chrome\/Edge:<\/strong> Ustawienia \u2192 Prywatno\u015b\u0107 i bezpiecze\u0144stwo \u2192 Ustawienia witryn \u2192 JavaScript<\/li>\n                            <li><strong>Firefox:<\/strong> Wpisz &#8222;about:config&#8221; w pasku adresu \u2192 javascript.enabled \u2192 ustaw na true<\/li>\n                            <li><strong>Safari:<\/strong> Preferencje \u2192 Bezpiecze\u0144stwo \u2192 W\u0142\u0105cz JavaScript<\/li>\n                        <\/ul>\n                    <\/div>\n                <\/div>\n            <\/div>\n        <\/div>\n    <\/div>\n\n    <!-- Formularz (widoczny tylko gdy JS jest w\u0142\u0105czony) -->\n    <div class=\"form-container max-w-6xl mx-auto\">\n        <div class=\"fade-in\">\n            <div class=\"text-center mb-8\">\n                <div class=\"mb-6\">\n                    <img decoding=\"async\" src=\"https:\/\/telemedi.com\/wp-content\/themes\/telemedico-home-page\/src\/icons\/telemedi.svg\"\n                         alt=\"Telemedi Logo\"\n                         class=\"mx-auto h-16 w-auto\">\n                <\/div>\n                <h1 class=\"text-3xl font-bold text-gray-800 mb-2\">Formularz Medycyny Pracy<\/h1>\n                <p class=\"text-gray-600\">Wype\u0142nij wszystkie wymagane pola<\/p>\n            <\/div>\n\n            <form id=\"occupationalMedicineForm\" method=\"POST\" enctype=\"multipart\/form-data\"\n                  class=\"bg-white p-6 rounded-lg shadow-md w-full max-w-4xl mx-auto\"\n                  data-hs-cf-bound=\"true\"\n                  novalidate\n            >\n                <!-- Krok 1: Wyb\u00f3r typu badania -->\n                <div class=\"mb-8\">\n                    <h3 class=\"text-lg font-semibold text-gray-800 mb-4 border-b border-teal-500 pb-2\">Krok 1: Wyb\u00f3r typu badania<\/h3>\n\n                    <div class=\"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4\">\n                        <div class=\"examination-type-card border border-gray-300 rounded-lg p-4 cursor-pointer hover:border-teal-500 hover:bg-teal-50 transition-colors\">\n                            <input type=\"checkbox\" id=\"exam_wstepne\" name=\"occupationalMedicineExamTypes[]\" value=\"1\" class=\"hidden\">\n                            <label for=\"exam_wstepne\" class=\"cursor-pointer\">\n                                <div class=\"flex items-start\">\n                                    <div class=\"flex-shrink-0\">\n                                        <div class=\"w-4 h-4 border-2 border-gray-300 rounded-sm mr-3 mt-1\"><\/div>\n                                    <\/div>\n                                    <div>\n                                        <h4 class=\"font-medium text-teal-700 mb-2\">Badanie wst\u0119pne<\/h4>\n                                        <p class=\"text-sm text-gray-600 mb-2\">Nowy pracownik przed rozpocz\u0119ciem pracy<\/p>\n                                        <ul class=\"text-xs text-gray-500 list-disc list-inside space-y-1\">\n                                            <li>Przed podj\u0119ciem pracy<\/li>\n                                            <li>Zdolno\u015b\u0107 do pracy<\/li>\n                                            <li>Wa\u017cne 30 dni<\/li>\n                                            <li>Pe\u0142ny zakres bada\u0144<\/li>\n                                        <\/ul>\n                                    <\/div>\n                                <\/div>\n                            <\/label>\n                        <\/div>\n\n                        <div class=\"examination-type-card border border-gray-300 rounded-lg p-4 cursor-pointer hover:border-teal-500 hover:bg-teal-50 transition-colors\">\n                            <input type=\"checkbox\" id=\"exam_okresowe\" name=\"occupationalMedicineExamTypes[]\" value=\"2\" class=\"hidden\">\n                            <label for=\"exam_okresowe\" class=\"cursor-pointer\">\n                                <div class=\"flex items-start\">\n                                    <div class=\"flex-shrink-0\">\n                                        <div class=\"w-4 h-4 border-2 border-gray-300 rounded-sm mr-3 mt-1\"><\/div>\n                                    <\/div>\n                                    <div>\n                                        <h4 class=\"font-medium text-teal-700 mb-2\">Badanie okresowe<\/h4>\n                                        <p class=\"text-sm text-gray-600 mb-2\">Pracownik w trakcie zatrudnienia<\/p>\n                                        <ul class=\"text-xs text-gray-500 list-disc list-inside space-y-1\">\n                                            <li>Co 1-5 lat<\/li>\n                                            <li>Zale\u017cne od stanowiska<\/li>\n                                            <li>Monitoruje zdrowie<\/li>\n                                            <li>Mo\u017cliwe badania dodatkowe<\/li>\n                                        <\/ul>\n                                    <\/div>\n                                <\/div>\n                            <\/label>\n                        <\/div>\n\n                        <div class=\"examination-type-card border border-gray-300 rounded-lg p-4 cursor-pointer hover:border-teal-500 hover:bg-teal-50 transition-colors\">\n                            <input type=\"checkbox\" id=\"exam_kontrolne\" name=\"occupationalMedicineExamTypes[]\" value=\"3\" class=\"hidden\">\n                            <label for=\"exam_kontrolne\" class=\"cursor-pointer\">\n                                <div class=\"flex items-start\">\n                                    <div class=\"flex-shrink-0\">\n                                        <div class=\"w-4 h-4 border-2 border-gray-300 rounded-sm mr-3 mt-1\"><\/div>\n                                    <\/div>\n                                    <div>\n                                        <h4 class=\"font-medium text-teal-700 mb-2\">Badanie kontrolne<\/h4>\n                                        <p class=\"text-sm text-gray-600 mb-2\">Po d\u0142ugiej chorobie<\/p>\n                                        <ul class=\"text-xs text-gray-500 list-disc list-inside space-y-1\">\n                                            <li>Po chorobie >30 dni<\/li>\n                                            <li>Po wypadku<\/li>\n                                            <li>Po urlopie zdrowotnym<\/li>\n                                            <li>Aktualne badania<\/li>\n                                        <\/ul>\n                                    <\/div>\n                                <\/div>\n                            <\/label>\n                        <\/div>\n\n                        <div class=\"examination-type-card border border-gray-300 rounded-lg p-4 cursor-pointer hover:border-teal-500 hover:bg-teal-50 transition-colors\">\n                            <input type=\"checkbox\" id=\"exam_sanitarno\" name=\"occupationalMedicineExamTypes[]\" value=\"4\" class=\"hidden\">\n                            <label for=\"exam_sanitarno\" class=\"cursor-pointer\">\n                                <div class=\"flex items-start\">\n                                    <div class=\"flex-shrink-0\">\n                                        <div class=\"w-4 h-4 border-2 border-gray-300 rounded-sm mr-3 mt-1\"><\/div>\n                                    <\/div>\n                                    <div>\n                                        <h4 class=\"font-medium text-teal-700 mb-2\">Badanie sanitarno-epidemiologiczne<\/h4>\n                                        <p class=\"text-sm text-gray-600 mb-2\">Bran\u017ca spo\u017cywcza i medyczna<\/p>\n                                        <ul class=\"text-xs text-gray-500 list-disc list-inside space-y-1\">\n                                            <li>W bran\u017cy spo\u017cywczej<\/li>\n                                            <li>W bran\u017cy medycznej<\/li>\n                                            <li>Zdolno\u015b\u0107 do pracy<\/li>\n                                            <li>Badania mikrobiologiczne<\/li>\n                                        <\/ul>\n                                    <\/div>\n                                <\/div>\n                            <\/label>\n                        <\/div>\n\n                        <div class=\"examination-type-card border border-gray-300 rounded-lg p-4 cursor-pointer hover:border-teal-500 hover:bg-teal-50 transition-colors\">\n                            <input type=\"checkbox\" id=\"exam_psycho\" name=\"occupationalMedicineExamTypes[]\" value=\"5\" class=\"hidden\">\n                            <label for=\"exam_psycho\" class=\"cursor-pointer\">\n                                <div class=\"flex items-start\">\n                                    <div class=\"flex-shrink-0\">\n                                        <div class=\"w-4 h-4 border-2 border-gray-300 rounded-sm mr-3 mt-1\"><\/div>\n                                    <\/div>\n                                    <div>\n                                        <h4 class=\"font-medium text-teal-700 mb-2\">Badania psychotechniczne<\/h4>\n                                        <p class=\"text-sm text-gray-600 mb-2\">Kierowcy i operatorzy maszyn<\/p>\n                                        <ul class=\"text-xs text-gray-500 list-disc list-inside space-y-1\">\n                                            <li>Kierowcy zawodowi<\/li>\n                                            <li>Operatorzy maszyn<\/li>\n                                            <li>Zdolno\u015b\u0107 psychofizyczna<\/li>\n                                            <li>Wa\u017cne 5 lat<\/li>\n                                        <\/ul>\n                                    <\/div>\n                                <\/div>\n                            <\/label>\n                        <\/div>\n                    <\/div>\n                <\/div>\n\n                <!-- Krok 2: Dane pracodawcy -->\n                <div class=\"mb-8\">\n                    <h3 class=\"text-lg font-semibold text-gray-800 mb-4 border-b border-teal-500 pb-2\">Krok 2: Dane pracodawcy<\/h3>\n\n                    <div class=\"p-4 rounded-lg mb-4\">\n                        <div class=\"mb-4\">\n                            <label for=\"employerNip\" class=\"block text-sm font-medium text-gray-700 mb-1\">NIP pracodawcy *<\/label>\n                            <div class=\"relative\">\n                                <input type=\"text\" id=\"employerNip\" name=\"employerNip\" required\n                                   placeholder=\"Wpisz NIP (10 cyfr)\"\n                                   class=\"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent\">\n                                <div id=\"nipLoader\" class=\"absolute right-3 top-1\/2 transform -translate-y-1\/2 hidden\">\n                                    <svg class=\"animate-spin h-5 w-5 text-blue-500\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" fill=\"none\" viewBox=\"0 0 24 24\">\n                                        <circle class=\"opacity-25\" cx=\"12\" cy=\"12\" r=\"10\" stroke=\"currentColor\" stroke-width=\"4\"><\/circle>\n                                        <path class=\"opacity-75\" fill=\"currentColor\" d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\"><\/path>\n                                    <\/svg>\n                                <\/div>\n                            <\/div>\n                            <p class=\"text-xs text-gray-500 mt-1\">Wprowad\u017a 10-cyfrowy NIP pracodawcy<\/p>\n                        <\/div>\n\n                        <!-- Employer details section - hidden by default -->\n                        <div id=\"employerDetails\" class=\"hidden\">\n                            <div class=\"bg-green-50 border border-green-200 rounded-lg p-4\">\n                                <div class=\"flex items-start\">\n                                    <div class=\"flex-shrink-0\">\n                                        <svg class=\"h-5 w-5 text-green-400\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n                                            <path fill-rule=\"evenodd\" d=\"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z\" clip-rule=\"evenodd\"><\/path>\n                                        <\/svg>\n                                    <\/div>\n                                    <div class=\"ml-3 flex-1\">\n                                        <h4 class=\"text-sm font-medium text-green-800\">Znaleziono pracodawc\u0119:<\/h4>\n                                        <div class=\"mt-2 text-sm text-green-700\">\n                                            <p><strong>Nazwa:<\/strong> <span id=\"employerName\"><\/span><\/p>\n                                            <p><strong>NIP:<\/strong> <span id=\"employerNipDisplay\"><\/span><\/p>\n                                        <\/div>\n                                    <\/div>\n                                <\/div>\n                            <\/div>\n                        <\/div>\n\n                        <!-- Hidden field for employer name -->\n                        <input type=\"hidden\" id=\"employerNameHidden\" name=\"employerName\">\n\n                        <!-- Hidden field for NIP (backend compatibility) -->\n                        <input type=\"hidden\" id=\"nipHidden\" name=\"nip\">\n\n                        <!-- Hidden field for source (Telemedi) -->\n                        <input type=\"hidden\" name=\"source\" value=\"4\">\n                    <\/div>\n                <\/div>\n\n                <!-- Krok 3: Dane pacjenta -->\n                <div class=\"mb-8\">\n                    <h3 class=\"text-lg font-semibold text-gray-800 mb-4 border-b border-teal-500 pb-2\">Krok 3: Dane pacjenta<\/h3>\n\n                    <!-- Wiersz 1: Imi\u0119 i Nazwisko -->\n                    <div class=\"grid grid-cols-1 md:grid-cols-2 gap-4 mb-4\">\n                        <div>\n                            <label for=\"firstName\" class=\"block text-sm font-medium text-gray-700 mb-1\">Imi\u0119 *<\/label>\n                            <input type=\"text\" id=\"firstName\" name=\"firstName\" required\n                                   class=\"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent\">\n                        <\/div>\n                        <div>\n                            <label for=\"lastName\" class=\"block text-sm font-medium text-gray-700 mb-1\">Nazwisko *<\/label>\n                            <input type=\"text\" id=\"lastName\" name=\"lastName\" required\n                                   class=\"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent\">\n                        <\/div>\n                    <\/div>\n\n                    <!-- Wiersz 2: PESEL i Data urodzenia -->\n                    <div class=\"grid grid-cols-1 md:grid-cols-2 gap-4 mb-4\">\n                        <div>\n                            <label for=\"pesel\" class=\"block text-sm font-medium text-gray-700 mb-1\">PESEL (opcjonalnie)<\/label>\n                            <input type=\"text\" id=\"pesel\" name=\"pesel\" pattern=\"[0-9]{11}\" maxlength=\"11\"\n                                   class=\"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent\">\n                        <\/div>\n                        <div>\n                            <label for=\"birthDate\" class=\"block text-sm font-medium text-gray-700 mb-1\">Data urodzenia (opcjonalnie)<\/label>\n                            <input type=\"date\" id=\"birthDate\" name=\"birthDate\"\n                                   class=\"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent\">\n                        <\/div>\n                    <\/div>\n\n                    <!-- Informacja o wymaganiach PESEL\/Data urodzenia -->\n                    <div class=\"mb-4\">\n                        <p class=\"text-xs text-red-600\">Obowi\u0105zkowe jest podanie <strong>PESEL<\/strong> lub <strong>daty urodzenia<\/strong> \u2013 jedna z tych danych musi by\u0107 uzupe\u0142niona.<\/p>\n                    <\/div>\n\n                    <!-- Wiersz 3: E-mail i Telefon -->\n                    <div class=\"grid grid-cols-1 md:grid-cols-2 gap-4 mb-4\">\n                        <div>\n                            <label for=\"email\" class=\"block text-sm font-medium text-gray-700 mb-1\">E-mail<\/label>\n                            <input type=\"email\" id=\"email\" name=\"userEmail\"\n                                   class=\"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent\">\n                        <\/div>\n                        <div>\n                            <label for=\"phone\" class=\"block text-sm font-medium text-gray-700 mb-1\">Telefon *<\/label>\n                            <input type=\"tel\" id=\"phone\" name=\"phone\" placeholder=\"+48 123 456 789\" required\n                                   class=\"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent\">\n                        <\/div>\n                    <\/div>\n\n                    <!-- Wiersz 4: Data dostarczenia orzeczenia -->\n                    <div class=\"mb-4\">\n                        <label for=\"deliveryDate\" class=\"block text-sm font-medium text-gray-700 mb-1\">Do kiedy musisz dostarczy\u0107 orzeczenie<\/label>\n                        <input type=\"date\" id=\"deliveryDate\" name=\"referralDeliveryDate\"\n                               class=\"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent\">\n                    <\/div>\n                <\/div>\n\n                <!-- Krok 4: Miejsce badania i preferencje -->\n                <div class=\"mb-8\">\n                    <h3 class=\"text-lg font-semibold text-gray-800 mb-4 border-b border-teal-500 pb-2\">Krok 4: Miejsce badania i preferencje<\/h3>\n\n                    <div class=\"grid grid-cols-1 md:grid-cols-2 gap-4 mb-4\">\n                        <div>\n                            <label for=\"city\" class=\"block text-sm font-medium text-gray-700 mb-1\">Miasto *<\/label>\n                            <input type=\"text\" id=\"city\" name=\"city\" required\n                                   class=\"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent\">\n                        <\/div>\n                        <div>\n                            <label for=\"postalCode\" class=\"block text-sm font-medium text-gray-700 mb-1\">Kod pocztowy *<\/label>\n                            <input type=\"text\" id=\"postalCode\" name=\"postalCode\" required placeholder=\"XX-XXX\"\n                                   class=\"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent\">\n                        <\/div>\n                    <\/div>\n\n                    <div class=\"mb-6\">\n                        <div class=\"flex items-center\">\n                            <input type=\"checkbox\" id=\"hasPreferences\" name=\"hasPreferences\"\n                                   class=\"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded\">\n                            <label for=\"hasPreferences\" class=\"ml-2 text-sm text-gray-700\">Mam preferencje<\/label>\n                        <\/div>\n                    <\/div>\n\n                    <div id=\"preferencesSection\" class=\"mb-6\">\n                        <div class=\"mb-6\">\n                            <label for=\"visitDatePreferences\" class=\"block text-sm font-medium text-gray-700 mb-1\">Opisz swoje preferencje, co do terminu wizyty: *<\/label>\n                            <textarea id=\"visitDatePreferences\" name=\"visitDatePreferences\" rows=\"3\" placeholder=\"Preferencje odno\u015bnie terminu\"\n                                      class=\"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent\"><\/textarea>\n                        <\/div>\n                    <\/div>\n\n                    <!-- Sekcja bada\u0144 psychotechnicznych (dla wst\u0119pnych i okresowych) -->\n                    <div id=\"psychoTechnicSection\" class=\"mb-6 space-y-2\" style=\"display: none;\">\n                        <div>\n                            <label class=\"block text-sm font-medium text-gray-700 mb-2\">Czy posiadasz AKTUALNE badania psychotechniczne i zabierzesz je ze sob\u0105 na badania *<\/label>\n                            <div class=\"space-y-2\">\n                                <div class=\"flex items-center\">\n                                    <input type=\"radio\" id=\"psychoTechnicExamsYes\" name=\"hasPsychotechnicalExams\" value=\"true\" required\n                                           class=\"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300\">\n                                    <label for=\"psychoTechnicExamsYes\" class=\"ml-2 text-sm text-gray-700\">Posiadam<\/label>\n                                <\/div>\n                                <div class=\"flex items-center\">\n                                    <input type=\"radio\" id=\"psychoTechnicExamsNo\" name=\"hasPsychotechnicalExams\" value=\"false\" required\n                                           class=\"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300\">\n                                    <label for=\"psychoTechnicExamsNo\" class=\"ml-2 text-sm text-gray-700\">Nie posiadam<\/label>\n                                <\/div>\n                            <\/div>\n                        <\/div>\n                    <\/div>\n\n                    <!-- Sekcja dla bada\u0144 wst\u0119pnych -->\n                    <div id=\"initialExamSection\" class=\"mb-6 space-y-4\" style=\"display: none;\">\n                        <h4 class=\"text-md font-medium text-gray-800 border-b border-gray-300 pb-2\">Dodatkowe informacje dla bada\u0144 wst\u0119pnych<\/h4>\n                        <div>\n                            <label for=\"plannedWorkStartDate\" class=\"block text-sm font-medium text-gray-700 mb-1\">Kiedy planujesz rozpocz\u0105\u0107 prac\u0119: *<\/label>\n                            <input type=\"date\" id=\"plannedWorkStartDate\" name=\"plannedWorkStartDate\" required\n                                   class=\"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent\">\n                        <\/div>\n                    <\/div>\n\n                    <!-- Sekcja dla bada\u0144 kontrolnych -->\n                    <div id=\"controlExamSection\" class=\"mb-6 space-y-4\" style=\"display: none;\">\n                        <h4 class=\"text-md font-medium text-gray-800 border-b border-gray-300 pb-2\">Dodatkowe informacje dla bada\u0144 kontrolnych<\/h4>\n\n                        <div>\n                            <label class=\"block text-sm font-medium text-gray-700 mb-2\">Jaki rodzaj zwolnienia: *<\/label>\n                            <div class=\"space-y-2\">\n                                <div class=\"flex items-center\">\n                                    <input type=\"radio\" id=\"leaveTypeSickness\" name=\"sickLeaveType\" value=\"1\" required\n                                           class=\"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300\">\n                                    <label for=\"leaveTypeSickness\" class=\"ml-2 text-sm text-gray-700\">Po chorobie<\/label>\n                                <\/div>\n                                <div class=\"flex items-center\">\n                                    <input type=\"radio\" id=\"leaveTypeMaternity\" name=\"sickLeaveType\" value=\"2\" required\n                                           class=\"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300\">\n                                    <label for=\"leaveTypeMaternity\" class=\"ml-2 text-sm text-gray-700\">Po macierzy\u0144skim<\/label>\n                                <\/div>\n                            <\/div>\n                        <\/div>\n\n                        <div>\n                            <label for=\"sickLeaveEndDate\" class=\"block text-sm font-medium text-gray-700 mb-1\">Do kiedy obowi\u0105zuje zwolnienie: *<\/label>\n                            <input type=\"date\" id=\"sickLeaveEndDate\" name=\"sickLeaveEndDate\" required\n                                   class=\"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent\">\n                        <\/div>\n                    <\/div>\n\n                    <!-- Sekcja dla bada\u0144 sanitarno-epidemiologicznych -->\n                    <div id=\"sanitaryExamSection\" class=\"mb-6 space-y-4\" style=\"display: none;\">\n                        <h4 class=\"text-md font-medium text-gray-800 border-b border-gray-300 pb-2\">Dodatkowe informacje dla bada\u0144 sanitarno-epidemiologicznych<\/h4>\n                        <div>\n                            <label class=\"block text-sm font-medium text-gray-700 mb-2\">Czy posiadasz ksi\u0105\u017ceczk\u0119 sanitarno-epidemiologiczn\u0105 lub wyniki bada\u0144 ka\u0142u *<\/label>\n                            <div class=\"space-y-2\">\n                                <div class=\"flex items-center\">\n                                    <input type=\"radio\" id=\"hasSanitaryDocumentsYes\" name=\"hasSanitaryEpidemiologicalBooklet\" value=\"true\" required\n                                           class=\"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300\">\n                                    <label for=\"hasSanitaryDocumentsYes\" class=\"ml-2 text-sm text-gray-700\">Posiadam<\/label>\n                                <\/div>\n                                <div class=\"flex items-center\">\n                                    <input type=\"radio\" id=\"hasSanitaryDocumentsNo\" name=\"hasSanitaryEpidemiologicalBooklet\" value=\"false\" required\n                                           class=\"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300\">\n                                    <label for=\"hasSanitaryDocumentsNo\" class=\"ml-2 text-sm text-gray-700\">Nie posiadam<\/label>\n                                <\/div>\n                            <\/div>\n                        <\/div>\n                    <\/div>\n\n                    <!-- Sekcja dla bada\u0144 okresowych -->\n                    <div id=\"periodicExamSection\" class=\"mb-6 space-y-4\" style=\"display: none;\">\n                        <h4 class=\"text-md font-medium text-gray-800 border-b border-gray-300 pb-2\">Dodatkowe informacje dla bada\u0144 okresowych<\/h4>\n                        <div>\n                            <label for=\"currentPeriodicValidUntil\" class=\"block text-sm font-medium text-gray-700 mb-1\">Do kiedy masz wa\u017cne obecne badania okresowe: *<\/label>\n                            <input type=\"date\" id=\"currentPeriodicValidUntil\" name=\"currentPeriodicExamsValidUntil\" required\n                                   class=\"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent\">\n\n                            <div class=\"mt-3\">\n                                <div class=\"flex items-center\">\n                                    <input type=\"checkbox\" id=\"dontKnowPeriodicDate\" name=\"dontKnowPeriodicDate\"\n                                           class=\"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded\">\n                                    <label for=\"dontKnowPeriodicDate\" class=\"ml-2 text-sm text-gray-700\">Nie wiem<\/label>\n                                <\/div>\n                            <\/div>\n\n                            <!-- Ukryte pole do przekazania informacji do backendu -->\n                            <input type=\"hidden\" id=\"skipPeriodicDateValidation\" name=\"skipPeriodicDateValidation\" value=\"false\">\n                        <\/div>\n                    <\/div>\n                <\/div>\n\n                <!-- Za\u0142\u0105czniki -->\n                <div class=\"mb-6\">\n                    <h3 class=\"text-lg font-semibold text-gray-800 mb-4 border-b border-teal-500 pb-2\">Krok 5: Za\u0142\u0105czniki *<\/h3>\n\n                    <p class=\"text-sm text-gray-600 mb-4\">\n                        Dodaj dodatkowe za\u0142\u0105czniki (skierowanie, dokumentacja medyczna, je\u017celi chcesz za\u0142\u0105czy\u0107 wi\u0119cej ni\u017c jeden plik, wybierz wszystkie pliki naraz) *\n                    <\/p>\n\n                    <div class=\"mb-4\">\n                        <input type=\"file\" id=\"attachments\" name=\"attachments[]\" multiple accept=\".jpg,.jpeg,.png,.pdf\"\n                               class=\"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent file:mr-4 file:py-2 file:px-4 file:rounded-md file:border-0 file:text-sm file:font-medium file:bg-blue-50 file:text-blue-700 hover:file:bg-blue-100\">\n                    <\/div>\n\n                    <!-- Lista za\u0142\u0105czonych plik\u00f3w -->\n                    <div id=\"fileList\" class=\"hidden mb-4\">\n                        <div class=\"bg-gray-50 border border-gray-200 rounded-lg p-4\">\n                            <div class=\"flex items-center justify-between mb-3\">\n                                <h4 class=\"font-medium text-gray-800\">Za\u0142\u0105czone pliki<\/h4>\n                                <span id=\"fileCount\" class=\"text-sm text-gray-500\">Liczba plik\u00f3w: 0<\/span>\n                            <\/div>\n                            <div id=\"fileItems\" class=\"space-y-2\"><\/div>\n                        <\/div>\n                    <\/div>\n\n                    <div class=\"text-xs text-gray-500 mb-2\">\n                        <strong>Akceptowane formaty:<\/strong> zdj\u0119cia i pliki PDF<br>\n                        <strong>Maksymalny rozmiar pliku:<\/strong> 10MB\n                    <\/div>\n\n                    <div class=\"bg-yellow-50 border-l-4 border-yellow-400 p-3 mb-4\">\n                        <div class=\"flex\">\n                            <div class=\"flex-shrink-0\">\n                                <svg class=\"h-5 w-5 text-yellow-400\" viewBox=\"0 0 20 20\" fill=\"currentColor\">\n                                    <path fill-rule=\"evenodd\" d=\"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z\" clip-rule=\"evenodd\"><\/path>\n                                <\/svg>\n                            <\/div>\n                            <div class=\"ml-3\">\n                                <p class=\"text-sm text-yellow-700\">\n                                    <strong>Wa\u017cne:<\/strong> Zaznacz wszystkie pliki za jednym razem (na komputerze przytrzymaj Ctrl lub Cmd podczas zaznaczania plik\u00f3w), a nie klikaj wielokrotnie &#8222;Wybierz pliki&#8221;\n                                <\/p>\n                            <\/div>\n                        <\/div>\n                    <\/div>\n                <\/div>\n\n                <!-- Uwagi -->\n                <div class=\"mb-6\">\n                    <h3 class=\"text-lg font-semibold text-gray-800 mb-4 border-b border-teal-500 pb-2\">Krok 6: Uwagi dodatkowe<\/h3>\n                    <textarea id=\"notes\" name=\"comment\" rows=\"4\"\n                              class=\"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent\"\n                              placeholder=\"Dodatkowe informacje...\"><\/textarea>\n                <\/div>\n\n                <!-- Zgody -->\n                <div class=\"mb-6 space-y-4\">\n                    <h3 class=\"text-lg font-semibold text-gray-800 mb-4 border-b border-teal-500 pb-2\">Krok 7: Zgody<\/h3>\n                    <!-- <div class=\"flex items-start\">\n                        <input type=\"checkbox\" id=\"consent1\" name=\"consent1\"\n                               class=\"mt-1 h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded flex-shrink-0\">\n                        <label for=\"consent1\" class=\"ml-3 text-sm text-gray-700\">\n                            Upowa\u017cniam Telmedicin Sp. z o.o. do dost\u0119pu do dokumentacji medycznej oraz weryfikacji przedstawionej faktury z podmiotem kt\u00f3ry ja wystawi\u0142 w celu weryfikacji zasadno\u015bci realizacji wniosku o refundacj\u0119 *\n                        <\/label>\n                    <\/div> -->\n\n                    <div class=\"flex items-start\">\n                        <input type=\"checkbox\" id=\"consent2\" name=\"consent2\" required\n                               class=\"mt-1 h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded flex-shrink-0\">\n                        <label for=\"consent2\" class=\"ml-3 text-sm text-gray-700\">\n                            Je\u017celi prze\u015blesz do nas formularz, administratorem Twoich danych osobowych b\u0119dzie Telmedicin sp. z o.o. z siedzib\u0105 w Warszawie. Twoje dane b\u0119dziemy przetwarza\u0107 w celu obs\u0142ugi zg\u0142oszenia (jako nasz prawnie uzasadniony interes). Szczeg\u00f3\u0142owe informacje o zasadach ochrony Twoich danych osobowych i przys\u0142uguj\u0105cych Ci prawach znajdziesz w naszej\n                            <a href=\"https:\/\/telemedi.com\/pl\/privacy-policy\/\" target=\"_blank\" class=\"text-blue-600 hover:text-blue-800 underline\">Polityce Prywatno\u015bci<\/a>. *\n                        <\/label>\n                    <\/div>\n\n                    <div class=\"flex items-start\">\n                        <input type=\"checkbox\" id=\"consent3\" name=\"consent3\" required\n                               class=\"mt-1 h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded flex-shrink-0\">\n                        <label for=\"consent3\" class=\"ml-3 text-sm text-gray-700\">\n                            O\u015bwiadczam, \u017ce wszystkie dane zawarte w formularzu s\u0105 zgodne ze stanem faktycznym oraz jestem \u015bwiadoma\/\u015bwiadomy odpowiedzialno\u015bci za wskazanie nieprawid\u0142owych danych mog\u0105cych mie\u0107 wp\u0142yw na proces realizacji zg\u0142oszenia *\n                        <\/label>\n                    <\/div>\n\n                    <div class=\"flex items-start\">\n                        <input type=\"checkbox\" id=\"consent4\" name=\"consent4\" required\n                               class=\"mt-1 h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded flex-shrink-0\">\n                        <label for=\"consent4\" class=\"ml-3 text-sm text-gray-700\">\n                            O\u015bwiadczam, \u017ce wyra\u017cam zgod\u0119 na przekazywanie informacji dotycz\u0105cych realizacji zg\u0142oszenia z wykorzystaniem \u015brodk\u00f3w porozumienia si\u0119 na odleg\u0142o\u015b\u0107 na wskazany przeze mnie w formularzu adres email *\n                        <\/label>\n                    <\/div>\n                <\/div>\n\n                <!-- Ukryte pole employerName -->\n                <input type=\"hidden\" id=\"employerName\" name=\"employerName\">\n\n                <!-- Przycisk submit -->\n                <div class=\"text-center\">\n                    <button type=\"submit\"\n                            class=\"w-full bg-green-600 hover:bg-green-700 text-white font-medium py-3 px-6 rounded-md transition duration-300 ease-in-out transform hover:scale-105 focus:outline-none focus:ring-2 focus:ring-green-500 focus:ring-offset-2\">\n                        Wy\u015blij wniosek\n                    <\/button>\n                <\/div>\n            <\/form>\n        <\/div>\n    <\/div>\n<\/div>\n<\/div>\n\n\n\n<script data-cookieconsent=\"ignore\">\n    \/\/ Konfiguracja API\n    const API_BASE_URL = 'https:\/\/ims-backend.tmdi00.com';\n\n    \/\/ Dodaj klas\u0119 js-enabled do body gdy JS jest w\u0142\u0105czony\n    document.body.classList.add('js-enabled');\n\n    \/\/ Walidacja NIP\n    function validateNIP(nip) {\n        \/\/ Usu\u0144 wszystkie nie-cyfry\n        nip = nip.replace(\/\\D\/g, '');\n\n        \/\/ Sprawd\u017a d\u0142ugo\u015b\u0107\n        if (nip.length !== 10) return false;\n\n        \/\/ Sprawd\u017a sum\u0119 kontroln\u0105\n        const weights = [6, 5, 7, 2, 3, 4, 5, 6, 7];\n        let sum = 0;\n\n        for (let i = 0; i < 9; i++) {\n            sum += parseInt(nip[i]) * weights[i];\n        }\n\n        const checksum = sum % 11;\n        const lastDigit = parseInt(nip[9]);\n\n        return checksum === lastDigit;\n    }\n\n    \/\/ Wyszukiwanie pracodawcy po NIP przez API\n    async function searchEmployerByNIP(nip) {\n        try {\n            const response = await fetch(`${API_BASE_URL}\/api\/occupational-medicine\/employers?nip=${nip}`, {\n                method: 'GET',\n                headers: {\n                    'Accept': 'application\/json',\n                    'Content-Type': 'application\/json'\n                }\n            });\n\n            if (!response.ok) {\n                if (response.status === 404) {\n                    \/\/ Pracodawca nie zosta\u0142 znaleziony\n                    return null;\n                }\n                throw new Error(`HTTP ${response.status}: ${response.statusText}`);\n            }\n\n            const result = await response.json();\n\n            \/\/ Sprawd\u017a czy API zwr\u00f3ci\u0142o b\u0142\u0105d\n            if (result.error === true) {\n                throw new Error('GUS_ERROR');\n            }\n\n            \/\/> this comment is used to circumvent the https:\/\/core.trac.wordpress.org\/ticket\/43785 bug\n            \/\/ Sprawd\u017a czy API zwr\u00f3ci\u0142o dane pracodawcy\n            if (result.data && result.data.length > 0) {\n                const employer = result.data[0]; \/\/ Zak\u0142adam \u017ce API zwraca tablic\u0119\n                return {\n                    name: employer.name,\n                    nip: employer.nip,\n                };\n            } else if (result.name) {\n                \/\/ Je\u015bli API zwraca bezpo\u015brednio obiekt pracodawcy\n                return {\n                    name: result.name,\n                    nip: result.nip,\n                };\n            }\n\n            return null;\n\n        } catch (error) {\n            console.error('B\u0142\u0105d podczas wyszukiwania pracodawcy:', error);\n            throw error;\n        }\n    }\n\n    \/\/ Funkcja do pokazywania\/ukrywania sekcji w zale\u017cno\u015bci od typu badania\n    function toggleConditionalSections() {\n        \/\/ Pobierz wszystkie sekcje\n        const psychoTechnicSection = document.getElementById('psychoTechnicSection');\n        const initialExamSection = document.getElementById('initialExamSection');\n        const controlExamSection = document.getElementById('controlExamSection');\n        const sanitaryExamSection = document.getElementById('sanitaryExamSection');\n        const periodicExamSection = document.getElementById('periodicExamSection');\n        const plannedWorkStartDate = document.getElementById('plannedWorkStartDate');\n\n        \/\/ Sprawd\u017a kt\u00f3re badania s\u0105 zaznaczone\n        const initialExam = document.getElementById('exam_wstepne').checked;\n        const periodicExam = document.getElementById('exam_okresowe').checked;\n        const controlExam = document.getElementById('exam_kontrolne').checked;\n        const sanitaryExam = document.getElementById('exam_sanitarno').checked;\n\n        \/\/ Ukryj wszystkie sekcje i wyczy\u015b\u0107 pola\n        [psychoTechnicSection, initialExamSection, controlExamSection, sanitaryExamSection, periodicExamSection].forEach(section => {\n            section.style.display = 'none';\n        });\n\n        \/\/ Wyczy\u015b\u0107 radio buttony\n        document.querySelectorAll('input[name=\"hasPsychotechnicalExams\"]').forEach(radio => {\n            radio.checked = false;\n        });\n        document.querySelectorAll('input[name=\"hasSanitaryEpidemiologicalBooklet\"]').forEach(radio => {\n            radio.checked = false;\n        });\n\n        \/\/ Wyczy\u015b\u0107 pola dat i radio buttons\n        document.getElementById('sickLeaveEndDate').value = '';\n        document.getElementById('currentPeriodicValidUntil').value = '';\n\n        \/\/ Wyczy\u015b\u0107 radio buttons dla typu zwolnienia\n        document.querySelectorAll('input[name=\"sickLeaveType\"]').forEach(radio => {\n            radio.checked = false;\n        });\n\n        \/\/ Wyczy\u015b\u0107 pole daty rozpocz\u0119cia pracy i ustaw wymagalno\u015b\u0107\n        plannedWorkStartDate.value = '';\n        clearError('plannedWorkStartDate');\n\n        \/\/ Poka\u017c sekcj\u0119 bada\u0144 psychotechnicznych dla wst\u0119pnych lub okresowych\n        if (initialExam || periodicExam) {\n            psychoTechnicSection.style.display = 'block';\n        }\n\n        \/\/ Poka\u017c odpowiednie sekcje\n        if (initialExam) {\n            initialExamSection.style.display = 'block';\n            plannedWorkStartDate.required = true;\n        } else {\n            plannedWorkStartDate.required = false;\n        }\n\n        if (controlExam) {\n            controlExamSection.style.display = 'block';\n        }\n\n        if (sanitaryExam) {\n            sanitaryExamSection.style.display = 'block';\n        }\n\n        if (periodicExam) {\n            periodicExamSection.style.display = 'block';\n        }\n    }\n\n    \/\/ Ustaw action formularza\n    const occupationalForm = document.getElementById('occupationalMedicineForm');\n    if (occupationalForm) {\n        occupationalForm.action = `${API_BASE_URL}\/api\/occupational-medicine\/issue\/create`;\n    }\n\n    \/\/ Obs\u0142uga kart wyboru typu badania (multi-select)\n    document.querySelectorAll('.examination-type-card').forEach(card => {\n        card.addEventListener('click', function() {\n            const checkbox = this.querySelector('input[type=\"checkbox\"]');\n            const visualCheckbox = this.querySelector('.w-4.h-4');\n\n            \/\/ Prze\u0142\u0105cz stan checkboxa\n            checkbox.checked = !checkbox.checked;\n\n            if (checkbox.checked) {\n                \/\/ Zaznacz kart\u0119\n                this.classList.remove('border-gray-300');\n                this.classList.add('border-teal-500', 'bg-teal-50');\n                visualCheckbox.classList.remove('border-gray-300');\n                visualCheckbox.classList.add('bg-teal-500', 'border-teal-500');\n                visualCheckbox.innerHTML = '<svg class=\"w-3 h-3 text-white\" fill=\"currentColor\" viewBox=\"0 0 20 20\"><path fill-rule=\"evenodd\" d=\"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z\" clip-rule=\"evenodd\"><\/path><\/svg>';\n            } else {\n                \/\/ Odznacz kart\u0119\n                this.classList.remove('border-teal-500', 'bg-teal-50');\n                this.classList.add('border-gray-300');\n                visualCheckbox.classList.remove('bg-teal-500', 'border-teal-500');\n                visualCheckbox.classList.add('border-gray-300');\n                visualCheckbox.innerHTML = '';\n            }\n\n            \/\/ Usu\u0144 b\u0142\u0105d walidacji je\u015bli jaki\u015b typ zosta\u0142 wybrany\n            const checkedTypes = document.querySelectorAll('input[name=\"occupationalMedicineExamTypes[]\"]:checked');\n            if (checkedTypes.length > 0) {\n                const existingError = document.getElementById('examination-types-error');\n                if (existingError) existingError.remove();\n            }\n\n            \/\/ Poka\u017c\/ukryj sekcje w zale\u017cno\u015bci od typu badania\n            toggleConditionalSections();\n        });\n    });\n\n    \/\/ Obs\u0142uga pola NIP pracodawcy\n    let nipSearchTimeout;\n\n    function processNipInput() {\n        const nipField = document.getElementById('employerNip');\n        let nip = nipField.value.replace(\/\\D\/g, ''); \/\/ Usu\u0144 wszystkie znaki nieb\u0119d\u0105ce cyframi\n\n        \/\/ Ogranicz do 10 cyfr\n        if (nip.length > 10) {\n            nip = nip.substring(0, 10);\n        }\n\n        \/\/ Zaktualizuj pole\n        nipField.value = nip;\n\n        const nipLoader = document.getElementById('nipLoader');\n        const employerDetails = document.getElementById('employerDetails');\n        const employerNameHidden = document.getElementById('employerNameHidden');\n        const nipHidden = document.getElementById('nipHidden');\n\n        \/\/ Synchronizuj ukryty pole NIP\n        nipHidden.value = nip;\n\n        \/\/ Ukryj szczeg\u00f3\u0142y pracodawcy je\u015bli NIP si\u0119 zmieni\u0142\n        employerDetails.classList.add('hidden');\n        employerNameHidden.value = '';\n\n        \/\/ Usu\u0144 b\u0142\u0119dy walidacji\n        clearError('employerNip');\n\n        \/\/ Anuluj poprzednie wyszukiwanie\n        if (nipSearchTimeout) {\n            clearTimeout(nipSearchTimeout);\n        }\n\n        \/\/ Sprawd\u017a czy NIP ma 10 cyfr\n        if (nip.length === 10) {\n            \/\/ Sprawd\u017a poprawno\u015b\u0107 NIP\n            if (!validateNIP(nip)) {\n                showError('employerNip', 'Nieprawid\u0142owy numer NIP - b\u0142\u0119dna suma kontrolna');\n                return;\n            }\n\n            \/\/ Poka\u017c loader i wyszukaj pracodawc\u0119\n            nipLoader.classList.remove('hidden');\n\n            nipSearchTimeout = setTimeout(async () => {\n                try {\n                    const employer = await searchEmployerByNIP(nip);\n                    nipLoader.classList.add('hidden');\n\n                    if (employer) {\n                        \/\/ Poka\u017c dane pracodawcy\n                        document.getElementById('employerName').textContent = employer.name;\n                        document.getElementById('employerNipDisplay').textContent = employer.nip;\n                        employerDetails.classList.remove('hidden');\n\n                        \/\/ Zapisz nazw\u0119 pracodawcy do ukrytego pola\n                        employerNameHidden.value = employer.name;\n\n                        \/\/ Usu\u0144 b\u0142\u0119dy je\u015bli pracodawca zosta\u0142 znaleziony\n                        clearError('employerNip');\n                    } else {\n                        showError('employerNip', 'Nie znaleziono pracodawcy o podanym numerze NIP');\n                    }\n                } catch (error) {\n                    nipLoader.classList.add('hidden');\n                    console.error('B\u0142\u0105d API:', error);\n\n                    \/\/ R\u00f3\u017cne komunikaty w zale\u017cno\u015bci od typu b\u0142\u0119du\n                    if (error.message === 'GUS_ERROR') {\n                        showError('employerNip', 'Wyst\u0105pi\u0142 problem z pobraniem danych pracodawcy z GUS');\n                    } else if (error.message.includes('404')) {\n                        showError('employerNip', 'Nie znaleziono pracodawcy o podanym numerze NIP');\n                    } else if (error.message.includes('500')) {\n                        showError('employerNip', 'B\u0142\u0105d serwera. Spr\u00f3buj ponownie za chwil\u0119');\n                    } else if (error.message.includes('Failed to fetch')) {\n                        showError('employerNip', 'B\u0142\u0105d po\u0142\u0105czenia z serwerem. Sprawd\u017a po\u0142\u0105czenie internetowe');\n                    } else {\n                        showError('employerNip', 'B\u0142\u0105d podczas wyszukiwania pracodawcy. Spr\u00f3buj ponownie');\n                    }\n                }\n            }, 100); \/\/ Ma\u0142e op\u00f3\u017anienie \u017ceby nie wysy\u0142a\u0107 request\u00f3w przy ka\u017cdej zmianie\n        }\n    }\n\n    \/\/ Obs\u0142uga zdarzenia input (wpisywanie)\n    document.getElementById('employerNip').addEventListener('input', processNipInput);\n\n    \/\/ Obs\u0142uga zdarzenia paste (wklejanie)\n    document.getElementById('employerNip').addEventListener('paste', function(e) {\n        \/\/ Daj przegl\u0105darce czas na wklejenie, potem przetw\u00f3rz\n        setTimeout(processNipInput, 10);\n    });\n\n    \/\/ Obs\u0142uga checkboxa \"Mam preferencje plac\u00f3wki\/terminu\"\n    document.getElementById('hasPreferences').addEventListener('change', function() {\n        const preferencesSection = document.getElementById('preferencesSection');\n        const plannedWorkStartDate = document.getElementById('plannedWorkStartDate');\n        const visitDatePreferences = document.getElementById('visitDatePreferences');\n\n        if (this.checked) {\n            \/\/ Poka\u017c sekcj\u0119 preferencji\n            preferencesSection.style.display = 'block';\n            \/\/ Przywr\u00f3\u0107 wymagalno\u015b\u0107 p\u00f3l tylko dla pola preferencji (data rozpocz\u0119cia pracy ma w\u0142asn\u0105 logik\u0119)\n            visitDatePreferences.required = true;\n        } else {\n            \/\/ Ukryj sekcj\u0119 preferencji\n            preferencesSection.style.display = 'none';\n            \/\/ Usu\u0144 wymagalno\u015b\u0107 p\u00f3l preferencji, ale zachowaj required dla daty rozpocz\u0119cia pracy je\u015bli badania wst\u0119pne\n            visitDatePreferences.required = false;\n            \/\/ Wyczy\u015b\u0107 b\u0142\u0119dy walidacji\n            clearError('plannedWorkStartDate');\n            clearError('visitDatePreferences');\n            \/\/ Wyczy\u015b\u0107 warto\u015bci p\u00f3l\n            visitDatePreferences.value = '';\n        }\n    });\n\n\n\n    \/\/ System walidacji\n    function showFormError(message) {\n        \/\/ Usu\u0144 poprzedni b\u0142\u0105d og\u00f3lny je\u015bli istnieje\n        const existingError = document.getElementById('form-general-error');\n        if (existingError) {\n            existingError.remove();\n        }\n\n        \/\/ Stw\u00f3rz kontener b\u0142\u0119du og\u00f3lnego\n        const errorDiv = document.createElement('div');\n        errorDiv.id = 'form-general-error';\n        errorDiv.className = 'error-message bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded-lg mt-4 mb-4 flex items-center';\n        errorDiv.innerHTML = `\n                <svg class=\"w-5 h-5 mr-2 flex-shrink-0\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n                    <path fill-rule=\"evenodd\" d=\"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z\" clip-rule=\"evenodd\"><\/path>\n                <\/svg>\n                <span class=\"font-medium\">${message}<\/span>\n            `;\n\n        \/\/ Dodaj b\u0142\u0105d na g\u00f3rze formularza\n        const form = document.getElementById('occupationalMedicineForm');\n        if (form) {\n            form.insertBefore(errorDiv, form.firstChild);\n\n            \/\/ Przewi\u0144 do b\u0142\u0119du\n            errorDiv.scrollIntoView({ behavior: 'smooth', block: 'center' });\n        }\n    }\n\n    function showError(fieldId, message) {\n        const field = document.getElementById(fieldId);\n        if (!field) return;\n\n        \/\/ Usu\u0144 poprzednie b\u0142\u0119dy\n        clearError(fieldId);\n\n        \/\/ Je\u015bli pole jest disabled, poka\u017c b\u0142\u0105d og\u00f3lny zamiast przy polu\n        if (field.disabled) {\n            showFormError(`${fieldId}: ${message}`);\n            return;\n        }\n\n        \/\/ Dodaj klas\u0119 b\u0142\u0119du do pola\n        field.classList.add('field-error');\n\n        \/\/ Stw\u00f3rz kontener b\u0142\u0119du\n        const errorDiv = document.createElement('div');\n        errorDiv.id = `${fieldId}-error`;\n        errorDiv.className = 'error-message text-red-600 text-sm mt-1 flex items-center';\n        errorDiv.innerHTML = `\n                <svg class=\"w-4 h-4 mr-1 flex-shrink-0\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n                    <path fill-rule=\"evenodd\" d=\"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z\" clip-rule=\"evenodd\"><\/path>\n                <\/svg>\n                ${message}\n            `;\n\n        \/\/ Dodaj b\u0142\u0105d po polu\n        field.parentNode.appendChild(errorDiv);\n    }\n\n    function clearError(fieldId) {\n        const field = document.getElementById(fieldId);\n        if (field) {\n            field.classList.remove('field-error');\n            const errorDiv = document.getElementById(`${fieldId}-error`);\n            if (errorDiv) {\n                errorDiv.remove();\n            }\n        }\n    }\n\n    function clearAllErrors() {\n        document.querySelectorAll('.field-error').forEach(field => {\n            field.classList.remove('field-error');\n        });\n        document.querySelectorAll('.error-message').forEach(error => {\n            \/\/ NIE usuwaj b\u0142\u0119du walidacji typ\u00f3w bada\u0144\n            if (error.id !== 'examination-types-error') {\n                error.remove();\n            }\n        });\n    }\n\n    function validateRequired(fieldId, fieldName) {\n        const field = document.getElementById(fieldId);\n        if (!field) return false;\n\n        const value = field.value.trim();\n        if (!value) {\n            showError(fieldId, `${fieldName} jest wymagane`);\n            return false;\n        }\n        clearError(fieldId);\n        return true;\n    }\n\n    function validateMaxLength(fieldId, maxLength, fieldName) {\n        const field = document.getElementById(fieldId);\n        if (!field) return true;\n\n        if (field.value.length > maxLength) {\n            showError(fieldId, `${fieldName} nie mo\u017ce by\u0107 d\u0142u\u017csze ni\u017c ${maxLength} znak\u00f3w`);\n            return false;\n        }\n        return true;\n    }\n\n    function validateEmailInput(input) {\n        const value = input.value.trim();\n        const errorId = input.id + '-error' || Math.random().toString(36).substr(2, 9) + '-error';\n        \/\/ Usu\u0144 poprzedni b\u0142\u0105d\n        if (input.nextElementSibling && input.nextElementSibling.classList.contains('error-message')) {\n            input.nextElementSibling.remove();\n        }\n        input.classList.remove('field-error');\n        if (!value) {\n            input.classList.add('field-error');\n            const errorDiv = document.createElement('div');\n            errorDiv.className = 'error-message text-red-600 text-sm mt-1 flex items-center';\n            errorDiv.innerHTML = `<svg class=\"w-4 h-4 mr-1 flex-shrink-0\" fill=\"currentColor\" viewBox=\"0 0 20 20\"><path fill-rule=\"evenodd\" d=\"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z\" clip-rule=\"evenodd\"><\/path><\/svg> Adres email jest wymagany`;\n            input.parentNode.appendChild(errorDiv);\n            return false;\n        }\n        if (!\/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$\/.test(value)) {\n            input.classList.add('field-error');\n            const errorDiv = document.createElement('div');\n            errorDiv.className = 'error-message text-red-600 text-sm mt-1 flex items-center';\n            errorDiv.innerHTML = `<svg class=\"w-4 h-4 mr-1 flex-shrink-0\" fill=\"currentColor\" viewBox=\"0 0 20 20\"><path fill-rule=\"evenodd\" d=\"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z\" clip-rule=\"evenodd\"><\/path><\/svg> Nieprawid\u0142owy format email`;\n            input.parentNode.appendChild(errorDiv);\n            return false;\n        }\n        return true;\n    }\n\n    function validatePesel(pesel) {\n        if (!pesel) return true;\n\n        \/\/ Sprawd\u017a d\u0142ugo\u015b\u0107 i czy sk\u0142ada si\u0119 tylko z cyfr\n        if (pesel.length !== 11 || !\/^\\d{11}$\/.test(pesel)) {\n            return false;\n        }\n\n        \/\/ Sprawd\u017a sum\u0119 kontroln\u0105 PESEL\n        const weights = [1, 3, 7, 9, 1, 3, 7, 9, 1, 3];\n        let sum = 0;\n        for (let i = 0; i < 10; i++) {\n            sum += parseInt(pesel[i]) * weights[i];\n        }\n        const checkSum = (10 - (sum % 10)) % 10;\n\n        if (checkSum !== parseInt(pesel[10])) {\n            return false;\n        }\n\n        \/\/ Sprawd\u017a dat\u0119 urodzenia w PESEL\n        const year = parseInt(pesel.substr(0, 2));\n        const month = parseInt(pesel.substr(2, 2));\n        const day = parseInt(pesel.substr(4, 2));\n\n        let fullYear;\n        if (month > 80) {\n            fullYear = 1800 + year;\n        } else if (month > 60) {\n            fullYear = 2200 + year;\n        } else if (month > 40) {\n            fullYear = 2100 + year;\n        } else if (month > 20) {\n            fullYear = 2000 + year;\n        } else {\n            fullYear = 1900 + year;\n        }\n\n        const actualMonth = month > 20 ? month - 20 : month;\n        const birthDate = new Date(fullYear, actualMonth - 1, day);\n\n        \/\/ Sprawd\u017a czy data jest prawid\u0142owa\n        if (birthDate.getFullYear() !== fullYear ||\n            birthDate.getMonth() !== actualMonth - 1 ||\n            birthDate.getDate() !== day) {\n            return false;\n        }\n\n        \/\/ Sprawd\u017a czy data nie jest w przysz\u0142o\u015bci\n        if (birthDate > new Date()) {\n            return false;\n        }\n\n        return true;\n    }\n\n    function extractBirthDateFromPesel(pesel) {\n        if (!pesel || pesel.length !== 11) {\n            return null;\n        }\n\n        const year = parseInt(pesel.substr(0, 2));\n        const month = parseInt(pesel.substr(2, 2));\n        const day = parseInt(pesel.substr(4, 2));\n\n        let fullYear;\n        if (month > 80) {\n            fullYear = 1800 + year;\n        } else if (month > 60) {\n            fullYear = 2200 + year;\n        } else if (month > 40) {\n            fullYear = 2100 + year;\n        } else if (month > 20) {\n            fullYear = 2000 + year;\n        } else {\n            fullYear = 1900 + year;\n        }\n\n        const actualMonth = month > 20 ? month - 20 : month;\n\n        \/\/ Formatuj dat\u0119 do formatu YYYY-MM-DD wymaganego przez input[type=\"date\"]\n        const formattedMonth = actualMonth.toString().padStart(2, '0');\n        const formattedDay = day.toString().padStart(2, '0');\n\n        return `${fullYear}-${formattedMonth}-${formattedDay}`;\n    }\n\n    function validatePostalCode(fieldId) {\n        const field = document.getElementById(fieldId);\n        if (!field) return true;\n\n        const value = field.value.trim();\n        if (value && !\/^\\d{2}-\\d{3}$\/.test(value)) {\n            showError(fieldId, 'Kod pocztowy musi by\u0107 w formacie XX-XXX');\n            return false;\n        }\n        if (value) {\n            clearError(fieldId);\n        }\n        return true;\n    }\n\n    function validateExaminationTypes() {\n        const examinationTypes = document.querySelectorAll('input[name=\"occupationalMedicineExamTypes[]\"]:checked');\n\n        \/\/ Usu\u0144 poprzedni b\u0142\u0105d\n        const existingError = document.getElementById('examination-types-error');\n        if (existingError) {\n            existingError.remove();\n        }\n\n        if (examinationTypes.length === 0) {\n            const errorDiv = document.createElement('div');\n            errorDiv.id = 'examination-types-error';\n            errorDiv.className = 'error-message text-red-600 text-sm mt-3 flex items-center bg-red-50 border border-red-200 rounded-md p-3';\n            errorDiv.innerHTML = `\n                    <svg class=\"w-4 h-4 mr-1 flex-shrink-0\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n                        <path fill-rule=\"evenodd\" d=\"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z\" clip-rule=\"evenodd\"><\/path>\n                    <\/svg>\n                    Prosz\u0119 wybra\u0107 przynajmniej jeden typ badania\n                `;\n\n            \/\/ Znajd\u017a sekcj\u0119 Krok 1 i dodaj b\u0142\u0105d na ko\u0144cu\n            const step1Header = Array.from(document.querySelectorAll('h3')).find(h => h.textContent.includes('Krok 1'));\n            const step1Section = step1Header ? step1Header.parentNode : null;\n\n            if (step1Section) {\n                step1Section.appendChild(errorDiv);\n            } else {\n                \/\/ Fallback - dodaj na ko\u0144cu formularza\n                const form = document.querySelector('form');\n                if (form) {\n                    form.appendChild(errorDiv);\n                }\n            }\n\n            return false;\n        }\n\n        return true;\n    }\n\n    function validatePeselOrBirthDate() {\n        const pesel = document.getElementById('pesel').value.trim();\n        const birthDate = document.getElementById('birthDate').value.trim();\n\n        clearError('pesel');\n        clearError('birthDate');\n\n        if (!pesel && !birthDate) {\n            showError('pesel', 'Obowi\u0105zkowe jest podanie PESEL lub daty urodzenia - jedna z tych danych musi by\u0107 uzupe\u0142niona');\n            return false;\n        }\n\n        if (pesel && !validatePesel(pesel)) {\n            showError('pesel', 'Nieprawid\u0142owy numer PESEL');\n            return false;\n        }\n\n        return true;\n    }\n\n    function validatePhoneRequirement() {\n        const phone = document.getElementById('phone').value.trim();\n\n        if (!phone) {\n            showError('phone', 'Numer telefonu jest wymagany');\n            return false;\n        }\n\n        clearError('phone');\n\n        if (phone && phone.length > 20) {\n            showError('phone', 'Numer telefonu nie mo\u017ce by\u0107 d\u0142u\u017cszy ni\u017c 20 znak\u00f3w');\n            return false;\n        }\n\n        return true;\n    }\n\n    function validatePhone(fieldId) {\n        const field = document.getElementById(fieldId);\n        if (!field) return true;\n\n        const value = field.value.trim();\n        if (!value) {\n            showError(fieldId, 'Numer telefonu jest wymagany');\n            return false;\n        }\n\n        if (value.length > 20) {\n            showError(fieldId, 'Numer telefonu nie mo\u017ce by\u0107 d\u0142u\u017cszy ni\u017c 20 znak\u00f3w');\n            return false;\n        }\n\n        clearError(fieldId);\n        return true;\n    }\n\n    function validateDateTime(fieldId, fieldName) {\n        const field = document.getElementById(fieldId);\n        if (!field) return true;\n\n        const value = field.value.trim();\n        if (!value) {\n            showError(fieldId, `${fieldName} jest wymagane`);\n            return false;\n        }\n\n        const selectedDate = new Date(value);\n        const now = new Date();\n\n        if (selectedDate <= now) {\n            showError(fieldId, 'Data musi by\u0107 w przysz\u0142o\u015bci');\n            return false;\n        }\n\n        clearError(fieldId);\n        return true;\n    }\n\n    function validateForm() {\n        let isValid = true;\n\n        \/\/ Walidacja typ\u00f3w bada\u0144\n        if (!validateExaminationTypes()) {\n            isValid = false;\n        }\n\n        \/\/ Walidacja danych pracodawcy (NIP)\n        const employerNip = document.getElementById('employerNip');\n        const employerNameHidden = document.getElementById('employerNameHidden');\n\n        if (!employerNip.value.trim()) {\n            showError('employerNip', 'NIP pracodawcy jest wymagany');\n            isValid = false;\n        } else if (employerNip.value.length !== 10) {\n            showError('employerNip', 'NIP musi sk\u0142ada\u0107 si\u0119 z 10 cyfr');\n            isValid = false;\n        } else if (!validateNIP(employerNip.value)) {\n            showError('employerNip', 'Nieprawid\u0142owy numer NIP - b\u0142\u0119dna suma kontrolna');\n            isValid = false;\n        } else if (!employerNameHidden.value.trim()) {\n            showError('employerNip', 'Nie znaleziono pracodawcy o podanym numerze NIP');\n            isValid = false;\n        } else {\n            clearError('employerNip');\n        }\n\n\n\n        \/\/ Walidacja danych pacjenta\n        if (!validateRequired('firstName', 'Imi\u0119')) isValid = false;\n        if (!validateMaxLength('firstName', 255, 'Imi\u0119')) isValid = false;\n\n        if (!validateRequired('lastName', 'Nazwisko')) isValid = false;\n        if (!validateMaxLength('lastName', 255, 'Nazwisko')) isValid = false;\n\n\n\n        if (!validatePeselOrBirthDate()) isValid = false;\n        if (!validatePhoneRequirement()) isValid = false;\n        if (!validatePhone('phone')) isValid = false;\n\n        \/\/ Walidacja miejsca (teraz wymagane)\n        if (!validateRequired('city', 'Miasto')) isValid = false;\n        if (!validateMaxLength('city', 255, 'Miasto')) isValid = false;\n\n        if (!validateRequired('postalCode', 'Kod pocztowy')) {\n            isValid = false;\n        }\n        if (!validatePostalCode('postalCode')) {\n            isValid = false;\n        }\n\n        \/\/ Walidacja preferencji (tylko je\u015bli \"Mam preferencje plac\u00f3wki\/terminu\" jest zaznaczone)\n        const hasPreferences = document.getElementById('hasPreferences').checked;\n        if (hasPreferences) {\n            if (!validateRequired('visitDatePreferences', 'Preferencje terminu wizyty')) isValid = false;\n        }\n\n        \/\/ Walidacja p\u00f3l dla bada\u0144 wst\u0119pnych (je\u015bli sekcja jest widoczna)\n        const initialExamSection = document.getElementById('initialExamSection');\n        \/\/> this comment is used to circumvent the https:\/\/core.trac.wordpress.org\/ticket\/43785 bug\n        if (initialExamSection && initialExamSection.style.display !== 'none') {\n            if (!validateRequired('plannedWorkStartDate', 'Data rozpocz\u0119cia pracy')) isValid = false;\n            if (!validateDateTime('plannedWorkStartDate', 'Data rozpocz\u0119cia pracy')) isValid = false;\n        }\n\n        \/\/ Walidacja p\u00f3l dla bada\u0144 kontrolnych (je\u015bli sekcja jest widoczna)\n        const controlExamSection = document.getElementById('controlExamSection');\n        \/\/> this comment is used to circumvent the https:\/\/core.trac.wordpress.org\/ticket\/43785 bug\n        if (controlExamSection && controlExamSection.style.display !== 'none') {\n            \/\/ Walidacja rodzaju zwolnienia\n            const sickLeaveType = document.querySelector('input[name=\"sickLeaveType\"]:checked');\n            if (!sickLeaveType) {\n                showError('leaveTypeSickness', 'Wyb\u00f3r rodzaju zwolnienia jest wymagany');\n                isValid = false;\n            } else {\n                clearError('leaveTypeSickness');\n                clearError('leaveTypeMaternity');\n            }\n\n            \/\/ Walidacja daty ko\u0144ca zwolnienia\n            if (!validateRequired('sickLeaveEndDate', 'Data ko\u0144ca zwolnienia')) isValid = false;\n        }\n\n        \/\/ Walidacja p\u00f3l dla bada\u0144 sanitarno-epidemiologicznych (je\u015bli sekcja jest widoczna)\n        const sanitaryExamSection = document.getElementById('sanitaryExamSection');\n        \/\/> this comment is used to circumvent the https:\/\/core.trac.wordpress.org\/ticket\/43785 bug\n        if (sanitaryExamSection && sanitaryExamSection.style.display !== 'none') {\n            const hasSanitaryDocuments = document.querySelector('input[name=\"hasSanitaryEpidemiologicalBooklet\"]:checked');\n            if (!hasSanitaryDocuments) {\n                showError('hasSanitaryDocumentsYes', 'To pole jest wymagane dla bada\u0144 sanitarno-epidemiologicznych');\n                isValid = false;\n            } else {\n                clearError('hasSanitaryDocumentsYes');\n                clearError('hasSanitaryDocumentsNo');\n            }\n        }\n\n        \/\/ Walidacja p\u00f3l dla bada\u0144 okresowych (je\u015bli sekcja jest widoczna)\n        const periodicExamSection = document.getElementById('periodicExamSection');\n        \/\/> this comment is used to circumvent the https:\/\/core.trac.wordpress.org\/ticket\/43785 bug\n        if (periodicExamSection && periodicExamSection.style.display !== 'none') {\n            const dontKnowPeriodicDate = document.getElementById('dontKnowPeriodicDate');\n            if (!dontKnowPeriodicDate.checked) {\n                if (!validateRequired('currentPeriodicValidUntil', 'Data wa\u017cno\u015bci obecnych bada\u0144 okresowych')) isValid = false;\n            }\n        }\n\n        \/\/ Walidacja p\u00f3l dla bada\u0144 psychotechnicznych (je\u015bli sekcja jest widoczna)\n        const psychoTechnicSection = document.getElementById('psychoTechnicSection');\n        \/\/> this comment is used to circumvent the https:\/\/core.trac.wordpress.org\/ticket\/43785 bug\n        if (psychoTechnicSection && psychoTechnicSection.style.display !== 'none') {\n            const psychoTechnicExams = document.querySelector('input[name=\"hasPsychotechnicalExams\"]:checked');\n            if (!psychoTechnicExams) {\n                showError('psychoTechnicExamsYes', 'To pole jest wymagane dla bada\u0144 psychotechnicznych');\n                isValid = false;\n            } else {\n                clearError('psychoTechnicExamsYes');\n                clearError('psychoTechnicExamsNo');\n            }\n        }\n\n        \/\/ Walidacja email pacjenta (opcjonalna)\n        \/\/ if (!validateEmail('email')) isValid = false;\n\n        \/\/ Walidacja za\u0142\u0105cznik\u00f3w\n        if (selectedFiles.length === 0) {\n            showError('attachments', 'Przynajmniej jeden za\u0142\u0105cznik ze skierowaniem jest wymagany');\n            isValid = false;\n        } else {\n            clearError('attachments');\n        }\n\n        \/\/ Walidacja zg\u00f3d\n        const consents = ['consent2', 'consent3', 'consent4'];\n        consents.forEach(consentId => {\n            const consent = document.getElementById(consentId);\n            if (!consent.checked) {\n                showError(consentId, 'Ta zgoda jest wymagana');\n                isValid = false;\n            } else {\n                clearError(consentId);\n            }\n        });\n\n        return isValid;\n    }\n\n    \/\/ Walidacja formularza przy submit\n    const form = document.querySelector('form');\n\n    if (form) {\n        form.addEventListener('submit', async function(e) {\n            \/\/ Przed wys\u0142aniem ustaw employerName z ukrytego pola\n            const employerNameHidden = document.getElementById('employerNameHidden');\n            const employerNameInput = document.getElementById('employerName');\n            if (employerNameInput) {\n                employerNameInput.value = employerNameHidden.value;\n            }\n\n            \/\/ Synchronizuj pole NIP przed wys\u0142aniem\n            const employerNipInput = document.getElementById('employerNip');\n            const nipHidden = document.getElementById('nipHidden');\n            if (employerNipInput && nipHidden) {\n                nipHidden.value = employerNipInput.value;\n            }\n\n            \/\/ Radio buttony ju\u017c obs\u0142uguj\u0105 warto\u015bci true\/false automatycznie\n            \/\/ Nie potrzebujemy dodatkowych hidden input\u00f3w\n\n            \/\/ Teraz dopiero tw\u00f3rz FormData\n            e.preventDefault();\n            clearAllErrors(); \/\/ Usuwam stare b\u0142\u0119dy\n            if (!validateForm()) {\n                const firstError = document.querySelector('.field-error, .error-message');\n                if (firstError) {\n                    firstError.scrollIntoView({ behavior: 'smooth', block: 'center' });\n                }\n                return false;\n            }\n            const submitBtn = this.querySelector('button[type=\"submit\"]');\n            submitBtn.textContent = 'Wysy\u0142anie...';\n            submitBtn.disabled = true;\n            const formData = new FormData(this);\n            try {\n                const response = await fetch(this.action, {\n                    method: this.method,\n                    body: formData\n                });\n                const data = await response.json().catch(() => ({}));\n\n                if (response.ok && data.successful) {\n                    this.style.display = 'none';\n                    const successDiv = document.createElement('div');\n                    successDiv.className = 'bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded relative mt-6 text-center';\n                    successDiv.innerHTML = '<strong>Dzi\u0119kujemy! Tw\u00f3j formularz zosta\u0142 przes\u0142any. Wkr\u00f3tce skontaktujemy si\u0119 z Tob\u0105 w celu ustalenia terminu bada\u0144 Medycyny Pracy.<\/strong>';\n                    this.parentNode.insertBefore(successDiv, this);\n\n                    \/\/ Scroll do g\u00f3ry strony\n                    window.scrollTo({\n                        top: 0,\n                        behavior: 'smooth'\n                    });\n                } else {\n                    \/\/ Przywr\u00f3\u0107 przycisk\n                    submitBtn.textContent = 'Wy\u015blij wniosek';\n                    submitBtn.disabled = false;\n\n                    \/\/ Je\u015bli mamy b\u0142\u0119dy walidacji, poka\u017c je przy polach\n                    if (data.errors && Array.isArray(data.errors)) {\n                        let hasFieldErrors = false;\n\n                        data.errors.forEach(err => {\n                            if (err.field && err.message) {\n                                \/\/ Spr\u00f3buj znale\u017a\u0107 pole w formularzu\n                                const field = document.getElementById(err.field);\n                                if (field) {\n                                    showError(err.field, err.message);\n                                    hasFieldErrors = true;\n                                } else {\n                                    \/\/ Je\u015bli nie ma pola, poka\u017c b\u0142\u0105d og\u00f3lny\n                                    console.warn('Nie znaleziono pola:', err.field);\n                                    showFormError(`${err.message}`);\n                                }\n                            }\n                        });\n\n                        if (hasFieldErrors) {\n                            \/\/ Przewi\u0144 do pierwszego b\u0142\u0119du\n                            const firstError = document.querySelector('.field-error, .error-message');\n                            if (firstError) {\n                                firstError.scrollIntoView({ behavior: 'smooth', block: 'center' });\n                            }\n                        }\n                    } else if (data.error) {\n                        showFormError(data.error);\n                    } else {\n                        showFormError('Wyst\u0105pi\u0142 nieznany b\u0142\u0105d podczas wysy\u0142ania formularza.');\n                    }\n                }\n            } catch (err) {\n                submitBtn.textContent = 'Wy\u015blij wniosek';\n                submitBtn.disabled = false;\n                showFormError('Nie uda\u0142o si\u0119 po\u0142\u0105czy\u0107 z serwerem. Spr\u00f3buj ponownie p\u00f3\u017aniej.');\n            }\n        });\n    }\n\n    \/\/ Walidacja w czasie rzeczywistym\n    document.getElementById('pesel').addEventListener('input', function(e) {\n        this.value = this.value.replace(\/\\D\/g, '');\n        if (this.value.length === 11) {\n            clearError('pesel');\n            clearError('birthDate');\n\n            \/\/ Sprawd\u017a, czy PESEL jest poprawny i wype\u0142nij dat\u0119 urodzenia\n            if (validatePesel(this.value)) {\n                const birthDate = extractBirthDateFromPesel(this.value);\n                if (birthDate) {\n                    const birthDateField = document.getElementById('birthDate');\n                    if (birthDateField) {\n                        birthDateField.value = birthDate;\n                    }\n                }\n            }\n        }\n    });\n\n    \/\/ Walidacja real-time dla kluczowych p\u00f3l\n    ['employerNip', 'firstName', 'lastName', 'city', 'visitDatePreferences', 'sickLeaveEndDate', 'currentPeriodicValidUntil', 'plannedWorkStartDate'].forEach(fieldId => {\n        const field = document.getElementById(fieldId);\n        if (field) {\n            field.addEventListener('blur', function() {\n                if (fieldId === 'employerNip') {\n                    \/\/ Specjalna walidacja dla NIP\n                    const nip = this.value.replace(\/\\D\/g, '');\n                    if (nip.length === 10 && validateNIP(nip)) {\n                        clearError(fieldId);\n                    }\n                } else if (this.value.trim()) {\n                    clearError(fieldId);\n                } else {\n                    \/\/ Sprawd\u017a czy pole jest wymagane\n                    if (this.hasAttribute('required')) {\n                        const fieldName = this.previousElementSibling.textContent.replace(' *', '');\n                        showError(fieldId, `${fieldName} jest wymagane`);\n                    }\n                }\n            });\n        }\n    });\n\n    \/\/ Walidacja radio buttons dla typu zwolnienia\n    document.querySelectorAll('input[name=\"sickLeaveType\"]').forEach(radio => {\n        radio.addEventListener('change', function() {\n            clearError('leaveTypeSickness');\n            clearError('leaveTypeMaternity');\n        });\n    });\n\n    \/\/ Walidacja radio buttons dla bada\u0144 sanitarno-epidemiologicznych\n    document.querySelectorAll('input[name=\"hasSanitaryEpidemiologicalBooklet\"]').forEach(radio => {\n        radio.addEventListener('change', function() {\n            clearError('hasSanitaryDocumentsYes');\n            clearError('hasSanitaryDocumentsNo');\n        });\n    });\n\n    \/\/ Walidacja radio buttons dla bada\u0144 psychotechnicznych\n    document.querySelectorAll('input[name=\"hasPsychotechnicalExams\"]').forEach(radio => {\n        radio.addEventListener('change', function() {\n            clearError('psychoTechnicExamsYes');\n            clearError('psychoTechnicExamsNo');\n        });\n    });\n\n    \/\/ Walidacja checkbox\u00f3w zg\u00f3d\n    ['consent2', 'consent3', 'consent4'].forEach(consentId => {\n        const consent = document.getElementById(consentId);\n        if (consent) {\n            consent.addEventListener('change', function() {\n                if (this.checked) {\n                    clearError(consentId);\n                }\n            });\n        }\n    });\n\n    \/\/ Obs\u0142uga checkbox \"Nie wiem\" dla bada\u0144 okresowych\n    const dontKnowPeriodicDate = document.getElementById('dontKnowPeriodicDate');\n    if (dontKnowPeriodicDate) {\n        dontKnowPeriodicDate.addEventListener('change', function() {\n            const currentPeriodicValidUntil = document.getElementById('currentPeriodicValidUntil');\n            const skipPeriodicDateValidation = document.getElementById('skipPeriodicDateValidation');\n\n            if (this.checked) {\n                \/\/ Wy\u0142\u0105cz pole daty\n                currentPeriodicValidUntil.disabled = true;\n                currentPeriodicValidUntil.value = '';\n                currentPeriodicValidUntil.required = false;\n                currentPeriodicValidUntil.classList.add('disabled-input');\n                \/\/ Ustaw ukryte pole na true\n                skipPeriodicDateValidation.value = 'true';\n                \/\/ Wyczy\u015b\u0107 b\u0142\u0119dy walidacji\n                clearError('currentPeriodicValidUntil');\n            } else {\n                \/\/ W\u0142\u0105cz pole daty\n                currentPeriodicValidUntil.disabled = false;\n                currentPeriodicValidUntil.required = true;\n                currentPeriodicValidUntil.classList.remove('disabled-input');\n                \/\/ Ustaw ukryte pole na false\n                skipPeriodicDateValidation.value = 'false';\n            }\n        });\n    }\n\n\n\n    \/\/ Walidacja email pacjenta w czasie rzeczywistym (wy\u0142\u0105czona)\n    \/\/ const emailField = document.getElementById('email');\n    \/\/ if (emailField) {\n    \/\/     emailField.addEventListener('blur', function() {\n    \/\/         validateEmail('email');\n    \/\/     });\n    \/\/     emailField.addEventListener('input', function() {\n    \/\/         if (this.classList.contains('field-error')) {\n    \/\/             validateEmail('email');\n    \/\/         }\n    \/\/     });\n    \/\/ }\n\n    \/\/ Walidacja kodu pocztowego w czasie rzeczywistym\n    ['postalCode', 'userPostalCode'].forEach(fieldId => {\n        const field = document.getElementById(fieldId);\n        if (field) {\n            field.addEventListener('input', function() {\n                \/\/ Auto-format postal code\n                let value = this.value.replace(\/\\D\/g, '');\n                if (value.length >= 3) {\n                    value = value.substring(0, 2) + '-' + value.substring(2, 5);\n                }\n                this.value = value;\n            });\n\n            field.addEventListener('blur', function() {\n                validatePostalCode(fieldId);\n            });\n        }\n    });\n\n    \/\/ Walidacja dat\n    const birthDateField = document.getElementById('birthDate');\n    if (birthDateField) {\n        birthDateField.addEventListener('change', function() {\n            clearError('pesel');\n            clearError('birthDate');\n        });\n    }\n\n    \/\/ Walidacja daty dostarczenia orzeczenia (wy\u0142\u0105czona)\n    \/\/ const deliveryDateField = document.getElementById('deliveryDate');\n    \/\/ if (deliveryDateField) {\n    \/\/     deliveryDateField.addEventListener('change', function() {\n    \/\/         if (this.value.trim()) {\n    \/\/             clearError('deliveryDate');\n    \/\/         }\n    \/\/     });\n    \/\/ }\n\n    \/\/ Walidacja daty rozpocz\u0119cia pracy\n    const workStartField = document.getElementById('plannedWorkStartDate');\n    if (workStartField) {\n        workStartField.addEventListener('change', function() {\n            validateDateTime('plannedWorkStartDate', 'Data rozpocz\u0119cia pracy');\n        });\n    }\n\n    \/\/ Walidacja telefonu w czasie rzeczywistym\n    const phoneField = document.getElementById('phone');\n    if (phoneField) {\n        phoneField.addEventListener('input', function() {\n            \/\/ Usu\u0144 nieprawid\u0142owe znaki\n            this.value = this.value.replace(\/[^0-9\\s\\+\\-\\(\\)]\/g, '');\n        });\n\n        phoneField.addEventListener('blur', function() {\n            validatePhone('phone');\n        });\n    }\n\n    \/\/ Obs\u0142uga listy za\u0142\u0105cznik\u00f3w\n    let selectedFiles = [];\n\n    document.getElementById('attachments').addEventListener('change', function(e) {\n        const files = Array.from(e.target.files);\n\n        \/\/ Walidacja plik\u00f3w\n        let validFiles = [];\n        let hasErrors = false;\n\n        for (let file of files) {\n            \/\/ Sprawd\u017a rozmiar pliku (max 10MB)\n            if (file.size > 10 * 1024 * 1024) {\n                showError('attachments', `Plik \"${file.name}\" jest za du\u017cy. Maksymalny rozmiar to 10MB.`);\n                hasErrors = true;\n                continue;\n            }\n\n            \/\/ Sprawd\u017a typ pliku\n            const allowedTypes = ['application\/pdf', 'image\/jpeg', 'image\/png', 'image\/jpg'];\n            if (!allowedTypes.includes(file.type)) {\n                showError('attachments', `Plik \"${file.name}\" ma nieprawid\u0142owy format. Dozwolone: PDF, JPEG, PNG.`);\n                hasErrors = true;\n                continue;\n            }\n\n            validFiles.push(file);\n        }\n\n        if (!hasErrors) {\n            clearError('attachments');\n        }\n\n        selectedFiles = validFiles;\n        updateFileList();\n\n        \/\/ Zaktualizuj input file z tylko poprawnymi plikami\n        if (validFiles.length !== files.length) {\n            const dt = new DataTransfer();\n            validFiles.forEach(file => dt.items.add(file));\n            this.files = dt.files;\n        }\n    });\n\n    function updateFileList() {\n        const fileList = document.getElementById('fileList');\n        const fileItems = document.getElementById('fileItems');\n        const fileCount = document.getElementById('fileCount');\n\n        if (selectedFiles.length === 0) {\n            fileList.classList.add('hidden');\n            return;\n        }\n\n        \/\/ Wyczy\u015b\u0107 b\u0142\u0105d walidacji, gdy s\u0105 pliki\n        clearError('attachments');\n\n        fileList.classList.remove('hidden');\n        fileCount.textContent = `Liczba plik\u00f3w: ${selectedFiles.length}`;\n\n        fileItems.innerHTML = '';\n\n        selectedFiles.forEach((file, index) => {\n            const fileItem = document.createElement('div');\n            fileItem.className = 'flex items-center justify-between p-3 bg-white border border-gray-200 rounded-md';\n\n            const fileSize = formatFileSize(file.size);\n            const fileIcon = getFileIcon(file.type);\n\n            fileItem.innerHTML = `\n                    <div class=\"flex items-center\">\n                        <div class=\"flex-shrink-0 mr-3\">\n                            ${fileIcon}\n                        <\/div>\n                        <div>\n                            <p class=\"text-sm font-medium text-gray-900\">${file.name}<\/p>\n                            <p class=\"text-xs text-gray-500\">${fileSize}<\/p>\n                        <\/div>\n                    <\/div>\n                    <button type=\"button\" onclick=\"removeFile(${index})\" class=\"text-red-600 hover:text-red-800 p-1\">\n                        <svg class=\"w-4 h-4\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n                            <path fill-rule=\"evenodd\" d=\"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z\" clip-rule=\"evenodd\"><\/path>\n                        <\/svg>\n                    <\/button>\n                `;\n\n            fileItems.appendChild(fileItem);\n        });\n    }\n\n    function removeFile(index) {\n        selectedFiles.splice(index, 1);\n        updateFileList();\n\n        \/\/ Poka\u017c b\u0142\u0105d, je\u015bli nie ma ju\u017c \u017cadnych plik\u00f3w\n        if (selectedFiles.length === 0) {\n            showError('attachments', 'Przynajmniej jeden za\u0142\u0105cznik ze skierowaniem jest wymagany');\n        }\n\n        \/\/ Zaktualizuj input file\n        const dt = new DataTransfer();\n        selectedFiles.forEach(file => dt.items.add(file));\n        document.getElementById('attachments').files = dt.files;\n    }\n\n    \/\/ Udost\u0119pnij funkcj\u0119 globalnie dla HTML onclick\n    window.removeFile = removeFile;\n\n    function formatFileSize(bytes) {\n        if (bytes === 0) return '0 Bytes';\n        const k = 1024;\n        const sizes = ['Bytes', 'KB', 'MB', 'GB'];\n        const i = Math.floor(Math.log(bytes) \/ Math.log(k));\n        return parseFloat((bytes \/ Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];\n    }\n\n    function getFileIcon(mimeType) {\n        if (mimeType.startsWith('image\/')) {\n            return `<svg class=\"w-6 h-6 text-green-500\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n                    <path fill-rule=\"evenodd\" d=\"M4 3a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V5a2 2 0 00-2-2H4zm12 12H4l4-8 3 6 2-4 3 6z\" clip-rule=\"evenodd\"><\/path>\n                <\/svg>`;\n        } else if (mimeType === 'application\/pdf') {\n            return `<svg class=\"w-6 h-6 text-red-500\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n                    <path fill-rule=\"evenodd\" d=\"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4zm2 6a1 1 0 011-1h6a1 1 0 100 2H7z\" clip-rule=\"evenodd\"><\/path>\n                <\/svg>`;\n        } else {\n            return `<svg class=\"w-6 h-6 text-gray-500\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n                    <path fill-rule=\"evenodd\" d=\"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z\" clip-rule=\"evenodd\"><\/path>\n                <\/svg>`;\n        }\n    }\n\n    function showSuccessMessage(message) {\n        \/\/ Usu\u0144 poprzedni komunikat sukcesu je\u015bli istnieje\n        const existingSuccess = document.getElementById('success-message');\n        if (existingSuccess) existingSuccess.remove();\n\n        \/\/ Stw\u00f3rz komunikat sukcesu\n        const successDiv = document.createElement('div');\n        successDiv.id = 'success-message';\n        successDiv.className = 'fixed top-4 right-4 bg-green-50 border border-green-200 rounded-lg p-4 shadow-lg z-50 max-w-md';\n        successDiv.innerHTML = `\n                <div class=\"flex items-start\">\n                    <div class=\"flex-shrink-0\">\n                        <svg class=\"w-6 h-6 text-green-400\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n                            <path fill-rule=\"evenodd\" d=\"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z\" clip-rule=\"evenodd\"><\/path>\n                        <\/svg>\n                    <\/div>\n                    <div class=\"ml-3\">\n                        <h3 class=\"text-sm font-medium text-green-800\">Sukces!<\/h3>\n                        <p class=\"mt-1 text-sm text-green-700\">${message}<\/p>\n                    <\/div>\n                    <div class=\"ml-auto pl-3\">\n                        <button onclick=\"this.parentElement.parentElement.parentElement.remove()\" class=\"text-green-400 hover:text-green-600\">\n                            <svg class=\"w-5 h-5\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n                                <path fill-rule=\"evenodd\" d=\"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z\" clip-rule=\"evenodd\"><\/path>\n                            <\/svg>\n                        <\/button>\n                    <\/div>\n                <\/div>\n            `;\n\n        document.body.appendChild(successDiv);\n\n        \/\/ Auto-ukryj po 5 sekundach\n        setTimeout(() => {\n            if (successDiv.parentNode) {\n                successDiv.remove();\n            }\n        }, 5000);\n\n        \/\/ Animacja pojawienia\n        successDiv.style.transform = 'translateX(100%)';\n        setTimeout(() => {\n            successDiv.style.transition = 'transform 0.3s ease-out';\n            successDiv.style.transform = 'translateX(0)';\n        }, 100);\n    }\n\n    function validateEmail(fieldId) {\n        const field = document.getElementById(fieldId);\n        if (!field) return true;\n\n        const value = field.value.trim();\n        if (!value) {\n            showError(fieldId, 'Adres email jest wymagany');\n            return false;\n        }\n\n        if (!\/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$\/.test(value)) {\n            showError(fieldId, 'Nieprawid\u0142owy format email');\n            return false;\n        }\n\n        clearError(fieldId);\n        return true;\n    }\n<\/script>\n","protected":false},"excerpt":{"rendered":"<p>JavaScript jest wy\u0142\u0105czony Ten formularz wymaga w\u0142\u0105czonego JavaScript aby dzia\u0142a\u0107 poprawnie. Prosz\u0119 w\u0142\u0105czy\u0107 JavaScript w przegl\u0105darce i od\u015bwie\u017cy\u0107 stron\u0119. Jak w\u0142\u0105czy\u0107 JavaScript: Chrome\/Edge: Ustawienia \u2192 Prywatno\u015b\u0107 i bezpiecze\u0144stwo \u2192 Ustawienia witryn \u2192 JavaScript Firefox: Wpisz &#8222;about:config&#8221; w pasku adresu \u2192 javascript.enabled \u2192 ustaw na true Safari: Preferencje \u2192 Bezpiecze\u0144stwo \u2192 W\u0142\u0105cz JavaScript Formularz Medycyny Pracy [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"page-full-width.php","meta":{"_acf_changed":false,"content-type":"","footnotes":""},"class_list":["post-23878","page","type-page","status-publish","hentry"],"acf":[],"lang":"pl","translations":{"pl":23878},"_links":{"self":[{"href":"https:\/\/telemedi.com\/tm-api\/wp\/v2\/pages\/23878","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/telemedi.com\/tm-api\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/telemedi.com\/tm-api\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/telemedi.com\/tm-api\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/telemedi.com\/tm-api\/wp\/v2\/comments?post=23878"}],"version-history":[{"count":1,"href":"https:\/\/telemedi.com\/tm-api\/wp\/v2\/pages\/23878\/revisions"}],"predecessor-version":[{"id":23879,"href":"https:\/\/telemedi.com\/tm-api\/wp\/v2\/pages\/23878\/revisions\/23879"}],"wp:attachment":[{"href":"https:\/\/telemedi.com\/tm-api\/wp\/v2\/media?parent=23878"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}