"""Prompt template for prior auth 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.prior_auth import PriorAuthOutput

_parser = PydanticOutputParser(pydantic_object=PriorAuthOutput)

PRIOR_AUTH_PROMPT = ChatPromptTemplate.from_messages([
    ("system",
     "You are a healthcare prior authorization specialist. Analyze this claim to "
     "identify services that likely require prior authorization.\n\n"
     "Consider:\n- High-cost imaging (MRI, CT, PET)\n- Surgical procedures above typical thresholds\n"
     "- Specialty medications and infusions\n- Durable medical equipment\n"
     "- Payer-specific prior auth requirements\n\n{format_instructions}"),
    MessagesPlaceholder("history", optional=True),
    ("human", "{claim_data}"),
]).partial(format_instructions=_parser.get_format_instructions())
