-- Adds the categorized forms directory (44 forms migrated from larcareservices.com/portal
-- across 4 batches) to the CMS-authored "portal" page (dim_web_pages, slug='portal') on the
-- LarCare site. The page's code-level fallback (LarCare/frontend/src/app/portal/page.tsx)
-- already lists these, but this CMS row takes priority over that fallback whenever it exists
-- (BlockRenderer renders layout_json directly) — so the code-only version never actually
-- rendered on the live site. Appends new richText blocks rather than replacing the row, so the
-- existing hero/intro/CTA blocks are preserved. Idempotent — guarded by block-id existence.
-- Deploy: mysql --default-character-set=utf8mb4 -u root -p db_abos_v0.1 < db/larcare_portal_page_forms_directory.sql

USE db_abos_v0.1;

SET @site_id = (SELECT id FROM dim_web_sites WHERE primary_domain = 'larcareservices.com' LIMIT 1);

UPDATE dim_web_pages
SET layout_json = JSON_ARRAY_APPEND(JSON_ARRAY_APPEND(JSON_ARRAY_APPEND(JSON_ARRAY_APPEND(JSON_ARRAY_APPEND(layout_json, '$.blocks', JSON_OBJECT('id', 'portal-forms-directory-heading', 'type', 'richText', 'props', JSON_OBJECT('html', '<h2 style="text-align:center">Forms</h2><p style="text-align:center">Every form staff and clients need, organized the same way as our internal portal.</p>'), 'children', JSON_ARRAY())), '$.blocks', JSON_OBJECT('id', 'portal-forms-category-1', 'type', 'richText', 'props', JSON_OBJECT('html', '<h3>Client / Patient</h3><ul><li><a href="/forms/patient-intake">Patient Information and Intake Form</a></li><li><a href="/forms/new-patient-checklist">New Patient Checklist</a></li><li><a href="/forms/va-rights-to-complain">Rights to Complain (Virginia)</a></li><li><a href="/forms/sc-rights-to-complain">Rights to Complain (South Carolina)</a></li><li><a href="/forms/client-rights-va">Client Rights (Virginia)</a></li><li><a href="/forms/personal-care-agreement">Client / Patient Personal Care Agreement</a></li><li><a href="/forms/va-advance-directives">Advance Directives (Virginia)</a></li><li><a href="/forms/sc-advance-directives">Advance Directives (South Carolina)</a></li><li><a href="/forms/private-pay-invoice-request">Request For Private Pay Invoice</a></li><li><a href="/forms/client-non-solicitation-agreement">Client Non Solicitation Agreement</a></li><li><a href="/forms/emergency-preparedness-plan">Emergency Preparedness Plan</a></li><li><a href="/forms/private-care-inquiry">Private Care Inquiry Form</a></li></ul>'), 'children', JSON_ARRAY())), '$.blocks', JSON_OBJECT('id', 'portal-forms-category-2', 'type', 'richText', 'props', JSON_OBJECT('html', '<h3>Caregivers / Contractors</h3><ul><li><a href="/forms/daily-tasksheet-report">Daily Tasksheet Report</a></li><li><a href="/forms/contractor-application">Contractor Application</a></li><li><a href="/forms/contractor-direct-deposit">Contractor Direct Deposit</a></li><li><a href="/forms/contractor-health-assessment">Contractor Health Assessment</a></li><li><a href="/forms/criminal-background-check-affirmation">Criminal Background Check and Sworn Statement of Affirmation</a></li><li><a href="/forms/drug-test-clearance-policy">Drug Test Clearance Policy</a></li><li><a href="/forms/tb-test">Tuberculosis (TB) Test Record</a></li><li><a href="/forms/caregiver-conduct-non-solicitation">Caregiver Conduct and Non Solicitation Agreement</a></li><li><a href="/forms/procedures-handbook-acknowledgment">Procedures/Handbook Acknowledgment</a></li><li><a href="/forms/address-license-verification">Address & Driver''s License Verification</a></li><li><a href="/forms/home-health-aide-performance-evaluation">Home Health Aide Performance Evaluation</a></li><li><a href="/forms/offer-letter-employment">Offer Letter of Employment</a></li><li><a href="/forms/employee-handbook-acknowledgment">Employee Handbook Acknowledgment</a></li><li><a href="/forms/contractor-w9">Contractor W9</a></li><li><a href="/forms/client-ack-aide-background-history">Client Acknowledgement of Aide''s Background History</a></li><li><a href="/forms/twelve-strike-policy">Twelve Strike Policy Acknowledgment</a></li><li><a href="/forms/competency-evaluation">Competency Evaluation Form</a></li><li><a href="/forms/photo-video-consent">Photo/Video Disclaimer and Consent</a></li><li><a href="/forms/substitute-aide-request">Substitute Aide Request</a></li><li><a href="/forms/call-out-time-off-request">Call Out or Request Time Off</a></li><li><a href="/forms/team-task-work-order">Team Task and Work Orders</a></li><li><a href="/forms/company-culture-awareness-sop">Company Culture Awareness SOP</a></li><li><a href="/forms/request-veteran-care">Request for Veteran Care</a></li></ul>'), 'children', JSON_ARRAY())), '$.blocks', JSON_OBJECT('id', 'portal-forms-category-3', 'type', 'richText', 'props', JSON_OBJECT('html', '<h3>Nurses</h3><ul><li><a href="/forms/nurse-site-visit-report-invoice">Nurse Site Visit Report and Invoice</a></li><li><a href="/forms/in-home-site-visit-report">In-Home Site Visit Report</a></li><li><a href="/forms/home-care-assessment">Home Care Assessment Form</a></li><li><a href="/forms/home-health-nurse-performance-evaluation">Home Health Nurse Performance Evaluation</a></li></ul>'), 'children', JSON_ARRAY())), '$.blocks', JSON_OBJECT('id', 'portal-forms-category-4', 'type', 'richText', 'props', JSON_OBJECT('html', '<h3>Operations / HR / Training</h3><ul><li><a href="/forms/background-check-result">Background Check Result</a></li><li><a href="/forms/orientation-training-tracking">Orientation Training Tracking Form</a></li><li><a href="/forms/skills-training-checkoff">Skills Training Check-Off List</a></li><li><a href="/forms/client-emergency-preparedness-document">Client Emergency Preparedness Document</a></li><li><a href="/forms/apprenticeship-request">Apprenticeship Request (Step 1)</a></li></ul>'), 'children', JSON_ARRAY()))
WHERE site_id = @site_id
  AND slug = 'portal'
  AND JSON_SEARCH(layout_json, 'one', 'portal-forms-directory-heading', NULL, '$.blocks[*].id') IS NULL;
