PDF & Document Pipeline
Overview
Document handling is one of the core workflows. NHC requires employees and clients to complete, sign, and store numerous compliance documents.
Flow
1. Admin assigns a Form to a User (creates a JobForm record)
2. User opens the form in portals
a. FILLABLE: SPA renders fields → user fills → submits JSON payload
b. UPLOAD: user uploads a scanned/external PDF
3. django-api receives submission
a. FILLABLE: WeasyPrint renders HTML template + data → PDF → upload to S3
b. UPLOAD: file stored directly to S3
4. If signature required: pyHanko applies a digital signature to the PDF
5. ComplianceDocument record updated with S3 key + status
6. Admin can review, approve, or request resubmissionStorage
All files live on AWS S3. The S3 key pattern is:
organizations/{org_id}/users/{user_id}/{document_type}/{filename}Presigned URLs are generated on-demand by the API for secure, time-limited access.
Key Libraries
| Library | Purpose |
|---|---|
WeasyPrint | HTML → PDF rendering |
pyHanko | Digital signatures (PAdES standard) |
PyPDF2 | PDF merging / manipulation |
django-storages + boto3 | S3 file backend |
Adding a New Form Template
- Create an HTML template in
novahomecareapi/templates/forms/. - Register a
Forminstance via Django admin (setform_type=FILLABLE, link the template). - Define the field schema (JSON) on the
Form. - Assign to users via the portals UI or directly via API.
Document Categories
Client Documents
Documents are split by admission type:
| Admission Type | Documents | Notes |
|---|---|---|
| HCC (Home Care Client) | 7 admission docs | All have validation rules |
| HHP (Home Health Patient) | 10 admission docs | 2 are admin-only manual uploads |
| Both | 6 docs added in v5.0.0 | |
| Compliance (v5.1.0) | 5 new types | Dual-signature: client then Case Manager — see Compliance Documents |
Additional slots: Other Documents (3), Miscellaneous (1), Client Admissions Files (single upload, up to 500 MB).
Employee Documents
| Category | Applies to | Notes |
|---|---|---|
| Application Documents | All applicants (HC + HH) | 8 docs |
| Home Care Onboarding | HC employees | 23 docs |
| HH Onboarding — Role-specific | Each HH role | Job Description, Job Acceptance Statement, Provisional Hiring Agreement — one set per role (RN/LPN/CNA/HHA/PT/OT/SLP/MSW) |
| HH Onboarding — Policy docs | All HH roles | 6 shared policy documents |
| v5.0.0 additions | Both HC + HH | 13 new employee docs |
| Competency Checklist | RN, LPN, CNA, HHA | Role-specific; PT/OT/SLP/MSW are N/A |
| Annual Competency Checklist | CNA, HHA | Simplified 25-item renewal |
| Drug Test | CNA, HHA only | |
| E-Verify | All | |
| Termination / Exit | All | 2 docs |
| Proof of Vehicle Insurance | All | |
| Miscellaneous | All |
See Employee Documents & Onboarding for the full role matrix, template variables, and policy details.
Template Variables (Key Notes)
- Job Acceptance Statement:
{employee_name},{employee_position},{service_start_date},{organization_name},{salary},{hourly_rate},{effective_date},{service_start_day} - Provisional Hiring Agreement:
{employee_name},{employee_positon}(typo in source template — "positon" not "position"),{service_start_date}
When building PDF merge logic, match variable names exactly as they appear in the templates.