Skip to content

수술분류표 검색기

<h3>수술 정보 검색</h3>
<p>가입일과 수술명을 입력하시면 해당되는 수술종수를 확인할 수 있습니다.</p>

<label>가입일</label><br/>
<input type="date" id="가입일" /><br/><br/>

<label>수술명</label><br/>
<input type="text" id="수술명" placeholder="예: 피부이식술(25㎠ 이상인 경우)" /><br/><br/>

<button onclick="검색()">검색</button>

<div id="결과" style="margin-top:20px; font-weight:bold; color:#333;"></div>

<script>
// JSON 데이터 URL - 실제 업로드한 주소로 변경하세요
const jsonUrl = "https://find-surgery.kr/wp-content/uploads/2025/07/수술분류표_검색용.json";

let data = [];

// JSON 파일 불러오기
fetch(jsonUrl)
  .then(res => res.json())
  .then(json => {
    data = json;
    console.log("데이터 로딩 완료:", data.length, "건");
  })
  .catch(err => {
    console.error("JSON 로드 오류:", err);
    document.getElementById("결과").innerText = "❌ 데이터 파일을 불러올 수 없습니다.";
  });

// 검색 함수
function 검색() {
  const 가입일 = new Date(document.getElementById("가입일").value);
  const 수술명 = document.getElementById("수술명").value.trim();
  const 결과 = document.getElementById("결과");

  if (!가입일 || !수술명) {
    결과.innerHTML = "⚠️ 가입일과 수술명을 모두 입력해 주세요.";
    return;
  }

  const result = data.find(item => {
    const 시작 = new Date(item.가입년도_시작);
    const 끝 = new Date(item.가입년도_끝);
    return item.수술명 === 수술명 && 가입일 >= 시작 && 가입일 <= 끝;
  });

  결과.innerHTML = result
    ? `✅ <strong>수술종수:</strong> ${result.수술종수}`
    : "❌ 해당 수술명 또는 가입일에 대한 정보가 없습니다.";
}
</script>