I'm writing a "simple" HL7 listener and then using the dcm4che
binary utility movescu
to make a query and retrieve operation from a remote PACS
I need to retrieve a Study and I have (00080050) AccessionNumber from the HL7 data, then I do the following:
./movescu -b LOCALAET@{local_ip}:044 -c REMOTEAET@{remote_ip}:104 --dest LOCALAET@{local_ip}:104 -m 00080050={known_accession_number}
with a remote PACS I am getting this:
(0000,0002) UI [1.2.840.10008.5.1.4.1.2.2.2] AffectedSOPClassUID
(0000,0100) US [32801] CommandField
(0000,0120) US [1] MessageIDBeingRespondedTo
(0000,0800) US [257] CommandDataSetType
(0000,0900) US [49152] Status
(0000,0902) LO [Error querying db (ImageRetrieve)] ErrorComment
(0000,1020) US [0] NumberOfRemainingSuboperations
(0000,1021) US [0] NumberOfCompletedSuboperations
(0000,1022) US [0] NumberOfFailedSuboperations
(0000,1023) US [0] NumberOfWarningSuboperations
And with a local Ginkgo I am getting:
17:12:58,906 DEBUG - LOCALAET->REMOTEAET(1): enter state: Sta6 - Association established and ready for data transfer
17:12:58,946 INFO - LOCALAET->REMOTEAET(1) >> A-ABORT[source: 0 - service-user, reason: 0]
17:12:58,946 INFO - LOCALAET->REMOTEAET(1): close Socket[addr=/XXX.XXX.X.XX,port=8080,localport=36105]
17:12:58,947 DEBUG - LOCALAET->REMOTEAET(1): enter state: Sta1 - Idle
movescu: Sta1 - Idle
org.dcm4che3.net.AssociationStateException: Sta1 - Idle
at org.dcm4che3.net.State.writeAReleaseRQ(State.java:223)
at org.dcm4che3.net.Association.release(Association.java:326)
at org.dcm4che3.tool.movescu.MoveSCU.close(MoveSCU.java:331)
at org.dcm4che3.tool.movescu.MoveSCU.main(MoveSCU.java:268)
(using different port on Ginkgo)
So what am I missing?
I do not know the Ginkgo PACS, but quite likely your retrieval fails because your request is malformed.
See PS3.4, C.4.2.1.4.1 Request Identifier Structure
Your request must include the attribute Query Retrieve Level (0008,0052) which I assume will be "STUDY" in your case since the Accession Number is a study-level attribute.
Furthermore it must contain
"Unique Key Attributes, which may include Patient ID (0010,0020), Study Instance UIDs (0020,000D), Series Instance UIDs (0020,000E), and the SOP Instance UIDs (0008,0018)"
That is, you have to specify the scope of your retrieve request by providing unique identifiers for the patient/study/series/image(s) you want to move - and nothing else!
So Accession Number may be used to query (C-FIND) for the corresponding Study Instance UID that you need for the C-MOVE. But it is not allowed in the C-MOVE-Request.
Caution: Whether or not you must include or omit the Patient-ID (0010,0020) in your C-MOVE request depends on the information model that you have negotiated during association establishment and that you select by choosing the presentation context for your message. You must include it in Patient Root, you must not include it in Study Root.