What you’re building
| Resource | Description |
|---|---|
| App (Public) | Patient intake form at /intake — no login required |
| App (Role-gated) | Clinical triage board at /triage — clinical staff only |
| Workflow | Intake submission → PHI-aware risk classifier → conditional notification |
| Entity | patient — intake record with risk level |
| Setting | on_call_clinician_email |
| Integration | Postmark (email notifications) |
Step 1: Create the project
In AI Studio, click New Project. Name it Patient Intake v1.Step 2: Describe what you want
In chat:“I need a patient intake form that patients can fill out without logging in. It should collect their name, date of birth, chief complaint, and whether they have any known allergies. When they submit, an AI should classify the urgency as low, medium, or high. If high, page the on-call clinician immediately. The clinician should see a dashboard with all recent intakes sorted by urgency.”The system responds:
- Creates a
patiententity with fields:name,date_of_birth,chief_complaint,known_allergies,risk_level - Creates a Public app (intake form) at
/intake - Creates a Role-gated app (clinical triage board) at
/triagewith audience: clinical staff - Creates an intake workflow with trigger: form submission
- Compiles a workflow with steps: receive payload → PHI detection → risk classifier (AI inference) → conditional branch → notification
Step 3: Review the contract
Open the contract view (right panel). The intake workflow contract shows:Step 4: Add the Postmark integration
The system flags that a Postmark integration is needed. In chat:“Use Postmark for the email. I’ll add the API key now.”Go to Settings → Integrations → Add Integration → Postmark. Enter your API key. The integration is now available to the workflow.
Step 5: Configure the setting
In the Settings resource section, add:Step 6: Test the intake form
The center pane shows the live intake form running in sandbox mode. Fill it out:- Name: Jane Doe
- Date of birth: 1985-03-15
- Chief complaint: Severe chest pain radiating to left arm, shortness of breath
- Known allergies: Penicillin
Step 7: Inspect the trace
The trace shows:phi_scan— detected PHI inname,date_of_birth. Anonymized for inference.risk_classify— AI classifiedrisk_level: high(confidence: 0.97). Inference ran on anonymized payload; re-identified for record write.entity_write— patient record created. Record ID:pat_01JA7QG2...condition—risk_level == "high"→ truenotify_oncall— sandbox: “would have sent email to [email protected] with subject: High-risk intake: chest pain.”
Step 8: Test the triage board
Switch center pane to the triage app (/triage). The board shows the intake you just submitted, sorted by risk level, with the urgency badge visible. Click the record to see the full intake summary.
Step 9: Release
Click Release. Review:- Summary: “First release: patient intake form, clinical triage board, and high-risk notification workflow.”
- Diff: 2 new apps, 1 new workflow, 1 new entity (6 fields), 1 new integration, 1 new setting.
- No schema migrations needed (first release).
acme.usehasp.run/intake. The triage board is live at acme.usehasp.run/triage (access-controlled to clinical staff).
What happens in production
- A real patient submits the intake form.
- PHI detection scans the payload. PHI is anonymized before the AI inference call.
- The risk classifier runs. Output:
risk_level: high. - Patient record is written with
risk_level: high. PHI is stored encrypted in the entity record. - Postmark sends the real alert to
[email protected]. - The clinician opens the triage board. The new intake appears at the top, risk badge: High.
- The full trace is available in the audit log. PHI-redacted view for standard users; PHI-view role required for raw data.
Extending the example
Common follow-ons:- Add a follow-up workflow triggered when the clinician marks the intake as reviewed (data-change event on
patient.status). - Add a discharge summary workflow triggered on discharge — AI generates a summary and posts to the billing system.
- Add appointment scheduling — integration with a scheduling system, triggered after clinician review.
- Require 2 approvers for all releases — set in Settings → Release Policy (or as the org floor).