Project Overview and Business Context
The client was a GP surgery chain looking to reduce the documentation burden on their clinical staff. The existing process required GPs to either dictate notes for a medical secretary to type up (slow, expensive, and creating a backlog) or type notes directly into their clinical system during or after each consultation (reducing consultation quality and extending working hours). The brief was to build an AI tool that a GP could use at the end of each consultation: upload a 3-5 minute voice recording or paste raw dictation text, and receive a structured SOAP note (Subjective, Objective, Assessment, Plan) ready for review and one-click import into their clinical system. The tool also needed to support referral letter drafting from the structured note, reducing the time spent on secondary documentation. Data sensitivity requirements were significant. Audio recordings of medical consultations contain special category health data under UK GDPR and must be handled with appropriate technical and organisational measures. The MHRA's position on AI-assisted clinical documentation tools is that they may constitute medical devices if they inform clinical decision-making rather than purely assisting with administrative transcription. The client's legal advisors classified the tool as administrative assistance, with the GP making all clinical judgments independently of the AI output. NHS Digital DTAC (Digital Technology Assessment Criteria) compliance was a requirement for deployment in NHS-adjacent settings.
Technical Architecture and Stack Decisions
The application is built on Next.js deployed on Vercel, with Supabase handling authentication, user management, and structured data storage. Audio file uploads go to AWS S3 with server-side encryption (AES-256) and are stored in an EU-region bucket to satisfy UK GDPR data residency requirements. Audio is never stored longer than 24 hours after transcription is complete, with automated S3 lifecycle policies enforcing deletion. The transcription pipeline uses OpenAI Whisper for audio-to-text conversion, chosen for its accuracy on medical terminology and its support for UK English accent profiles. Transcription output is passed directly to GPT-4o via a server-side API route, never exposed to the client-side browser. GPT-4o produces structured SOAP note output as a JSON object with separate fields for each SOAP section, which the Next.js frontend renders in an editable form. The GP reviews, edits, and approves the note before it enters any downstream system. The HL7 FHIR compatibility requirement was addressed by building an export layer that maps the structured SOAP JSON fields to FHIR R4 Clinical Note resource format, allowing integration with clinical systems that support FHIR. Supabase stores completed notes (post-clinician approval) with audit timestamps and user ID. Raw transcription text is not persisted after note generation. PostHog is excluded from this build due to the sensitivity of health data. A minimal internal logging table in Supabase tracks usage metrics (notes generated, average review time) without capturing clinical content.
Key AI and ML Components
Two AI components work in sequence. OpenAI Whisper handles transcription. The model is called server-side via the OpenAI API with the medical transcription prompt configuration enabled, which improves accuracy on drug names, anatomical terms, and clinical abbreviations. Whisper's output is a raw transcript with punctuation but no clinical structure. GPT-4o then receives this transcript with a system prompt that instructs it to extract and structure the content into SOAP format. The system prompt includes specific instructions for each SOAP section: Subjective (patient's reported symptoms, history, presenting complaint in the patient's own words), Objective (examination findings, vital signs, observations, results referenced in the consultation), Assessment (clinical impression, differential considerations), and Plan (medications prescribed, investigations ordered, referrals, follow-up timing, safety netting advice given). The prompt is parameterised by consultation type, so the template for a GP routine appointment differs from a hospital outpatient follow-up or an A&E presentation. Output is always a structured JSON object, never free text, which means the rendering and editing layer has full control over formatting and can validate field completeness before the note is submitted.
Challenges Solved and How
Medical audio transcription has specific accuracy challenges. Background noise in consultation rooms, overlapping speech between clinician and patient, and domain-specific terminology all reduce transcription accuracy. The system handles this with a pre-processing step that strips long silences and normalises audio levels before passing to Whisper, and a post-processing step that applies a medical terminology dictionary to catch common Whisper errors on drug names and anatomical terms. Structuring free-form consultation content into SOAP format is harder than it appears. Real consultations are non-linear: a patient mentions a concern, the GP asks a follow-up question, a medication is discussed, and then the original concern resurfaces. GPT-4o is instructed to identify and consolidate thematically related content across the full transcript rather than treating it as a linear sequence, producing SOAP notes that reflect the clinical logic of the consultation rather than the conversational order. DTAC compliance required a data flow diagram showing all processing steps, data categories, retention periods, and access controls. SpeedMVPs produced this as part of the build documentation, covering audio storage, transcription processing, note storage, and user access management.
Outcome and Measurable Results
The client ran a four-week pilot with six GPs across two surgeries. Average note completion time fell from 8 minutes (manual typing) to 2.5 minutes (AI draft plus review), a 69% reduction. Participating GPs rated 87% of AI-generated SOAP notes as requiring minimal edits (changing fewer than 10% of the content). The referral letter drafting feature reduced letter preparation time from an average of 12 minutes to 4 minutes. Over the four-week pilot, the six participating GPs collectively recovered an estimated 18 hours of administrative time per week. Qualitative feedback highlighted that the quality of SOAP notes improved as well as the speed: GPs reported that the structured format prompted them to review all four SOAP sections and caught instances where they had not documented safety netting advice given verbally in the consultation.
Lessons for Similar Projects
Invest in the system prompt per consultation type. A generic SOAP prompt works reasonably well for standard GP appointments but fails on specialist consultations with different documentation conventions. Build parameterisation into the prompt architecture from the start so templates can be extended without changing the core system. Do not persist audio longer than necessary. Health data regulation in the UK, including NHS DSP Toolkit requirements and UK GDPR, imposes strict obligations on special category data. Automated deletion of raw audio after transcription reduces your data processing footprint and simplifies your compliance documentation significantly. Make the editing interface the priority. GPs adopt tools that feel fast and trustworthy. If reviewing and editing the AI output takes longer than typing the note manually, adoption fails. Invest in the editing UX, including keyboard shortcuts, field-by-field navigation, and one-click acceptance of unchanged sections. Finally, involve a clinical informatics lead from the NHS trust or practice in the FHIR mapping design. FHIR implementation details vary between clinical systems, and getting the mapping wrong creates import failures that damage trust in the product.