> ## Documentation Index
> Fetch the complete documentation index at: https://hmis-docs.derrickmugabwa.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# End-to-end testing

> Validate the complete HMIS, OIE, PACS, modality, and viewer workflow.

## Start and verify the stack

From the HMIS project directory:

```powershell theme={null}
docker compose -f docker-compose.yml -f docker-compose.local.yml up -d
docker compose -f docker-compose.yml -f docker-compose.local.yml ps
```

Confirm HMIS, its queue worker, OIE, Orthanc, OHIF, and the mock modality are running.

## Acceptance flow

<Steps>
  <Step title="Create and bill a mapped radiology order">
    Create a Chest X-Ray or another mapped radiology service. After billing, confirm the requisition is `open` and record its accession number.
  </Step>

  <Step title="Confirm automatic worklist publication">
    Wait for the Laravel database queue. In OIE, confirm `HMIS Radiology Worklist Lookup` processed the publication and both destinations succeeded.
  </Step>

  <Step title="Query the PACS from the modality">
    Open `http://localhost:8091`, enter the accession, and run the DICOM MWL query. Confirm the returned patient and procedure match the HMIS order.
  </Step>

  <Step title="Mark the examination pending">
    In HMIS, select **Mark pending** and confirm the requisition status changes to `pending`.
  </Step>

  <Step title="Transmit a deidentified DICOM image">
    Load the sample, select the worklist item, and transmit it to `HMIS_PACS` on port `4242`.
  </Step>

  <Step title="Wait for the stable-study event">
    Orthanc normally declares the study stable after its configured stable age. With a five-second OIE poll interval, allow approximately 60–90 seconds in the demo.
  </Step>

  <Step title="Verify the HMIS study link">
    Confirm `Orthanc Stable Study Poller` and `PACS Study Events Relay` succeeded. The requisition should expose **View images** but should remain `pending`.
  </Step>

  <Step title="Open OHIF">
    Select **View images** in HMIS and confirm OHIF loads the study using its Study Instance UID.
  </Step>

  <Step title="Report and authorize">
    Enter the report to change the requisition to `completed`, then authorize it to change it to `authorized`.
  </Step>
</Steps>

## Safety and idempotency checks

* Replay the identical study event and confirm HMIS reports `duplicate` without creating another study.
* Reuse a message ID with a changed payload and confirm a conflict.
* Send an unknown accession and confirm quarantine.
* Send a study before **Mark pending** and confirm quarantine.
* Attempt to link a second PACS study to the same examination and confirm quarantine.
* Confirm study linking does not change `pending` to `completed`.

## Evidence to retain

For every PACS pilot, retain sanitized evidence of the worklist response, modality association, C-STORE outcome, PACS study, OIE message history, HMIS integration audit, viewer launch, and final report status.
