top of page

Techunison-style research blueprint

Frappe Health AI Scribe, Coding, and Billing Automation

Detailed research and implementation document for building an ambient clinical documentation platform on top of Frappe Health and ERPNext. This document covers architecture, source-code patterns, open-source research, security guardrails, coding extraction, and invoice automation.

Frappe Health

Core system of record

AI SOAP Notes

Primary use case

ERPNext Sales Invoice

Billing target

Open + Hybrid AI

Delivery model

Executive Summary
Research Findings
Model Strategy
Architecture
Implementation
Source Code
Security
Roadmap
Sources

1. Executive Summary

What should be built, why it matters, and where Frappe Health fits.

Recommended platform direction

Build a custom Frappe Health extension for AI-assisted clinical documentation rather than treating the AI scribe as an isolated tool. Frappe Health should remain the system of record for patient, encounter, medication, clinical coding, and billing workflows. The AI stack should sit beside it as an assistive service layer.

Best-fit approach: Browser or mobile audio capture → speech-to-text → structured SOAP JSON → draft Patient Encounter → optional ICD/CPT extraction → draft Sales Invoice → human review and submission.

Why this approach wins
  • Preserves full workflow control inside Frappe Health and ERPNext.

  • Supports both cloud and self-hosted AI models.

  • Allows phased rollout: notes first, then coding, then billing automation.

  • Fits Techunison’s enterprise healthcare implementation model.

  • Keeps the doctor in control by saving AI output as draft before submission.

Key design decisions
Decision Area
Recommended Choice
Clinical record ownership
Frappe Health Patient Encounter
Audio capture
Browser recorder / mobile app / room mic station
Speech engine
Whisper or equivalent STT layer
SOAP structuring
Prompted LLM returning strict JSON
Coding extraction
Separate coding prompt and validator
Billing logic
ERPNext item mapping with invoice draft
Safety mode
Mandatory clinician review before final submission

Do not let the model directly submit clinical records or invoices without validation, access control, and approval workflow.

2. Research Findings

Condensed from the provided research notes and validated against official Frappe/Frappe Health documentation.

Finding 1

Frappe already exposes REST APIs for DocTypes

That means Patient Encounter, Sales Invoice, Item lookups, and custom DocTypes can all be created or queried using standard REST endpoints without building a separate backend first.

Finding 2

Patient Encounter is the right clinical anchor

Encounter is where visit-level documentation, diagnosis coding, medication, and downstream billing context naturally belong.

Finding 3

Open source is viable, but hybrid is stronger

Open-source stacks such as scribeHC and local STT can reduce lock-in, but production-grade performance often improves when combined with stronger hosted reasoning models or managed inference infrastructure.

What the research strongly suggests
Area
Research Direction
Implementation Reading
Ambient documentation
Use a healthcare-specific capture flow, then normalize into structured SOAP JSON.
Keep transcript, note draft, and clinician edit history separate.
Open-source tools
Use scribeHC-style tooling for the listening layer and Frappe for system workflows.
Best when you want customization and self-hosting control.
Medical coding
Prompt the model for diagnosis and procedure suggestions in strict JSON
Always validate against your own Medical Code / Item master before billing.
Billing automation
Generate invoice drafts, not final submitted invoices.
Map extracted codes to ERPNext billable items dynamically.
Security
Consent, audit trails, restricted retention, and no silent auto-filing.
High-risk workflows need explicit human approval.

3. AI Model Strategy

Choose model roles instead of chasing one model for everything.

Layer
Recommended Role
Best Fit
Notes
Speech-to-text
Audio transcription
Whisper-class model or managed STT
Use domain noise filtering, speaker separation if possible.
Clinical summarization
SOAP generation
Strong reasoning model or tuned medical model
Needs strict JSON schema and hallucination controls.
Medical coding extraction
ICD/CPT suggestions
Dedicated prompt or smaller coding specialist model
Never trust coding output without validation.
Billing assistant
Item lookup + invoice draft
Application logic first, LLM second
LLM can suggest codes; ERPNext should decide billable items.

Practical rule: use the LLM to extract and propose, but use Frappe/ERPNext logic to validate and transact.

Open-source path
  • Self-hosted STT

  • Open-weight note-generation model

  • Local or private-cloud deployment

  • Best for data sovereignty

Hybrid path
  • Local audio capture

  • Managed reasoning model for SOAP

  • On-prem or VPC middleware

  • Best for implementation speed

Enterprise path
  • Private inference + governance

  • Human QA queues

  • Role-based approvals

  • Best for hospital-scale rollout

4. Reference Architecture

A practical Frappe Health-native workflow for ambient care documentation.

1. Audio Capture

Doctor-patient or nurse-patient conversation recorded through browser, tablet, or kiosk mic.

2. Transcription

Speech engine converts audio into timestamped text, optionally with speaker separation.

3. Structuring

LLM converts transcript into strict SOAP JSON, medications, diagnosis, and next-step suggestions.

4. Frappe Draft

Create Patient Encounter draft with subjective, objective, assessment, plan, and child tables.

5. Coding & Billing

Validate ICD/CPT and map approved billable items into ERPNext Sales Invoice draft.

6. Human Review

Doctor or billing user edits, signs off, submits, and closes the workflow.

Suggested custom DocTypes / app modules
DocType
Purpose
AI Scribe Session
Stores encounter audio metadata, transcript status, model used, and review state.
AI Transcript Chunk
Optional segmented transcript storage for long sessions.
AI Coding Suggestion
Stores proposed ICD/CPT/E&M with confidence and reviewer action.
AI Billing Draft Log
Tracks mapping of extracted codes to ERPNext items.
AI Audit Event
Captures access, generation, review, and submission events.
Recommended UI design inside Frappe
  • Encounter form action: “Start Ambient Note”

  • Live recorder panel: waveform, consent state, elapsed time, pause/resume

  • Transcript split view: raw transcript on left, structured SOAP draft on right

  • Coding assistant drawer: primary diagnosis, secondary diagnoses, CPT / procedure candidates

  • Billing panel: matched items, missing items, pricing, approval notes

Build for editability, not for one-click automation. Clinicians trust systems they can correct quickly.

5. Step-by-Step Implementation Plan

Start simple, then layer safety, coding, and billing.

Phase 1
Encounter draft creation

Record audio, transcribe, and push SOAP draft into Patient Encounter.

Phase 2
Medication & diagnosis extraction

Populate child tables for drugs and diagnosis suggestions.

Phase 3
Coding validation

Match model output with your Medical Code and Item master.

Phase 4
Invoice drafting

Create Sales Invoice drafts after human review and pricing rules.

Detailed implementation sequence
  1. Create a dedicated API user in Frappe for the scribe service.

  2. Generate API Key and API Secret and restrict permissions to only required DocTypes.

  3. Add a custom app such as techunison_ai_scribe to isolate this feature cleanly.

  4. Create an “AI Scribe Session” DocType for session tracking and traceability.

  5. Add a custom button on Patient Encounter to launch audio capture.

  6. Transcribe audio using your chosen speech layer.

  7. Send transcript to the note-generation prompt and require JSON-only output.

  8. Validate schema server-side before POSTing to Frappe Health.

  9. Populate Encounter draft, including diagnosis and medication child tables where applicable.

  10. Run ICD/CPT mapping logic against Frappe master data.

  11. Build a billing preview and create a draft Sales Invoice.

  12. Add review states: Generated, Reviewed, Approved, Rejected.

  13. Log every generation, edit, submit, and invoice action in an audit table.

6. Source Code and Prompts

Starter examples for Techunison implementation. Review and adapt field names to your exact Frappe version and customizations.

6.1 Frappe REST API pattern for Patient Encounter

TUIFrappe1.jpg

6.2 Prompt for SOAP JSON extraction

TUIFrappe2.jpg

6.3 Prompt for ICD-10 extraction

TUIFrappe3.jpg

6.4 Encounter with diagnosis + medication child tables

TUIFrappe4.jpg

6.5 Sales Invoice draft creation

TUIFrappe5.jpg

6.6 Automatic item mapping from extracted codes

TUIFrappe6.jpg

6.7 Frappe custom app server stub

TUIFrappe7.jpg

7. Security, Governance, and Clinical Safety

This is the part many teams under-design. Do not skip it.

Consent and transparency
  • Record patient consent for audio capture.

  • Display clear recording status in UI.

  • Store consent event in audit trail.

Access and retention
  • Role-based access for transcript and notes.

  • Limit raw audio retention aggressively.

  • Separate audio, transcript, and final note permissions.

Clinical control
  • Mandatory human review before submission.

  • Flag low-confidence outputs.

  • Never auto-finalize diagnoses or invoices silently.

Security checklist
Control
Implementation Guidance
API auth
Use token-based auth with dedicated integration user and least privilege.
Transport security
Use HTTPS/TLS for all API traffic and media upload flows.
Encryption
Encrypt stored media, transcripts, and related secrets at rest.
Audit trail
Track transcript creation, note generation, code edits, invoice draft creation, and submit actions.
Prompt safety
Require strict JSON output and reject malformed payloads server-side.
Data minimization
Store only what is operationally needed; purge raw audio when policy allows.
Review workflow
Save all AI-generated records as drafts first.
Master data validation
Validate ICD/CPT and item codes against local Frappe masters before billing.

8. Implementation Portfolio

A portfolio of implementations across industries, showcasing scalable digital solutions and workflow-driven system design.
Built to enable integration, automation, and efficient operations at scale.

Frappe Assistant Core: AI Execution Layer for ERPNext

MCP-based platform connecting ERPNext with GPT, Claude, and enterprise agents through secure, standardized workflows.

Frappe Assistant Core: LLM Integration Layer for ERPNext

Connects ERPNext to MCP-compatible AI models through secure, standardized tools, enabling AI-driven workflows and automation.

9. Delivery Roadmap for Techunison

A realistic path from pilot to hospital-scale deployment.

Stage 1: Proof of Value
  • Single specialty pilot

  • Encounter draft only

  • No auto-billing

  • Doctor review mandatory

Stage 2: Structured Coding
  • Diagnosis suggestions

  • Medication extraction

  • Item validation against masters

  • Billing preview dashboard

Stage 3: Revenue Workflow
  • Draft Sales Invoice creation

  • Billing desk approval

  • Exception queues

  • Audit and KPI reporting

Recommended KPIs
KPI
Why it matters
Time saved per encounter
Measures documentation efficiency.
Draft acceptance rate
Shows note quality and clinician trust.
Coding correction rate
Shows whether the model is safe for coding support.
Invoice draft match rate
Shows billing usefulness without over-automation.
Audio-to-note turnaround time
Important for busy OPD flow.
Human override frequency
High values reveal prompt or model weakness.

10. Research Sources

Source list included in the HTML for stakeholder review.

  • Frappe Framework REST API documentation

  • Frappe Framework token-based authentication documentation

  • Frappe Health Patient Encounter documentation

  • Frappe Health Patient documentation

  • scribeHC GitHub repository

  • Provided research notes consolidated from the uploaded conversation text

This blueprint intentionally treats model/vendor choice as replaceable, while keeping Frappe Health and ERPNext workflow ownership central.

Techunison implementation stance

The strongest version of this product is not “an AI note generator.” It is a clinical workflow automation layer built around Frappe Health, where ambient documentation, coding support, and billing assistance are integrated into one governed workflow.

bottom of page