MAGDQR00 ;WOIFO/EdM,BT - Imaging RPCs for Query/Retrieve ; 04/05/2006 08:43
 ;;3.0;IMAGING;**51,54,118**;Mar 19, 2002;Build 4525;May 01, 2013
 ;; Per VHA Directive 2004-038, this routine should not be modified.
 ;; +---------------------------------------------------------------+
 ;; | Property of the US Government.                                |
 ;; | No permission to copy or redistribute this software is given. |
 ;; | Use of unreleased versions of this software requires the user |
 ;; | to execute a written test agreement with the VistA Imaging    |
 ;; | Development Office of the Department of Veterans Affairs,     |
 ;; | telephone (301) 734-0100.                                     |
 ;; | The Food and Drug Administration classifies this software as  |
 ;; | a medical device.  As such, it may not be changed in any way. |
 ;; | Modifications to this software may result in an adulterated   |
 ;; | medical device under 21CFR820, the use of which is considered |
 ;; | to be a violation of US Federal Statutes.                     |
 ;; +---------------------------------------------------------------+
 ;;
 Q
 ;
 ; Query/Retrieve
 ;
 ; Step 1: The application (Java system) receives a C-FIND request
 ;
 ; Step 2: The application interprets the DICOM message and
 ;         calls an RPC on traditional VistA
 ;
 ;           RPC name: MAG CFIND QUERY
 ;             input:  array of:    tag | VR | flag | value
 ;             input:  scalar:      batch-identifier, see below
 ;             input:  scalar:      max # entities in response
 ;             output: array of:    header = # entities total | # in current batch
 ;                    followed by   tag | VR | flag | value
 ;                             or   <start sequence>
 ;                             or   <end sequence>
 ;
 ;          Batch-identifier:
 ;          There are four kinds of calls:
 ;           1. initial call
 ;              value of this parameter is "0"
 ;              RPC will create result-set and start a background process to
 ;              perform the query
 ;           2. "are you ready" call
 ;              value of this parameter is "n|0"
 ;              where 'n' identifies the result-set
 ;              RPC will check if the query is ready and, when available, will
 ;              return "initial batch" of responses
 ;           3. continuation call
 ;              value of this parameter is "n|m"
 ;              where 'n' identifies the result-set
 ;              where 'm' identifies the sequence
 ;              number of the first item to be returned RPC will return
 ;              next batch of responses
 ;           4. final call
 ;              value of this parameter is "n|-1"
 ;              where 'n' identifies the result-set
 ;              RPC will not return any responses but clean-up any storage used
 ;              for result-set
 ;
 ;          Suggested values for second parameter:
 ;            0 for initial call
 ;           -1 for final call
 ;           >0 (sequence number of first entity to be returned)
 ;              for continuation call
 ;          Result-set will also have a "time stamp of last access"
 ;          so that an overall clean-up process can get rid of
 ;          obsolete result-sets.
 ;
 ; Step 3: The application interprets the results from the RPC
 ;         and will ask VistA which images belong to a
 ;         study-UID:
 ;
 ;           RPC name: MAG STUDY UID QUERY
 ;             input:  scalar       study uid
 ;             input:  scalar       flag: include routed copies in result
 ;             input:  scalar       "my location" identifier
 ;             output: array of:    header = # of entities in response
 ;                                  image# | path+file name | username | password
 ;
 ;         Do we want to return the username and password in each
 ;         result, or do we want two separate RPC calls: one to
 ;         get path+filename for each file, and one that returns
 ;         the username and password given a path?
 ;
 ; Step 4: The application will create new DICOM entities to transmit
 ;         to its client. It has the information to access the
 ;         image files that exist on VistA (either .dcm files or
 ;         .txt + .tga pairs). It needs to ask VistA for the
 ;         current and correct information to place in the headers
 ;         of the DICOM entities to be transmitted:
 ;
 ;           RPC name: MAG IMAGE CURRENT INFO
 ;             input:  scalar       image #
 ;             output: array of:    header = # of entities in response
 ;                                  tag | VS | flag | value
 ;
 ;         Do we need an additional input array to specify the
 ;         list of data-fields to be returned?
 ;
 ; Non-supported tags for Query/Retrieve
 ; 0008,1110  O  Referenced Study Sequence
 ; 0008,1150  O  >Referenced SOP Class UID
 ; 0008,1155  O  >Referenced SOP Instance UID
 ; 0008,1120  O  Referenced Patient Sequence
 ; 0008,1150  O  >Referenced SOP Class UID
 ; 0008,1155  O  >Referenced SOP Instance UID
 ; 0010,1020  O  Patient's Size   [field not populated]
 ; 0010,1030  O  Patient's Weight [field not populated]
 ; 0020,1070  O  Other Study Numbers
 ; 0020,1200  O  Number of Patient Related Studies
 ; 0020,1202  O  Number of Patient Related Series
 ; 0020,1204  O  Number of Patient Related Instances
 ;
 ; Supported tags
 ; 0008,0020  R  Study Date
 ; 0008,0030  R  Study Time
 ; 0008,0050  R  Accession Number
 ; 0010,0010  R  Patient's Name
 ; 0010,0020  R  Patient ID
 ; 0020,0010  R  Study ID
 ; 0020,000D  U  Study Instance UID
 ; 0008,0018  U  Image Instance UID
 ; 0020,000E  U  Series Instance UID
 ;
 ; 0008,0061  O  Modalities in Study
 ; 0008,0090  O  Referring Physician's Name
 ; 0008,1030  O  Study Description
 ; 0008,1032  O  Procedure Code Sequence
 ; 0008,0100  O  >Code Value
 ; 0008,0102  O  >Coding Scheme Designator
 ; 0008,0103  O  >Coding Scheme Version
 ; 0008,0104  O  >Code Meaning
 ; 0008,1060  O  Name of Physician(s) Reading Study
 ; 0010,0030  O  Patient's Birth Date
 ; 0010,0032  O  Patient's Birth Time [probably always blank]
 ; 0010,0040  O  Patient's Sex
 ; 0010,1000  O  Other Patient IDs
 ; 0010,1001  O  Other Patient Names
 ; 0010,1010  O  Patient's Age
 ; 0010,2160  O  Ethnic Group
 ; 0010,2180  O  Occupation
 ; 0010,21B0  O  Additional Patient History
 ; 0020,1206  O  Number of Study Related Series
 ; 0020,1208  O  Number of Study Related Instances
 ; 4008,010C  O  Interpretation Author
 ;
 ; Problem cases left over:
 ; 0008,0062  O  SOP Classes in Study [supported?]
 ; 0008,1080  O  Admitting Diagnoses Description
 ; 0010,4000  O  Patient Comments
 ;
 ;
HDRTAG() ; Result Header
 Q "0000,0902"
 ;
STDESTAG() ; Study Description
 Q "0008,1030"
 ;
STUIDTAG() ; Study UID 
 Q "0020,000D"
 ;
ACCNTAG() ; Accession Number
 Q "0008,0050"
 ;
MODTAG() ; Modality
 Q "0008,0061"
 ;
NSRSTAG() ; Number of Study Related Series
 Q "0020,1206"
 ;
NSRITAG() ; Number of Study Related Instances
 Q "0020,1208"
 ;
PTNAMTAG() ; Patient Name
 Q "0010,0010"
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGDQR00   7226     printed  Sep 23, 2025@19:36:59                                                                                                                                                                                                    Page 2
MAGDQR00  ;WOIFO/EdM,BT - Imaging RPCs for Query/Retrieve ; 04/05/2006 08:43
 +1       ;;3.0;IMAGING;**51,54,118**;Mar 19, 2002;Build 4525;May 01, 2013
 +2       ;; Per VHA Directive 2004-038, this routine should not be modified.
 +3       ;; +---------------------------------------------------------------+
 +4       ;; | Property of the US Government.                                |
 +5       ;; | No permission to copy or redistribute this software is given. |
 +6       ;; | Use of unreleased versions of this software requires the user |
 +7       ;; | to execute a written test agreement with the VistA Imaging    |
 +8       ;; | Development Office of the Department of Veterans Affairs,     |
 +9       ;; | telephone (301) 734-0100.                                     |
 +10      ;; | The Food and Drug Administration classifies this software as  |
 +11      ;; | a medical device.  As such, it may not be changed in any way. |
 +12      ;; | Modifications to this software may result in an adulterated   |
 +13      ;; | medical device under 21CFR820, the use of which is considered |
 +14      ;; | to be a violation of US Federal Statutes.                     |
 +15      ;; +---------------------------------------------------------------+
 +16      ;;
 +17       QUIT 
 +18      ;
 +19      ; Query/Retrieve
 +20      ;
 +21      ; Step 1: The application (Java system) receives a C-FIND request
 +22      ;
 +23      ; Step 2: The application interprets the DICOM message and
 +24      ;         calls an RPC on traditional VistA
 +25      ;
 +26      ;           RPC name: MAG CFIND QUERY
 +27      ;             input:  array of:    tag | VR | flag | value
 +28      ;             input:  scalar:      batch-identifier, see below
 +29      ;             input:  scalar:      max # entities in response
 +30      ;             output: array of:    header = # entities total | # in current batch
 +31      ;                    followed by   tag | VR | flag | value
 +32      ;                             or   <start sequence>
 +33      ;                             or   <end sequence>
 +34      ;
 +35      ;          Batch-identifier:
 +36      ;          There are four kinds of calls:
 +37      ;           1. initial call
 +38      ;              value of this parameter is "0"
 +39      ;              RPC will create result-set and start a background process to
 +40      ;              perform the query
 +41      ;           2. "are you ready" call
 +42      ;              value of this parameter is "n|0"
 +43      ;              where 'n' identifies the result-set
 +44      ;              RPC will check if the query is ready and, when available, will
 +45      ;              return "initial batch" of responses
 +46      ;           3. continuation call
 +47      ;              value of this parameter is "n|m"
 +48      ;              where 'n' identifies the result-set
 +49      ;              where 'm' identifies the sequence
 +50      ;              number of the first item to be returned RPC will return
 +51      ;              next batch of responses
 +52      ;           4. final call
 +53      ;              value of this parameter is "n|-1"
 +54      ;              where 'n' identifies the result-set
 +55      ;              RPC will not return any responses but clean-up any storage used
 +56      ;              for result-set
 +57      ;
 +58      ;          Suggested values for second parameter:
 +59      ;            0 for initial call
 +60      ;           -1 for final call
 +61      ;           >0 (sequence number of first entity to be returned)
 +62      ;              for continuation call
 +63      ;          Result-set will also have a "time stamp of last access"
 +64      ;          so that an overall clean-up process can get rid of
 +65      ;          obsolete result-sets.
 +66      ;
 +67      ; Step 3: The application interprets the results from the RPC
 +68      ;         and will ask VistA which images belong to a
 +69      ;         study-UID:
 +70      ;
 +71      ;           RPC name: MAG STUDY UID QUERY
 +72      ;             input:  scalar       study uid
 +73      ;             input:  scalar       flag: include routed copies in result
 +74      ;             input:  scalar       "my location" identifier
 +75      ;             output: array of:    header = # of entities in response
 +76      ;                                  image# | path+file name | username | password
 +77      ;
 +78      ;         Do we want to return the username and password in each
 +79      ;         result, or do we want two separate RPC calls: one to
 +80      ;         get path+filename for each file, and one that returns
 +81      ;         the username and password given a path?
 +82      ;
 +83      ; Step 4: The application will create new DICOM entities to transmit
 +84      ;         to its client. It has the information to access the
 +85      ;         image files that exist on VistA (either .dcm files or
 +86      ;         .txt + .tga pairs). It needs to ask VistA for the
 +87      ;         current and correct information to place in the headers
 +88      ;         of the DICOM entities to be transmitted:
 +89      ;
 +90      ;           RPC name: MAG IMAGE CURRENT INFO
 +91      ;             input:  scalar       image #
 +92      ;             output: array of:    header = # of entities in response
 +93      ;                                  tag | VS | flag | value
 +94      ;
 +95      ;         Do we need an additional input array to specify the
 +96      ;         list of data-fields to be returned?
 +97      ;
 +98      ; Non-supported tags for Query/Retrieve
 +99      ; 0008,1110  O  Referenced Study Sequence
 +100     ; 0008,1150  O  >Referenced SOP Class UID
 +101     ; 0008,1155  O  >Referenced SOP Instance UID
 +102     ; 0008,1120  O  Referenced Patient Sequence
 +103     ; 0008,1150  O  >Referenced SOP Class UID
 +104     ; 0008,1155  O  >Referenced SOP Instance UID
 +105     ; 0010,1020  O  Patient's Size   [field not populated]
 +106     ; 0010,1030  O  Patient's Weight [field not populated]
 +107     ; 0020,1070  O  Other Study Numbers
 +108     ; 0020,1200  O  Number of Patient Related Studies
 +109     ; 0020,1202  O  Number of Patient Related Series
 +110     ; 0020,1204  O  Number of Patient Related Instances
 +111     ;
 +112     ; Supported tags
 +113     ; 0008,0020  R  Study Date
 +114     ; 0008,0030  R  Study Time
 +115     ; 0008,0050  R  Accession Number
 +116     ; 0010,0010  R  Patient's Name
 +117     ; 0010,0020  R  Patient ID
 +118     ; 0020,0010  R  Study ID
 +119     ; 0020,000D  U  Study Instance UID
 +120     ; 0008,0018  U  Image Instance UID
 +121     ; 0020,000E  U  Series Instance UID
 +122     ;
 +123     ; 0008,0061  O  Modalities in Study
 +124     ; 0008,0090  O  Referring Physician's Name
 +125     ; 0008,1030  O  Study Description
 +126     ; 0008,1032  O  Procedure Code Sequence
 +127     ; 0008,0100  O  >Code Value
 +128     ; 0008,0102  O  >Coding Scheme Designator
 +129     ; 0008,0103  O  >Coding Scheme Version
 +130     ; 0008,0104  O  >Code Meaning
 +131     ; 0008,1060  O  Name of Physician(s) Reading Study
 +132     ; 0010,0030  O  Patient's Birth Date
 +133     ; 0010,0032  O  Patient's Birth Time [probably always blank]
 +134     ; 0010,0040  O  Patient's Sex
 +135     ; 0010,1000  O  Other Patient IDs
 +136     ; 0010,1001  O  Other Patient Names
 +137     ; 0010,1010  O  Patient's Age
 +138     ; 0010,2160  O  Ethnic Group
 +139     ; 0010,2180  O  Occupation
 +140     ; 0010,21B0  O  Additional Patient History
 +141     ; 0020,1206  O  Number of Study Related Series
 +142     ; 0020,1208  O  Number of Study Related Instances
 +143     ; 4008,010C  O  Interpretation Author
 +144     ;
 +145     ; Problem cases left over:
 +146     ; 0008,0062  O  SOP Classes in Study [supported?]
 +147     ; 0008,1080  O  Admitting Diagnoses Description
 +148     ; 0010,4000  O  Patient Comments
 +149     ;
 +150     ;
HDRTAG()  ; Result Header
 +1        QUIT "0000,0902"
 +2       ;
STDESTAG() ; Study Description
 +1        QUIT "0008,1030"
 +2       ;
STUIDTAG() ; Study UID 
 +1        QUIT "0020,000D"
 +2       ;
ACCNTAG() ; Accession Number
 +1        QUIT "0008,0050"
 +2       ;
MODTAG()  ; Modality
 +1        QUIT "0008,0061"
 +2       ;
NSRSTAG() ; Number of Study Related Series
 +1        QUIT "0020,1206"
 +2       ;
NSRITAG() ; Number of Study Related Instances
 +1        QUIT "0020,1208"
 +2       ;
PTNAMTAG() ; Patient Name
 +1        QUIT "0010,0010"