Pre-visit Patient UI
Relevant source files
The following files were used as context for generating this wiki page:
The Pre-visit Patient UI is a standalone, patient-facing application designed for intake and waiting-room environments. Its primary goal is to facilitate a calm, voice-first conversation flow that integrates with Sarvam STT/TTS (Speech-to-Text and Text-to-Speech) services to collect patient data before a clinical visit. The application streamlines the intake process by allowing patients to verify their identity and provide health information through guided voice interactions.
The system is built as a hybrid architecture where the frontend manages voice interactions and UI states, while a FastAPI backend orchestrates patient context from OpenMRS, manages chat turns, and generates audio prompts. This UI serves as the entry point for patients to provide structured data—such as vitals and medical history—which is then processed via AI for clinical review.
Sources: patient-previsit-app/README.md, readmes/README_VOICE_VITALS.md
Application Flow and User Interaction
The pre-visit experience follows a structured four-stage process designed to ensure data accuracy and ease of use for the patient.
- Verify: The patient enters their ID, Date of Birth (DOB), and an optional appointment code to authenticate.
- Voice Intake: A guided conversation begins. The backend provides an initial prompt and audio. Subsequent turns are managed via a chat-based interface where the patient records responses.
- Review: The patient reviews a summary of all collected data before final submission.
- Wait: Upon check-in, the patient is shown their current position in the clinic queue.
Sources: patient-previsit-app/README.md
Voice Interaction Logic
The UI prioritizes "tap-to-toggle" recording. While voice is the primary medium, the system includes a text fallback option labeled "Type instead" which remains hidden until needed. Audio prompts are generated by the backend to avoid unnecessary client-side generation, with manual controls for muting and replaying prompts.
The following diagram illustrates the high-level patient interaction flow:
Sources: patient-previsit-app/README.md
System Architecture and Tech Stack
The Pre-visit UI is part of a larger ecosystem that bridges patient inputs with the OpenMRS backend. It utilizes modern web technologies and AI services for natural language processing.
Technical Stack
- Frontend: React 18, TypeScript, Vite, Tailwind CSS, and shadcn/ui.
- State Management: TanStack Query for server state and React Hook Form with Zod for data validation.
- Animations: Framer Motion for intentional, calm transitions.
- Backend Orchestration: FastAPI (Python) which interacts with OpenMRS via REST and FHIR.
- AI Integration: Sarvam AI for STT/TTS and Google Gemini for structured data extraction.
Sources: patient-previsit-app/README.md, readmes/FINAL_SUMMARY.md, readmes/IMPLEMENTATION_SUMMARY.md
Data Flow and Integration
The application uses a hybrid conversation model. When a session starts, the backend builds patient context from a combination of OpenMRS REST resources and optional FHIR resources.
Voice-to-Vitals Implementation
A core module within the pre-visit and clinical UI is the Voice Vitals system. This allows for the structured extraction of 10 vital sign fields from natural speech, which are then auto-populated into OpenMRS forms.
Component Breakdown
| Component | Responsibility | File Path |
|---|---|---|
useVitalsRecorder | Manages microphone access and audio blob creation. | useVitalsRecorder.ts |
VitalsRecordingWidget | UI for Record/Stop/Extract controls and timer. | vitals-recording.component.tsx |
vitals-recording.service | Communicates with /transcribe_batch and /process_vitals_transcription. | vitals-recording.service.ts |
vitals-data.mapper | Maps AI-structured JSON to OpenMRS form fields. | vitals-data.mapper.ts |
Sources: readmes/VOICE_VITALS_IMPLEMENTATION.md, readmes/FINAL_SUMMARY.md
AI Extraction and Normalization
The system performs automatic unit conversion and normalization to ensure data consistency in the medical record:
- Temperature: Fahrenheit to Celsius.
- Weight: Pounds (lbs) to Kilograms (kg).
- Height: Inches/Feet to Centimeters (cm).
- Blood Pressure: Spoken "120 over 80" is parsed into distinct systolic and diastolic fields.
- BMI: Automatically calculated based on extracted weight and height.
Sources: readmes/VOICE_VITALS_IMPLEMENTATION.md, readmes/IMPLEMENTATION_SUMMARY.md
Backend API Endpoints
The Pre-visit Patient UI relies on several key FastAPI endpoints for session management and data processing.
| Endpoint | Method | Description |
|---|---|---|
/previsit/verify | POST | Verifies patient identity using ID and DOB. |
/previsit/session | POST | Creates a new intake session; auto-loads OpenMRS context. |
/previsit/chat | POST | Sends recorded message, returns next question and audio. |
/transcribe_batch | POST | Processes audio blobs using Sarvam AI for transcription. |
/process_vitals_transcription | POST | Uses Gemini API to extract vitals from a text transcript. |
/previsit/report/{id} | GET | Retrieves the generated summary/report for the session. |
/previsit/submit | POST | Finalizes the intake and checks the patient into the queue. |
Sources: patient-previsit-app/README.md, readmes/VOICE_VITALS_IMPLEMENTATION.md
Summary
The Pre-visit Patient UI provides a streamlined, voice-first interface for patient intake. By leveraging a React-based frontend and a FastAPI orchestration layer, the system successfully integrates voice recording with high-level AI services to automate data collection. This reduces manual data entry for clinical staff while providing a modern, accessible experience for patients. The architecture ensures that even when voice interactions fail, robust fallback mechanisms and manual review steps maintain medical data integrity.
Sources: readmes/FINAL_SUMMARY.md, readmes/ARCHITECTURE_OVERVIEW.md