Prefetching Orhtanc pancs to AW server

Hello,
I am a radiologist and my computer skills are average.
I’m looking for a solution for prefetching. I installed Orhtanc as a PACS and I view the exams on an AW server (GE) client.
Is it possible for Orhtanc to search the history of the same patient’s ID and push all the old exams directly to the AW server when it receives a new study?
Thank you very much.

Hi @Relam,

A while ago, I made this sample that implements prefetching but, in this sample, Orthanc is acting as a middleman between a PACS and a Workstation. So you’ll have to adapt the lua script to your use case.

If you need support to adapt the script and configure your system, there are a bunch of professionals who can provide support.

Hope this helps,

Alain.

Hello,

The following simple Python script will forward all the studies of the same patient upon receiving a stable study (to a modality whose symbolic name is local1_dicom, in this case). This includes the study just received.

This is done synchronously, without a job, and there is no error handling, so this is clearly not production-ready.

HTH


import json
import orthanc

def OnStableStudy(study_id: str):

    study_data = json.loads(orthanc.RestApiGet(f"/studies/{study_id}"))

    orthanc.LogInfo(f"TRANSFER_20250401: {study_data=}")
   
    patient_uuid = study_data["ParentPatient"]

    orthanc.LogInfo(f"TRANSFER_20250401: study_id: {study_id=} belongs to {patient_uuid=}")

    payload = {
        "Resources": [patient_uuid]
    }

    orthanc.LogInfo(f"TRANSFER_20250401: About to POST to /store with {payload=}")

    try:
        store_response = json.loads(orthanc.RestApiPost("/modalities/local1_dicom/store", json.dumps(payload)))
        orthanc.LogInfo(f"TRANSFER_20250401: {store_response=}")
    except Exception as exc:
        orthanc.LogError(f"TRANSFER_20250401: Error storing patient {payload=}: {exc=}")


def OnChange(changeType, level, resource):
    if changeType == orthanc.ChangeType.STABLE_STUDY:
        orthanc.LogInfo(f"STABLE_STUDY: {resource=}")
        OnStableStudy(resource)

orthanc.RegisterOnChangeCallback(OnChange)