# Patient History Report with Barcode Integration

This plan addresses the requirement to create patient reports that include a barcode (unique to each patient) and list **all past records** of the patient.

## Proposed Changes

We will introduce a new "Full Patient History" report that lists all past bookings / test history for a single patient, and includes a dynamically generated barcode representing their unique `UHID`. We will also add the barcode to the normal Lab Reports.

### 1. New File: `admin/patient_history_report.php`
- Create a new printable report page similar to the regular `generate_report.php`.
- The report will fetch the complete clinical timeline (all past bookings, tests, and statuses) for a given `patient_id`.
- The report will use a JavaScript barcode library (`JsBarcode`) to automatically draw a barcode corresponding to the patient's `uhid` at the top of the document.

### 2. Update File: `admin/patients.php` (Patient 360 View)
- In the "Patient 360" modal where a patient's timeline is currently shown, we will add a new button: **<i class="bi bi-printer"></i> Print Full History**.
- Clicking this button will open the `patient_history_report.php?id=...` in a new tab for printing.

### 3. Update File: `admin/generate_report.php` & `lab_admin/generate_report.php`
- Add the patient's unique barcode to the standard Lab Report.
- Use `JsBarcode` to generate it automatically matching the `uhid`.

## Open Questions

> [!IMPORTANT]
> **Clarification Needed on the Scope**
> 1. Should we create a **new "Full History" Print Report** that shows all past testing history for a patient (which sounds like what you requested), OR did you want me to list all past records at the bottom of the *standard* Lab Result Report (`generate_report.php`)?
> 2. For the barcode, is using the patient's **UHID (Unique Health ID)** as the barcode value ideal?
> 3. Are there specific past details (like amount paid, doctor assigned) you want omitted from the printable history?

## Verification Plan

### Automated Tests
- None required.

### Manual Verification
1. Open Patient Registry (`admin/patients.php`).
2. Open a patient's "Patient 360" modal and click "Print Full History".
3. Verify that the printable report displays a valid, scannable Barcode, the patient's demographics, and the chronological list of all previous tests/records.
4. Open the regular Lab Report (`generate_report.php`) and ensure the barcode is visible and correctly functioning there as well.
