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
|
| 3 |
+
import random
|
| 4 |
+
import tempfile
|
| 5 |
+
from io import BytesIO
|
| 6 |
+
from datetime import date, datetime
|
| 7 |
+
|
| 8 |
+
import pandas as pd
|
| 9 |
+
import streamlit as st
|
| 10 |
+
from openpyxl import Workbook
|
| 11 |
+
from openpyxl.styles import Font, Alignment, Border, Side, PatternFill
|
| 12 |
+
from openpyxl.utils import get_column_letter
|
| 13 |
+
from openpyxl.drawing.image import Image as XLImage
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
# =========================================================
|
| 17 |
+
# 13지침 교육일지 통합연동 생성기
|
| 18 |
+
# - Client Center DB와 같은 clients.db 사용
|
| 19 |
+
# - 기관정보/참석자/강사/교육자료 첨부/교육결과/평가 적합도 점검
|
| 20 |
+
# - 결재라인 담당자/시설장 2칸, 지저분한 빈칸 없이 출력
|
| 21 |
+
# =========================================================
|
| 22 |
+
|
| 23 |
+
st.set_page_config(
|
| 24 |
+
page_title="13지침 교육일지",
|
| 25 |
+
page_icon="📘",
|
| 26 |
+
layout="wide"
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
|
| 30 |
+
|
| 31 |
+
DB_CANDIDATES = [
|
| 32 |
+
os.path.join(CURRENT_DIR, "data", "clients.db"),
|
| 33 |
+
os.path.join(CURRENT_DIR, "..", "Client Center", "data", "clients.db"),
|
| 34 |
+
os.path.join(CURRENT_DIR, "..", "ClientCenter", "data", "clients.db"),
|
| 35 |
+
os.path.join(CURRENT_DIR, "..", "Client_Center", "data", "clients.db"),
|
| 36 |
+
]
|
| 37 |
+
|
| 38 |
+
DB_PATH = None
|
| 39 |
+
for p in DB_CANDIDATES:
|
| 40 |
+
if os.path.exists(p):
|
| 41 |
+
DB_PATH = p
|
| 42 |
+
break
|
| 43 |
+
|
| 44 |
+
if DB_PATH is None:
|
| 45 |
+
os.makedirs(os.path.join(CURRENT_DIR, "data"), exist_ok=True)
|
| 46 |
+
DB_PATH = os.path.join(CURRENT_DIR, "data", "clients.db")
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
# -----------------------------
|
| 50 |
+
# 디자인
|
| 51 |
+
# -----------------------------
|
| 52 |
+
st.markdown("""
|
| 53 |
+
<style>
|
| 54 |
+
.block-container { padding-top: 2rem; }
|
| 55 |
+
.hero {
|
| 56 |
+
background: linear-gradient(135deg, #7C2D12, #EA580C);
|
| 57 |
+
padding: 30px;
|
| 58 |
+
border-radius: 22px;
|
| 59 |
+
text-align: center;
|
| 60 |
+
margin-bottom: 22px;
|
| 61 |
+
}
|
| 62 |
+
.hero h1 { color: white; margin: 0; font-size: 36px; }
|
| 63 |
+
.hero p { color: white; margin-top: 10px; font-size: 18px; }
|
| 64 |
+
.notice {
|
| 65 |
+
background: #fff8e1;
|
| 66 |
+
border-left: 7px solid #f9a825;
|
| 67 |
+
padding: 15px;
|
| 68 |
+
border-radius: 12px;
|
| 69 |
+
margin-bottom: 18px;
|
| 70 |
+
}
|
| 71 |
+
.okbox {
|
| 72 |
+
background: #e8f5e9;
|
| 73 |
+
border-left: 7px solid #43a047;
|
| 74 |
+
padding: 14px;
|
| 75 |
+
border-radius: 12px;
|
| 76 |
+
margin-bottom: 14px;
|
| 77 |
+
}
|
| 78 |
+
.warnbox {
|
| 79 |
+
background: #fff3e0;
|
| 80 |
+
border-left: 7px solid #fb8c00;
|
| 81 |
+
padding: 14px;
|
| 82 |
+
border-radius: 12px;
|
| 83 |
+
margin-bottom: 14px;
|
| 84 |
+
}
|
| 85 |
+
</style>
|
| 86 |
+
""", unsafe_allow_html=True)
|
| 87 |
+
|
| 88 |
+
st.markdown("""
|
| 89 |
+
<div class="hero">
|
| 90 |
+
<h1>📘 13지침 교육일지 생성기</h1>
|
| 91 |
+
<p>종사자 급여제공지침 교육일지를 통합연동 방식으로 생성하고 이수기록을 저장합니다.</p>
|
| 92 |
+
</div>
|
| 93 |
+
""", unsafe_allow_html=True)
|
| 94 |
+
|
| 95 |
+
st.markdown("""
|
| 96 |
+
<div class="notice">
|
| 97 |
+
<strong>필수 구조:</strong> 교육명, 교육일시, 장소, 강사명, 참석자 명단, 교육목적, 교육내용, 교육자료 첨부, 교육결과, 평가 적합도 점검, 결재라인을 포함합니다.
|
| 98 |
+
</div>
|
| 99 |
+
""", unsafe_allow_html=True)
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
# -----------------------------
|
| 103 |
+
# DB
|
| 104 |
+
# -----------------------------
|
| 105 |
+
def get_conn():
|
| 106 |
+
return sqlite3.connect(DB_PATH, check_same_thread=False)
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
def init_db():
|
| 110 |
+
conn = get_conn()
|
| 111 |
+
cur = conn.cursor()
|
| 112 |
+
|
| 113 |
+
cur.execute("""
|
| 114 |
+
CREATE TABLE IF NOT EXISTS staff_members (
|
| 115 |
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
| 116 |
+
name TEXT NOT NULL,
|
| 117 |
+
position TEXT,
|
| 118 |
+
department TEXT,
|
| 119 |
+
phone TEXT,
|
| 120 |
+
employment_status TEXT DEFAULT '재직',
|
| 121 |
+
created_at TEXT
|
| 122 |
+
)
|
| 123 |
+
""")
|
| 124 |
+
|
| 125 |
+
cur.execute("""
|
| 126 |
+
CREATE TABLE IF NOT EXISTS education_records (
|
| 127 |
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
| 128 |
+
institution_name TEXT,
|
| 129 |
+
institution_type TEXT,
|
| 130 |
+
education_title TEXT,
|
| 131 |
+
guideline_items TEXT,
|
| 132 |
+
education_date TEXT,
|
| 133 |
+
education_time TEXT,
|
| 134 |
+
education_place TEXT,
|
| 135 |
+
instructor_name TEXT,
|
| 136 |
+
instructor_position TEXT,
|
| 137 |
+
attendees TEXT,
|
| 138 |
+
absent_staff TEXT,
|
| 139 |
+
education_method TEXT,
|
| 140 |
+
education_purpose TEXT,
|
| 141 |
+
education_content TEXT,
|
| 142 |
+
education_materials TEXT,
|
| 143 |
+
education_result TEXT,
|
| 144 |
+
followup_plan TEXT,
|
| 145 |
+
evaluation_score INTEGER,
|
| 146 |
+
missing_items TEXT,
|
| 147 |
+
compliance_result TEXT,
|
| 148 |
+
created_at TEXT
|
| 149 |
+
)
|
| 150 |
+
""")
|
| 151 |
+
|
| 152 |
+
conn.commit()
|
| 153 |
+
conn.close()
|
| 154 |
+
|
| 155 |
+
|
| 156 |
+
def load_staff():
|
| 157 |
+
conn = get_conn()
|
| 158 |
+
try:
|
| 159 |
+
df = pd.read_sql_query("SELECT * FROM staff_members ORDER BY id DESC", conn)
|
| 160 |
+
except Exception:
|
| 161 |
+
df = pd.DataFrame()
|
| 162 |
+
conn.close()
|
| 163 |
+
return df
|
| 164 |
+
|
| 165 |
+
|
| 166 |
+
def save_staff(name, position, department, phone):
|
| 167 |
+
conn = get_conn()
|
| 168 |
+
cur = conn.cursor()
|
| 169 |
+
cur.execute("""
|
| 170 |
+
INSERT INTO staff_members (name, position, department, phone, employment_status, created_at)
|
| 171 |
+
VALUES (?, ?, ?, ?, ?, ?)
|
| 172 |
+
""", (name, position, department, phone, "재직", datetime.now().strftime("%Y-%m-%d %H:%M:%S")))
|
| 173 |
+
conn.commit()
|
| 174 |
+
conn.close()
|
| 175 |
+
|
| 176 |
+
|
| 177 |
+
def save_education_record(data):
|
| 178 |
+
conn = get_conn()
|
| 179 |
+
cur = conn.cursor()
|
| 180 |
+
cur.execute("""
|
| 181 |
+
INSERT INTO education_records (
|
| 182 |
+
institution_name, institution_type, education_title, guideline_items,
|
| 183 |
+
education_date, education_time, education_place,
|
| 184 |
+
instructor_name, instructor_position, attendees, absent_staff,
|
| 185 |
+
education_method, education_purpose, education_content,
|
| 186 |
+
education_materials, education_result, followup_plan,
|
| 187 |
+
evaluation_score, missing_items, compliance_result, created_at
|
| 188 |
+
)
|
| 189 |
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
| 190 |
+
""", (
|
| 191 |
+
data["institution_name"],
|
| 192 |
+
data["institution_type"],
|
| 193 |
+
data["education_title"],
|
| 194 |
+
data["guideline_items"],
|
| 195 |
+
data["education_date"],
|
| 196 |
+
data["education_time"],
|
| 197 |
+
data["education_place"],
|
| 198 |
+
data["instructor_name"],
|
| 199 |
+
data["instructor_position"],
|
| 200 |
+
data["attendees"],
|
| 201 |
+
data["absent_staff"],
|
| 202 |
+
data["education_method"],
|
| 203 |
+
data["education_purpose"],
|
| 204 |
+
data["education_content"],
|
| 205 |
+
data["education_materials"],
|
| 206 |
+
data["education_result"],
|
| 207 |
+
data["followup_plan"],
|
| 208 |
+
data["evaluation_score"],
|
| 209 |
+
data["missing_items"],
|
| 210 |
+
data["compliance_result"],
|
| 211 |
+
datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
|
| 212 |
+
))
|
| 213 |
+
conn.commit()
|
| 214 |
+
conn.close()
|
| 215 |
+
|
| 216 |
+
|
| 217 |
+
def load_education_records():
|
| 218 |
+
conn = get_conn()
|
| 219 |
+
try:
|
| 220 |
+
df = pd.read_sql_query("SELECT * FROM education_records ORDER BY id DESC", conn)
|
| 221 |
+
except Exception:
|
| 222 |
+
df = pd.DataFrame()
|
| 223 |
+
conn.close()
|
| 224 |
+
return df
|
| 225 |
+
|
| 226 |
+
|
| 227 |
+
init_db()
|
| 228 |
+
|
| 229 |
+
|
| 230 |
+
# -----------------------------
|
| 231 |
+
# 13지침
|
| 232 |
+
# -----------------------------
|
| 233 |
+
GUIDELINES = {
|
| 234 |
+
"01. 종사자 윤리지침": {
|
| 235 |
+
"purpose": "종사자의 직업윤리와 수급자 존중 태도를 강화하여 전문적인 급여제공이 이루어지도록 한다.",
|
| 236 |
+
"content": [
|
| 237 |
+
"수급자 인격 존중과 사생활 보호",
|
| 238 |
+
"급여제공 범위 준수와 부당요구 대응",
|
| 239 |
+
"전문직 종사자로서의 책임과 보고체계",
|
| 240 |
+
"서비스 제공 중 비밀유지와 공정한 태도",
|
| 241 |
+
],
|
| 242 |
+
},
|
| 243 |
+
"02. 노인인권보호지침": {
|
| 244 |
+
"purpose": "수급자의 권리와 자기결정권을 존중하고 인권침해를 예방한다.",
|
| 245 |
+
"content": [
|
| 246 |
+
"노인 인권의 기본 원칙",
|
| 247 |
+
"신체적·정서적·언어적 인권침해 예방",
|
| 248 |
+
"수급자의 의사표현과 선택권 존중",
|
| 249 |
+
"인권침해 발생 시 보고 및 조치 절차",
|
| 250 |
+
],
|
| 251 |
+
},
|
| 252 |
+
"03. 노인학대예방지침": {
|
| 253 |
+
"purpose": "노인학대 유형을 이해하고 의심사례 발견 시 즉시 보고할 수 있도록 한다.",
|
| 254 |
+
"content": [
|
| 255 |
+
"신체적·정서적·경제적 학대 및 방임의 유형",
|
| 256 |
+
"학대 의심 징후 확인",
|
| 257 |
+
"신고의무와 신고절차",
|
| 258 |
+
"학대 예방을 위한 종사자 행동수칙",
|
| 259 |
+
],
|
| 260 |
+
},
|
| 261 |
+
"04. 개인정보보호지침": {
|
| 262 |
+
"purpose": "수급자와 보호자의 개인정보를 안전하게 관리하고 유출을 예방한다.",
|
| 263 |
+
"content": [
|
| 264 |
+
"개인정보 수집·이용·보관 원칙",
|
| 265 |
+
"문서 및 전산자료 접근관리",
|
| 266 |
+
"사진·영상 사용 시 동의와 보호조치",
|
| 267 |
+
"개인정보 유출 시 보고 절차",
|
| 268 |
+
],
|
| 269 |
+
},
|
| 270 |
+
"05. 성폭력예방 및 대응지침": {
|
| 271 |
+
"purpose": "수급자와 종사자의 성적 자기결정권을 보호하고 성희롱·성폭력을 예방한다.",
|
| 272 |
+
"content": [
|
| 273 |
+
"성희롱·성폭력의 개념과 사례",
|
| 274 |
+
"목욕·배변·신체지원 시 유의사항",
|
| 275 |
+
"불쾌감 표현 시 즉시 중단 및 보고",
|
| 276 |
+
"피해 발생 시 보호조치와 보고체계",
|
| 277 |
+
],
|
| 278 |
+
},
|
| 279 |
+
"06. 응급상황대응지침": {
|
| 280 |
+
"purpose": "낙상, 호흡곤란, 의식저하 등 응급상황 발생 시 신속하고 적절하게 대응한다.",
|
| 281 |
+
"content": [
|
| 282 |
+
"응급상황 유형과 초기 확인",
|
| 283 |
+
"119 신고 및 보호자 연락 절차",
|
| 284 |
+
"기관 보고체계와 기록 방법",
|
| 285 |
+
"심폐소생술 및 기본 응급처치 유의사항",
|
| 286 |
+
],
|
| 287 |
+
},
|
| 288 |
+
"07. 감염예방 및 관리지침": {
|
| 289 |
+
"purpose": "감염병 전파를 예방하고 수급자와 종사자의 건강을 보호한다.",
|
| 290 |
+
"content": [
|
| 291 |
+
"손위생과 개인보호구 사용",
|
| 292 |
+
"발열·호흡기 증상 확인과 격리 안내",
|
| 293 |
+
"환경소독 및 환기관리",
|
| 294 |
+
"감염 의심 시 보고 및 조치",
|
| 295 |
+
],
|
| 296 |
+
},
|
| 297 |
+
"08. 욕창예방지침": {
|
| 298 |
+
"purpose": "욕창 위험요인을 조기에 발견하고 체위변경과 피부관찰을 통해 욕창을 예방한다.",
|
| 299 |
+
"content": [
|
| 300 |
+
"욕창 위험��인과 호발부위",
|
| 301 |
+
"체위변경과 압박 완화",
|
| 302 |
+
"피부 발적·상처 관찰 및 보고",
|
| 303 |
+
"영양·수분섭취와 청결관리",
|
| 304 |
+
],
|
| 305 |
+
},
|
| 306 |
+
"09. 낙상예방지침": {
|
| 307 |
+
"purpose": "수급자의 낙상 위험을 줄이고 안전한 이동과 생활환경을 유지한다.",
|
| 308 |
+
"content": [
|
| 309 |
+
"낙상 위험요인 확인",
|
| 310 |
+
"보행보조와 화장실 이동 지원",
|
| 311 |
+
"환경정리와 미끄럼 예방",
|
| 312 |
+
"낙상 발생 시 조치와 기록",
|
| 313 |
+
],
|
| 314 |
+
},
|
| 315 |
+
"10. 치매예방 및 관리지침": {
|
| 316 |
+
"purpose": "인지기능 저하 수급자의 특성을 이해하고 안정적인 돌봄을 제공한다.",
|
| 317 |
+
"content": [
|
| 318 |
+
"치매 증상과 행동심리증상 이해",
|
| 319 |
+
"반복설명과 안정적 환경 제공",
|
| 320 |
+
"인지활동과 일상생활 지원",
|
| 321 |
+
"배회·불안·공격성 대응 방법",
|
| 322 |
+
],
|
| 323 |
+
},
|
| 324 |
+
"11. 근골격계질환 예방지침": {
|
| 325 |
+
"purpose": "종사자의 허리·어깨·손목 손상을 예방하고 안전한 업무수행 방법을 익힌다.",
|
| 326 |
+
"content": [
|
| 327 |
+
"근골격계질환 위험요인",
|
| 328 |
+
"이동·체위변경 시 올바른 자세",
|
| 329 |
+
"보조도구 활용과 2인 협조",
|
| 330 |
+
"통증 발생 시 보고와 업무조정",
|
| 331 |
+
],
|
| 332 |
+
},
|
| 333 |
+
"12. 종사자 인권침해 예방지침": {
|
| 334 |
+
"purpose": "종사자에 대한 폭언·폭행·성희롱 등 인권침해를 예방하고 보호체계를 이해한다.",
|
| 335 |
+
"content": [
|
| 336 |
+
"종사자 인권침해 유형",
|
| 337 |
+
"부당요구와 폭언·폭행 대응",
|
| 338 |
+
"고충 접수와 기관 보호조치",
|
| 339 |
+
"재발방지를 위한 기록과 보고",
|
| 340 |
+
],
|
| 341 |
+
},
|
| 342 |
+
"13. 고충처리 및 야간근무지침": {
|
| 343 |
+
"purpose": "수급자·보호자·종사자 고충을 체계적으로 처리하고 야간근무 시 안전관리 원칙을 준수한다.",
|
| 344 |
+
"content": [
|
| 345 |
+
"고충 접수와 처리 절차",
|
| 346 |
+
"민원 예방과 상담기록 관리",
|
| 347 |
+
"야간근무 시 순찰·응급상황 대응",
|
| 348 |
+
"야간 특이사항 보고 및 인수인계",
|
| 349 |
+
],
|
| 350 |
+
},
|
| 351 |
+
}
|
| 352 |
+
|
| 353 |
+
METHODS = ["집합교육", "개별교육", "온라인교육", "회의교육", "자료배포 후 확인", "현장실습 병행"]
|
| 354 |
+
|
| 355 |
+
|
| 356 |
+
# -----------------------------
|
| 357 |
+
# 생성 로직
|
| 358 |
+
# -----------------------------
|
| 359 |
+
def build_education_text(selected_items, institution_type, method, custom_content):
|
| 360 |
+
if not selected_items:
|
| 361 |
+
return "", ""
|
| 362 |
+
|
| 363 |
+
purpose_lines = []
|
| 364 |
+
content_lines = []
|
| 365 |
+
for item in selected_items:
|
| 366 |
+
g = GUIDELINES[item]
|
| 367 |
+
purpose_lines.append(f"- {item}: {g['purpose']}")
|
| 368 |
+
content_lines.append(f"[{item}]")
|
| 369 |
+
for c in g["content"]:
|
| 370 |
+
content_lines.append(f"- {c}")
|
| 371 |
+
content_lines.append("")
|
| 372 |
+
|
| 373 |
+
institution_note = {
|
| 374 |
+
"방문요양": "방문서비스 현장에서 단독 근무 중 발생할 수 있는 응급상황, 개인정보보호, 보호자 요청 대응을 중심으로 교육함.",
|
| 375 |
+
"방문목욕": "목욕지원 과정에서 신체노출, 낙상, 피부상태 확인, 감염예방, 응급상황 대응을 중심으로 교육함.",
|
| 376 |
+
"방문간호": "건강상태 관찰, 감염관리, 개인정보보호, 의료연계 및 응급상황 대응을 중심으로 교육함.",
|
| 377 |
+
"주간보호": "센터 내 단체생활, 프로그램 참여, 송영안전, 낙상·감염예방, 수급자 간 갈등 예방을 중심으로 교육함.",
|
| 378 |
+
"요양원": "입소생활 전반의 인권보호, 욕창·낙상·감염예방, 야간근무, 응급상황 대응을 중심으로 교육함.",
|
| 379 |
+
"공동생활가정": "소규모 공동생활 중 인권보호, 정서지원, 야간안전, 감염예방, 고충처리를 중심으로 교육함.",
|
| 380 |
+
}.get(institution_type, "")
|
| 381 |
+
|
| 382 |
+
purpose = "교육 목적\n" + "\n".join(purpose_lines)
|
| 383 |
+
|
| 384 |
+
content = f"""
|
| 385 |
+
[교육방법]
|
| 386 |
+
{method}
|
| 387 |
+
|
| 388 |
+
[기관유형별 교육 중점]
|
| 389 |
+
{institution_note}
|
| 390 |
+
|
| 391 |
+
[교육내용]
|
| 392 |
+
{chr(10).join(content_lines)}
|
| 393 |
+
|
| 394 |
+
[기관 추가 교육내용]
|
| 395 |
+
{custom_content or '기관 운영규정과 종사자 업무수칙에 따라 실제 사례 중심으로 교육을 진행함.'}
|
| 396 |
+
""".strip()
|
| 397 |
+
|
| 398 |
+
return purpose, content
|
| 399 |
+
|
| 400 |
+
|
| 401 |
+
def build_result_text(selected_items, attendees, absent_staff, method):
|
| 402 |
+
item_text = ", ".join(selected_items)
|
| 403 |
+
attendee_count = len([a for a in attendees.splitlines() if a.strip()])
|
| 404 |
+
absent_text = absent_staff.strip() or "미참석자 없음"
|
| 405 |
+
|
| 406 |
+
variants = [
|
| 407 |
+
f"{item_text} 교육을 통해 종사자의 지침 이해도를 높이고 실제 급여제공 과정에서 준수해야 할 보고체계와 행동수칙을 재확인하였다.",
|
| 408 |
+
f"참석자들은 {item_text}의 주요 내용을 확인하였으며, 수급자 안전과 권리보호를 위한 실천방법을 공유하였다.",
|
| 409 |
+
f"교육 후 질의응답을 통��� 현장에서 발생할 수 있는 사례를 점검하였고, 지침 미준수 예방과 기록관리의 중요성을 확인하였다.",
|
| 410 |
+
]
|
| 411 |
+
|
| 412 |
+
return f"""
|
| 413 |
+
교육결과, 총 {attendee_count}명의 종사자가 {method} 방식으로 교육에 참여하였다.
|
| 414 |
+
{random.choice(variants)}
|
| 415 |
+
|
| 416 |
+
참석자 전원이 교육내용을 잘 숙지하였으며, 교육자료에 제시된 지침 내용을 실제 급여제공 과정에서 준수하기로 하였다.
|
| 417 |
+
기관은 13개 급여제공지침 교육자료를 종사자가 쉽게 확인할 수 있는 장소에 공개 게시하고, 종사자가 수시로 지침 내용을 확인하여 급여제공에 반영할 수 있도록 관리한다.
|
| 418 |
+
또한 신규직원, 미참석자, 지침 숙지가 부족한 종사자에게는 보충교육을 실시하고, 교육내용이 현장에서 이행되는지 지속적으로 모니터링한다.
|
| 419 |
+
|
| 420 |
+
미참석자 관리: {absent_text}
|
| 421 |
+
""".strip()
|
| 422 |
+
|
| 423 |
+
|
| 424 |
+
def evaluate_education(data):
|
| 425 |
+
required = {
|
| 426 |
+
"교육명": bool(data["education_title"].strip()),
|
| 427 |
+
"교육일시": bool(data["education_date"]) and bool(data["education_time"].strip()),
|
| 428 |
+
"교육장소": bool(data["education_place"].strip()),
|
| 429 |
+
"강사명": bool(data["instructor_name"].strip()),
|
| 430 |
+
"교육대상/참석자": bool(data["attendees"].strip()),
|
| 431 |
+
"교육지침 선택": bool(data["guideline_items"].strip()),
|
| 432 |
+
"교육목적": bool(data["education_purpose"].strip()),
|
| 433 |
+
"교육내용": bool(data["education_content"].strip()),
|
| 434 |
+
"교육자료 첨부/명시": bool(data["education_materials"].strip()),
|
| 435 |
+
"교육결과": bool(data["education_result"].strip()),
|
| 436 |
+
"미참석자 관리": "미참석" in data["education_result"] or bool(data["absent_staff"].strip()),
|
| 437 |
+
"후속조치": bool(data["followup_plan"].strip()),
|
| 438 |
+
}
|
| 439 |
+
|
| 440 |
+
score = int(sum(required.values()) / len(required) * 100)
|
| 441 |
+
missing = [k for k, v in required.items() if not v]
|
| 442 |
+
|
| 443 |
+
if score >= 90:
|
| 444 |
+
result = "평가 적합도가 높습니다. 교육일시, 강사, 참석자, 교육내용, 결과 및 후속조치가 잘 반영되었습니다."
|
| 445 |
+
elif score >= 75:
|
| 446 |
+
result = "대체로 적합하나 일부 보완이 필요합니다. 부족 항목을 보완하면 평가 대응력이 높아집니다."
|
| 447 |
+
else:
|
| 448 |
+
result = "보완이 필요합니다. 참석자 명단, 교육자료, 교육결과, 미참석자 관리가 구체적으로 들어가야 합니다."
|
| 449 |
+
|
| 450 |
+
return score, missing, result
|
| 451 |
+
|
| 452 |
+
|
| 453 |
+
def save_uploaded_materials(uploaded_files):
|
| 454 |
+
paths = []
|
| 455 |
+
names = []
|
| 456 |
+
for file in (uploaded_files or [])[:3]:
|
| 457 |
+
suffix = os.path.splitext(file.name)[1].lower() or ".png"
|
| 458 |
+
temp_path = os.path.join(tempfile.gettempdir(), f"edu_material_{datetime.now().strftime('%Y%m%d%H%M%S%f')}{suffix}")
|
| 459 |
+
with open(temp_path, "wb") as f:
|
| 460 |
+
f.write(file.getbuffer())
|
| 461 |
+
paths.append(temp_path)
|
| 462 |
+
names.append(file.name)
|
| 463 |
+
return paths, names
|
| 464 |
+
|
| 465 |
+
|
| 466 |
+
# -----------------------------
|
| 467 |
+
# 엑셀 (디자인 선명화 및 셀 잘림 방지 반영)
|
| 468 |
+
# -----------------------------
|
| 469 |
+
def style_range(ws, cell_range, border_on=True, fill=None, font=None, alignment=None):
|
| 470 |
+
"""병합 셀 포함 범위 전체에 스타일 적용 (검정색 얇은 테두리로 선명하게)"""
|
| 471 |
+
thin = Side(style="thin", color="000000")
|
| 472 |
+
border = Border(left=thin, right=thin, top=thin, bottom=thin)
|
| 473 |
+
|
| 474 |
+
cells = ws[cell_range]
|
| 475 |
+
if not isinstance(cells, tuple):
|
| 476 |
+
cells = ((cells,),)
|
| 477 |
+
|
| 478 |
+
for row in cells:
|
| 479 |
+
for cell in row:
|
| 480 |
+
if border_on:
|
| 481 |
+
cell.border = border
|
| 482 |
+
if fill:
|
| 483 |
+
cell.fill = fill
|
| 484 |
+
if font:
|
| 485 |
+
cell.font = font
|
| 486 |
+
if alignment:
|
| 487 |
+
cell.alignment = alignment
|
| 488 |
+
|
| 489 |
+
def write_title_with_approval(ws, title, title_fill, header_fill):
|
| 490 |
+
for col in range(1, 10):
|
| 491 |
+
ws.column_dimensions[get_column_letter(col)].width = 11.5
|
| 492 |
+
|
| 493 |
+
# 타이틀 영역 (A1~G2 병합)
|
| 494 |
+
ws.merge_cells("A1:G2")
|
| 495 |
+
c = ws.cell(1, 1)
|
| 496 |
+
c.value = title
|
| 497 |
+
c.font = Font(name="Malgun Gothic", size=24, bold=True)
|
| 498 |
+
c.alignment = Alignment(horizontal="center", vertical="center")
|
| 499 |
+
style_range(ws, "A1:G2", fill=title_fill)
|
| 500 |
+
|
| 501 |
+
# 결재라인 (우측 상단 H~I열 2칸) 지저분한 선 방지를 위해 셀별로 적용
|
| 502 |
+
ws.cell(1, 8).value = "담당자"
|
| 503 |
+
ws.cell(1, 9).value = "시설장"
|
| 504 |
+
ws.cell(2, 8).value = ""
|
| 505 |
+
ws.cell(2, 9).value = ""
|
| 506 |
+
|
| 507 |
+
for rr in [1, 2]:
|
| 508 |
+
for cc in [8, 9]:
|
| 509 |
+
cell = ws.cell(rr, cc)
|
| 510 |
+
cell.alignment = Alignment(horizontal="center", vertical="center", wrap_text=True)
|
| 511 |
+
if rr == 1:
|
| 512 |
+
cell.font = Font(name="Malgun Gothic", size=11, bold=True)
|
| 513 |
+
cell.fill = header_fill
|
| 514 |
+
else:
|
| 515 |
+
cell.font = Font(name="Malgun Gothic", size=11)
|
| 516 |
+
|
| 517 |
+
# 각각의 셀 영역만 정확히 테두리 스타일 지정
|
| 518 |
+
cell_name = f"{get_column_letter(cc)}{rr}"
|
| 519 |
+
style_range(ws, f"{cell_name}:{cell_name}")
|
| 520 |
+
|
| 521 |
+
ws.row_dimensions[1].height = 28
|
| 522 |
+
ws.row_dimensions[2].height = 42
|
| 523 |
+
|
| 524 |
+
def write_info_row(ws, row, a, b, c, d, e, f, header_fill):
|
| 525 |
+
ws.cell(row, 1).value = a
|
| 526 |
+
ws.merge_cells(start_row=row, start_column=2, end_row=row, end_column=3)
|
| 527 |
+
ws.cell(row, 2).value = b
|
| 528 |
+
|
| 529 |
+
ws.cell(row, 4).value = c
|
| 530 |
+
ws.merge_cells(start_row=row, start_column=5, end_row=row, end_column=6)
|
| 531 |
+
ws.cell(row, 5).value = d
|
| 532 |
+
|
| 533 |
+
ws.cell(row, 7).value = e
|
| 534 |
+
ws.merge_cells(start_row=row, start_column=8, end_row=row, end_column=9)
|
| 535 |
+
ws.cell(row, 8).value = f
|
| 536 |
+
|
| 537 |
+
for col in [1, 4, 7]:
|
| 538 |
+
ws.cell(row, col).fill = header_fill
|
| 539 |
+
ws.cell(row, col).font = Font(name="Malgun Gothic", size=11, bold=True)
|
| 540 |
+
ws.cell(row, col).alignment = Alignment(horizontal="center", vertical="center", wrap_text=True)
|
| 541 |
+
|
| 542 |
+
for col in [2, 5, 8]:
|
| 543 |
+
ws.cell(row, col).font = Font(name="Malgun Gothic", size=11)
|
| 544 |
+
ws.cell(row, col).alignment = Alignment(horizontal="center", vertical="center", wrap_text=True)
|
| 545 |
+
|
| 546 |
+
style_range(ws, f"A{row}:I{row}")
|
| 547 |
+
ws.row_dimensions[row].height = 30
|
| 548 |
+
|
| 549 |
+
def write_section(ws, row, title, content, header_fill, min_height=100):
|
| 550 |
+
# 제목 행
|
| 551 |
+
ws.merge_cells(start_row=row, start_column=1, end_row=row, end_column=9)
|
| 552 |
+
t_cell = ws.cell(row, 1)
|
| 553 |
+
t_cell.value = title
|
| 554 |
+
t_cell.font = Font(name="Malgun Gothic", size=15, bold=True)
|
| 555 |
+
t_cell.alignment = Alignment(horizontal="center", vertical="center")
|
| 556 |
+
t_cell.fill = header_fill
|
| 557 |
+
style_range(ws, f"A{row}:I{row}")
|
| 558 |
+
ws.row_dimensions[row].height = 30
|
| 559 |
+
row += 1
|
| 560 |
+
|
| 561 |
+
# 내용 행
|
| 562 |
+
ws.merge_cells(start_row=row, start_column=1, end_row=row, end_column=9)
|
| 563 |
+
c_cell = ws.cell(row, 1)
|
| 564 |
+
c_cell.value = content
|
| 565 |
+
c_cell.font = Font(name="Malgun Gothic", size=11)
|
| 566 |
+
c_cell.alignment = Alignment(horizontal="left", vertical="top", wrap_text=True)
|
| 567 |
+
style_range(ws, f"A{row}:I{row}")
|
| 568 |
+
|
| 569 |
+
# 줄바꿈과 텍스트 길이에 비례해 셀 높이 정밀 계산 (여유 간격 확대)
|
| 570 |
+
content_str = str(content)
|
| 571 |
+
lines = 0
|
| 572 |
+
for line in content_str.split("\n"):
|
| 573 |
+
lines += (len(line) // 45) + 1
|
| 574 |
+
calculated_height = lines * 24 + 30
|
| 575 |
+
ws.row_dimensions[row].height = max(min_height, calculated_height)
|
| 576 |
+
|
| 577 |
+
return row + 1
|
| 578 |
+
|
| 579 |
+
def generate_excel(data):
|
| 580 |
+
wb = Workbook()
|
| 581 |
+
title_fill = PatternFill("solid", fgColor="FFEDD5")
|
| 582 |
+
header_fill = PatternFill("solid", fgColor="F3F4F6")
|
| 583 |
+
|
| 584 |
+
ws = wb.active
|
| 585 |
+
ws.title = "13지침교육일지"
|
| 586 |
+
|
| 587 |
+
# 인쇄 잘림 방지를 위한 페이지 셋업 (강제 1페이지 축소 방지)
|
| 588 |
+
ws.page_setup.paperSize = ws.PAPERSIZE_A4
|
| 589 |
+
ws.page_setup.orientation = "portrait"
|
| 590 |
+
ws.page_setup.fitToWidth = 1
|
| 591 |
+
ws.page_setup.fitToHeight = 0
|
| 592 |
+
ws.sheet_properties.pageSetUpPr.fitToPage = True
|
| 593 |
+
ws.page_margins.left = 0.3
|
| 594 |
+
ws.page_margins.right = 0.3
|
| 595 |
+
ws.page_margins.top = 0.4
|
| 596 |
+
ws.page_margins.bottom = 0.4
|
| 597 |
+
ws.sheet_view.showGridLines = False
|
| 598 |
+
|
| 599 |
+
write_title_with_approval(ws, "13지침 교육일지", title_fill, header_fill)
|
| 600 |
+
|
| 601 |
+
r = 3
|
| 602 |
+
write_info_row(ws, r, "기관명", data["institution_name"], "기관유형", data["institution_type"], "교육일자", data["education_date"], header_fill); r += 1
|
| 603 |
+
write_info_row(ws, r, "교육명", data["education_title"], "교육시간", data["education_time"], "교육장소", data["education_place"], header_fill); r += 1
|
| 604 |
+
write_info_row(ws, r, "강사명", data["instructor_name"], "강사직책", data["instructor_position"], "교육방법", data["education_method"], header_fill); r += 1
|
| 605 |
+
|
| 606 |
+
r = write_section(ws, r, "교육지침", data["guideline_items"], header_fill, 80)
|
| 607 |
+
r = write_section(ws, r, "참석자 명단", data["attendees"], header_fill, 110)
|
| 608 |
+
r = write_section(ws, r, "미참석자 및 보충교육 계획", data["absent_staff"] or "미참석자 없음", header_fill, 70)
|
| 609 |
+
r = write_section(ws, r, "교육목적", data["education_purpose"], header_fill, 110)
|
| 610 |
+
r = write_section(ws, r, "교육내용", data["education_content"], header_fill, 260)
|
| 611 |
+
r = write_section(ws, r, "교육자료 첨부/자료명", data["education_materials"], header_fill, 80)
|
| 612 |
+
r = write_section(ws, r, "교육결과", data["education_result"], header_fill, 150)
|
| 613 |
+
r = write_section(ws, r, "후속조치 및 현장 적용계획", data["followup_plan"], header_fill, 90)
|
| 614 |
+
r = write_section(ws, r, "평가 적합도 점검", f"{data['evaluation_score']}점\n부족 항목: {data['missing_items']}\n{data['compliance_result']}", header_fill, 80)
|
| 615 |
+
|
| 616 |
+
# 교육자료 이미지 첨부: 이미지 파일일 때만 삽입
|
| 617 |
+
image_paths = [p for p in data.get("material_paths", []) if os.path.splitext(p)[1].lower() in [".png", ".jpg", ".jpeg"]]
|
| 618 |
+
if image_paths:
|
| 619 |
+
ws.merge_cells(start_row=r, start_column=1, end_row=r, end_column=9)
|
| 620 |
+
ws.cell(r, 1).value = "교육자료 이미지"
|
| 621 |
+
ws.cell(r, 1).font = Font(name="Malgun Gothic", size=15, bold=True)
|
| 622 |
+
ws.cell(r, 1).alignment = Alignment(horizontal="center", vertical="center")
|
| 623 |
+
ws.cell(r, 1).fill = header_fill
|
| 624 |
+
style_range(ws, f"A{r}:I{r}")
|
| 625 |
+
r += 1
|
| 626 |
+
|
| 627 |
+
anchors = ["A", "D", "G"]
|
| 628 |
+
img_row = r
|
| 629 |
+
for idx, img_path in enumerate(image_paths[:3]):
|
| 630 |
+
try:
|
| 631 |
+
img = XLImage(img_path)
|
| 632 |
+
img.width = 210
|
| 633 |
+
img.height = 150
|
| 634 |
+
ws.add_image(img, f"{anchors[idx]}{img_row}")
|
| 635 |
+
except Exception:
|
| 636 |
+
pass
|
| 637 |
+
|
| 638 |
+
# 이미지 영역 병합 및 스타일 적용
|
| 639 |
+
ws.merge_cells(start_row=img_row, start_column=1, end_row=img_row+7, end_column=9)
|
| 640 |
+
style_range(ws, f"A{img_row}:I{img_row+7}")
|
| 641 |
+
for rr in range(img_row, img_row + 8):
|
| 642 |
+
ws.row_dimensions[rr].height = 22
|
| 643 |
+
r = img_row + 8
|
| 644 |
+
|
| 645 |
+
output = BytesIO()
|
| 646 |
+
wb.save(output)
|
| 647 |
+
output.seek(0)
|
| 648 |
+
return output
|
| 649 |
+
|
| 650 |
+
|
| 651 |
+
# -----------------------------
|
| 652 |
+
# 화면
|
| 653 |
+
# -----------------------------
|
| 654 |
+
menu = st.sidebar.radio("메뉴", ["교육일지 생성", "직원 등록", "교육기록 보기"])
|
| 655 |
+
|
| 656 |
+
st.sidebar.success("DB 연결")
|
| 657 |
+
st.sidebar.caption(DB_PATH)
|
| 658 |
+
|
| 659 |
+
if menu == "직원 등록":
|
| 660 |
+
st.subheader("👥 직원 등록")
|
| 661 |
+
with st.form("staff_form"):
|
| 662 |
+
c1, c2, c3, c4 = st.columns(4)
|
| 663 |
+
name = c1.text_input("직원명")
|
| 664 |
+
position = c2.selectbox("직책", ["시설장", "사회복지사", "요양보호사", "간호조무사", "간호사", "물리치료사", "작업치료사", "조리원", "사무원", "기타"])
|
| 665 |
+
department = c3.text_input("부서", "")
|
| 666 |
+
phone = c4.text_input("연락처", "")
|
| 667 |
+
submitted = st.form_submit_button("직원 등록")
|
| 668 |
+
if submitted:
|
| 669 |
+
if not name.strip():
|
| 670 |
+
st.error("직원명은 필수입니다.")
|
| 671 |
+
else:
|
| 672 |
+
save_staff(name, position, department, phone)
|
| 673 |
+
st.success("직원이 등록되었습니다.")
|
| 674 |
+
|
| 675 |
+
df = load_staff()
|
| 676 |
+
if not df.empty:
|
| 677 |
+
st.dataframe(df, use_container_width=True)
|
| 678 |
+
|
| 679 |
+
elif menu == "교육기록 보기":
|
| 680 |
+
st.subheader("📚 저장된 교육기록")
|
| 681 |
+
records = load_education_records()
|
| 682 |
+
if records.empty:
|
| 683 |
+
st.info("저장된 교육기록이 없습니다.")
|
| 684 |
+
else:
|
| 685 |
+
st.dataframe(records, use_container_width=True)
|
| 686 |
+
|
| 687 |
+
elif menu == "교육일지 생성":
|
| 688 |
+
st.subheader("📘 13지침 교육일지 생성")
|
| 689 |
+
|
| 690 |
+
staff_df = load_staff()
|
| 691 |
+
|
| 692 |
+
col1, col2, col3 = st.columns(3)
|
| 693 |
+
# 초기 기관명에서 BeeCare 삭제
|
| 694 |
+
institution_name = col1.text_input("기관명", "장기요양기관")
|
| 695 |
+
institution_type = col2.selectbox("기관유형", ["방문요양", "방문목욕", "방문간호", "주간보호", "요양원", "공동생활가정"])
|
| 696 |
+
education_title = col3.text_input("교육명", "급여제공지침 종사자 교육")
|
| 697 |
+
|
| 698 |
+
col4, col5, col6 = st.columns(3)
|
| 699 |
+
education_date = col4.date_input("교육일자", value=date.today())
|
| 700 |
+
education_time = col5.text_input("교육시간", "14:00~15:00")
|
| 701 |
+
education_place = col6.text_input("교육장소", "기관 내 프로그램실")
|
| 702 |
+
|
| 703 |
+
col7, col8, col9 = st.columns(3)
|
| 704 |
+
instructor_name = col7.text_input("강사명", "시설장")
|
| 705 |
+
instructor_position = col8.text_input("강사직책", "시설장")
|
| 706 |
+
education_method = col9.selectbox("교육방법", METHODS)
|
| 707 |
+
|
| 708 |
+
selected_guidelines = st.multiselect(
|
| 709 |
+
"교육 지침 선택",
|
| 710 |
+
list(GUIDELINES.keys()),
|
| 711 |
+
default=["02. 노인인권보호지침", "03. 노인학대예방지침", "07. 감염예방 및 관리지침", "09. 낙상예방지침"]
|
| 712 |
+
)
|
| 713 |
+
|
| 714 |
+
st.markdown("### 참석자 명단")
|
| 715 |
+
if staff_df.empty:
|
| 716 |
+
st.info("등록된 직원이 없습니다. 직접 참석자 명단을 입력하세요.")
|
| 717 |
+
selected_staff_text = ""
|
| 718 |
+
else:
|
| 719 |
+
staff_options = staff_df.apply(lambda x: f"{x['name']} / {x['position']}", axis=1).tolist()
|
| 720 |
+
selected_staff = st.multiselect("등록직원에서 참석자 선택", staff_options, default=staff_options[:min(5, len(staff_options))])
|
| 721 |
+
selected_staff_text = "\n".join(selected_staff)
|
| 722 |
+
|
| 723 |
+
attendees_manual = st.text_area(
|
| 724 |
+
"참석자 직접 입력/수정",
|
| 725 |
+
value=selected_staff_text,
|
| 726 |
+
height=120,
|
| 727 |
+
placeholder="예:\n김복지 / 사회복지사\n이요양 / 요양보호사"
|
| 728 |
+
)
|
| 729 |
+
|
| 730 |
+
absent_staff = st.text_area(
|
| 731 |
+
"미참석자 및 보충교육 계획",
|
| 732 |
+
placeholder="예: 박요양보호사 연차로 미참석, 6월 20일 개별 보충교육 예정",
|
| 733 |
+
height=80
|
| 734 |
+
)
|
| 735 |
+
|
| 736 |
+
custom_content = st.text_area(
|
| 737 |
+
"기관 추가 교육내용",
|
| 738 |
+
placeholder="기관에서 실제 발생할 수 있는 사례, 자체 운영규정, 유의사항 등을 입력하세요.",
|
| 739 |
+
height=90
|
| 740 |
+
)
|
| 741 |
+
|
| 742 |
+
education_material_files = st.file_uploader(
|
| 743 |
+
"교육자료 첨부 (이미지/PDF/문서 가능, 최대 3개)",
|
| 744 |
+
type=["png", "jpg", "jpeg", "pdf", "docx", "xlsx"],
|
| 745 |
+
accept_multiple_files=True
|
| 746 |
+
)
|
| 747 |
+
|
| 748 |
+
material_paths, material_names = save_uploaded_materials(education_material_files)
|
| 749 |
+
material_text = ", ".join(material_names) if material_names else "13개 급여제공지침 교육자료 비치 및 공개게시 자료 사용"
|
| 750 |
+
|
| 751 |
+
purpose, content = build_education_text(
|
| 752 |
+
selected_guidelines,
|
| 753 |
+
institution_type,
|
| 754 |
+
education_method,
|
| 755 |
+
custom_content
|
| 756 |
+
)
|
| 757 |
+
|
| 758 |
+
result_text = build_result_text(
|
| 759 |
+
selected_guidelines,
|
| 760 |
+
attendees_manual,
|
| 761 |
+
absent_staff,
|
| 762 |
+
education_method
|
| 763 |
+
) if selected_guidelines else ""
|
| 764 |
+
|
| 765 |
+
followup_plan = st.text_area(
|
| 766 |
+
"후속조치 및 현장 적용계획",
|
| 767 |
+
value="13개 급여제공지침 교육자료를 기관 내 종사자가 확인하기 쉬운 장소에 공개 게시하고, 종사자가 수시로 지침 내용을 확인하여 실제 급여제공에 반영하도록 한다. 교육 후 종사자가 현장에서 지침을 준수하는지 모니터링하고, 미참석자 또는 신규직원에 대해서는 보충교육을 실시한다.",
|
| 768 |
+
height=100
|
| 769 |
+
)
|
| 770 |
+
|
| 771 |
+
if st.button("📘 교육일지 생성", use_container_width=True):
|
| 772 |
+
data = {
|
| 773 |
+
"institution_name": institution_name,
|
| 774 |
+
"institution_type": institution_type,
|
| 775 |
+
"education_title": education_title,
|
| 776 |
+
"guideline_items": "\n".join(selected_guidelines),
|
| 777 |
+
"education_date": str(education_date),
|
| 778 |
+
"education_time": education_time,
|
| 779 |
+
"education_place": education_place,
|
| 780 |
+
"instructor_name": instructor_name,
|
| 781 |
+
"instructor_position": instructor_position,
|
| 782 |
+
"attendees": attendees_manual,
|
| 783 |
+
"absent_staff": absent_staff,
|
| 784 |
+
"education_method": education_method,
|
| 785 |
+
"education_purpose": purpose,
|
| 786 |
+
"education_content": content,
|
| 787 |
+
"education_materials": material_text,
|
| 788 |
+
"education_result": result_text,
|
| 789 |
+
"followup_plan": followup_plan,
|
| 790 |
+
"material_paths": material_paths,
|
| 791 |
+
}
|
| 792 |
+
|
| 793 |
+
score, missing, compliance = evaluate_education(data)
|
| 794 |
+
data["evaluation_score"] = score
|
| 795 |
+
data["missing_items"] = ", ".join(missing) if missing else "부족 항목 없음"
|
| 796 |
+
data["compliance_result"] = compliance
|
| 797 |
+
|
| 798 |
+
st.session_state["edu_data"] = data
|
| 799 |
+
|
| 800 |
+
if "edu_data" in st.session_state:
|
| 801 |
+
data = st.session_state["edu_data"]
|
| 802 |
+
|
| 803 |
+
st.markdown("---")
|
| 804 |
+
st.subheader("생성 결과 수정")
|
| 805 |
+
|
| 806 |
+
data["education_purpose"] = st.text_area("교육목적", value=data["education_purpose"], height=140)
|
| 807 |
+
data["education_content"] = st.text_area("교육내용", value=data["education_content"], height=260)
|
| 808 |
+
data["education_result"] = st.text_area("교육결과", value=data["education_result"], height=140)
|
| 809 |
+
data["followup_plan"] = st.text_area("후속조치", value=data["followup_plan"], height=100)
|
| 810 |
+
|
| 811 |
+
score, missing, compliance = evaluate_education(data)
|
| 812 |
+
data["evaluation_score"] = score
|
| 813 |
+
data["missing_items"] = ", ".join(missing) if missing else "부족 항목 없음"
|
| 814 |
+
data["compliance_result"] = compliance
|
| 815 |
+
|
| 816 |
+
st.subheader("평가 적합도 점검")
|
| 817 |
+
e1, e2, e3 = st.columns(3)
|
| 818 |
+
e1.metric("평가 적합도", f"{score}점")
|
| 819 |
+
e2.metric("부족 항목", data["missing_items"])
|
| 820 |
+
e3.metric("결재라인", "담당자/시설장 2칸")
|
| 821 |
+
|
| 822 |
+
if score >= 90:
|
| 823 |
+
st.markdown(f'<div class="okbox">{compliance}</div>', unsafe_allow_html=True)
|
| 824 |
+
else:
|
| 825 |
+
st.markdown(f'<div class="warnbox">{compliance}</div>', unsafe_allow_html=True)
|
| 826 |
+
|
| 827 |
+
if st.button("💾 교육기록 DB 저장", use_container_width=True):
|
| 828 |
+
save_education_record(data)
|
| 829 |
+
st.success("교육기록이 저장되었습니다.")
|
| 830 |
+
|
| 831 |
+
filename = f"13지침교육일지_{data['education_date']}.xlsx"
|
| 832 |
+
st.download_button(
|
| 833 |
+
"📥 13지침 교육일지 엑셀 다운로드",
|
| 834 |
+
data=generate_excel(data),
|
| 835 |
+
file_name=filename,
|
| 836 |
+
mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
| 837 |
+
use_container_width=True,
|
| 838 |
+
)
|
| 839 |
+
|
| 840 |
+
# 하단 캡션 수정
|
| 841 |
+
st.caption("13지침 교육일지 통합연동 생성기")
|