OPENINTAKE 2.1.0
Patient forms on the patient's phone, delivered to your front desk
=====================================================================
Made by Bobker Labs. Questions: hello@bobkerlabs.com

WHAT THIS IS
Patients fill in your clinic's forms on their own phone. The form page
sends each finished, signed PDF to one computer at your front desk. Staff
sign in with their own name, open each form, add it to the patient's
chart, and mark it filed. Patient forms are kept on that computer only.

This folder is the OpenIntake relay: the small program on the front-desk
computer that receives the forms and shows them to your staff.

Bobker Labs normally installs OpenIntake with you on a short call and
sets up your form page at the same time. You do not need to do the steps
below alone.

WHAT YOU NEED
- One Windows 10 or Windows 11 computer at the front desk that stays on
  during clinic hours. Use the Windows account that stays signed in at
  the desk when you install.
- Node.js 22 LTS (free, from nodejs.org). Version 16 or newer works.
- Tailscale (free app, tailscale.com). It carries finished forms from the
  internet to this computer without opening your clinic network. Bobker
  Labs adds this computer to its Tailscale network and pays for it.
- BitLocker turned on for the drive where forms are saved (see below).

INSTALL, STEP BY STEP
1. Install Node.js 22 LTS: open nodejs.org, click the LTS download, run
   it, and click Next until it finishes. Keep the default choices.
2. Download OpenIntake-Setup-2.1.0.zip.
3. Open your Downloads folder, right-click the zip, choose "Extract All",
   then click "Extract". A folder named openintake-relay appears.
4. Click Start, type PowerShell, right-click "Windows PowerShell" and
   choose "Run as administrator". Click Yes.
5. Paste this line (right-click pastes), then press Enter. Put your own
   practice and location names between the quotes:

   powershell -NoProfile -ExecutionPolicy Bypass -File "$env:USERPROFILE\Downloads\OpenIntake-Setup-2.1.0\openintake-relay\install.ps1" -ClinicName "Your Practice Name" -SiteName "Main Street"

   If Windows says the file cannot be found, open the extracted folder,
   find install.ps1, hold Shift, right-click it, choose "Copy as path",
   and paste that path in place of the one in quotes above.
6. The installer copies OpenIntake to C:\OpenIntake, starts it, and adds
   two Windows startup tasks named "OpenIntake" and "OpenIntake Watchdog"
   so it starts again after a restart. It prints a report between two
   green lines. Copy that report and send it to Bobker Labs.
7. On the same computer, open Chrome and go to:
      http://localhost:8080/setup
   Type the practice name, the location name, your own name, a username
   and a password. That creates the administrator account.
8. Click "Users" and add each staff member by name. Each person gets a
   temporary password and chooses their own on first sign-in.

You will know it worked when http://localhost:8080/staff shows the
sign-in page with your practice name at the top.

CONNECT YOUR FORM PAGE
A new install accepts no forms until your form page is allowed to send
them. Until then the staff page says "Online forms are not connected yet".
Bobker Labs does this step with you. To do it yourself, open PowerShell
on this computer and run (with your own form page address, no slash at
the end):
   cd C:\OpenIntake
   node server.js allow-origin https://your-clinic-forms.pages.dev
It prints ALLOWED. Then restart the computer.
(The address goes into "allowedOrigins" in settings.json. Running the
installer again with -FormSite https://your-clinic-forms.pages.dev does
the same and restarts OpenIntake for you.)

EVERYDAY USE
  Staff page on this computer:   http://localhost:8080/staff
  Staff page on another computer in the clinic:
                                 http://<this computer's name>:8080/staff
  Everyone is signed out after 15 minutes without activity.
  Forgot password: an admin clicks "Reset password" next to the name.

IF THE ADMINISTRATOR IS LOCKED OUT
On this computer, open PowerShell and run (use your own username in
place of jsmith):
  cd C:\OpenIntake
  node server.js reset-admin jsmith
It prints a temporary password. Sign in with it and choose a new one.

OTHER CHECKS (run in C:\OpenIntake)
  node server.js verify-audit       is the audit log untouched?
  node server.js check-encryption   is the forms drive encrypted?
  node server.js version

HOW OPENINTAKE STARTS
The scheduled tasks "OpenIntake" (at sign-in) and "OpenIntake Watchdog"
(every 5 minutes) run openintake-watchdog.vbs. If nothing answers on
port 8080, it starts the relay in the background with no window.
An upgrade keeps the folder and startup tasks that are already in place.
Test the watchdog without starting anything:
  cscript //Nologo "C:\OpenIntake\openintake-watchdog.vbs" /check

WHERE THINGS ARE KEPT (all inside C:\OpenIntake unless settings.json
says otherwise)
  submissions\           the patient PDFs
  submissions\.removed   forms taken off the list as junk (never deleted)
  data\                  staff accounts (passwords kept only as one-way
                         hashes), the audit log and the form index
  settings.json          settings (no passwords in it)
  relay-console.log      the relay's own messages (form numbers, never
                         patient names)
  server.js, lib\        the program
  last-install.json      what the last install did (used by rollback)
  _backup_v2_<date>\     an earlier version replaced by an upgrade
  _rolled_back_<date>\   a newer version set aside by rollback

TURN ON BITLOCKER AND KEEP A BACKUP
- BitLocker encrypts the drive, so a stolen computer does not expose
  patient forms. Windows Pro: Start, type "Manage BitLocker", click
  "Turn on BitLocker". Save the recovery key somewhere off this
  computer (print it and keep it locked away). The top of the staff page
  says whether encryption is on.
- Back up the submissions and data folders to an encrypted USB drive or
  another encrypted place on a schedule. Without a backup, a failed disk
  loses every form that has not been filed in the chart yet.

GO BACK TO THE PREVIOUS VERSION
From an administrator PowerShell window, paste:
  powershell -NoProfile -ExecutionPolicy Bypass -File "C:\OpenIntake\rollback.ps1"
After an upgrade, this puts the previous version back. Patient forms,
accounts and the audit log are not touched.

REMOVE OPENINTAKE
Run the same rollback line on a computer where OpenIntake was a new
install. It stops OpenIntake and removes its two startup tasks. Patient
forms, accounts and the audit log stay in C:\OpenIntake. Move or file
them first, then delete the folder yourself. Tell Bobker Labs so the
computer is taken off the Tailscale network.

WHAT THIS SOFTWARE HANDLES, AND WHAT STAYS WITH THE PRACTICE
Handles: individual sign-ins, automatic sign-out, a tamper-evident record
of who opened which form, encrypted transport from the patient's phone to
this computer, staff pages closed to the internet, a warning if the disk
is not encrypted.
Stays with the practice: turning on BitLocker and encrypting the backup,
deciding who gets an account and removing people who leave, reviewing
the audit log, the HIPAA risk assessment and policies, and how long forms
are kept after they are filed in the chart.
Once a week, an admin should write down the "Latest entry" number and
fingerprint shown at the bottom of the Audit log page. Someone with full
control of this computer could rewrite the whole log; only a copy kept
off the computer can prove it was not.

NEVER
- Never publish the staff pages with Tailscale Funnel. Only this exact
  command is correct (it publishes the form drop-off and nothing else):
    tailscale funnel --bg --set-path=/api/submit http://127.0.0.1:8080/api/submit
- Never use Funnel's "--tcp" or "--tls-terminated-tcp" options for port 8080.
