"""Prompt template for PA interpreter AI chain."""
from __future__ import annotations
from langchain_core.output_parsers import PydanticOutputParser
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
from claim_validator.chains.output_schemas.pa_interpreter import PAInterpreterOutput

_parser = PydanticOutputParser(pydantic_object=PAInterpreterOutput)

PA_INTERPRETER_PROMPT = ChatPromptTemplate.from_messages([
    ("system",
     "You are a healthcare prior authorization analyst. Interpret this PA response "
     "data and provide:\n1. A clear summary of the authorization decision\n"
     "2. Any denial reasons with plain-English explanations\n"
     "3. Recommended next steps (appeal strategy, additional info needed)\n\n"
     "IMPORTANT: Do not include any patient-identifying information.\n\n{format_instructions}"),
    MessagesPlaceholder("history", optional=True),
    ("human", "{pa_response}"),
]).partial(format_instructions=_parser.get_format_instructions())
