File size: 7,113 Bytes
3f47633
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7ae78bd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3f47633
7ae78bd
 
 
 
 
 
 
 
 
 
 
 
 
201a81c
 
7ae78bd
 
 
 
 
3f47633
 
7ae78bd
3f47633
 
 
 
 
 
 
 
7ae78bd
3f47633
e8a8ed7
3f47633
 
 
 
 
 
 
 
 
 
7ae78bd
 
e8a8ed7
3f47633
 
e8a8ed7
3f47633
 
 
 
 
 
 
7ae78bd
3f47633
e8a8ed7
3f47633
 
e8a8ed7
3f47633
 
 
 
 
 
 
7ae78bd
 
3f47633
 
7ae78bd
e8a8ed7
3f47633
 
 
 
 
 
 
 
 
e8a8ed7
3f47633
 
 
 
 
 
 
 
 
 
 
 
e8a8ed7
3f47633
 
 
 
 
 
 
 
 
 
 
 
e8a8ed7
3f47633
 
e8a8ed7
3f47633
 
 
 
 
 
 
 
 
e8a8ed7
3f47633
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
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()