Skip to content

Backend Forms ESign Documents

Ankit Upadhyay edited this page Jul 24, 2026 · 2 revisions

Backend: Forms, E-Sign, Documents

Form templates and assignments, PDF rendering, Documenso-backed e-signature, and document/attachment storage with virus scanning. Part of Backend Overview.

What it owns

Clinics build form templates, assign them to appointments/companions, render them to PDF, and collect e-signatures through Documenso. FHIR template + rendered-document + clinical-artifact resources back the clinical document-packet flow. Documents and organisation-documents cover uploads/attachments.

Routers

form.router.ts (FormController + FormSigningController), form-assignment.router.ts, template.router.ts, template.fhir.router.ts, rendered-document.fhir.router.ts, clinical-artifact.fhir.router.ts, document.router.ts, organisation-document.router.ts, documenso.router.ts.

Controllers

web/form.controller.ts, web/formSigning.contorller.ts (sic), web/form-assignment.controller.ts, web/template.controller.ts, web/template.fhir.controller.ts, web/rendered-document.fhir.controller.ts, web/clinical-artifact.fhir.controller.ts, app/document.controller.ts, web/organisation-document.controller.ts, web/documenso.controller.ts (DocumensoAuthController, DocumensoKeyController, DocumensoWebhookController).

Services

form.service.ts, formPDF.service.ts, formSigning.service.ts, form-assignment.service.ts, template.service.ts, rendered-document.service.ts, rendered-document-renderer.service.ts, clinical-artifact.service.ts, clinical-packet-pdf.service.ts, document.service.ts, document-scope.ts (binds documents/templates to their owning tenant), document-pdf-template-registry.service.ts, organisation-document.service.ts, documenso.service.ts, workspace-document-packet.service.ts, attachmentScanner.service.ts (VirusTotal). Mappers: fhir-template.mapper.ts, fhir-clinical-artifact.mapper.ts; blueprints clinical-template-blueprints.ts; PDF assets in utils/pdf-templates/ and utils/formPDFTemplate.html.

Models

form.ts, organisation-document.ts (documents, templates, and rendered docs are Prisma-side; models/document.ts was removed in PR #1819).

Notable

  • Documenso is the e-sign provider: per-org API keys are stored (DocumensoKeyController.storeApiKey) and its webhook (/v1/documenso/webhook) is verified via an x-documenso-signature header (raw-body route).
  • Attachment safety — uploads are scanned with VirusTotal (attachmentScanner.service.ts); Stream chat uploads have a separate blocked-extension policy.
  • The PMS Documents plan (Plans: PMS Documents) threads captured metadata (visitType, issuingBusinessName, issueDate) through DocumentService.create.

Related

Product & Domain
Architecture
Applications
Design & Accessibility
Engineering Handbook
Decisions (ADRs)
Design Docs & Plans
Roadmap
Operations
Meta

Canonical code & docs: main repo · Auto-generated companion: DeepWiki

Clone this wiki locally