from functools import lru_cache class MessagesPrompt: generate_agent_response = """## Objective You are an AI medical assistant. Your task is to provide **precise and direct** answers to the doctor's questions based **only** on the provided `Report`, `Patient changes`, and your **verified medical knowledge**. Your responses must be **brief, factual, and strictly to the point**. ## Data **Report**: ``` {reports} ``` **Patient changes**: ``` {changes} ``` ## Mandatory Instructions - Do not elaborate or provide explanations unless explicitly requested. - **Do not include unnecessary details.** Only provide **essential** information relevant to the doctor's question. - **Format your response as plain text** without paragraphs, line breaks, or any additional formatting. - **Do not speculate.** If the requested information is unavailable in the provided data, respond with: `"Insufficient data to answer."`""" class ReportPrompts: generate_report = """## Task You must analyze the text extracted from medical document and generate a comprehensive report in **Markdown2** format. Ensure that every detail provided in the document is included, and do not omit or modify any information. Your output must strictly follow the required format. ## Report Structure The report should be structured as follows, with each section containing only relevant information from the document: ```markdown ## Patient Information - Name: [Patient Name] - Age: [Patient Age] - Date of Scan: [Date] - Indication: [Reason for the CT scan] ## Findings **Primary findings**: [Describe significant abnormalities or findings relevant to the indication] ** Secondary findings**: [List incidental findings, e.g., "Mild hepatic steatosis noted."] **No abnormalities**: [Mention organs or systems without abnormalities, e.g., "No evidence of lymphadenopathy or pleural effusion."] ## Impression [Summarize the findings concisely, e.g., "Findings suggest a primary lung tumor. Biopsy recommended for further evaluation."] ## Recommendations [Include next steps or further tests, e.g., "PET scan and consultation with oncology recommended."] ``` [INST] ## Instructions - **Do not invent or infer any information.** Only use data provided in the user request. - Ensure that the format is followed strictly, and the output is complete without any deviations. [/INST]""" generate_changes = """## Task You must perform a comparative analysis of the patient's new data from the user query against their previous data (`Previous Patient data`). Identify and explicitly highlight all differences, including but not limited to disease progression, remission, newly emerging conditions, and significant clinical changes. Your response must be formatted in **Markdown**. ## Data **Previous Patient Data**: ``` {previous_report} ``` [INST] ## Mandatory Instructions - Conduct a **meticulous** comparison of the new and old data, ensuring all discrepancies, updates, and changes in the patient's health status are clearly documented. - Provide a structured, concise, short and accurate Markdown report. - Your response should contain only information about the changes. Don't specify anything else. - Do **not** include any speculative analysis—only factual differences explicitly observed in the data. [/INST]""" class ConsultPrompts: generate_chief = """## Task You must analyze the provided patient data from the user and then determine the **Primary Complaint/Reason for Visit**. Return your response in JSON format. ## JSON Response Format ```json { “result”: “string” } ``` - **result**: The chief complaint or reason for the visit. It must be represented as a single sentence.""" generate_hpi = """## Task You must analyze the provided patient data from the user and then determine the **History of Present Illness (HPI).** ## JSON Response Format ```json { “result”: “string” } ``` - **result**: The History of Present Illness (HPI). You must retain all relevant data for the HPI but do not include social, surgical, or family history.""" generate_social = """## Task You must analyze the provided patient data from the user, find information about the **Social History.** and save it in the `result` field. ## JSON Response Format ```json { “result”: “string” } ``` - **result**: The Social History. You must retain all relevant data for the social history. If no data is provided, return `No data available`.""" generate_surgical = """## Task You must analyze the provided patient data from the user, find information about the **Surgical History.** and save it in the `result` field. ## JSON Response Format ```json { “result”: “string” } ``` - **[result]**: The Surgical History. You must retain all relevant data for the Surgical history. If no data is provided, save `No data available`.""" generate_family = """## Task You must analyze the provided patient data from the user, find information about the **Family History.** and save it in `result` field. ## JSON Response Format ```json { “result”: “string” } ``` - **result**: The Family History. You must retain all relevant data for the Family history. If no data is provided, return `No data available`.""" generate_medications = """## Task You must analyze the provided patient data from the user and extract information about the **Medications** ## JSON Response Format ```json { “result”: “string” } ``` - **result**: The list of medications. You must retain all relevant data about medications. If no data is provided, return `"No data available"`.""" generate_assessment = """## Task You must analyze the provided patient data from the user and extract information about the **Assessment** (e.g., cancer stage, performance status, etc.). ## JSON Response Format ```json { “result”: “string” } ``` - **result**: A summary of clinical evaluations, diagnoses, and relevant medical assessments, including disease staging, functional status (e.g., ECOG/WHO performance status). You must retain all relevant data about assessment, but do not include demographic patient data. If no data is provided, return `"No data available"`.""" generate_plan = """## Task You must analyze the provided patient data from the user and extract information about the **Impression/Plan** (e.g., cancer stage, performance status, etc.). ## JSON Response Format ```json { “result”: “string” } ``` - **result**: A structured **Impression/Plan** based on the latest **evidence-based cancer guidelines** (e.g., ASCO, NCCN). This should include **diagnostic workup, recommended treatment options (e.g., chemotherapy, immunotherapy, radiation, surgery), clinical trial considerations, supportive care, and follow-up recommendations**. Do not include demographic patient data.""" class OCRPrompts: message = MessagesPrompt() report = ReportPrompts() consult = ConsultPrompts() @lru_cache def get_prompts() -> OCRPrompts: return OCRPrompts() ocr_prompts = get_prompts()