# Phase 10.6.3 — Review Workflow UI Validation + Oracle Persistence QA

## Purpose
This phase closes the gap after Phase 10.6.2.1 where Oracle storage was installed successfully but no audit rows existed yet because no review save had been executed.

## Confirmed prerequisite
The previous storage check must show:

```text
Review storage: oracle
main_table     | DASH_EXEC_ACTION_REVIEW       | found
audit_table    | DASH_EXEC_ACTION_REVIEW_AUDIT | found
active_storage | oracle
```

## What changed

1. Fixed the Oracle save path so the review row and audit row are written through the shared Database transaction helper.
2. Added per-action audit history retrieval from Oracle and JSON fallback.
3. Added audit history timeline inside `index.php?page=action-review&action=...`.
4. Added `public/executive-action-review-workflow-qa.php` with PASS/PENDING gates.
5. Added `tools/E15_H1063_Review_Workflow_QA.ps1` to generate a repeatable evidence folder.
6. Updated the Action Center quick tools with `Review QA`.

## Important bug fixed
`ExecutiveActionReviewRepository::saveOracle()` previously called:

```php
$pdo = Database::connection($this->hospitalCode);
$pdo->beginTransaction();
```

But `Database::connection()` returns a connection metadata array, not a raw PDO object. This would fail during the first actual review save even though read-only storage checks passed.

Phase 10.6.3 now uses:

```php
Database::executeTransaction($hospitalCode, [...]);
```

This keeps the main review row and audit row atomic for PDO_OCI, OCI8, and ODBC.

## Manual UI test

1. Open Action Center:

```text
http://localhost/public/index.php?page=action-center&lang=en
```

2. Open any `Review workflow` action.
3. Change status or add a note.
4. Save.
5. The same review page should show `Oracle Audit History` with at least one row.
6. Run:

```text
http://localhost/public/executive-action-review-workflow-qa.php?hospital=njch
```

Expected gates:

```text
[PASS] active_storage_is_oracle
[PASS] main_table_found
[PASS] audit_table_found
[PASS] worklist_has_actions
[PASS] audit_rows_exist_for_day
[PASS] selected_action_audit_history
```

If no save has happened yet, audit gates may be `PENDING`, which is expected.

## Optional automated write proof

Set one of these in `.env`:

```text
EXEC_ACTION_REVIEW_QA_TOKEN=change-this-token
```

or reuse:

```text
EXECUTIVE_REFRESH_TOKEN=change-this-token
```

Then run:

```powershell
powershell -ExecutionPolicy Bypass -File tools\E15_H1063_Review_Workflow_QA.ps1 -BaseUrl http://localhost -Hospital njch -WriteTest -Token "change-this-token"
```

This writes one controlled review save against the selected/current action and produces evidence files.

## Evidence script without write

```powershell
powershell -ExecutionPolicy Bypass -File tools\E15_H1063_Review_Workflow_QA.ps1 -BaseUrl http://localhost -Hospital njch
```

This does not modify data. It only records the current state.

## Files changed

```text
app/Core/Database.php
app/Repositories/ExecutiveActionReviewRepository.php
app/Repositories/ExecutiveActionRepository.php
app/Controllers/ActionCenterController.php
app/Views/action_center/index.php
app/Views/action_center/review.php
public/assets/css/action-center.css
public/executive-action-review-check.php
public/executive-action-review-storage-check.php
public/executive-action-review-workflow-qa.php
tools/E15_H1063_Review_Workflow_QA.ps1
docs/phase10_6_3_review_workflow_qa.md
```
