Skip to content

Commit 904adea

Browse files
refactoring prompt class
1 parent 9e168be commit 904adea

File tree

3 files changed

+89
-14
lines changed

3 files changed

+89
-14
lines changed

lib/PrivateData.dart

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ final GenerativeModel GeminiModel = GenerativeModel(
55
apiKey: GeminiApiKey,
66
);
77

8-
const analyzeReportPrompt =
9-
"Analyze the following medical report in detail. Summarize the key findings, focusing on any abnormal test results that may require further investigation or medical attention. Identify any patterns or trends in the data that could indicate potential health concerns. Additionally, highlight any specific instructions, recommendations, or advice to the patient for follow-up care or lifestyle changes. Be thorough and ensure nothing important is overlooked.";
10-
118
const String ocrPrompt = '''
129
You are analyzing a haematology report image. Extract all test names and their corresponding values, ensuring the values match the units used in the provided sample report. For scientific notation (e.g., \`14.00 x 10^9/uL\`), convert it to its full numeric form (e.g., \`14000000000\`).
1310
@@ -77,7 +74,7 @@ P-LCR: 19.4
7774
PCT: 0.26
7875
''';
7976

80-
const st="Haemoglobin";
77+
const st = "Haemoglobin";
8178

8279
const String generalPrompt = '''
8380
You are analyzing a medical diagnostic report image. Extract all test names and their corresponding values (consider only these test which gives numerical value). For scientific notation (e.g., \`14.00 x 10^9/uL\`), convert it to its full numeric form (e.g., \`14000000000\`).
@@ -94,7 +91,7 @@ $st: 11.8
9491
9592
''';
9693

97-
String matchChecker='''
94+
String matchChecker = '''
9895
Here are two comma-separated string:
9996
10097
Predefined Test Names: [insert your predefined names here]
@@ -114,4 +111,4 @@ CBC (Complete Blood Count) : CBC (Complete Blood Count)
114111
115112
Provide the mappings for all user-input test names in the specified format.
116113
117-
''';
114+
''';

lib/constant/constant_prompt.dart

Lines changed: 84 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
class Prompt{
2-
static String similarCheckPrompt(String exist, String notun) {
3-
String prompt = '''
1+
class Prompt {
2+
static String similarCheckPrompt(String exist, String notun) {
3+
String prompt = '''
44
Here are two comma-separated string:
55
66
Predefined Test Names: $exist
@@ -21,6 +21,84 @@ CBC (Complete Blood Count) : CBC (Complete Blood Count)
2121
Provide the mappings for all user-input test names in the specified format. dont give any additional text.
2222
2323
''';
24-
return prompt;
25-
}
26-
}
24+
return prompt;
25+
}
26+
27+
static String analyzeReportPrompt() {
28+
String prompt =
29+
"Analyze the following medical report in detail. Summarize the key findings, focusing on any abnormal test results that may require further investigation or medical attention. Identify any patterns or trends in the data that could indicate potential health concerns. Additionally, highlight any specific instructions, recommendations, or advice to the patient for follow-up care or lifestyle changes. Be thorough and ensure nothing important is overlooked.";
30+
return prompt;
31+
}
32+
33+
static String ocrPrompt() {
34+
String prompt = '''
35+
You are analyzing a haematology report image. Extract all test names and their corresponding values, ensuring the values match the units used in the provided sample report. For scientific notation (e.g., \`14.00 x 10^9/uL\`), convert it to its full numeric form (e.g., \`14000000000\`).
36+
37+
**Predefined Test Names and Examples**:
38+
- Haemoglobin
39+
- ESR
40+
- Total WBC Count
41+
- Total RBC Count (Map from: "RBC" or "Total RBC")
42+
- Platelet Count (Map from: "Platelet" or "Total Platelet Count")
43+
- Neutrophils
44+
- Lymphocytes
45+
- Monocytes
46+
- Eosinophils
47+
- Basophils
48+
- HCT/PCV
49+
- MCV
50+
- MCH
51+
- MCHC
52+
- RDW-CV
53+
- RDW-SD
54+
- MPV
55+
- PDW
56+
- P-LCR
57+
- PCT
58+
59+
**Guidelines**:
60+
1. Extract numeric values from the report and match them to the correct predefined test names.
61+
2. Convert all values to the predefined units. If the input uses different units (e.g., g/ml vs g/dl), calculate and provide the value in the required unit. Use standard conversion formulas when needed.
62+
3. Use the following units for each test:
63+
- Haemoglobin: g/dL
64+
- ESR: mm in 1st hr
65+
- WBC, RBC, Platelet Count: cells/uL
66+
- Neutrophils, Lymphocytes, Monocytes, Eosinophils, Basophils: %
67+
- HCT/PCV: %
68+
- MCV: fl
69+
- MCH: pg
70+
- MCHC: g/dL
71+
- RDW-CV: %
72+
- RDW-SD: fl
73+
- MPV, PDW: fl
74+
- P-LCR, PCT: %
75+
4. Convert values when necessary and exclude unit symbols in the output. For scientific notation (e.g., `4 x 10^12`), convert the value to its full numeric form (e.g., `4000000000000`).
76+
5. Ignore any extra information such as comments or reference ranges.
77+
6. If a value is missing for a test, output " ".
78+
7. Ensure the output matches the exact format and structure shown in the **Sample Output** section.
79+
80+
**Sample Output**:
81+
Haemoglobin: 11.8
82+
ESR: 20
83+
WBC: 14000000000
84+
Neutrophils: 70
85+
Lymphocytes: 22
86+
Monocytes: 6
87+
Eosinophils: 2
88+
Basophils: 0
89+
RBC: 4000000000000
90+
HCT/PCV: 33.8
91+
MCV: 84.5
92+
MCH: 29.5
93+
MCHC: 34.9
94+
RDW-CV: 13
95+
RDW-SD: 40.2
96+
Platelet: 285000000000
97+
MPV: 9.4
98+
PDW: 9.7
99+
P-LCR: 19.4
100+
PCT: 0.26
101+
''';
102+
return prompt;
103+
}
104+
}

lib/screens/report_add/ReportAnalysisScreen.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class _ReportAnalysisState extends State<ReportAnalysis> {
2828
String? email = FirebaseAuth.instance.currentUser?.email;
2929
uname = email!.substring(0, email.indexOf('@'));
3030
_chat = GeminiModel.startChat();
31-
_sendImagePrompt(analyzeReportPrompt);
31+
_sendImagePrompt(Prompt.analyzeReportPrompt());
3232
}
3333

3434
@override
@@ -105,7 +105,7 @@ class _ReportAnalysisState extends State<ReportAnalysis> {
105105
15,
106106
!_loading
107107
? () async {
108-
_sendImagePrompt(analyzeReportPrompt);
108+
_sendImagePrompt(Prompt.analyzeReportPrompt());
109109
}
110110
: null,
111111
)

0 commit comments

Comments
 (0)