Repin777's picture
Давай добавим отображение даты сегодняшего дня где-нибудь вверху главной страницы, красиво - Follow Up Deployment
721621d verified
Raw History Blame Contribute Delete
62.9 kB
<!DOCTYPE html> <html lang="ru"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Система учёта пациентов</title> <script src="https://cdn.tailwindcss.com"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> <style> @import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap'); body { font-family: 'Roboto', sans-serif; background-color: #111827; color: #e5e7eb; } .monospace { font-family: 'Courier New', Courier, monospace; } .modal { transition: opacity 0.3s ease; } .patient-card { transition: all 0.3s ease; } .patient-card:hover { transform: translateY(-2px); box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); } .status-active { color: white; background: linear-gradient(135deg, #10b981 0%, #059669 100%); padding: 2px 8px; border-radius: 12px; display: inline-block; font-weight: 500; box-shadow: 0 1px 2px rgba(0,0,0,0.1); } .status-warning { color: white; background: linear-gradient(135deg, #eab308 0%, #ca8a04 100%); padding: 2px 8px; border-radius: 12px; display: inline-block; font-weight: 500; box-shadow: 0 1px 2px rgba(0,0,0,0.1); } .status-inactive { color: white; background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%); padding: 2px 8px; border-radius: 12px; display: inline-block; font-weight: 500; box-shadow: 0 1px 2px rgba(0,0,0,0.1); } /* Custom scrollbar */ ::-webkit-scrollbar { width: 6px; } ::-webkit-scrollbar-track { background: #1f2937; } ::-webkit-scrollbar-thumb { background: #4b5563; border-radius: 3px; } ::-webkit-scrollbar-thumb:hover { background: #6b7280; } /* Animation for new tag button */ @keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } } .pulse { animation: pulse 2s infinite; } </style> </head> <body class="min-h-screen"> <div class="container mx-auto px-4 py-6 max-w-3xl"> <!-- Header --> <header class="mb-6"> <h1 class="text-2xl font-bold text-center text-gray-100">Система учёта пациентов</h1> <div class="text-center text-gray-400 text-sm mb-2"> <span id="currentDate" class="bg-gray-700/50 px-3 py-1 rounded-full"></span> </div> <div id="newTagAlert" class="hidden mt-4"> <button id="newTagBtn" class="w-full py-2 px-4 bg-red-600 hover:bg-red-700 text-white font-bold rounded-lg shadow-md pulse"> ⚠️ Обнаружена новая метка </button> </div> </header> <!-- Demo mode toggle --> <div class="flex justify-end mb-4"> <label class="inline-flex items-center cursor-pointer"> <input type="checkbox" id="demoModeToggle" class="sr-only peer" checked> <div class="relative w-11 h-6 bg-gray-700 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:start-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-blue-600"></div> <span class="ms-3 text-sm font-medium text-gray-300">DEMO MODE</span> </label> </div> <!-- Filters --> <div class="bg-gray-800 rounded-lg p-4 mb-6 shadow-lg"> <div class="grid grid-cols-1 md:grid-cols-2 gap-4"> <div> <label for="searchInput" class="block text-sm font-medium text-gray-300 mb-1">Поиск по фамилии</label> <input type="text" id="searchInput" placeholder="Введите фамилию..." class="w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded-md text-gray-200 focus:outline-none focus:ring-1 focus:ring-blue-500"> </div> <div> <label for="statusFilter" class="block text-sm font-medium text-gray-300 mb-1">Статус</label> <select id="statusFilter" class="w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded-md text-gray-200 focus:outline-none focus:ring-1 focus:ring-blue-500"> <option value="all">Все</option> <option value="Активен">Активен</option> <option value="Пропустил 1 день">Пропустил 1 день</option> <option value="Пропустил 2 дня">Пропустил 2 дня</option> </select> </div> <div> <label for="admissionDateFilter" class="block text-sm font-medium text-gray-300 mb-1">Дата поступления</label> <input type="date" id="admissionDateFilter" class="w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded-md text-gray-200 focus:outline-none focus:ring-1 focus:ring-blue-500"> </div> <div> <label for="dischargeDateFilter" class="block text-sm font-medium text-gray-300 mb-1">Дата выписки</label> <input type="date" id="dischargeDateFilter" class="w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded-md text-gray-200 focus:outline-none focus:ring-1 focus:ring-blue-500"> </div> </div> <div class="mt-4 flex justify-end"> <button id="resetFiltersBtn" class="px-4 py-2 bg-gray-600 hover:bg-gray-500 text-white rounded-md text-sm"> Сбросить фильтры </button> </div> </div> <!-- Patients list --> <div class="bg-gray-800 rounded-lg shadow-lg p-4"> <div id="patientsGrid" class="grid grid-cols-1 gap-4"> <!-- Patients will be loaded here as cards --> </div> <div id="loadingIndicator" class="p-4 text-center text-gray-400"> <i class="fas fa-spinner fa-spin mr-2"></i> Загрузка данных... </div> <div id="noPatientsFound" class="hidden p-4 text-center text-gray-400"> Пациенты не найдены </div> </div> <!-- Demo mode controls --> <div id="demoControls" class="mt-6 bg-gray-800 rounded-lg p-4 shadow-lg"> <h3 class="text-lg font-medium text-gray-300 mb-3">Демо-контролы</h3> <div class="grid grid-cols-1 md:grid-cols-2 gap-4"> <div> <label for="demoUidInput" class="block text-sm font-medium text-gray-300 mb-1">UID метки</label> <input type="text" id="demoUidInput" value="A1B2C3D4" class="w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded-md text-gray-200 focus:outline-none focus:ring-1 focus:ring-blue-500 monospace"> </div> <div class="flex items-end"> <button id="simulateTagBtn" class="w-full px-4 py-2 bg-blue-600 hover:bg-blue-500 text-white rounded-md"> Эмулировать метку </button> </div> </div> </div> </div> <!-- Modals --> <!-- Edit Patient Modal --> <div id="editPatientModal" class="fixed inset-0 z-50 hidden overflow-y-auto"> <div class="flex items-center justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0"> <div class="fixed inset-0 transition-opacity" aria-hidden="true"> <div class="absolute inset-0 bg-gray-900 opacity-75"></div> </div> <span class="hidden sm:inline-block sm:align-middle sm:h-screen" aria-hidden="true">&#8203;</span> <div class="inline-block align-bottom bg-gray-800 rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full"> <div class="px-4 pt-5 pb-4 sm:p-6 sm:pb-4"> <h3 class="text-lg leading-6 font-medium text-gray-100 mb-4" id="editPatientModalTitle">Редактировать пациента</h3> <div class="space-y-4"> <div> <label for="editName" class="block text-sm font-medium text-gray-300">ФИО</label> <input type="text" id="editName" class="mt-1 block w-full bg-gray-700 border border-gray-600 rounded-md text-gray-200 px-3 py-2 focus:outline-none focus:ring-1 focus:ring-blue-500"> </div> <div> <label for="editHist" class="block text-sm font-medium text-gray-300">№ истории</label> <input type="text" id="editHist" class="mt-1 block w-full bg-gray-700 border border-gray-600 rounded-md text-gray-200 px-3 py-2 focus:outline-none focus:ring-1 focus:ring-blue-500"> </div> <div> <label for="editDischarge" class="block text-sm font-medium text-gray-300">Дата выписки</label> <input type="date" id="editDischarge" class="mt-1 block w-full bg-gray-700 border border-gray-600 rounded-md text-gray-200 px-3 py-2 focus:outline-none focus:ring-1 focus:ring-blue-500"> </div> </div> </div> <div class="bg-gray-700 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse"> <button type="button" id="savePatientBtn" class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-blue-600 text-base font-medium text-white hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 sm:ml-3 sm:w-auto sm:text-sm"> Сохранить </button> <button type="button" id="cancelEditBtn" class="mt-3 w-full inline-flex justify-center rounded-md border border-gray-600 shadow-sm px-4 py-2 bg-gray-600 text-base font-medium text-gray-100 hover:bg-gray-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500 sm:mt-0 sm:ml-3 sm:w-auto sm:text-sm"> Отмена </button> </div> </div> </div> </div> <!-- New Tag Modal --> <div id="newTagModal" class="fixed inset-0 z-50 hidden overflow-y-auto"> <div class="flex items-center justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0"> <div class="fixed inset-0 transition-opacity" aria-hidden="true"> <div class="absolute inset-0 bg-gray-900 opacity-75"></div> </div> <span class="hidden sm:inline-block sm:align-middle sm:h-screen" aria-hidden="true">&#8203;</span> <div class="inline-block align-bottom bg-gray-800 rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full"> <div class="px-4 pt-5 pb-4 sm:p-6 sm:pb-4"> <h3 class="text-lg leading-6 font-medium text-gray-100 mb-4">Обнаружена новая метка: <span id="newTagUid" class="font-mono text-blue-400"></span></h3> <div class="space-y-4"> <button id="newPatientBtn" class="w-full text-left p-4 bg-gray-700 hover:bg-gray-600 rounded-lg"> <h4 class="font-medium text-gray-100">Новый пациент</h4> <p class="text-sm text-gray-400">Создать нового пациента и привязать метку</p> </button> <button id="assignPatientBtn" class="w-full text-left p-4 bg-gray-700 hover:bg-gray-600 rounded-lg"> <h4 class="font-medium text-gray-100">Присвоить существующему</h4> <p class="text-sm text-gray-400">Найти пациента и привязать метку</p> </button> </div> </div> <div class="bg-gray-700 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse"> <button type="button" id="cancelNewTagBtn" class="w-full inline-flex justify-center rounded-md border border-gray-600 shadow-sm px-4 py-2 bg-gray-600 text-base font-medium text-gray-100 hover:bg-gray-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500 sm:ml-3 sm:w-auto sm:text-sm"> Отмена </button> </div> </div> </div> </div> <!-- New Patient Modal --> <div id="newPatientModal" class="fixed inset-0 z-50 hidden overflow-y-auto"> <div class="flex items-center justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0"> <div class="fixed inset-0 transition-opacity" aria-hidden="true"> <div class="absolute inset-0 bg-gray-900 opacity-75"></div> </div> <span class="hidden sm:inline-block sm:align-middle sm:h-screen" aria-hidden="true">&#8203;</span> <div class="inline-block align-bottom bg-gray-800 rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full"> <div class="px-4 pt-5 pb-4 sm:p-6 sm:pb-4"> <h3 class="text-lg leading-6 font-medium text-gray-100 mb-4">Новый пациент</h3> <div class="space-y-4"> <div> <label for="newName" class="block text-sm font-medium text-gray-300">ФИО</label> <input type="text" id="newName" class="mt-1 block w-full bg-gray-700 border border-gray-600 rounded-md text-gray-200 px-3 py-2 focus:outline-none focus:ring-1 focus:ring-blue-500"> </div> <div> <label for="newHist" class="block text-sm font-medium text-gray-300">№ истории</label> <input type="text" id="newHist" class="mt-1 block w-full bg-gray-700 border border-gray-600 rounded-md text-gray-200 px-3 py-2 focus:outline-none focus:ring-1 focus:ring-blue-500"> </div> <div> <label for="newAdmission" class="block text-sm font-medium text-gray-300">Дата поступления</label> <input type="date" id="newAdmission" class="mt-1 block w-full bg-gray-700 border border-gray-600 rounded-md text-gray-200 px-3 py-2 focus:outline-none focus:ring-1 focus:ring-blue-500"> </div> </div> </div> <div class="bg-gray-700 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse"> <button type="button" id="saveNewPatientBtn" class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-blue-600 text-base font-medium text-white hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 sm:ml-3 sm:w-auto sm:text-sm"> Сохранить </button> <button type="button" id="cancelNewPatientBtn" class="mt-3 w-full inline-flex justify-center rounded-md border border-gray-600 shadow-sm px-4 py-2 bg-gray-600 text-base font-medium text-gray-100 hover:bg-gray-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500 sm:mt-0 sm:ml-3 sm:w-auto sm:text-sm"> Отмена </button> </div> </div> </div> </div> <!-- Assign Patient Modal --> <div id="assignPatientModal" class="fixed inset-0 z-50 hidden overflow-y-auto"> <div class="flex items-center justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0"> <div class="fixed inset-0 transition-opacity" aria-hidden="true"> <div class="absolute inset-0 bg-gray-900 opacity-75"></div> </div> <span class="hidden sm:inline-block sm:align-middle sm:h-screen" aria-hidden="true">&#8203;</span> <div class="inline-block align-bottom bg-gray-800 rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full"> <div class="px-4 pt-5 pb-4 sm:p-6 sm:pb-4"> <h3 class="text-lg leading-6 font-medium text-gray-100 mb-4">Присвоить метку <span id="assignTagUid" class="font-mono text-blue-400"></span></h3> <div class="mb-4"> <label for="assignSearch" class="block text-sm font-medium text-gray-300 mb-1">Поиск пациента</label> <input type="text" id="assignSearch" placeholder="Введите фамилию или № истории..." class="w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded-md text-gray-200 focus:outline-none focus:ring-1 focus:ring-blue-500"> </div> <div class="max-h-60 overflow-y-auto"> <table class="min-w-full divide-y divide-gray-700"> <thead class="bg-gray-700"> <tr> <th scope="col" class="px-4 py-2 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">ФИО</th> <th scope="col" class="px-4 py-2 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">№ истории</th> <th scope="col" class="px-4 py-2 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Выбрать</th> </tr> </thead> <tbody id="assignPatientsList" class="bg-gray-800 divide-y divide-gray-700"> <!-- Patients will be loaded here --> </tbody> </table> <div id="noAssignPatientsFound" class="hidden p-4 text-center text-gray-400"> Пациенты не найдены </div> </div> </div> <div class="bg-gray-700 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse"> <button type="button" id="cancelAssignBtn" class="w-full inline-flex justify-center rounded-md border border-gray-600 shadow-sm px-4 py-2 bg-gray-600 text-base font-medium text-gray-100 hover:bg-gray-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500 sm:ml-3 sm:w-auto sm:text-sm"> Отмена </button> </div> </div> </div> </div> <!-- Confirm Assign Modal --> <div id="confirmAssignModal" class="fixed inset-0 z-50 hidden overflow-y-auto"> <div class="flex items-center justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0"> <div class="fixed inset-0 transition-opacity" aria-hidden="true"> <div class="absolute inset-0 bg-gray-900 opacity-75"></div> </div> <span class="hidden sm:inline-block sm:align-middle sm:h-screen" aria-hidden="true">&#8203;</span> <div class="inline-block align-bottom bg-gray-800 rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full"> <div class="px-4 pt-5 pb-4 sm:p-6 sm:pb-4"> <h3 class="text-lg leading-6 font-medium text-gray-100 mb-4">Подтверждение</h3> <p class="text-gray-300 mb-4">Присвоить метку <span id="confirmTagUid" class="font-mono text-blue-400"></span> пациенту <span id="confirmPatientName" class="font-medium"></span>?</p> <div class="bg-gray-700 p-3 rounded-md"> <p class="text-sm text-gray-300">№ истории: <span id="confirmPatientHist" class="font-mono"></span></p> </div> </div> <div class="bg-gray-700 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse"> <button type="button" id="confirmAssignBtn" class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-blue-600 text-base font-medium text-white hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 sm:ml-3 sm:w-auto sm:text-sm"> Подтвердить </button> <button type="button" id="cancelConfirmAssignBtn" class="mt-3 w-full inline-flex justify-center rounded-md border border-gray-600 shadow-sm px-4 py-2 bg-gray-600 text-base font-medium text-gray-100 hover:bg-gray-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500 sm:mt-0 sm:ml-3 sm:w-auto sm:text-sm"> Отмена </button> </div> </div> </div> </div> <!-- Visit Confirmation Modal --> <div id="visitConfirmationModal" class="fixed inset-0 z-50 hidden overflow-y-auto"> <div class="flex items-center justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0"> <div class="fixed inset-0 transition-opacity" aria-hidden="true"> <div class="absolute inset-0 bg-gray-900 opacity-75"></div> </div> <span class="hidden sm:inline-block sm:align-middle sm:h-screen" aria-hidden="true">&#8203;</span> <div class="inline-block align-bottom bg-gray-800 rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full"> <div class="px-4 pt-5 pb-4 sm:p-6 sm:pb-4"> <h3 class="text-lg leading-6 font-medium text-gray-100 mb-4">Посещение пациента</h3> <p class="text-gray-300 mb-4">Метка <span id="visitTagUid" class="font-mono text-blue-400"></span> уже привязана к пациенту <span id="visitPatientName" class="font-medium"></span>.</p> <div class="bg-gray-700 p-3 rounded-md mb-4"> <p class="text-sm text-gray-300">№ истории: <span id="visitPatientHist" class="font-mono"></span></p> <p class="text-sm text-gray-300">Последнее посещение: <span id="visitPatientLastVisit" class="font-mono"></span></p> </div> <p class="text-gray-300">Зарегистрировать посещение сейчас?</p> </div> <div class="bg-gray-700 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse"> <button type="button" id="confirmVisitBtn" class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-blue-600 text-base font-medium text-white hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 sm:ml-3 sm:w-auto sm:text-sm"> Подтвердить </button> <button type="button" id="cancelVisitBtn" class="mt-3 w-full inline-flex justify-center rounded-md border border-gray-600 shadow-sm px-4 py-2 bg-gray-600 text-base font-medium text-gray-100 hover:bg-gray-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500 sm:mt-0 sm:ml-3 sm:w-auto sm:text-sm"> Отмена </button> </div> </div> </div> </div> <script> // Demo data const demoPatients = [ { id: 1, name: "Иванов И.И.", hist: "12345", uid: "3A63D805", admission: "2025-08-01", discharge: "", lastVisit: "2025-08-25", status: "Активен" }, { id: 2, name: "Петров П.П.", hist: "67890", uid: "72FFA1B4", admission: "2025-08-05", discharge: "", lastVisit: "2025-08-24", status: "Активен" }, { id: 3, name: "Сидоров С.С.", hist: "54321", uid: "5C89E1F2", admission: "2025-08-10", discharge: "2025-08-20", lastVisit: "2025-08-20", status: "Пропустил 2 дня" }, { id: 4, name: "Кузнецов К.К.", hist: "98765", uid: "A1B2C3D4", admission: "2025-07-15", discharge: "", lastVisit: "2025-08-26", status: "Активен" }, { id: 5, name: "Смирнова А.А.", hist: "13579", uid: "9D4F7B12", admission: "2025-08-15", discharge: "", lastVisit: "2025-08-25", status: "Пропустил 1 день" }, { id: 6, name: "Васильев В.В.", hist: "24680", uid: "E6F5A3C8", admission: "2025-08-10", discharge: "", lastVisit: "", status: "Пропустил 2 дня" } ]; // State let patients = []; let filteredPatients = []; let currentPatientId = null; let currentUid = null; let demoMode = true; let pollingInterval = null; let lastUid = null; // DOM elements const patientsTableBody = document.getElementById('patientsTableBody'); const loadingIndicator = document.getElementById('loadingIndicator'); const noPatientsFound = document.getElementById('noPatientsFound'); const searchInput = document.getElementById('searchInput'); const statusFilter = document.getElementById('statusFilter'); const admissionDateFilter = document.getElementById('admissionDateFilter'); const dischargeDateFilter = document.getElementById('dischargeDateFilter'); const resetFiltersBtn = document.getElementById('resetFiltersBtn'); const newTagAlert = document.getElementById('newTagAlert'); const newTagBtn = document.getElementById('newTagBtn'); const demoModeToggle = document.getElementById('demoModeToggle'); const demoControls = document.getElementById('demoControls'); const demoUidInput = document.getElementById('demoUidInput'); const simulateTagBtn = document.getElementById('simulateTagBtn'); // Modals const editPatientModal = document.getElementById('editPatientModal'); const editName = document.getElementById('editName'); const editHist = document.getElementById('editHist'); const editDischarge = document.getElementById('editDischarge'); const savePatientBtn = document.getElementById('savePatientBtn'); const cancelEditBtn = document.getElementById('cancelEditBtn'); const newTagModal = document.getElementById('newTagModal'); const newTagUid = document.getElementById('newTagUid'); const newPatientBtn = document.getElementById('newPatientBtn'); const assignPatientBtn = document.getElementById('assignPatientBtn'); const cancelNewTagBtn = document.getElementById('cancelNewTagBtn'); const newPatientModal = document.getElementById('newPatientModal'); const newName = document.getElementById('newName'); const newHist = document.getElementById('newHist'); const newAdmission = document.getElementById('newAdmission'); const saveNewPatientBtn = document.getElementById('saveNewPatientBtn'); const cancelNewPatientBtn = document.getElementById('cancelNewPatientBtn'); const assignPatientModal = document.getElementById('assignPatientModal'); const assignTagUid = document.getElementById('assignTagUid'); const assignSearch = document.getElementById('assignSearch'); const assignPatientsList = document.getElementById('assignPatientsList'); const noAssignPatientsFound = document.getElementById('noAssignPatientsFound'); const cancelAssignBtn = document.getElementById('cancelAssignBtn'); const confirmAssignModal = document.getElementById('confirmAssignModal'); const confirmTagUid = document.getElementById('confirmTagUid'); const confirmPatientName = document.getElementById('confirmPatientName'); const confirmPatientHist = document.getElementById('confirmPatientHist'); const confirmAssignBtn = document.getElementById('confirmAssignBtn'); const cancelConfirmAssignBtn = document.getElementById('cancelConfirmAssignBtn'); const visitConfirmationModal = document.getElementById('visitConfirmationModal'); const visitTagUid = document.getElementById('visitTagUid'); const visitPatientName = document.getElementById('visitPatientName'); const visitPatientHist = document.getElementById('visitPatientHist'); const visitPatientLastVisit = document.getElementById('visitPatientLastVisit'); const confirmVisitBtn = document.getElementById('confirmVisitBtn'); const cancelVisitBtn = document.getElementById('cancelVisitBtn'); // Initialize document.addEventListener('DOMContentLoaded', function() { // Update current date updateCurrentDate(); // Load patients loadPatients(); // Set up event listeners setupEventListeners(); // Start polling for new UIDs startPolling(); // Set today's date as default for new patient admission const today = new Date().toISOString().split('T')[0]; newAdmission.value = today; }); function updateCurrentDate() { const now = new Date(); const options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric', hour: '2-digit', minute: '2-digit' }; document.getElementById('currentDate').textContent = now.toLocaleDateString('ru-RU', options); } function setupEventListeners() { // Filter controls searchInput.addEventListener('input', applyFilters); statusFilter.addEventListener('change', applyFilters); admissionDateFilter.addEventListener('change', applyFilters); dischargeDateFilter.addEventListener('change', applyFilters); resetFiltersBtn.addEventListener('click', resetFilters); // Demo mode toggle demoModeToggle.addEventListener('change', toggleDemoMode); // New tag button newTagBtn.addEventListener('click', showNewTagModal); // Demo controls simulateTagBtn.addEventListener('click', simulateTag); // Edit patient modal savePatientBtn.addEventListener('click', savePatient); cancelEditBtn.addEventListener('click', () => hideModal(editPatientModal)); // New tag modal newPatientBtn.addEventListener('click', showNewPatientModal); assignPatientBtn.addEventListener('click', showAssignPatientModal); cancelNewTagBtn.addEventListener('click', () => hideModal(newTagModal)); // New patient modal saveNewPatientBtn.addEventListener('click', saveNewPatient); cancelNewPatientBtn.addEventListener('click', () => hideModal(newPatientModal)); // Assign patient modal assignSearch.addEventListener('input', filterAssignPatients); cancelAssignBtn.addEventListener('click', () => hideModal(assignPatientModal)); // Confirm assign modal confirmAssignBtn.addEventListener('click', assignTagToPatient); cancelConfirmAssignBtn.addEventListener('click', () => hideModal(confirmAssignModal)); // Visit confirmation modal confirmVisitBtn.addEventListener('click', logVisit); cancelVisitBtn.addEventListener('click', () => hideModal(visitConfirmationModal)); } function loadPatients() { if (demoMode) { // Use demo data patients = [...demoPatients]; renderPatients(patients); loadingIndicator.classList.add('hidden'); } else { // Fetch from API fetch('/api/patients') .then(response => response.json()) .then(data => { patients = data.patients; renderPatients(patients); loadingIndicator.classList.add('hidden'); }) .catch(error => { console.error('Error loading patients:', error); // Fallback to demo data if API fails patients = [...demoPatients]; renderPatients(patients); loadingIndicator.classList.add('hidden'); }); } } function renderPatients(patientsToRender) { const patientsGrid = document.getElementById('patientsGrid'); patientsGrid.innerHTML = ''; if (patientsToRender.length === 0) { noPatientsFound.classList.remove('hidden'); return; } noPatientsFound.classList.add('hidden'); patientsToRender.forEach(patient => { const card = document.createElement('div'); card.className = `patient-card bg-gray-700 rounded-lg p-4 shadow-md hover:shadow-lg transition-shadow cursor-pointer ${lastUid && patient.uid === lastUid ? 'border-2 border-blue-500' : ''}`; card.dataset.id = patient.id; card.innerHTML = ` <div class="flex items-start mb-3 gap-2"> <button class="edit-btn text-gray-400 hover:text-blue-400" data-id="${patient.id}"> <i class="fas fa-edit"></i> </button> <h3 class="text-lg font-medium text-gray-100 truncate">${patient.name}</h3> </div> <div class="grid grid-cols-2 gap-2 text-sm"> <div> <p class="text-gray-400">№ истории:</p> <p class="text-gray-300">${patient.hist}</p> </div> <div> <p class="text-gray-400">UID:</p> <p class="text-gray-300 monospace">${patient.uid || '-'}</p> </div> <div> <p class="text-gray-400">Поступление:</p> <p class="text-gray-300">${formatDate(patient.admission)}</p> </div> <div> <p class="text-gray-400">Выписка:</p> <p class="text-gray-300">${patient.discharge ? formatDate(patient.discharge) : '-'}</p> </div> <div> <p class="text-gray-400">Последнее посещение:</p> <p class="text-gray-300">${patient.lastVisit ? formatDate(patient.lastVisit) : '-'}</p> </div> <div> <p class="text-gray-400">Статус:</p> <span class="${ patient.status === 'Активен' ? 'status-active' : patient.status === 'Пропустил 1 день' ? 'status-warning' : 'status-inactive' }">${patient.status}</span> </div> </div> `; patientsGrid.appendChild(card); }); // Add event listeners to edit buttons document.querySelectorAll('.edit-btn').forEach(btn => { btn.addEventListener('click', (e) => { e.stopPropagation(); const patientId = parseInt(btn.dataset.id); showEditPatientModal(patientId); }); }); // Add click event to cards document.querySelectorAll('.patient-card').forEach(card => { card.addEventListener('click', () => { // Remove active class from all cards document.querySelectorAll('.patient-card').forEach(c => { c.classList.remove('border-blue-500'); }); // Add active class to clicked card card.classList.add('border-blue-500'); // Store current patient ID currentPatientId = parseInt(card.dataset.id); }); }); } function applyFilters() { const searchTerm = searchInput.value.toLowerCase(); const statusFilterValue = statusFilter.value; const admissionDateFilterValue = admissionDateFilter.value; const dischargeDateFilterValue = dischargeDateFilter.value; filteredPatients = patients.filter(patient => { // Search by name if (searchTerm && !patient.name.toLowerCase().includes(searchTerm)) { return false; } // Filter by status if (statusFilterValue !== 'all' && patient.status !== statusFilterValue) { return false; } // Filter by admission date if (admissionDateFilterValue && patient.admission !== admissionDateFilterValue) { return false; } // Filter by discharge date if (dischargeDateFilterValue) { if (dischargeDateFilterValue && patient.discharge !== dischargeDateFilterValue) { // If patient doesn't have discharge date but we're filtering for empty if (dischargeDateFilterValue === 'empty' && patient.discharge === '') { return true; } return false; } } return true; }); renderPatients(filteredPatients); } function resetFilters() { searchInput.value = ''; statusFilter.value = 'all'; admissionDateFilter.value = ''; dischargeDateFilter.value = ''; applyFilters(); } function toggleDemoMode() { demoMode = demoModeToggle.checked; demoControls.classList.toggle('hidden', !demoMode); if (demoMode) { // Stop polling stopPolling(); // Reload demo data loadPatients(); } else { // Start polling startPolling(); // Load from API loadPatients(); } } function startPolling() { if (demoMode) return; // Clear any existing interval stopPolling(); // Poll every 1.5 seconds pollingInterval = setInterval(() => { fetch('/api/last_uid') .then(response => response.json()) .then(data => { if (data.uid && data.uid !== lastUid) { lastUid = data.uid; handleNewUid(data.uid); } }) .catch(error => { console.error('Error polling for last UID:', error); }); }, 1500); } function stopPolling() { if (pollingInterval) { clearInterval(pollingInterval); pollingInterval = null; } } function handleNewUid(uid) { // Check if this UID is already assigned to a patient const patientWithUid = patients.find(p => p.uid === uid); if (patientWithUid) { // UID is already assigned - show visit confirmation showVisitConfirmation(patientWithUid, uid); } else { // New UID - show the alert button currentUid = uid; newTagAlert.classList.remove('hidden'); } } function showNewTagModal() { newTagUid.textContent = currentUid; showModal(newTagModal); } function showNewPatientModal() { hideModal(newTagModal); newName.value = ''; newHist.value = ''; // Set today's date as default newAdmission.value = new Date().toISOString().split('T')[0]; showModal(newPatientModal); } function showAssignPatientModal() { hideModal(newTagModal); assignTagUid.textContent = currentUid; // Populate assign patients list with ALL patients assignPatientsList.innerHTML = ''; if (patients.length === 0) { noAssignPatientsFound.classList.remove('hidden'); } else { noAssignPatientsFound.classList.add('hidden'); patients.forEach(patient => { const row = document.createElement('tr'); row.className = `hover:bg-gray-700 ${patient.uid ? 'bg-gray-700/50' : ''}`; row.innerHTML = ` <td class="px-4 py-2 text-gray-300">${patient.name}</td> <td class="px-4 py-2 text-gray-300">${patient.hist}</td> <td class="px-4 py-2 text-gray-300 monospace text-sm">${patient.uid || 'нет метки'}</td> <td class="px-4 py-2"> <button class="select-patient-btn px-3 py-1 ${patient.uid ? 'bg-yellow-600 hover:bg-yellow-500' : 'bg-blue-600 hover:bg-blue-500'} text-white rounded text-sm" data-id="${patient.id}" data-name="${patient.name}" data-hist="${patient.hist}"> ${patient.uid ? 'Заменить' : 'Присвоить'} </button> </td> `; assignPatientsList.appendChild(row); }); // Add event listeners to select buttons document.querySelectorAll('.select-patient-btn').forEach(btn => { btn.addEventListener('click', () => { const patientId = parseInt(btn.dataset.id); const patientName = btn.dataset.name; const patientHist = btn.dataset.hist; showConfirmAssignModal(patientId, patientName, patientHist); }); }); } showModal(assignPatientModal); } function filterAssignPatients() { const searchTerm = assignSearch.value.toLowerCase(); let hasResults = false; document.querySelectorAll('#assignPatientsList tr').forEach(row => { const name = row.querySelector('td:first-child').textContent.toLowerCase(); const hist = row.querySelector('td:nth-child(2)').textContent.toLowerCase(); const uid = row.querySelector('td:nth-child(3)').textContent.toLowerCase(); if (name.includes(searchTerm) || hist.includes(searchTerm) || uid.includes(searchTerm)) { row.classList.remove('hidden'); hasResults = true; } else { row.classList.add('hidden'); } }); noAssignPatientsFound.classList.toggle('hidden', hasResults); } function showConfirmAssignModal(patientId, patientName, patientHist) { hideModal(assignPatientModal); currentPatientId = patientId; confirmTagUid.textContent = currentUid; confirmPatientName.textContent = patientName; confirmPatientHist.textContent = patientHist; showModal(confirmAssignModal); } function showVisitConfirmation(patient, uid) { visitTagUid.textContent = uid; visitPatientName.textContent = patient.name; visitPatientHist.textContent = patient.hist; visitPatientLastVisit.textContent = patient.lastVisit || 'никогда'; currentPatientId = patient.id; showModal(visitConfirmationModal); } function showEditPatientModal(patientId) { const patient = patients.find(p => p.id === patientId); if (!patient) return; currentPatientId = patientId; editName.value = patient.name; editHist.value = patient.hist; editDischarge.value = patient.discharge || ''; showModal(editPatientModal); } function assignTagToPatient() { hideModal(confirmAssignModal); if (demoMode) { // Update patient in demo data const patientIndex = patients.findIndex(p => p.id === currentPatientId); if (patientIndex !== -1) { patients[patientIndex].uid = currentUid; patients[patientIndex].lastVisit = new Date().toISOString().split('T')[0]; patients[patientIndex].status = "Активен"; // Hide the new tag alert newTagAlert.classList.add('hidden'); lastUid = null; // Re-render patients renderPatients(patients); applyFilters(); } } else { // Call API to assign tag fetch('/api/assign', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ uid: currentUid, patient_id: currentPatientId }) }) .then(response => response.json()) .then(data => { if (data.ok) { // Reload patients loadPatients(); // Hide the new tag alert newTagAlert.classList.add('hidden'); lastUid = null; } }) .catch(error => { console.error('Error assigning tag:', error); }); } } function logVisit() { hideModal(visitConfirmationModal); if (demoMode) { // Update patient in demo data const patientIndex = patients.findIndex(p => p.id === currentPatientId); if (patientIndex !== -1) { patients[patientIndex].lastVisit = new Date().toISOString().split('T')[0]; patients[patientIndex].status = "Активен"; // Re-render patients renderPatients(patients); applyFilters(); } } else { // Call API to log visit fetch('/api/log_visit', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ uid: lastUid, patient_id: currentPatientId, timestamp: new Date().toISOString() }) }) .then(response => response.json()) .then(data => { if (data.ok) { // Reload patients loadPatients(); } }) .catch(error => { console.error('Error logging visit:', error); }); } } function savePatient() { const name = editName.value.trim(); const hist = editHist.value.trim(); const discharge = editDischarge.value; if (!name || !hist) { alert('Пожалуйста, заполните все обязательные поля'); return; } hideModal(editPatientModal); if (demoMode) { // Update patient in demo data const patientIndex = patients.findIndex(p => p.id === currentPatientId); if (patientIndex !== -1) { patients[patientIndex].name = name; patients[patientIndex].hist = hist; patients[patientIndex].discharge = discharge || ''; // Recalculate status if discharge date was added/removed if (discharge) { patients[patientIndex].status = "Пропустил 2 дня"; } else { // Check if patient has recent visit const lastVisit = patients[patientIndex].lastVisit; if (!lastVisit) { patients[patientIndex].status = "Пропустил 2 дня"; } else { const overdueStatus = isVisitOverdue(lastVisit); if (overdueStatus === 2) { patients[patientIndex].status = "Пропустил 2 дня"; } else if (overdueStatus === 1) { patients[patientIndex].status = "Пропустил 1 день"; } else { patients[patientIndex].status = "Активен"; } } } // Re-render patients renderPatients(patients); applyFilters(); } } else { // Call API to update patient fetch(`/api/patients/${currentPatientId}`, { method: 'PUT', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ name: name, hist: hist, discharge: discharge || null }) }) .then(response => response.json()) .then(data => { // Reload patients loadPatients(); }) .catch(error => { console.error('Error updating patient:', error); }); } } function saveNewPatient() { const name = newName.value.trim(); const hist = newHist.value.trim(); const admission = newAdmission.value; if (!name || !hist || !admission) { alert('Пожалуйста, заполните все обязательные поля'); return; } hideModal(newPatientModal); if (demoMode) { // Create new patient in demo data const newId = patients.length > 0 ? Math.max(...patients.map(p => p.id)) + 1 : 1; const newPatient = { id: newId, name: name, hist: hist, uid: currentUid, admission: admission, discharge: '', lastVisit: new Date().toISOString().split('T')[0], status: "Активен" }; patients.push(newPatient); // Hide the new tag alert newTagAlert.classList.add('hidden'); lastUid = null; // Re-render patients renderPatients(patients); applyFilters(); } else { // Call API to create new patient fetch('/api/patients', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ name: name, hist: hist, admission: admission, discharge: null }) }) .then(response => response.json()) .then(data => { // Now assign the UID to this patient return fetch('/api/assign', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ uid: currentUid, patient_id: data.id }) }); }) .then(response => response.json()) .then(data => { if (data.ok) { // Reload patients loadPatients(); // Hide the new tag alert newTagAlert.classList.add('hidden'); lastUid = null; } }) .catch(error => { console.error('Error creating new patient:', error); }); } } function simulateTag() { const uid = demoUidInput.value.trim().toUpperCase(); if (!uid) { alert('Пожалуйста, введите UID метки'); return; } // Simulate new UID detection lastUid = uid; handleNewUid(uid); } function formatDate(isoDate) { if (!isoDate) return ''; const [year, month, day] = isoDate.split('-'); return `${day}.${month}.${year}`; } function isVisitOverdue(lastVisitDate) { const today = new Date(); const lastVisit = new Date(lastVisitDate); const diffTime = today - lastVisit; const diffDays = diffTime / (1000 * 60 * 60 * 24); if (diffDays > 2) { return 2; // Пропустил 2+ дней } else if (diffDays > 1) { return 1; // Пропустил 1 день } return 0; // Активен } function showModal(modal) { modal.classList.remove('hidden'); document.body.classList.add('overflow-hidden'); } function hideModal(modal) { modal.classList.add('hidden'); document.body.classList.remove('overflow-hidden'); } </script> <!-- README section (hidden by default) --> <div id="readme" class="hidden"> <h1>Система учёта пациентов с RFID</h1> <h2>API Endpoints</h2> <h3>GET /api/patients</h3> <p>Получить список всех пациентов.</p> <p><strong>Ответ:</strong></p> <pre>{ "patients": [ { "id": 1, "name": "Иванов И.И.", "hist": "12345", "uid": "3A63D805", "admission": "2025-08-01", "discharge": "", "lastVisit": "2025-08-25", "status": "Активен" }, ... ] }</pre> <h3>POST /api/patients</h3> <p>Создать нового пациента.</p> <p><strong>Тело запроса:</strong></p> <pre>{ "name": "...", "hist": "...", "admission": "YYYY-MM-DD", "discharge": "YYYY-MM-DD?" }</pre> <p><strong>Ответ:</strong> Созданный объект пациента (с id).</p> <h3>PUT /api/patients/&lt;id&gt;</h3> <p>Редактировать пациента.</p> <p><strong>Тело запроса:</strong> Поля для изменения (name, hist, discharge).</p> <h3>GET /api/last_uid</h3> <p>Вернуть последний считанный UID (если есть).</p> <p><strong>Ответ:</strong></p> <pre>{ "uid": "72FFA1B4" }</pre> <p>или</p> <pre>{ "uid": null }</pre> <h3>POST /api/assign</h3> <p>Присвоить UID существующему пациенту.</p> <p><strong>Тело запроса:</strong></p> <pre>{ "uid": "...", "patient_id": 123 }</pre> <p><strong>Ответ:</strong></p> <pre>{ "ok": true, "patient": { ... } }</pre> <h3>POST /api/log_visit</h3> <p>Зарегистрировать посещение пациента.</p> <p><strong>Тело запроса:</strong></p> <pre>{ "uid": "...", "patient_id": 123, "timestamp": "ISO" }</pre> <p><strong>Ответ:</strong></p> <pre>{ "ok": true }</pre> <h3>GET /api/time</h3> <p>Получить текущую метку времени (опционально).</p> <p><strong>Ответ:</strong></p> <pre>{ "iso": "2025-08-26T14:22:00+03:00" }</pre> <h2>Формат лог-файла</h2> <p>Одной строкой на событие:</p> <pre>TS(iso) UID: &lt;UID&gt; PATIENT_ID: &lt;id&gt; NAME: &lt;ФИО&gt; ACTION: &lt;assigned|visit|created&gt;</pre> <p>Пример:</p> <pre>2025-08-26T14:22:00+03:00 UID: 727FA104 PATIENT_ID: 12 NAME: Иванов И.И. ACTION: visit</pre> <h2>Инструкция по публикации</h2> <ol> <li>Скопируйте файл index.html в SPIFFS на ESP32</li> <li>Убедитесь, что ESP32 реализует все необходимые API endpoints</li> <li>Настройте WiFi (AP или STA mode) в скетче ESP32</li> <li>Подключите RFID-ридер (MFRC522), RTC модуль (DS3231) и SD карту</li> </ol> </div> <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Repin777/https-huggingface-co-spaces-repin777-repinsite" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> </html>
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Система учёта пациентов</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');
body {
font-family: 'Roboto', sans-serif;
background-color: #111827;
color: #e5e7eb;
}
.monospace {
font-family: 'Courier New', Courier, monospace;
}
.modal {
transition: opacity 0.3s ease;
}
.patient-card {
transition: all 0.3s ease;
}
.patient-card:hover {
transform: translateY(-2px);
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}
.status-active {
color: white;
background: linear-gradient(135deg, #10b981 0%, #059669 100%);
padding: 2px 8px;
border-radius: 12px;
display: inline-block;
font-weight: 500;
box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.status-warning {
color: white;
background: linear-gradient(135deg, #eab308 0%, #ca8a04 100%);
padding: 2px 8px;
border-radius: 12px;
display: inline-block;
font-weight: 500;
box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.status-inactive {
color: white;
background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
padding: 2px 8px;
border-radius: 12px;
display: inline-block;
font-weight: 500;
box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
/* Custom scrollbar */
::-webkit-scrollbar {
width: 6px;
}
::-webkit-scrollbar-track {
background: #1f2937;
}
::-webkit-scrollbar-thumb {
background: #4b5563;
border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
background: #6b7280;
}
/* Animation for new tag button */
@keyframes pulse {
0% {
transform: scale(1);
}
50% {
transform: scale(1.05);
}
100% {
transform: scale(1);
}
}
.pulse {
animation: pulse 2s infinite;
}
</style>
</head>