o
    *2i                     @   s   d dl Z G dd dZdS )    Nc                   @   sV   e Zd Zdd ZdddZdd Zdd	 Zdd
dZdddZdddZ	dddZ
dS )Promptsc                 C   s   d S N )selfr   r   J/Users/harjaapdhillon/Desktop/newidea/medvista_backend/Services/prompts.py__init__   s   zPrompts.__init__Nc                 C   s   d}d}d}d}d}d}|r!|  |}d| d}d}d}d}d}d}|jdi d	|d
|d|d|d|d|d|d|d|	d|
d|d|d|d|d|d|d|d|d|}|S )zN
        Generate possible causes prompt with optional report context
         z"medicalReportsData": ,z"3.5": "CRITICAL: Analyze the actual test results from uploaded medical reports. Prioritize conditions that explain abnormal lab values and imaging findings.",z"PRIORITY RULE: Base your diagnosis PRIMARILY on actual test results from medical reports. If lab values are abnormal, the conditions MUST explain those specific abnormalities.",a  
                {
                    "name": "Medical Report Analysis",
                    "description": "Must demonstrate thorough analysis of uploaded medical reports. Each diagnosis should reference specific test results, abnormal findings, or imaging data when available. Conditions suggested must logically explain the documented lab abnormalities."
                },
            z. Each cause should reference specific test results when applicable (e.g., "Type 2 Diabetes - supported by HbA1c: 8.2%, Fasting Glucose: 145 mg/dL")a  
        {{
            "prompt": "Create a list As a doctor what can be the probable cause corresponding to the symptoms and purpose of visit",
            "parameters": {{
                "role": "Experienced Doctor",
                "department": "medical",
                "location": "India",
                "task": "Create a list of possible causes based on the patient purpose of visit or Consultation.",
                "experienceLevel": "30 Years",
                "personalityTraits": "Empathetic listener, Professionalism, expert in assessing and treating the Causes",
                "keyLessons": "Should be easily understandable and accessible to medical professional. Core success factors include accuracy, clarity, and will be measured by its ability to facilitate successful and error-free execution of medical procedures."
            }},
            "patientDetails": {{
                "name": "{patient_name}",
                "gender": "{gender}",
                "age": "{age}",
                "medicalDetails": {{
                    "allergies": "{allergies}",
                    "medication": "{medication}"
                }},
                "healthStatus": {{
                    "reasonForConsultation": "{reasonForConsultation}",
                    "height": "{height} cm",
                    "weight": "{weight} kg",
                    "glucoseLevel": "{glucoseLevel} mg/dL(milligrams per deciliter)",
                    "bp": "{bp} mmHg"
                }},
                "lifestyleFactors": {{
                    "tobaccoUse": "{tobaccoUse}",
                    "alcoholConsumption": "{alcoholConsumption}",
                    "dietAndExerciseHabits": "{dietAndExerciseHabits}"
                }}
            }},
            "patientSymptoms": "{patientSymptoms}",
            {report_data_section}
            "steps": {{
                "1": "You are a doctor with having 30 Years of experience in the medical field.",
                "2": "Start by reviewing the patient's symptoms and reason for consultation.",
                "3": "Take all the patient details including all medical issue, lifestyleFactors, healthStatus, before start the analyze",
                {report_step}
                "4": "Approach the assessment systematically, considering each factor's possible impact.",
                "5": "Before attempting to solve the solution, pause and analyze the perspective of the User. It's essential to understand their viewpoint.",
                "6": "Based on your comprehensive understanding and analysis, provide actionable insights."
            }},
            "rules": [
                "Always follow the steps in sequence.",
                "Each step should be approached methodically.",
                "Use all the patientDetails as a user to generate the accurate result",
                {report_rule}
                "Dedicate appropriate time for deep reflection before responding.",
                "For blood pressure (BP) analysis: If BP is above the normal range (e.g., >120/80 mmHg), consider potential causes such as hypertension, stress, or cardiovascular concerns. If BP is below the normal range (e.g., <90/60 mmHg), explore possibilities like hypotension, dehydration, or heart conditions.",
                "For glucose level analysis: If glucose levels are below the normal range (e.g., <3.9 mg/dL), possible causes include hypoglycemia, poor diet, or endocrine issues. If glucose levels are elevated (e.g., >7 mg/dL), consider hyperglycemia, diabetes, or metabolic disorders."
            ],
            "criteria": [
                {{
                    "name": "Use of Reference Material",
                    "description": "Evaluates how well insights from external reference materials are integrated into the task at hand. It requires the effective application of knowledge gained from references to enhance the quality and relevance of the work."
                }},
                {{
                    "name": "Use the Patient Details",
                    "description": "Use the Patient Details to give the result with the accuracy"
                }},
                {report_criteria}
                {{
                    "name": "Point of View from an Industry Expert",
                    "description": "A highly critical evaluation of the work from the perspective of a seasoned expert in the relevant field or industry. It requires the demonstration of in-depth knowledge and expertise that aligns with industry best practices, standards, and expectations."
                }}
            ],
            "response_structure": {{
                "content": "Provide just an array of causes such that the response can be directly rendered as a python dictionary by the code{report_response_note}",
                "format": {{
                    "possible_causes": [
                        "cause1",
                        "cause2",
                        "cause3",
                        "...",
                        "causeN"
                    ]
                }}
            }}
        }}
        patient_namegenderage	allergies
medicationreasonForConsultationheightweightglucoseLevelbp
tobaccoUsealcoholConsumptiondietAndExerciseHabitspatientSymptomsreport_data_sectionreport_stepreport_rulereport_criteriareport_response_noteNr   ))_build_report_section_for_possible_causesformat)r   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   report_contextZreport_sectionr   r   r   r   r   prompt_templatepromptr   r   r   possible_causes   sl   

S	
zPrompts.possible_causesc                 C   st  |sdS g }d|v rP|d rPg }|d   D ].\}}|dd}|dkr&dnd}|| d|d	 d
|d d|d d| 	 q|dt|  d|v re|d re|dt|d   d|v rz|d rz|dt|d   d|v r|d r|dt|d   d|v r|d|d  d d|v r|d|d  d |rdd| d S dS )zABuild formatted medical report section for possible causes promptz{}lab_resultsstatusunknownabnormalu   🔴 ABNORMALu   🟢 NORMAL: value unitz (Reference: Zreference_rangez) - z"labResults": abnormal_findingsz"abnormalFindings": imaging_findingsz"imagingFindings": Zprevious_diagnosesz"previousDiagnoses": Zclinical_summaryz"clinicalSummary": ""Zdoctor_notesz"doctorNotes": "{, })itemsgetappendjsondumpsjoin)r   r   sectionsZlab_results_formattedZ	test_nameZ	test_datar$   flagr   r   r   r      s6   z1Prompts._build_report_section_for_possible_causesc                 C   s   d| dS )zR
        Prompt for parsing uploaded medical reports into structured JSON
        a  
You are a medical data extraction expert. Analyze the following medical report(s) and extract ALL relevant medical data into a structured JSON format.

Focus on extracting:
1. **Lab Test Results** - All test names with values, units, and reference ranges
2. **Vital Signs** - Blood pressure, heart rate, temperature, SpO2, etc.
3. **Imaging Results** - X-Ray, MRI, CT, Ultrasound findings
4. **Previous Diagnoses** - Any mentioned conditions or diseases
5. **Current Medications** - All medications mentioned in reports
6. **Abnormal Findings** - Any values outside normal range or concerning findings
7. **Doctor's Notes** - Observations, recommendations, clinical impressions
8. **Report Metadata** - Date, lab name, doctor name

Medical Report(s):
aM  

Return ONLY valid JSON in this EXACT format (no markdown, no code blocks):
{
    "lab_results": {
        "hemoglobin": {"value": "13.5", "unit": "g/dL", "reference_range": "12-16", "status": "normal"},
        "glucose_fasting": {"value": "145", "unit": "mg/dL", "reference_range": "70-100", "status": "abnormal"},
        "hba1c": {"value": "8.2", "unit": "%", "reference_range": "4-6", "status": "abnormal"}
    },
    "vitals": {
        "blood_pressure": "140/90 mmHg",
        "heart_rate": "82 bpm",
        "temperature": "98.6 F",
        "spo2": "97%"
    },
    "imaging_findings": [
        "Chest X-ray: Clear lung fields",
        "No signs of pneumonia or pleural effusion"
    ],
    "previous_diagnoses": [
        "Type 2 Diabetes Mellitus",
        "Hypertension"
    ],
    "current_medications": [
        "Metformin 500mg twice daily",
        "Amlodipine 5mg once daily"
    ],
    "abnormal_findings": [
        "Elevated fasting glucose: 145 mg/dL (normal: 70-100)",
        "High HbA1c: 8.2% indicates poor glycemic control",
        "Blood pressure elevated: 140/90 mmHg"
    ],
    "doctor_notes": "Patient shows signs of uncontrolled diabetes. Recommend medication adjustment and dietary changes.",
    "report_metadata": {
        "report_date": "2024-11-10",
        "lab_name": "City Diagnostic Center",
        "doctor_name": "Dr. Smith"
    },
    "clinical_summary": "45-year-old patient with poorly controlled Type 2 Diabetes (HbA1c 8.2%) and Stage 1 Hypertension. Lab results show elevated fasting glucose and borderline anemia. Immediate medication review recommended."
}

IMPORTANT:
- If any section has no data, use empty object {} or array []
- Extract ALL values with their exact units
- Mark abnormal values clearly in the abnormal_findings array
- Be thorough and accurate
- Return ONLY the JSON object, no additional text
r   )r   Zreport_textr   r   r   parse_medical_reports   s   zPrompts.parse_medical_reportsc                 C   s  d}d}d}|rGg }g }d|v r|d rt |d  }d|v r(|d r(|d }|r/d|nd}|r8d|nd}d| d| d}d	}d
}d}|jdi d|d|d|d|d|d|d|d|d|	d|
d|d|d|d|d|d|d|d|}|S ) zJ
        Generate diagnostics prompt with optional report context
        r   r#   r,   r/   Nonez'"testsAlreadyCompleted": {"labTests": "z", "imaging": "z"},z}"3.5": "CRITICAL: Review tests already completed from uploaded reports. DO NOT recommend tests that have already been done.",a  "AVOID DUPLICATE TESTS: Do not recommend tests that appear in testsAlreadyCompleted. Instead recommend: (1) Follow-up tests if values are borderline/abnormal, (2) Additional confirmatory tests, (3) Tests to rule out differential diagnoses, (4) Tests NOT in the uploaded reports.",a  
        {{
            "prompt": "Create a list of Possible Diagnostic Tests based on the patient symptoms and patient details.",
            "parameters": {{
                "role": "Experienced Doctor",
                "department": "medical",
                "location": "India",
                "task": "Create a list of possible Diagnostic on the patient symptoms.",
                "experienceLevel": "30 Years",
                "personalityTraits": "Empathetic listener, Professionalism, expert in assessing and treating the Causes",
                "keyLessons": "Should be easily understandable and accessible to medical professional. Core success factors include accuracy, clarity, and will be measured by its ability to facilitate successful and error-free execution of medical procedures."
            }},
            "patientDetails": {{
                "name": "{patient_name}",
                "gender": "{gender}",
                "age": "{age}",
                "medicalDetails": {{
                    "allergies": "{allergies}",
                    "medication": "{medication}"
                }},
                "healthStatus": {{
                    "reasonForConsultation": "{reasonForConsultation}",
                    "height": "{height} cm",
                    "weight": "{weight} kg",
                    "glucoseLevel": "{glucoseLevel} mg/dL(milligrams per deciliter)",
                    "bp": "{bp} mmHg"
                }},
                "lifestyleFactors": {{
                    "tobaccoUse": "{tobaccoUse}",
                    "alcoholConsumption": "{alcoholConsumption}",
                    "dietAndExerciseHabits": "{dietAndExerciseHabits}"
                }}
            }},
            "patientSymptoms": "{patientSymptoms}",
            "possible_causes_by_doctor": "{possibleCausesByDoctor}",
            {report_data_section}
            "steps": {{
                "1": "You are a doctor with having 30 Years of experience in the medical field.",
                "2": "Begin by reviewing the patient's symptoms, details, and reason for consultation.",
                "3": "Take all the patient details including all medical issue, lifestyleFactors, healthStatus, patientSymptoms, before start the analyze",
                {report_step}
                "4": "Carefully think through the diagnostic options that best align with the patient's profile and needs.",
                "5": "Before attempting to solve the solution, pause and analyze the perspective of the User. It's essential to understand their viewpoint.",
                "6": "Based on your comprehensive understanding and analysis, provide actionable insights."
            }},
            "rules": [
                "Always follow the steps in sequence.",
                "Each step should be approached methodically.",
                "Use all the patientDetails as a user to generate the accurate result",
                {report_rule}
                "Dedicate appropriate time for deep reflection before responding."
            ],
            "key_references": {{
                "key_reference_1_title": "The Checklist Manifesto: How to Get Things Right",
                "key_reference_1_author": "Atul Gawande",
                "key_reference_1_year": "2009",
                "key_reference_1_keyinsights": [
                    "The book emphasizes the importance of checklists in complex tasks, such as medical procedures, to reduce errors and improve outcomes.",
                    "Checklists help ensure that all necessary steps are followed, reducing the risk of missed or skipped actions.",
                    "The author provides real-life examples from various industries, including healthcare, to demonstrate the effectiveness of checklists in improving performance and reducing complications."
                ],
                "key_reference_2_title": "Effective Documentation for Physical Therapy Professionals",
                "key_reference_2_author": "Eric Shamus",
                "key_reference_2_year": "2011",
                "key_reference_2_keyinsights": [
                    "This book specifically focuses on documentation in the field of physical therapy but offers valuable insights applicable to medical procedure documentation as well.",
                    "It emphasizes the importance of clear and concise language in documentation to ensure understanding and reduce the risk of misinterpretation.",
                    "The book provides practical frameworks and guidelines for organizing and structuring documentation, ensuring comprehensive coverage of all necessary information.",
                    "It highlights the significance of accurate and up-to-date documentation for effective communication among healthcare professionals and for legal and reimbursement purposes."
                ]
            }},
            "criteria": [
                {{
                    "name": "Use of Reference Material",
                    "description": "Evaluates how well insights from external reference materials are integrated into the task at hand. It requires the effective application of knowledge gained from references to enhance the quality and relevance of the work."
                }},
                {{
                    "name": "Use the Patient Details",
                    "description": "Use the Patient Details to give the result with the accuracy"
                }},
                {{
                    "name": "Point of View from an Industry Expert",
                    "description": "A highly critical evaluation of the work from the perspective of a seasoned expert in the relevant field or industry. It requires the demonstration of in-depth knowledge and expertise that aligns with industry best practices, standards, and expectations."
                }}
            ],
            "response_structure": {{
                "content": "Provide just an array of diagnostics_required such that the response can be directly rendered as a python dictionary by the code",
                "format": {{
                    "diagnostics_required": [
                        "diagnostic1",
                        "diagnostic2",
                        "diagnostic3",
                        "...",
                        "diagnosticN"
                    ]
                }}
            }}
        }}
        r
   r   r   r   r   r   r   r   r   r   r   r   r   r   possibleCausesByDoctorr   r   r   Nr   )listkeysr6   r   )r   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r;   r   r   r   r   Zexisting_testsZexisting_imagingZ
tests_doneZimaging_doner    r!   r   r   r   get_diagnostics   sl   
d	
zPrompts.get_diagnosticsr   c                 C   s  d}d}d}|rCg }g }d|v r|d r|d }d|v r$|d r$|d }|r+d |nd}|r4d |nd}d| d| d}d	}d
}d}|jd i d|d|d|d|d|d|d|d|d|	d|
d|d|d|d|d|d|d|d|d|}|S )!zJ
        Generate medications prompt with optional report context
        r   Zcurrent_medicationsr+   r/   r:   z""currentMedicationsFromReports": "z*", "abnormalFindingsRequiringTreatment": "",z"3.5": "CRITICAL: Review current medications from reports. Check for drug interactions and adjust dosing based on kidney/liver function if available in reports.",a  "MEDICATION SAFETY: (1) Check for drug interactions with current medications listed in reports, (2) Adjust dosing based on kidney/liver function if available, (3) Prioritize treating abnormal findings from reports, (4) Avoid medications patient is allergic to.",a8  
        {{
            "prompt": "Create a list of possible medications based on the patient symptoms and patient details.",
            "parameters": {{
                "role": "Doctor",
                "department": "medical",
                "location": "India",
                "task": "Create a list of possible medications based on the patient symptoms.",
                "experienceLevel": "30 Years",
                "personalityTraits": "Empathetic listener, Professionalism, expert in assessing and treating the Causes",
                "keyLessons": "Should be easily understandable and accessible to medical professionals. Core success factors include accuracy, clarity, and will be measured by its ability to facilitate successful and error-free execution of medical procedures."
            }},
            "patientDetails": {{
                "name": "{patient_name}",
                "gender": "{gender}",
                "age": "{age}",
                "medicalDetails": {{
                    "allergies": "{allergies}",
                    "medication": "{medication}"
                }},
                "healthStatus": {{
                    "reasonForConsultation": "{reasonForConsultation}",
                    "height": "{height} cm",
                    "weight": "{weight} kg",
                    "glucoseLevel": "{glucoseLevel} mg/dL(milligrams per deciliter)",
                    "bp": "{bp} mmHg"
                }},
                "lifestyleFactors": {{
                    "tobaccoUse": "{tobaccoUse}",
                    "alcoholConsumption": "{alcoholConsumption}",
                    "dietAndExerciseHabits": "{dietAndExerciseHabits}"
                }}
            }},
            "patientSymptoms": "{patientSymptoms}",
            "possibleCausesByDoctor": "{possibleCausesByDoctor}",
            "diagnosticsByDoctor": "{diagnosticsByDoctor}",
            {report_data_section}
            "steps": {{
                "1": "You are a doctor with 30 years of experience in the medical field.",
                "2": "Analyze the patient issue based on the symptoms provided.",
                "3": "Use all patient details, including medical issues, lifestyle factors, health status, and symptoms to generate medication recommendations.",
                {report_step}
                "4": "Provide a comprehensive list of medications.",
                "5": "Ensure the response is formatted as a list of dictionaries with each dictionary containing the medication details."
            }},
            "rules": [
                "Follow the steps in sequence.",
                "Use all patient details to generate accurate results.",
                "Provide the response in the specified format.",
                {report_rule}
                "If BP is above the normal range (e.g., >120/80 mmHg), consider antihypertensive medications or lifestyle modifications.",
                "If BP is below the normal range (e.g., <90/60 mmHg), consider fluids, dietary recommendations, or medications to stabilize blood pressure if symptomatic.",
                "For elevated glucose levels (e.g., >7 mg/dL), consider oral hypoglycemics or insulin based on severity and existing conditions.",
                "For low glucose levels (e.g., <3.9 mg/dL), recommend dietary adjustments or medications as needed to stabilize glucose.",
                "Don't provide me the anything like some extra text ext. beyond json format",
                "Please give me the proper json formate as we have defined in the format"
            ],
            "response_structure": {{
                "content": "Provide just an array of 5 medications such that the response can be directly rendered as a python dictionary by the code",         
                "format": {{ 
                    "medications": [              
                        {{
                            "MedicineName": "",
                            "Duration": "",
                            "Salt": "",
                            "Dosage": "",
                            "Time": "",
                            "Interval": "",
                            "Reason": ""
                        }},
                        "...",
                        {{
                            "MedicineName": "",
                            "Duration": "",
                            "Salt": "",
                            "Dosage": "",
                            "Time": "",
                            "Interval": "",
                            "Reason": ""
                        }}
                    ]
                }}
            }}
        }}
        r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r;   diagnosticsByDoctorr   r   r   Nr   )r6   r   )r   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r;   r@   r   r   r   r   Zcurrent_medsr+   Z	meds_listZabnormal_listr    r!   r   r   r   get_medications  sp   
V	
zPrompts.get_medicationsvegc           "   
   C   s  d}d}d}|rdg }g }d|v r9|d r9|d   D ]\}}|ddkr8|| d|d d|d  qd	|v rE|d	 rE|d	 }|rLd
|nd}|rUd
|nd}d| d| d}d}d}d}d}|rnd}d}d} | jd-i d|d|d|d|d|d|d|d|d|	d|
d|d|d |d!|d"|d#|d$|d%|d&|d'|d(|d)|d*|d+|}!|!S ).zT
        Generate diet plan prompt with optional report context and pincode
        r   r#   r$   r&   r'   r(   r)   r*   r+   r/   r:   z"labResultsForDiet": "z", "abnormalFindingsForDiet": "r?   z"3.5": "CRITICAL: Tailor diet based on actual lab values from reports. For high glucose/HbA1c: low glycemic index. For high cholesterol: low saturated fat. For high BP: low sodium.",a&  "DIET CUSTOMIZATION RULES: (1) If glucose/HbA1c high: Low glycemic index, controlled carbs. (2) If cholesterol high: Low saturated fat, high fiber. (3) If BP high: Low sodium (<2000mg/day), DASH diet. (4) If anemia: Iron-rich foods. (5) If kidney issues: Limit protein, potassium, phosphorus.",z"3.6": "TAILOR TO REGION: Based on pincode {pincode}, include locally available foods, seasonal produce, and consider regional dietary preferences and food availability.",z"REGIONAL ADAPTATION: Include foods commonly available in the region corresponding to pincode {pincode}. Consider local cuisine, seasonal availability, and regional nutritional patterns.",a#  
        {{
            "prompt": "Create a personalized diet plan based on the patient symptoms and patient details.",
            "parameters": {{
                "role": "Nutritionist",
                "department": "Diet and Nutrition",
                "location": "India",
                "task": "Create a personalized diet plan based on the patient details.",
                "experienceLevel": "15 Years",
                "personalityTraits": "Empathetic listener, expert in assessing and recommending personalized diets",
                "keyLessons": "Diet plans should be tailored to individual needs and focus on holistic well-being. Success factors include balance, nutritional adequacy, and patient satisfaction."
            }},
            "patientDetails": {{
                "name": "{patient_name}",
                "gender": "{gender}",
                "age": "{age}",
                "medicalDetails": {{
                    "allergies": "{allergies}",
                    "dietRestrictions": "{dietRestrictions}"
                }},
                "healthStatus": {{
                    "reasonForConsultation": "{reasonForConsultation}",
                    "height": "{height} cm",
                    "weight": "{weight} kg",
                    "glucoseLevel": "{glucoseLevel} mg/dL(milligrams per deciliter)",
                    "bp": "{bp} mmHg"
                }},
                "lifestyleFactors": {{
                    "tobaccoUse": "{tobaccoUse}",
                    "alcoholConsumption": "{alcoholConsumption}",
                    "dietAndExerciseHabits": "{dietAndExerciseHabits}"
                }},
                "region": "{pincode}"
            }},
            "patientSymptoms": "{patientSymptoms}",
            "possibleCausesByDoctor": "{possibleCausesByDoctor}",
            "diagnosticsByDoctor": "{diagnosticsByDoctor}",
            "medicationsByDoctor": "{medicationsByDoctor}",
            "food_type": "{food_type}",
            {report_data_section}
            "steps": {{
                "1": "You are a nutritionist with 15 years of experience in diet planning.",
                "2": "Analyze the patient details and symptoms to create a personalized diet plan.",
                "3": "Use all patient details, including medical issues, lifestyle factors, health status, symptoms, and food type to generate the diet plan.",
                {report_step}
                {pincode_section}
                "4": "Provide a comprehensive diet plan.",
                "5": "Ensure the response is formatted as a list of dictionaries with each dictionary containing the diet details."
            }},
            "rules": [
                "Follow the steps in sequence.",
                "Use all patient details to generate accurate results.",
                "Provide the response in the specified format.",
                {report_rule}
                {pincode_rule}
                "Don't provide me the anything like some extra text ext. beyond json format",
                "Please give me the proper json formate as we have defined in the format",
                "For blood pressure (BP): If BP is low (e.g., <90/60 mmHg), recommend foods high in sodium, fluid intake, and nutrient-rich foods. If BP is high (e.g., >120/80 mmHg), suggest foods low in sodium, rich in potassium, and high in fiber.",
                "For glucose levels: If glucose levels are low (e.g., <70 mg/dL), recommend fast-acting carbohydrates like fruit juice or glucose tablets. If glucose levels are high (e.g., >140 mg/dL), suggest foods high in fiber and low in sugar.",
                "Consider the food type preference (vegetarian, non-vegetarian, or mixed) when creating the diet plan."
            ],
            "response_structure": {{
                "content": "Provide just an array of 5 diet items such that the response can be directly rendered as a Python dictionary by the code., I need proper json data from this response",           
                "format": {{ 
                    "diet": [              
                        {{
                            "weight_g": "",
                            "water_intake": "",
                            "time": "",
                            "meal": "",
                            "food_item": "",
                            "key_vitamins": "",
                            "benefits": ""
                        }},
                        "...",
                        {{
                            "weight_g": "",
                            "water_intake": "",
                            "time": "",
                            "meal": "",
                            "food_item": "",
                            "key_vitamins": "",
                            "benefits": ""
                        }}
                    ]
                }}
            }}
        }}
        r
   r   r   r   dietRestrictionsr   r   r   r   r   r   r   r   r   r;   r@   medicationsByDoctor	food_typepincoder   r   pincode_sectionr   pincode_ruleNr   r1   r2   r3   r6   r   "r   r
   r   r   r   rC   r   r   r   r   r   r   r   r   r   r;   r@   rD   rE   rF   r   r   r   r   Zlab_summaryZabnormal_summarytestdataZlab_dataZabnormal_datarG   rH   r    r!   r   r   r   get_diet_plan  s   &
Z	
zPrompts.get_diet_plannon-vegc           "   
   C   s  d}d}d}|rdg }g }d|v r9|d r9|d   D ]\}}|ddkr8|| d|d d|d  qd	|v rE|d	 rE|d	 }|rLd
|nd}|rUd
|nd}d| d| d}d}d}d}d}|rvd| d}d| d}d} | jd/i d|d|d|d|d|d|d|d|d|	d|
d |d!|d"|d#|d$|d%|d&|d'|d(|d)|d*|d+|d,|d-|}!|!S )0z[
        Generate weekly diet plan prompt with optional report context and pincode
        r   r#   r$   r&   r'   r(   r)   r*   r+   r/   r:   z"labResultsForWeeklyDiet": "z%", "abnormalFindingsForWeeklyDiet": "r?   z"3.5": "CRITICAL: Create 7-day meal plan based on actual lab values. Ensure consistency with medical report findings throughout the week.",a  "WEEKLY DIET RULES BASED ON REPORTS: (1) Maintain dietary restrictions based on lab values throughout all 7 days. (2) Gradually increase dietary fiber if glucose is high. (3) Ensure sodium restriction is consistent if BP is high. (4) Include iron-rich foods daily if anemia is present.",z+"3.6": "TAILOR TO REGION: Based on pincode z, include locally available foods, seasonal produce specific to that region, and consider regional dietary preferences, cooking methods, and food availability for all 7 days.",z""REGIONAL ADAPTATION: For pincode z region, include foods commonly available in that area. Consider local cuisine patterns, seasonal availability of produce, regional nutritional habits, and traditional cooking methods for all meals throughout the week.",a  
        {{
            "prompt": "Create a personalized diet plan based on the patient symptoms and patient details.",
            "parameters": {{
                "role": "Nutritionist",
                "department": "Diet and Nutrition",
                "location": "India",
                "task": "Create a personalized diet plan based on the patient details.",
                "experienceLevel": "15 Years",
                "personalityTraits": "Empathetic listener, expert in assessing and recommending personalized diets",
                "keyLessons": "Diet plans should be tailored to individual needs and focus on holistic well-being. Success factors include balance, nutritional adequacy, and patient satisfaction."
            }},
            "patientDetails": {{
                "name": "{patient_name}",
                "gender": "{gender}",
                "age": "{age}",
                "medicalDetails": {{
                    "allergies": "{allergies}",
                    "dietRestrictions": "{dietRestrictions}"
                }},
                "healthStatus": {{
                    "reasonForConsultation": "{reasonForConsultation}",
                    "height": "{height} cm",
                    "weight": "{weight} kg",
                    "glucoseLevel": "{glucoseLevel} mg/dL(milligrams per deciliter)",
                    "bp": "{bp} mmHg"
                }},
                "lifestyleFactors": {{
                    "tobaccoUse": "{tobaccoUse}",
                    "alcoholConsumption": "{alcoholConsumption}",
                    "dietAndExerciseHabits": "{dietAndExerciseHabits}"
                }},
                "region": "{pincode}"
            }},
            "patientSymptoms": "{patientSymptoms}",
            "possibleCausesByDoctor": "{possibleCausesByDoctor}",
            "diagnosticsByDoctor": "{diagnosticsByDoctor}",
            "medicationsByDoctor": "{medicationsByDoctor}",
            "food_type": "{food_type}",
            {report_data_section}
            "steps": {{
                "1": "You are a nutritionist with 15 years of experience in diet planning.",
                "2": "Analyze the patient details and symptoms to create a personalized diet plan.",
                "3": "Use all patient details, including medical issues, lifestyle factors, health status, symptoms, and food type to generate the diet plan.",
                {report_step}
                {pincode_section}
                "4": "Provide a comprehensive diet plan formatted in a table showing meals for each day of the week.",
                "5": "Ensure the response contains an array of dictionaries, each representing a daily meal breakdown from Monday to Sunday."
            }},
            "rules": [
                "Follow the steps in sequence.",
                "Use all patient details to generate accurate results.",
                "Provide the response in the specified format.",
                {report_rule}
                {pincode_rule}
                "Don't provide anything outside the defined json format.",
                "Ensure the output is properly formatted as an array of dictionaries.",
                "For blood pressure (BP): If BP is low (e.g., <90/60 mmHg), recommend foods high in sodium, fluid intake, and nutrient-rich foods. If BP is high (e.g., >120/80 mmHg), suggest foods low in sodium, rich in potassium, and high in fiber.",
                "For glucose levels: If glucose levels are low (e.g., <70 mg/dL), recommend fast-acting carbohydrates like fruit juice or glucose tablets. If glucose levels are high (e.g., >140 mg/dL), suggest foods high in fiber and low in sugar.",
                "Consider the food type preference (vegetarian, non-vegetarian) when creating the diet plan. if food type is non-veg then give only non-veg food and if food type is veg give only veg food.",
                "Add do and dont's in the diet plan."
            ],
            "response_structure": {{
                "content": "Provide an array of dictionaries with each representing a day and containing meal details for Breakfast, Mid-Morning Snack, Lunch, Evening Snack, and Dinner.",
                "format": {{ 
                    "weekly_diet": [
                        {{
                            "day": "DAY 1",
                            "Breakfast": {{
                                "meal": "",
                                "vitamins": "",
                                "weight_g": ""
                            }},
                            "Mid-Morning Snack": {{
                                "meal": "",
                                "vitamins": "",
                                "weight_g": ""
                            }},
                            "Lunch": {{
                                "meal": "",
                                "vitamins": "",
                                "weight_g": ""
                            }},
                            "Evening Snack": {{
                                "meal": "",
                                "vitamins": "",
                                "weight_g": ""
                            }},
                            "Dinner": {{
                                "meal": "",
                                "vitamins": "",
                                "weight_g": ""
                            }}
                        }},
                        "...",
                        {{
                            "day": "DAY 7",
                            "Breakfast": {{
                                "meal": "",
                                "vitamins": "",
                                "weight_g": ""
                            }},
                            "Mid-Morning Snack": {{
                                "meal": "",
                                "vitamins": "",
                                "weight_g": ""
                            }},
                            "Lunch": {{
                                "meal": "",
                                "vitamins": "",
                                "weight_g": ""
                            }},
                            "Evening Snack": {{
                                "meal": "",
                                "vitamins": "",
                                "weight_g": ""
                            }},
                            "Dinner": {{
                                "meal": "",
                                "vitamins": "",
                                "weight_g": ""
                            }}
                        }},
                        {{
                            "do": ""
                        }},
                        {{
                            "donts": ""
                        }}
                    ]
                }}
            }}
        }}
        r
   r   r   r   rC   r   r   r   r   r   r   r   r   r   r;   r@   rD   rE   rF   r   r   rG   r   rH   Nr   rI   rJ   r   r   r   get_weekly_diet_plan  s   & 
	
zPrompts.get_weekly_diet_planr   )r   N)r   r   rB   r   N)r   r   rN   r   N)__name__
__module____qualname__r   r"   r   r9   r>   rA   rM   rO   r   r   r   r   r      s    
 )
C 
 

 r   )r4   r   r   r   r   r   <module>   s    