// ElderlyHealthcareSystem — 画面固有設定（app-core.js が window.SYSTEM_CONFIG を読む）
window.SYSTEM_CONFIG = {
  domains: [
  { id: "elderly-insured", label: "被保険者", endpoint: "/api/elderly-insured",
    cols: [{ key: "insuredNumber", label: "被保険者番号" }, { key: "fullName", label: "氏名" }, { key: "birthDate", label: "生年月日" }, { key: "status", label: "状態", badge: true }, { key: "createdAt", label: "登録日時" }],
    createFields: [{ name: "fullName", label: "氏名", required: true, placeholder: "山田 太郎" }, { name: "birthDate", label: "生年月日", required: true, type: "date" }, { name: "address", label: "住所", placeholder: "東京都..." }] },
  { id: "premiums", label: "保険料賦課", endpoint: "/api/premiums",
    cols: [{ key: "insuredId", label: "被保険者ID" }, { key: "period", label: "期間" }, { key: "amount", label: "保険料（円）" }, { key: "status", label: "状態", badge: true }, { key: "createdAt", label: "賦課日時" }],
    createFields: [{ name: "insuredId", label: "被保険者ID", required: true, placeholder: "登録済み被保険者のIDを入力" }, { name: "period", label: "期間", required: true, placeholder: "2026-01" }, { name: "amount", label: "保険料（円）", required: true, type: "number", placeholder: "15000" }] },
],
  calc: { title: "後期高齢者医療 保険料の試算", endpoint: "/api/kouki/premium", primary: { key: "total", label: "年間保険料", format: "yen" }, fields: [ { key: "income", label: "所得（円）", type: "number", placeholder: "2000000" }, { key: "dependents", label: "同一世帯の後期被保険者数（本人除く）", type: "number", default: 0 } ] },
  // 中間サーバ照会（別表: 後期高齢者医療資格賦課事務）
  linkage: {
    agency: "kouki", procedure: "後期高齢者医療資格賦課事務",
    queries: [ { holder: "tax", item: "所得金額" } ],
    apply(values, setField) {
      if (values["所得金額"] === undefined) return false;
      setField("income", String(values["所得金額"]));
      return true;
    },
  },
};
