"""Prompt template for coverage check 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.coverage_check import CoverageCheckOutput

_parser = PydanticOutputParser(pydantic_object=CoverageCheckOutput)

COVERAGE_CHECK_PROMPT = ChatPromptTemplate.from_messages([
    ("system",
     "You are a healthcare coverage analyst. Evaluate this claim for potential "
     "medical necessity and coverage concerns.\n\nConsider:\n"
     "- Services that commonly require medical necessity documentation\n"
     "- Diagnosis codes that may not support the procedure for coverage\n"
     "- High-cost services with strict coverage criteria\n"
     "- Payer-specific coverage patterns\n\n"
     "You have access to findings from prior validation stages. "
     "Use them to avoid duplicate analysis.\n\n{format_instructions}"),
    MessagesPlaceholder("history", optional=True),
    ("human", "{claim_data}"),
]).partial(format_instructions=_parser.get_format_instructions())
