{
  "ursId": "URS-021",
  "title": "Warn users before submitting a duplicate Bill-Only order",
  "timestamp": "2026-04-23T03:38:09.990Z",
  "durationMs": 50465,
  "config": {
    "inboxUrl": "http://localhost:63274",
    "dbHost": "localhost",
    "dbPort": 63275,
    "dbName": "cc_repinbox_dev"
  },
  "setup": {
    "status": "pass"
  },
  "scenarios": [
    {
      "name": "Step 1: Rep logs in and opens /billing/new",
      "status": "pass",
      "description": "Step 1: Rep logs in and opens /billing/new",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-021-duplicate-order-warning/2026-04-23T03-38-09-989Z/screenshots/step-01-billing-new-step2.png"
      ],
      "explanation": "Logs in as Bob Kauffman (StellarTech rep) and opens /billing/new. Because Bob's organization has exactly one manufacturer partner (ZuriMED), +page.server.ts auto-selects the manufacturer and advances initialFormData.step to 2, so the form lands directly on the \"Surgery Details\" step. No duplicate warning appears yet because the sales account and procedure date fields are still empty — the duplicate check input builder returns null until both are filled.",
      "startedAt": "2026-04-23T03:38:18.428Z",
      "finishedAt": "2026-04-23T03:38:18.428Z",
      "videoPath": "/Users/jason/projects/casecohort/code/validation_test_results/urs-021-duplicate-order-warning/2026-04-23T03-38-09-989Z/videos/step-01-login.webm"
    },
    {
      "name": "Step 2: Duplicate warning appears",
      "status": "pass",
      "description": "Step 2: Duplicate warning appears",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-021-duplicate-order-warning/2026-04-23T03-38-09-989Z/screenshots/step-02-warning-visible.png"
      ],
      "explanation": "Selects BOSS Surgical Account Request and enters procedure date 2026-04-09 — the same (sales_account_id, procedure_date) pair used by the existing ZBO-2025-002 (status=submitted). The checkDuplicateBillingOrders remote query returns ZBO-2025-002, DuplicateCheckState.blocked flips to true, and DuplicateOrderWarning.svelte renders the amber \"Possible Duplicate Submission\" alert listing the existing order with a View affordance, an acknowledge button (\"This is not a duplicate — continue\"), and an \"Exit and review existing submissions\" link. The NavigationFooter's Next button is disabled because manager.stepBlocked propagates from DuplicateCheckState.blocked.",
      "startedAt": "2026-04-23T03:38:30.864Z",
      "finishedAt": "2026-04-23T03:38:30.864Z",
      "videoPath": "/Users/jason/projects/casecohort/code/validation_test_results/urs-021-duplicate-order-warning/2026-04-23T03-38-09-989Z/videos/step-02-warning-appears.webm"
    },
    {
      "name": "Step 3: Exit returns user to /billing",
      "status": "pass",
      "description": "Step 3: Exit returns user to /billing",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-021-duplicate-order-warning/2026-04-23T03-38-09-989Z/screenshots/step-03-billing-list-after-exit.png"
      ],
      "explanation": "Re-triggers the warning, then clicks the \"Exit and review existing submissions\" link — an <a href=\"/billing\"> that leaves the wizard without submitting anything. The user lands on /billing. validate-db.ts independently confirms that no new billing_orders row was persisted during the run, proving the cancel path is non-destructive.",
      "startedAt": "2026-04-23T03:38:44.296Z",
      "finishedAt": "2026-04-23T03:38:44.296Z",
      "videoPath": "/Users/jason/projects/casecohort/code/validation_test_results/urs-021-duplicate-order-warning/2026-04-23T03-38-09-989Z/videos/step-03-exit-and-review.webm"
    },
    {
      "name": "Step 4: Warning acknowledged, Next enabled",
      "status": "pass",
      "description": "Step 4: Warning acknowledged, Next enabled",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-021-duplicate-order-warning/2026-04-23T03-38-09-989Z/screenshots/step-04-acknowledged-state.png"
      ],
      "explanation": "Re-triggers the warning, then clicks \"This is not a duplicate — continue\". The DuplicateCheckState.acknowledge() method sets confirmedNotDuplicate=true, which flips DuplicateCheckState.blocked to false. The alert transitions to its green \"Reviewed — Not a Duplicate\" state with an Undo button, and the Next button becomes enabled — proving the form is unblocked and the rep can proceed through the remaining wizard steps.",
      "startedAt": "2026-04-23T03:38:57.958Z",
      "finishedAt": "2026-04-23T03:38:57.958Z",
      "videoPath": "/Users/jason/projects/casecohort/code/validation_test_results/urs-021-duplicate-order-warning/2026-04-23T03-38-09-989Z/videos/step-04-acknowledge.webm"
    }
  ],
  "dbValidations": [
    {
      "name": "ZBO-2025-002 still matches the duplicate-check criteria after the run",
      "query": "\n      SELECT id, order_number, status, procedure_date::text AS procedure_date, sales_account_id\n        FROM billing_orders\n       WHERE order_number = $1",
      "status": "pass",
      "rows": [
        {
          "id": "ba000002-0000-4000-8000-000000000002",
          "order_number": "ZBO-2025-002",
          "status": "submitted",
          "procedure_date": "2026-04-15",
          "sales_account_id": "fea7b8c9-d0e1-2345-0123-456789012345"
        }
      ],
      "assertion": "ZBO-2025-002 must still have status=\"submitted\", procedure_date=\"2026-04-15\", sales_account_id=\"fea7b8c9-d0e1-2345-0123-456789012345\" (BOSS Surgical Account Request)."
    },
    {
      "name": "Cancel path did not persist a new billing_orders row",
      "query": "\n      SELECT COUNT(*)::int AS cnt\n        FROM billing_orders\n       WHERE sales_account_id = $1\n         AND procedure_date = $2",
      "status": "pass",
      "rows": [
        {
          "cnt": 1
        }
      ],
      "assertion": "Count of billing_orders at (sales_account_id=fea7b8c9-d0e1-2345-0123-456789012345, procedure_date=2026-04-15) must not increase during the run (baseline=1)."
    },
    {
      "name": "A duplicate-check-qualifying row still exists for the test (account, date)",
      "query": "\n      SELECT id, order_number, status, procedure_date::text AS procedure_date\n        FROM billing_orders\n       WHERE sales_account_id = $1\n         AND procedure_date = $2\n         AND status = ANY($3::text[])",
      "status": "pass",
      "rows": [
        {
          "id": "ba000002-0000-4000-8000-000000000002",
          "order_number": "ZBO-2025-002",
          "status": "submitted",
          "procedure_date": "2026-04-15"
        }
      ],
      "assertion": "At least one billing_orders row at (sales_account_id=fea7b8c9-d0e1-2345-0123-456789012345, procedure_date=2026-04-15) must have status in BILLING_ORDER_RULES.DUPLICATE_CHECK_STATUSES (submitted, processing, po_missing, billed, completed) — otherwise the duplicate-warning query returns zero rows and the UX silently stops firing. ZBO-2025-002 is expected to satisfy this."
    }
  ],
  "overallStatus": "pass",
  "outputDir": "/Users/jason/projects/casecohort/code/validation_test_results/urs-021-duplicate-order-warning/2026-04-23T03-38-09-989Z",
  "auditStartTime": "2026-04-23T03:38:08.095Z",
  "auditEventEvidence": [
    {
      "createdAt": "2026-04-23T03:38:14.253Z",
      "eventType": "user_log",
      "action": "user:login",
      "userEmail": "bob.kauffman@stellartech.com",
      "userId": "17b8c9d0-e1f2-3456-1234-567890123456",
      "organizationName": "StellarTech Medical Solutions",
      "organizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "objectId": null,
      "secondaryObjectId": null,
      "payload": {
        "email": "bob.kauffman@stellartech.com"
      },
      "route": "/login",
      "traceId": "00000000000000000000000000000000"
    },
    {
      "createdAt": "2026-04-23T03:38:22.974Z",
      "eventType": "user_log",
      "action": "user:login",
      "userEmail": "bob.kauffman@stellartech.com",
      "userId": "17b8c9d0-e1f2-3456-1234-567890123456",
      "organizationName": "StellarTech Medical Solutions",
      "organizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "objectId": null,
      "secondaryObjectId": null,
      "payload": {
        "email": "bob.kauffman@stellartech.com"
      },
      "route": "/login",
      "traceId": "00000000000000000000000000000000"
    },
    {
      "createdAt": "2026-04-23T03:38:35.907Z",
      "eventType": "user_log",
      "action": "user:login",
      "userEmail": "bob.kauffman@stellartech.com",
      "userId": "17b8c9d0-e1f2-3456-1234-567890123456",
      "organizationName": "StellarTech Medical Solutions",
      "organizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "objectId": null,
      "secondaryObjectId": null,
      "payload": {
        "email": "bob.kauffman@stellartech.com"
      },
      "route": "/login",
      "traceId": "00000000000000000000000000000000"
    },
    {
      "createdAt": "2026-04-23T03:38:49.486Z",
      "eventType": "user_log",
      "action": "user:login",
      "userEmail": "bob.kauffman@stellartech.com",
      "userId": "17b8c9d0-e1f2-3456-1234-567890123456",
      "organizationName": "StellarTech Medical Solutions",
      "organizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "objectId": null,
      "secondaryObjectId": null,
      "payload": {
        "email": "bob.kauffman@stellartech.com"
      },
      "route": "/login",
      "traceId": "00000000000000000000000000000000"
    }
  ],
  "auditQuery": "SELECT\n    ae.created_at,\n    ae.event_type,\n    ae.action,\n    ae.user_id,\n    u.email AS user_email,\n    ae.organization_id,\n    o.name AS organization_name,\n    ae.object_id,\n    ae.secondary_object_id,\n    ae.payload,\n    ae.route,\n    ae.trace_id\n  FROM audit_events ae\n  LEFT JOIN users u ON u.id = ae.user_id\n  LEFT JOIN organizations o ON o.id = ae.organization_id\n  WHERE ae.created_at >= $1\n    AND ae.organization_id = ANY($2::uuid[])\n  ORDER BY ae.created_at ASC",
  "auditAssertions": [],
  "emailAssertions": []
}