app:
  description: 退院時の診療記録から服薬指示・リハビリ計画・外来予約の要点を抽出し、分かりやすいサマリーを生成します。
  icon: 🩺
  icon_background: '#FFEAD5'
  mode: workflow
  name: 退院計画サマリー生成
  use_icon_as_answer_icon: false
kind: app
version: 0.6.0
workflow:
  conversation_variables: []
  environment_variables: []
  features:
    file_upload:
      image:
        enabled: false
    opening_statement: ''
    suggested_questions: []
    suggested_questions_after_answer:
      enabled: false
    text_to_speech:
      enabled: false
  graph:
    edges:
    - data:
        sourceType: start
        targetType: parameter-extractor
      id: start-to-extract1
      source: start
      target: extract1
    - data:
        sourceType: parameter-extractor
        targetType: code
      id: extract1-to-code1
      source: extract1
      target: code1
    - data:
        sourceType: code
        targetType: end
      id: code1-to-end
      source: code1
      target: end
    nodes:
    - data:
        title: 開始
        type: start
        variables:
        - label: query
          max_length: 2048
          options: []
          required: true
          type: paragraph
          variable: query
      height: 90
      id: start
      position:
        x: 80
        y: 282
      type: custom
      width: 244
    - data:
        title: 情報抽出（退院計画）
        type: parameter-extractor
        model:
          provider: openai
          name: gpt-5-mini
          mode: chat
          completion_params:
            temperature: 0.2
        query:
        - start
        - query
        parameters:
        - name: medication_instructions
          type: string
          description: 服薬指示（投薬名、用量、服薬方法、期間、注意点など）
          required: true
        - name: rehab_plan
          type: string
          description: リハビリ計画（目的、頻度、目標、注意事項）
          required: true
        - name: outpatient_appointments
          type: string
          description: 外来予約（診療科、日時、予約の有無・手続き）
          required: true
        reasoning_mode: prompt
        instruction: '以下の退院時診療記録から、下記項目を抽出してください。出力は各項目ごとに明確に分けたプレーンテキスト（値は簡潔に）で返してください。1)
          medication_instructions: 服薬指示、2) rehab_plan: リハビリ計画、3) outpatient_appointments:
          外来予約情報。抽出できない場合は''該当なし''と記載してください。'
      height: 90
      id: extract1
      position:
        x: 380
        y: 282
      type: custom
      width: 244
    - data:
        title: サマリー整形（コード）
        type: code
        code_language: python3
        code: "def _safe_str(v):\n    \"\"\"Convert any value to string safely.\"\"\
          \"\n    if v is None:\n        return \"\"\n    if isinstance(v, list):\n\
          \        return \"\\n\".join(str(i) for i in v)\n    return str(v)\n\ndef\
          \ _safe_list(v):\n    \"\"\"Ensure value is a list.\"\"\"\n    if v is None:\n\
          \        return []\n    if isinstance(v, str):\n        return [v]\n   \
          \ if isinstance(v, list):\n        return v\n    return [v]\n\ndef main(**kwargs)\
          \ -> dict:\n    inputs = kwargs\n    # 安全に文字列化して結合し、見やすいサマリーを作成する\n    med\
          \ = str(inputs.get(\"medication_instructions\", \"\") or \"該当なし\")\n   \
          \ rehab = str(inputs.get(\"rehab_plan\", \"\") or \"該当なし\")\n    appt =\
          \ str(inputs.get(\"outpatient_appointments\", \"\") or \"該当なし\")\n    lines\
          \ = []\n    lines.append(\"■ 服薬指示:\")\n    lines.append(med)\n    lines.append(\"\
          \")\n    lines.append(\"■ リハビリ計画:\")\n    lines.append(rehab)\n    lines.append(\"\
          \")\n    lines.append(\"■ 外来予約:\")\n    lines.append(appt)\n    summary\
          \ = \"\\n\".join(lines)\n    return dict(output=summary)\n"
        variables:
        - value_selector:
          - extract1
          - medication_instructions
          variable: medication_instructions
        - value_selector:
          - extract1
          - rehab_plan
          variable: rehab_plan
        - value_selector:
          - extract1
          - outpatient_appointments
          variable: outpatient_appointments
        outputs:
          output:
            type: string
            children: null
      height: 90
      id: code1
      position:
        x: 680
        y: 282
      type: custom
      width: 244
    - data:
        title: 終了
        type: end
        outputs:
        - value_selector:
          - code1
          - output
          variable: result
      height: 90
      id: end
      position:
        x: 980
        y: 282
      type: custom
      width: 244
  hash: null
