Logic review: Web API call when a study is complete

I’m ultimately looking for Orthanc to make an API call to my application once a study has been successfully received and I’m looking for a little bit of logic confirmation on what I’ve been working on so far. This is also my first foray into using Lua, so bear with me!

My API needs to record the AET that the study came from and Orthanc’s AET it was sent to.

Logic

  1. Orthanc is configured with
    1. DicomCheckCalledAet : false. This puts Orthanc into promiscuous mode, allowing me to effectively have an unlimited set of AETs that Orthanc will respond to (Orthanc doesn’t check the calling partys’ AET or the AET that they called Orthanc with - it just accepts all connections)
    2. StableAge : 60. From my understanding, if a study doesn’t receive any more instances after this number of seconds, it’s deemed to be complete.
  2. From what I can see, the only way of obtaining the AET information is through Lua’s OnStoredInstance() function, as OnStoredStudy() doesn’t appear to have the origin property available to it.
  3. Once the an instance is stored, I have its InstanceID, which I then use to make an internal API call to /instances/instance_UID to obtain the parent SeriesID
  4. Another internal API call is immediately made to /series/series_UID to obtain the parent StudyID
  5. A final internal API call is made to /study/study_UID to obtain the IsStable status of the study itself.
  6. If the study is stable then I can notify my application using a technique similar to Alain’s excellent example.
    Questions
    If all this logic kinda makes sense, can I ask for confirmation on a couple of questions / assumptions that I’m making:
  7. OnStoredInstance() is the only function that I can use to obtain the AET information (referred to in Logic #2)
  8. There’s no single API call, using an instance UID to obtain it’s parent’s study status - I have to find the instances’ parent series, then that series’ parent study.
  9. Am I missing anything?!! :O)

Thanks to all,

Dave

Hello Dave,

My API needs to record the AET that the study came from and Orthanc’s AET it was sent to.

The origin AET is only available at the instance level, because different instances from a study could come from different sources.

OnStoredInstance() is the only function that I can use to obtain the AET information (referred to in Logic #2)

No, the origin AET is also available in the “RemoteAET” metadata associated with the instance, which can be accessed using the REST API:
https://book.orthanc-server.com/faq/features.html#core-metadata

For instance on our demo server (“RemoteAET” is not available in this sample call because the instances were uploaded using the REST API):

$ curl https://demo.orthanc-server.com/instances/be338e79-1c3b0033-f250392d-ab4d437a-7f13730e/metadata?expand
{
“HttpUsername” : “orthanc”,
“IndexInSeries” : “171”,
“Origin” : “RestApi”,
“ReceptionDate” : “20200803T131236”,
“RemoteAET” : “”,
“RemoteIP” : “172.17.0.1”,
“SopClassUid” : “1.2.840.10008.5.1.4.1.1.2”,
“TransferSyntax” : “1.2.840.10008.1.2”
}

There’s no single API call, using an instance UID to obtain it’s parent’s study status - I have to find the instances’ parent series, then that series’ parent study.

You can use the “/instances/{…}/study” route in the REST API, then check the value of the “IsStable” field. For instance on our demo server:

$ curl https://demo.orthanc-server.com/instances/be338e79-1c3b0033-f250392d-ab4d437a-7f13730e/study
{
“ID” : “1c379a23-9fd28bba-02b60e5b-850ff34e-4349f09b”,
“IsStable” : true,
[…]

Check out the reference of the REST API for more information:

https://api.orthanc-server.com/#tag/Instances/paths/~1instances~1{id}~1study/get

HTH,
Sébastien-

Dave,
As Sebastien noted, that is what I do, on isStable I send a REST API, then have the receiver query Orthanc for the AET. An extra step but works and have not had an issue.