Spaces:
Sleeping
Sleeping
File size: 3,156 Bytes
d31fe8c |
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 |
import pytest
import sys
import os
# Add parent directory to path to import app modules
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
class TestSOAPGeneration:
"""Test SOAP note generation functionality"""
def test_generate_soap_note_with_valid_input(self, sample_medical_text):
"""Test SOAP generation with valid medical text"""
# Mock the generate_soap_note function since it requires the model
def mock_generate_soap_note(text, include_timestamp=True):
if not text.strip():
return "β Please enter some medical notes to process."
# Return a mock SOAP note
return """
SUBJECTIVE:
45-year-old male presents with chief complaint of chest pain for 2 hours.
OBJECTIVE:
Vital Signs: BP 150/90, HR 110, RR 22, O2 Sat 96%
Physical exam shows patient appears anxious and diaphoretic.
ASSESSMENT:
Acute chest pain, rule out myocardial infarction
PLAN:
1. EKG
2. Cardiac enzymes
3. Chest X-ray
4. Aspirin 325mg
"""
result = mock_generate_soap_note(sample_medical_text)
assert "SUBJECTIVE:" in result
assert "OBJECTIVE:" in result
assert "ASSESSMENT:" in result
assert "PLAN:" in result
assert "45-year-old male" in result
def test_generate_soap_note_empty_input(self):
"""Test SOAP generation with empty input"""
def mock_generate_soap_note(text, include_timestamp=True):
if not text.strip():
return "β Please enter some medical notes to process."
return "Valid SOAP note"
result = mock_generate_soap_note("")
assert "β Please enter some medical notes to process." in result
def test_generate_soap_note_whitespace_only(self):
"""Test SOAP generation with whitespace only"""
def mock_generate_soap_note(text, include_timestamp=True):
if not text.strip():
return "β Please enter some medical notes to process."
return "Valid SOAP note"
result = mock_generate_soap_note(" \n\t ")
assert "β Please enter some medical notes to process." in result
def test_soap_note_structure(self, sample_medical_text):
"""Test that generated SOAP notes have proper structure"""
def mock_generate_soap_note(text, include_timestamp=True):
return """
SUBJECTIVE:
Patient reports chest pain.
OBJECTIVE:
Vital signs stable.
ASSESSMENT:
Chest pain evaluation.
PLAN:
Further testing recommended.
"""
result = mock_generate_soap_note(sample_medical_text)
lines = result.strip().split('\n')
# Check that SOAP sections are present and in order
soap_sections = []
for line in lines:
if line.strip().endswith(':') and line.strip() in ['SUBJECTIVE:', 'OBJECTIVE:', 'ASSESSMENT:', 'PLAN:']:
soap_sections.append(line.strip())
expected_order = ['SUBJECTIVE:', 'OBJECTIVE:', 'ASSESSMENT:', 'PLAN:']
assert soap_sections == expected_order |