Source: https://github.com/aipoch/medical-research-skills
Lab Result Interpretation Skill
A medical assistant tool that transforms complex biochemical laboratory test results into clear, patient-friendly explanations.
Quick Check
Use this command to verify that the packaged script entry point can be parsed before deeper execution.
python -m py_compile scripts/main.py
Audit-Ready Commands
Use these concrete commands for validation. They are intentionally self-contained and avoid placeholder paths.
python -m py_compile scripts/main.py
python scripts/main.py --help
When to Use
- Interpreting biochemical laboratory test results for patients
- Generating patient-friendly explanations of abnormal lab values
- Flagging critical values requiring immediate medical attention
- Creating structured lab result summary reports
Workflow
- Parse lab report — Input: lab result text or file (--file/--input) → extract test names, values, units, reference ranges using regex patterns → Output: structured test data array
- Compare to reference ranges — Match each test against
references/lab_reference_ranges.json → determine status (normal/high/low) → Output: status classification per test
- Assess severity — Classify: mild (slightly outside range), moderate (clinically significant deviation), critical (requires immediate attention) → Output: severity rating per abnormal value
- Generate explanations — For each abnormal value: explain what the test measures, what the deviation means, contextual health information → ⛔ Checkpoint: Flag critical values to user with "Seek immediate medical attention" warning before continuing → Output: patient-friendly explanation per test
- Format output — Combine all results into structured JSON with test_name, value, status, explanation, severity, recommendation → include medical disclaimer → Output: final interpretation report
Features
- Parses various lab test formats (numeric values, units, reference ranges)
- Compares values against standard reference ranges
- Generates patient-friendly explanations in Chinese
- Flags abnormal values with severity indicators
- Provides contextual health recommendations
Supported Test Types
| Category |
Tests |
| Blood Routine |
WBC, RBC, Hemoglobin, Platelets, Hematocrit |
| Lipid Panel |
Total Cholesterol, LDL, HDL, Triglycerides |
| Liver Function |
ALT, AST, ALP, GGT, Bilirubin, Total Protein, Albumin |
| Kidney Function |
Creatinine, BUN, eGFR, Uric Acid |
| Blood Sugar |
Fasting Glucose, HbA1c |
| Thyroid |
TSH, T3, T4, FT3, FT4 |
| Electrolytes |
Sodium, Potassium, Chloride, Calcium, Magnesium |
| Inflammation |
CRP, ESR |
Usage
As Module
from scripts.main import LabResultInterpreter
interpreter = LabResultInterpreter()
result = interpreter.interpret("Total Cholesterol: 5.8 mmol/L (Reference: 3.1-5.7)")
print(result.explanation)
CLI
python scripts/main.py --file lab_report.txt
python scripts/main.py --interactive
Parameters
| Name |
Type |
Default |
Required |
Description |
| file |
string |
"" |
No |
Path to lab report file to process |
| interactive |
boolean |
false |
No |
Enable interactive mode for manual input |
| input |
string |
"" |
No |
Direct lab test input string for interpretation |
Input Format
Accepts flexible formats:
Test Name: Value Unit (Reference: Min-Max)
Test Name Value Unit Ref: Min-Max
Test Name: Value (Min-Max)
Output Format
{
"test_name": "Total Cholesterol",
"value": 5.8,
"unit": "mmol/L",
"reference_min": 3.1,
"reference_max": 5.7,
"status": "high",
"explanation": "Your total cholesterol is slightly above the normal range...",
"severity": "mild",
"recommendation": "Consider reducing saturated fat intake..."
}
Technical Details
Difficulty: Medium
Key Components:
- Lab value parsing with regex patterns
- Reference range comparison logic
- Medical knowledge base (references/lab_reference_ranges.json)
- Patient-friendly explanation templates
Safety:
- Includes medical disclaimer in all outputs
- Flags values requiring immediate medical attention
- Does not diagnose - only explains test meanings
References
references/lab_reference_ranges.json - Standard reference ranges
references/explanation_templates.json - Patient-friendly templates
references/test_metadata.json - Test descriptions and clinical notes
Medical Disclaimer
This tool provides educational information only and is not a substitute for professional medical advice, diagnosis, or treatment. Always consult with a qualified healthcare provider for interpretation of lab results.
Risk Assessment
| Risk Indicator |
Assessment |
Level |
| Code Execution |
Python/R scripts executed locally |
Medium |
| Network Access |
No external API calls |
Low |
| File System Access |
Read input files, write output files |
Medium |
| Instruction Tampering |
Standard prompt guidelines |
Low |
| Data Exposure |
Output files saved to workspace |
Low |
Security Checklist
Prerequisites
# Python dependencies
pip install -r requirements.txt
Evaluation Criteria
Success Metrics
Test Cases
- Basic Functionality: Standard input → Expected output
- Edge Case: Invalid input → Graceful error handling
- Performance: Large dataset → Acceptable processing time
Lifecycle Status
- Current Stage: Draft
- Next Review Date: 2026-03-06
- Known Issues: None
- Planned Improvements:
- Performance optimization
- Additional feature support
Output Requirements
Every final response should make these items explicit when they are relevant:
- Objective or requested deliverable
- Inputs used and assumptions introduced
- Workflow or decision path
- Core result, recommendation, or artifact
- Constraints, risks, caveats, or validation needs
- Unresolved items and next-step checks
Error Handling
- If required inputs are missing, state exactly which fields are missing and request only the minimum additional information.
- If the task goes outside the documented scope, stop instead of guessing or silently widening the assignment.
- If
scripts/main.py fails, report the failure point, summarize what still can be completed safely, and provide a manual fallback.
- Do not fabricate files, citations, data, search results, or execution outcomes.
Input Validation
This skill accepts requests that match the documented purpose of lab-result-interpretation and include enough context to complete the workflow safely.
Do not continue the workflow when the request is out of scope, missing a critical input, or would require unsupported assumptions. Instead respond:
lab-result-interpretation only handles its documented workflow. Please provide the missing required inputs or switch to a more suitable skill.
Response Template
Use the following fixed structure for non-trivial requests:
- Objective
- Inputs Received
- Assumptions
- Workflow
- Deliverable
- Risks and Limits
- Next Checks
If the request is simple, you may compress the structure, but still keep assumptions and limits explicit when they affect correctness.
1---2name: lab-result-interpretation3description: Transforms biochemical lab test results into clear, patient-friendly explanations. Covers blood routine, lipid panel, liver/kidney function, thyroid, electrolytes, and inflammation markers. Flags critical values, classifies severity, and generates structured interpretation rep...4license: MIT5---6> **Source**: [https://github.com/aipoch/medical-research-skills](https://github.com/aipoch/medical-research-skills)
7
8# Lab Result Interpretation Skill
9
10A medical assistant tool that transforms complex biochemical laboratory test results into clear, patient-friendly explanations.
11
12## Quick Check
13
14Use this command to verify that the packaged script entry point can be parsed before deeper execution.
15
16```bash
17python -m py_compile scripts/main.py
18```
19
20## Audit-Ready Commands
21
22Use these concrete commands for validation. They are intentionally self-contained and avoid placeholder paths.
23
24```bash
25python -m py_compile scripts/main.py
26python scripts/main.py --help
27```
28
29## When to Use
30
31- Interpreting biochemical laboratory test results for patients
32- Generating patient-friendly explanations of abnormal lab values
33- Flagging critical values requiring immediate medical attention
34- Creating structured lab result summary reports
35
36## Workflow
37
381. **Parse lab report** — Input: lab result text or file (--file/--input) → extract test names, values, units, reference ranges using regex patterns → Output: structured test data array
392. **Compare to reference ranges** — Match each test against `references/lab_reference_ranges.json` → determine status (normal/high/low) → Output: status classification per test
403. **Assess severity** — Classify: mild (slightly outside range), moderate (clinically significant deviation), critical (requires immediate attention) → Output: severity rating per abnormal value
414. **Generate explanations** — For each abnormal value: explain what the test measures, what the deviation means, contextual health information → ⛔ Checkpoint: Flag critical values to user with "Seek immediate medical attention" warning before continuing → Output: patient-friendly explanation per test
425. **Format output** — Combine all results into structured JSON with test_name, value, status, explanation, severity, recommendation → include medical disclaimer → Output: final interpretation report
43
44## Features
45
46- Parses various lab test formats (numeric values, units, reference ranges)
47- Compares values against standard reference ranges
48- Generates patient-friendly explanations in Chinese
49- Flags abnormal values with severity indicators
50- Provides contextual health recommendations
51
52## Supported Test Types
53
54| Category | Tests |
55|----------|-------|
56| **Blood Routine** | WBC, RBC, Hemoglobin, Platelets, Hematocrit |
57| **Lipid Panel** | Total Cholesterol, LDL, HDL, Triglycerides |
58| **Liver Function** | ALT, AST, ALP, GGT, Bilirubin, Total Protein, Albumin |
59| **Kidney Function** | Creatinine, BUN, eGFR, Uric Acid |
60| **Blood Sugar** | Fasting Glucose, HbA1c |
61| **Thyroid** | TSH, T3, T4, FT3, FT4 |
62| **Electrolytes** | Sodium, Potassium, Chloride, Calcium, Magnesium |
63| **Inflammation** | CRP, ESR |
64
65## Usage
66
67### As Module
68
69```python
70from scripts.main import LabResultInterpreter
71
72interpreter = LabResultInterpreter()
73result = interpreter.interpret("Total Cholesterol: 5.8 mmol/L (Reference: 3.1-5.7)")
74print(result.explanation)
75```
76
77### CLI
78
79```text
80python scripts/main.py --file lab_report.txt
81python scripts/main.py --interactive
82```
83
84## Parameters
85
86| Name | Type | Default | Required | Description |
87|------|------|---------|----------|-------------|
88| file | string | "" | No | Path to lab report file to process |
89| interactive | boolean | false | No | Enable interactive mode for manual input |
90| input | string | "" | No | Direct lab test input string for interpretation |
91
92## Input Format
93
94Accepts flexible formats:
95```
96Test Name: Value Unit (Reference: Min-Max)
97Test Name Value Unit Ref: Min-Max
98Test Name: Value (Min-Max)
99```
100
101## Output Format
102
103```json
104{
105 "test_name": "Total Cholesterol",
106 "value": 5.8,
107 "unit": "mmol/L",
108 "reference_min": 3.1,
109 "reference_max": 5.7,
110 "status": "high",
111 "explanation": "Your total cholesterol is slightly above the normal range...",
112 "severity": "mild",
113 "recommendation": "Consider reducing saturated fat intake..."
114}
115```
116
117## Technical Details
118
119**Difficulty:** Medium
120
121**Key Components:**
122- Lab value parsing with regex patterns
123- Reference range comparison logic
124- Medical knowledge base (references/lab_reference_ranges.json)
125- Patient-friendly explanation templates
126
127**Safety:**
128- Includes medical disclaimer in all outputs
129- Flags values requiring immediate medical attention
130- Does not diagnose - only explains test meanings
131
132## References
133
134- `references/lab_reference_ranges.json` - Standard reference ranges
135- `references/explanation_templates.json` - Patient-friendly templates
136- `references/test_metadata.json` - Test descriptions and clinical notes
137
138## Medical Disclaimer
139
140This tool provides educational information only and is not a substitute for professional medical advice, diagnosis, or treatment. Always consult with a qualified healthcare provider for interpretation of lab results.
141
142## Risk Assessment
143
144| Risk Indicator | Assessment | Level |
145|----------------|------------|-------|
146| Code Execution | Python/R scripts executed locally | Medium |
147| Network Access | No external API calls | Low |
148| File System Access | Read input files, write output files | Medium |
149| Instruction Tampering | Standard prompt guidelines | Low |
150| Data Exposure | Output files saved to workspace | Low |
151
152## Security Checklist
153
154- [ ] No hardcoded credentials or API keys
155- [ ] No unauthorized file system access (../)
156- [ ] Output does not expose sensitive information
157- [ ] Prompt injection protections in place
158- [ ] Input file paths validated (no ../ traversal)
159- [ ] Output directory restricted to workspace
160- [ ] Script execution in sandboxed environment
161- [ ] Error messages sanitized (no stack traces exposed)
162- [ ] Dependencies audited
163
164## Prerequisites
165
166```text
167# Python dependencies
168pip install -r requirements.txt
169```
170
171## Evaluation Criteria
172
173### Success Metrics
174- [ ] Successfully executes main functionality
175- [ ] Output meets quality standards
176- [ ] Handles edge cases gracefully
177- [ ] Performance is acceptable
178
179### Test Cases
1801. **Basic Functionality**: Standard input → Expected output
1812. **Edge Case**: Invalid input → Graceful error handling
1823. **Performance**: Large dataset → Acceptable processing time
183
184## Lifecycle Status
185
186- **Current Stage**: Draft
187- **Next Review Date**: 2026-03-06
188- **Known Issues**: None
189- **Planned Improvements**:
190 - Performance optimization
191 - Additional feature support
192
193## Output Requirements
194
195Every final response should make these items explicit when they are relevant:
196
197- Objective or requested deliverable
198- Inputs used and assumptions introduced
199- Workflow or decision path
200- Core result, recommendation, or artifact
201- Constraints, risks, caveats, or validation needs
202- Unresolved items and next-step checks
203
204## Error Handling
205
206- If required inputs are missing, state exactly which fields are missing and request only the minimum additional information.
207- If the task goes outside the documented scope, stop instead of guessing or silently widening the assignment.
208- If `scripts/main.py` fails, report the failure point, summarize what still can be completed safely, and provide a manual fallback.
209- Do not fabricate files, citations, data, search results, or execution outcomes.
210
211## Input Validation
212
213This skill accepts requests that match the documented purpose of `lab-result-interpretation` and include enough context to complete the workflow safely.
214
215Do not continue the workflow when the request is out of scope, missing a critical input, or would require unsupported assumptions. Instead respond:
216
217> `lab-result-interpretation` only handles its documented workflow. Please provide the missing required inputs or switch to a more suitable skill.
218
219## Response Template
220
221Use the following fixed structure for non-trivial requests:
222
2231. Objective
2242. Inputs Received
2253. Assumptions
2264. Workflow
2275. Deliverable
2286. Risks and Limits
2297. Next Checks
230
231If the request is simple, you may compress the structure, but still keep assumptions and limits explicit when they affect correctness.