Skip to content

Inpatient AI Assisted Diagnosis Card

Dr M H B Ariyaratne edited this page Jun 4, 2026 · 1 revision

Inpatient — AI-Assisted Diagnosis Card

Module: Inpatient / EHR — Clinical Data
Path: Admission Profile → Clinical Data → Diagnosis Cards
XHTML: /inward/inward_diagnosis_cards.xhtml
Controller: InpatientClinicalDataController (generateDiagnosisCardWithAi())
Privilege: InpatientClinicalDischarge


Overview

The AI-Assisted Diagnosis Card feature generates a professional, print-ready clinical summary document for an inpatient episode using the Anthropic Claude API. In a single click, the system assembles the patient's complete clinical record — demographics, vital signs, diagnoses, medications, investigations, surgeries, and discharge instructions — and passes it to Claude, which returns a fully formatted HTML table suitable for printing on hospital letterhead or downloading as a PDF.

This eliminates manual card composition and reduces the time from clinical discharge decision to a signed, formatted document to under one minute.


Page Layout

The Diagnosis Cards page uses a two-panel layout:

Left Panel

Control Purpose
Template selector (dropdown) Optionally select a pre-defined InpatientDiagnosisCard template to impose institution-specific formatting rules or section headings
Refresh (sync icon button) Reload the template list if new templates were added by the administrator in the same session
Generate (magic wand icon) Submit the generation request to Claude; triggers BlockUI overlay
Saved Diagnosis Cards (list box) All previously generated or saved cards for this BHT, identified by card name; click any entry to load it into the right panel

Right Panel

Displays the selected or newly generated card with a toolbar:

Button Action
Edit / View toggle Switch between rendered HTML view and a WYSIWYG editor
Save Persist any edits made in the editor back to the database
Delete Remove the card from the BHT (confirmation prompt shown)
Print Send the rendered card to the browser print dialog
Download PDF Download the card as a PDF file

A patient information strip above both panels shows Patient Name, BHT Number, Age/Sex, Admission Date, and Ward — confirming context before generating.


Generation Workflow

  1. Navigate to Admission Profile → Clinical Data → Diagnosis Cards
  2. Optionally select a template from the dropdown (or leave as -- Default --)
  3. Click Generate
  4. A blocking overlay appears: "Generating diagnosis card with AI… This may take a few seconds"
  5. The system collects all clinical data for the BHT (see below) and calls the Claude API
  6. The generated HTML card appears immediately in the right panel under the title "AI Generated Diagnosis Card" (or the template name if one was selected)
  7. The new card is also added to the Saved Diagnosis Cards list on the left

Clinical Data Collected Automatically

The system prompt sent to Claude includes the following data, pulled live from the patient's BHT:

Category Detail
Patient demographics Name, age, sex, BHT number, date of admission, date of discharge
Vital signs Blood pressure, pulse rate, respiratory rate, SpO₂ saturation, temperature, height, weight, BMI
Vital sign trends Time-series readings recorded throughout the admission
Current diagnoses ICD-10 coded diagnoses entered at clinical discharge
Past medical history Conditions from the EHR history panel
Allergies All recorded drug or other allergies
Investigations Laboratory and radiology tests performed, with results
Procedures Bedside and clinical procedures performed during the admission
Surgeries Surgeon name, anaesthetist name, operative notes
Ward medications (Rx) Medicines administered during the inpatient stay
Discharge medications (DRx) Prescriptions ordered for post-discharge use
Routine medicines Any standing/routine medications
Clinical discharge details Discharge condition, clinical summary narrative, follow-up plan, activity instructions, diet instructions
Patient comments Free-text notes recorded against the admission

No data is entered manually for generation — the system assembles everything automatically from the existing EHR record.


AI Output Rules

The Claude system prompt enforces the following rules:

  • No fabrication — Claude is explicitly instructed to use only the clinical data provided; it must not invent findings, diagnoses, or medications
  • Discharge status alert — if the patient has not yet been discharged, the discharge status cell in the output table is highlighted in orange, providing a clear visual warning
  • Empty sections omitted — if a category has no data (e.g., no surgeries performed), that section is not included in the output; the card remains compact and relevant
  • Bold surgery and procedure names — for quick scanning by clinical and administrative reviewers
  • Print-ready format — output is a single HTML table with inline CSS styled for A4 paper; no external stylesheets are required

Post-Generation Editing

After the card is generated, clinical staff can refine it before printing:

  1. Click Edit in the right panel toolbar — the card switches to a WYSIWYG content-editable mode
  2. A formatting toolbar provides: Bold, Italic, Underline, Bullet List, Numbered List, Undo, Redo
  3. Edits are tracked via JavaScript in a hidden input field
  4. Click Save to persist the edited version back to the database
  5. Click View to return to the rendered display

Storage

The generated card is stored as a ClinicalFindingValue entity of type VisitDocument against the PatientEncounter (BHT). Fields used:

Field Content
stringValue Card title (template name or "AI Generated Diagnosis Card")
lobValue Full HTML content of the card

Multiple cards can be saved for the same BHT — for example, a general discharge card and a separate surgical summary. All appear in the Saved Diagnosis Cards list and can be viewed, edited, printed, or downloaded individually.


Configuration

Three application-level settings control the AI connection. Set via Admin → Application Configuration:

Config Key Purpose Default
AI Chat - Claude API Key Anthropic API authentication key (must be set)
AI Chat - Claude Model Claude model version claude-sonnet-4-20250514
AI Chat - Max Tokens Maximum output token budget 4096 (system enforces minimum 8192)

If the API key is not configured, the Generate button will produce an error message. No card is stored until generation succeeds.


Template Administration

Administrators can define templates of type InpatientDiagnosisCard via Admin → Inpatient → Form Templates. Each template can carry:

  • A name (shown in the template dropdown and used as the card title)
  • Instructions appended to the system prompt — for example, specifying required sections, formatting preferences, or institution-specific headers

Templates can be deactivated (not deleted) when no longer needed; historical cards generated from deactivated templates are preserved unchanged.

See: Admin — Inpatient Form Templates


Related Pages

Page Link
Inpatient — Discharge Summary and Diagnosis Card Wiki
Inpatient EHR — Clinical Discharge Wiki
Inpatient EHR — Clinical Data Wiki
Admin — Inpatient Form Templates Wiki
Inpatient Admission Profile Dashboard Wiki

Clone this wiki locally