Skip to content

test: cover the discharge summary and the LLM provider dispatch - #672

Merged
marceloarocha merged 1 commit into
developfrom
claude/magical-wozniak-jj1x6k
Sep 6, 2026
Merged

test: cover the discharge summary and the LLM provider dispatch#672
marceloarocha merged 1 commit into
developfrom
claude/magical-wozniak-jj1x6k

Conversation

@marceloarocha

Copy link
Copy Markdown
Collaborator

Two features had no tests at all. This adds one integration suite and one unit suite for them.

GET /summary/<admission_number> — discharge summary (integration)

tests/integration/test_summary.py — 17 tests, services/summary_service.py goes from 30% → 100%.

The interesting logic is the annotation windowing: each summary topic reads its own time window relative to the first or the last clinical note of the admission (the admission reason covers the first four days, previous drugs only the first day, the discharge topics only the last day, and diagnosis/procedures/exams have no window at all). The fixture lays out four notes so every window has a note inside it and a note outside it, and the tests assert both sides.

Also covered: the patient header and the derived IMC (and the None case when weight/height are unknown), the exams filter (out-of-range and within the last 7 days), active-only allergies named by substance when the drug is catalogued, de-duplication across notes, the clinicalSummary composition from reason + procedures + summary, the saved draft, the ?mock=true prompt preview, an admission with no notes, and the 401/400 boundaries.

llm_service.prompt — model provider dispatch (unit)

tests/unit/test_llm_service.py — 16 tests, services/llm_service.py goes from 24% → 100%.

Both boundaries are mocked (the summary-config lookup and the Bedrock client), so no database and no AWS access. Covers the dispatch table, each provider's request body, model id and region, the answer extraction for claude / gpt_oss / llama (including the <reasoning> stripping, single and repeated), and the guards: permission gating, empty messages, missing configuration, unknown provider, and the two configurable-but-unimplemented providers.

Notes

  • All test data is synthetic and self-cleaning; the suite was run twice back-to-back with no leftover rows.
  • Full suite: 2326 → 2359 passing. ruff check clean.
  • Combined services + repository coverage: 80% → 81%.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Kmjcsax3vdE2YXXDKEBk96


Generated by Claude Code

Two features had no tests at all.

`GET /summary/<admission>` assembles the discharge summary screen. The
integration tests cover the patient header and derived IMC, the recent
out-of-range exams, the active allergies, the saved draft, and the
annotation time windows that decide which clinical note feeds each
summary topic — including the `clinicalSummary` composition, the
de-duplication across notes and the `?mock=true` prompt preview.

`llm_service.prompt` dispatches to the model named by the
`summary-config` record. The unit tests mock the config lookup and the
Bedrock client to cover the dispatch table, each provider's request body
and region, the answer extraction (including the gpt-oss `<reasoning>`
stripping), and the validation branches.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kmjcsax3vdE2YXXDKEBk96

@amazon-q-developer amazon-q-developer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR adds comprehensive test coverage for two previously untested features: the discharge summary endpoint and the LLM provider dispatch logic. The integration tests thoroughly validate the annotation windowing logic, exam filtering, and authorization boundaries. The unit tests provide complete coverage of the provider dispatch table and response parsing. Both test suites follow best practices with proper mocking, synthetic data, and self-cleaning fixtures. All 33 new tests are well-structured and the PR achieves the stated coverage improvements (30% → 100% for summary_service and 24% → 100% for llm_service).


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

@marceloarocha
marceloarocha merged commit 87fb835 into develop Sep 6, 2026
10 checks passed
@marceloarocha
marceloarocha deleted the claude/magical-wozniak-jj1x6k branch September 6, 2026 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants