MAGDSTQ5 ;WOIFO/PMK - Study Tracker - Patient Level Query/Retrieve Display; Jul 23, 2020@07:39:54
;;3.0;IMAGING;**231**;Mar 19, 2002;Build 9;Aug 30, 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. |
;; +---------------------------------------------------------------+
;;
;
; Notice: This routine is on both VistA and the DICOM Gateway
;
;
Q
;
DISPLAY ;
; the values of the following four status is important
N INCORRECT S INCORRECT=-1 ; incorrect selection
N NOTSELECTED S NOTSELECTED=-2 ; proposed selection not selected
N CARET S CARET=-3 ; caret (^) indicator
;
N JPATIENT,JSTUDY,JSERIES,JIMAGE ; IENs
N SETKEYS S SETKEYS=0 ; query keys are set for the next operation
N HIT ; flag indicated that a patient, study, series, image(s) were selected
N REPEAT ; loop control
N RETURN
;
I $D(^XTMP(MAGXTMP,HOSTNAME,$J,QRSTACK,"MESSAGE","MSG",0)) D Q
. ; display the message, decrement QRSTACK and quit
. N I
. F I=1:1:^XTMP(MAGXTMP,HOSTNAME,$J,QRSTACK,"MESSAGE","MSG",0) W !,^(I)
. D CONTINUE^MAGDSTQ
. D POP^MAGDSTQ0(.QRSTACK) ; remove the last q/r key entry from the stack
. Q
;
S HIT=0,REPEAT=1
F D Q:'REPEAT
. S RETURN=$$DISPLAY1()
. I HIT S REPEAT=0 Q
. ; check for going back - RETURN should be 0 for QRSTACK=1
. I 'RETURN S X="YES" ; ignore prompt
. E D ; do prompt
. . W !!,"Nothing selected -- Exit display of query results?"
. . R " y// ",X:DTIME E S X="^"
. . Q
. I X="" S X="y" W X
. I "Yy"[$E(X) D
. . S REPEAT=0
. . D POP^MAGDSTQ0(.QRSTACK) ; remove the last q/r key entry from the stack
. . Q
. Q
Q
;
DISPLAY1() ; select the patient
N N,REPEAT,RETURN1,RETURN2
S N=$G(^XTMP(MAGXTMP,HOSTNAME,$J,QRSTACK,"PATIENT"),0)
I N=0 Q 0 ; no patient data
;
S REPEAT=1
F D Q:'REPEAT
. I N=1,$G(^XTMP(MAGXTMP,HOSTNAME,$J,QRSTACK,"STUDY",1),0) D
. . S JPATIENT=1
. . S RETURN1=0
. . Q
. E D Q:'REPEAT ; N>1
. . S RETURN1=$$MULTIPLE("PATIENT",N)
. . I RETURN1=INCORRECT Q
. . I RETURN1>0 S HIT=1 ; patient selected
. . I RETURN1'=0 S REPEAT=0 Q
. . Q
. S RETURN2=$$DISPLAY2()
. I HIT S REPEAT=0
. I RETURN2=NOTSELECTED,N=1 S REPEAT=0,RETURN1=NOTSELECTED
. Q
Q RETURN1
;
DISPLAY2() ; select the study
N N,REPEAT,RETURN1,RETURN2
I '$D(JPATIENT) Q 0 ; no patient selected
S N=$G(^XTMP(MAGXTMP,HOSTNAME,$J,QRSTACK,"STUDY",JPATIENT),0)
I N=0 Q 0 ; no study data
;
S REPEAT=1
F D Q:'REPEAT
. I N=1,$G(^XTMP(MAGXTMP,HOSTNAME,$J,QRSTACK,"SERIES",JPATIENT,1),0) D
. . S JSTUDY=1
. . S RETURN1=0
. . Q
. E D Q:'REPEAT ; N>1
. . S RETURN1=$$MULTIPLE("STUDY",N)
. . I RETURN1=INCORRECT Q
. . I RETURN1>0 S HIT=1 ; study selected
. . I RETURN1'=0 S REPEAT=0 Q
. . Q
. S RETURN2=$$DISPLAY3()
. I HIT S REPEAT=0
. I RETURN2=NOTSELECTED,N=1 S REPEAT=0,RETURN1=NOTSELECTED
. Q
Q RETURN1
;
DISPLAY3() ; select the series
N N,REPEAT,RETURN1,RETURN2
I '$D(JSTUDY) Q 0 ; no study selected
S N=$G(^XTMP(MAGXTMP,HOSTNAME,$J,QRSTACK,"SERIES",JPATIENT,JSTUDY),0)
I N=0 Q 0 ; no series data
;
S REPEAT=1
F D Q:'REPEAT
. I N=1,$G(^XTMP(MAGXTMP,HOSTNAME,$J,QRSTACK,"IMAGE",JPATIENT,JSTUDY,1),0) D
. . S JSERIES=1
. . S RETURN1=0
. . Q
. E D Q:'REPEAT ; N>1
. . S RETURN1=$$MULTIPLE("SERIES",N)
. . I RETURN1=INCORRECT Q
. . I RETURN1>0 S HIT=1 ; series selected
. . I RETURN1'=0 S REPEAT=0 Q
. . Q
. S RETURN2=$$DISPLAY4()
. I HIT S REPEAT=0
. I RETURN2=NOTSELECTED,N=1 S REPEAT=0,RETURN1=NOTSELECTED
. Q
Q RETURN1
;
DISPLAY4() ; select the image
N N,REPEAT,RETURN1
I '$D(JSERIES) Q 0 ; no series selected
S N=$G(^XTMP(MAGXTMP,HOSTNAME,$J,QRSTACK,"IMAGE",JPATIENT,JSTUDY,JSERIES),0)
I N=0 Q 0 ; no image data
;
S REPEAT=1
F D Q:'REPEAT
. S RETURN1=$$MULTIPLE("IMAGE",N)
. I RETURN1=INCORRECT Q
. I RETURN1>0 S HIT=1 ; image selected
. I RETURN1'=0 S REPEAT=0 Q
. Q
Q RETURN1
;
;
;
MULTIPLE(LEVEL,N) ; display information for multiple entries
N DONE,IBEGIN,IEND,INCREMENT,PROMPT,SELECT
S DONE=0
;
I N=1 D
. S SELECT=$$SINGLE(LEVEL,1)
. I SELECT=INCORRECT S SELECT=NOTSELECTED
. Q
E D ; multiple matches, select one
. S IBEGIN=1 F D MULTI Q:DONE D Q:DONE
. . S IBEGIN=IBEGIN+INCREMENT
. . I IBEGIN>N S SELECT=NOTSELECTED,DONE=1
. . Q
. Q
Q SELECT
;
MULTI ; display one set of information
N FIRSTLINE,FINISHED,I,OLDMODALITY,RETURN
S FINISHED=0 F D Q:FINISHED
. I IBEGIN=1 D
. . D MULTITOP
. . S FIRSTLINE=0
. . Q
. E D
. . W @IOF
. . S FIRSTLINE=1
. . Q
. ;
. S INCREMENT=(IOSL-4)-$Y
. I INCREMENT<5 S INCREMENT=22
. S IEND=IBEGIN+INCREMENT-1 I IEND>N S IEND=N
. F I=IBEGIN:1:IEND D MULTIONE
. W !!,"Enter 1-",IEND," to see the ",PROMPT(1)," details"
. I IEND<N W ", <Enter> to see more ",PROMPT(2)
. R ": ",I:DTIME E D MULTIEND S FINISHED=1 Q
. I I="" S SELECT=NOTSELECTED S FINISHED=1 Q
. I I["^" D MULTIEND S FINISHED=1 Q
. I I?1N.N,I'<1,I'>IEND S SELECT=$$SINGLE(LEVEL,I) S DONE=1,FINISHED=1 Q
. R " ???",X:DTIME E D MULTIEND S FINISHED=1 Q
. Q
Q
;
MULTIEND ; set loop end variables
S DONE=1,I="",SELECT=NOTSELECTED
Q
;
MULTITOP ; display the MULTI header
I LEVEL="PATIENT" D
. W @IOF,?4,"Identifier ",?17,"Patient Name",?60,"Birth Date",?75,"Sex"
. W !?4,"-----------",?17,"------------",?60,"----------",?75,"---"
. S PROMPT(1)="patient",PROMPT(2)="patients"
. S (JPATIENT,JSTUDY,JSERIES)=""
. Q
E I LEVEL="STUDY" D
. D HEADER
. S RETURN=$$PATIENT^MAGDSTQ6() ; ignore RETURN
. W !!?4,"Accession Number",?22,"Study Date",?34,"Description"
. W !?4,"----------------",?22,"----------",?34,"-----------"
. S PROMPT(1)="study",PROMPT(2)="studies"
. S (JSTUDY,JSERIES)=""
. Q
E I LEVEL="SERIES" D
. D HEADER
. S RETURN=$$STUDY^MAGDSTQ6() ; ignore RETURN
. S PROMPT(1)="series",PROMPT(2)="series"
. Q
E D ; image (composite SOP object)
. D HEADER
. S RETURN=$$SERIES^MAGDSTQ6() ; ignore RETURN
. S PROMPT(1)="image",PROMPT(2)="images"
. Q
Q
;
MULTIONE ; display one line of data for each patient, study, series, or image
N VAR
S VAR=""
W:'FIRSTLINE !
I LEVEL="SERIES" D
. N MODALITY
. S MODALITY=^XTMP(MAGXTMP,HOSTNAME,$J,QRSTACK,"SERIES",JPATIENT,JSTUDY,I,"MODALITY")
. I MODALITY=$G(OLDMODALITY) Q
. W "Modality: ",MODALITY,!
. S OLDMODALITY=MODALITY
. Q
W $J(I,3),")",?5 S FIRSTLINE=0
I LEVEL="PATIENT" D
. F S VAR=$O(^XTMP(MAGXTMP,HOSTNAME,$J,QRSTACK,"PATIENT",I,VAR)) Q:VAR="" N @VAR S @VAR=^(VAR)
. W PID,?17,$E($$NAME^MAGDSTQ6(PNAME),1,40),?60,$$DATE^MAGDSTQ6(DOB,"SHORT"),?76,SEX
. Q
E I LEVEL="STUDY" D
. F S VAR=$O(^XTMP(MAGXTMP,HOSTNAME,$J,QRSTACK,"STUDY",JPATIENT,I,VAR)) Q:VAR="" N @VAR S @VAR=^(VAR)
. W ACNUMB
. W ?22,$$DATE^MAGDSTQ6(STUDYDATE,"SHORT")
. W ?34,$E(DESCRIPTION,1,80-34) ; output to end of 80 character line
. Q
E I LEVEL="SERIES" D
. F S VAR=$O(^XTMP(MAGXTMP,HOSTNAME,$J,QRSTACK,"SERIES",JPATIENT,JSTUDY,I,VAR)) Q:VAR="" N @VAR S @VAR=^(VAR)
. I $G(SERIESDESC)'="",SERIESDESC'="<unknown>" W SERIESDESC
. E W "Series UID: ",SERIESUID
. Q
E I LEVEL="IMAGE" D
. F S VAR=$O(^XTMP(MAGXTMP,HOSTNAME,$J,QRSTACK,"IMAGE",JPATIENT,JSTUDY,JSERIES,I,VAR)) Q:VAR="" N @VAR S @VAR=^(VAR)
. W "SOP Instance UID: ",SOPUID
. Q
Q
;
SINGLE(LEVEL,I) ; display detailed information for one entity
N RETURN,X
D HEADER
I LEVEL="PATIENT" D
. S JPATIENT=I,RETURN=$$PATIENT^MAGDSTQ6()
. Q
E I LEVEL="STUDY" D
. S JSTUDY=I,RETURN=$$STUDY^MAGDSTQ6()
. Q
E I LEVEL="SERIES" D
. S JSERIES=I,RETURN=$$SERIES^MAGDSTQ6()
. Q
E D
. S JIMAGE=I,RETURN=$$IMAGE^MAGDSTQ6()
. Q
Q RETURN
;
N I,J,X
S X=$S(OPTION="QR":"QUERY/RETRIEVE",1:"QUERY")_" RESULTS"
S J=80-$L(X)/2
W @IOF,?J,X
W !,?J F I=1:1:$L(X) W "-"
W !
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGDSTQ5 8750 printed Nov 22, 2024@17:12:07 Page 2
MAGDSTQ5 ;WOIFO/PMK - Study Tracker - Patient Level Query/Retrieve Display; Jul 23, 2020@07:39:54
+1 ;;3.0;IMAGING;**231**;Mar 19, 2002;Build 9;Aug 30, 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 ;
+18 ; Notice: This routine is on both VistA and the DICOM Gateway
+19 ;
+20 ;
+21 QUIT
+22 ;
DISPLAY ;
+1 ; the values of the following four status is important
+2 ; incorrect selection
NEW INCORRECT
SET INCORRECT=-1
+3 ; proposed selection not selected
NEW NOTSELECTED
SET NOTSELECTED=-2
+4 ; caret (^) indicator
NEW CARET
SET CARET=-3
+5 ;
+6 ; IENs
NEW JPATIENT,JSTUDY,JSERIES,JIMAGE
+7 ; query keys are set for the next operation
NEW SETKEYS
SET SETKEYS=0
+8 ; flag indicated that a patient, study, series, image(s) were selected
NEW HIT
+9 ; loop control
NEW REPEAT
+10 NEW RETURN
+11 ;
+12 IF $DATA(^XTMP(MAGXTMP,HOSTNAME,$JOB,QRSTACK,"MESSAGE","MSG",0))
Begin DoDot:1
+13 ; display the message, decrement QRSTACK and quit
+14 NEW I
+15 FOR I=1:1:^XTMP(MAGXTMP,HOSTNAME,$JOB,QRSTACK,"MESSAGE","MSG",0)
WRITE !,^(I)
+16 DO CONTINUE^MAGDSTQ
+17 ; remove the last q/r key entry from the stack
DO POP^MAGDSTQ0(.QRSTACK)
+18 QUIT
End DoDot:1
QUIT
+19 ;
+20 SET HIT=0
SET REPEAT=1
+21 FOR
Begin DoDot:1
+22 SET RETURN=$$DISPLAY1()
+23 IF HIT
SET REPEAT=0
QUIT
+24 ; check for going back - RETURN should be 0 for QRSTACK=1
+25 ; ignore prompt
IF 'RETURN
SET X="YES"
+26 ; do prompt
IF '$TEST
Begin DoDot:2
+27 WRITE !!,"Nothing selected -- Exit display of query results?"
+28 READ " y// ",X:DTIME
IF '$TEST
SET X="^"
+29 QUIT
End DoDot:2
+30 IF X=""
SET X="y"
WRITE X
+31 IF "Yy"[$EXTRACT(X)
Begin DoDot:2
+32 SET REPEAT=0
+33 ; remove the last q/r key entry from the stack
DO POP^MAGDSTQ0(.QRSTACK)
+34 QUIT
End DoDot:2
+35 QUIT
End DoDot:1
if 'REPEAT
QUIT
+36 QUIT
+37 ;
DISPLAY1() ; select the patient
+1 NEW N,REPEAT,RETURN1,RETURN2
+2 SET N=$GET(^XTMP(MAGXTMP,HOSTNAME,$JOB,QRSTACK,"PATIENT"),0)
+3 ; no patient data
IF N=0
QUIT 0
+4 ;
+5 SET REPEAT=1
+6 FOR
Begin DoDot:1
+7 IF N=1
IF $GET(^XTMP(MAGXTMP,HOSTNAME,$JOB,QRSTACK,"STUDY",1),0)
Begin DoDot:2
+8 SET JPATIENT=1
+9 SET RETURN1=0
+10 QUIT
End DoDot:2
+11 ; N>1
IF '$TEST
Begin DoDot:2
+12 SET RETURN1=$$MULTIPLE("PATIENT",N)
+13 IF RETURN1=INCORRECT
QUIT
+14 ; patient selected
IF RETURN1>0
SET HIT=1
+15 IF RETURN1'=0
SET REPEAT=0
QUIT
+16 QUIT
End DoDot:2
if 'REPEAT
QUIT
+17 SET RETURN2=$$DISPLAY2()
+18 IF HIT
SET REPEAT=0
+19 IF RETURN2=NOTSELECTED
IF N=1
SET REPEAT=0
SET RETURN1=NOTSELECTED
+20 QUIT
End DoDot:1
if 'REPEAT
QUIT
+21 QUIT RETURN1
+22 ;
DISPLAY2() ; select the study
+1 NEW N,REPEAT,RETURN1,RETURN2
+2 ; no patient selected
IF '$DATA(JPATIENT)
QUIT 0
+3 SET N=$GET(^XTMP(MAGXTMP,HOSTNAME,$JOB,QRSTACK,"STUDY",JPATIENT),0)
+4 ; no study data
IF N=0
QUIT 0
+5 ;
+6 SET REPEAT=1
+7 FOR
Begin DoDot:1
+8 IF N=1
IF $GET(^XTMP(MAGXTMP,HOSTNAME,$JOB,QRSTACK,"SERIES",JPATIENT,1),0)
Begin DoDot:2
+9 SET JSTUDY=1
+10 SET RETURN1=0
+11 QUIT
End DoDot:2
+12 ; N>1
IF '$TEST
Begin DoDot:2
+13 SET RETURN1=$$MULTIPLE("STUDY",N)
+14 IF RETURN1=INCORRECT
QUIT
+15 ; study selected
IF RETURN1>0
SET HIT=1
+16 IF RETURN1'=0
SET REPEAT=0
QUIT
+17 QUIT
End DoDot:2
if 'REPEAT
QUIT
+18 SET RETURN2=$$DISPLAY3()
+19 IF HIT
SET REPEAT=0
+20 IF RETURN2=NOTSELECTED
IF N=1
SET REPEAT=0
SET RETURN1=NOTSELECTED
+21 QUIT
End DoDot:1
if 'REPEAT
QUIT
+22 QUIT RETURN1
+23 ;
DISPLAY3() ; select the series
+1 NEW N,REPEAT,RETURN1,RETURN2
+2 ; no study selected
IF '$DATA(JSTUDY)
QUIT 0
+3 SET N=$GET(^XTMP(MAGXTMP,HOSTNAME,$JOB,QRSTACK,"SERIES",JPATIENT,JSTUDY),0)
+4 ; no series data
IF N=0
QUIT 0
+5 ;
+6 SET REPEAT=1
+7 FOR
Begin DoDot:1
+8 IF N=1
IF $GET(^XTMP(MAGXTMP,HOSTNAME,$JOB,QRSTACK,"IMAGE",JPATIENT,JSTUDY,1),0)
Begin DoDot:2
+9 SET JSERIES=1
+10 SET RETURN1=0
+11 QUIT
End DoDot:2
+12 ; N>1
IF '$TEST
Begin DoDot:2
+13 SET RETURN1=$$MULTIPLE("SERIES",N)
+14 IF RETURN1=INCORRECT
QUIT
+15 ; series selected
IF RETURN1>0
SET HIT=1
+16 IF RETURN1'=0
SET REPEAT=0
QUIT
+17 QUIT
End DoDot:2
if 'REPEAT
QUIT
+18 SET RETURN2=$$DISPLAY4()
+19 IF HIT
SET REPEAT=0
+20 IF RETURN2=NOTSELECTED
IF N=1
SET REPEAT=0
SET RETURN1=NOTSELECTED
+21 QUIT
End DoDot:1
if 'REPEAT
QUIT
+22 QUIT RETURN1
+23 ;
DISPLAY4() ; select the image
+1 NEW N,REPEAT,RETURN1
+2 ; no series selected
IF '$DATA(JSERIES)
QUIT 0
+3 SET N=$GET(^XTMP(MAGXTMP,HOSTNAME,$JOB,QRSTACK,"IMAGE",JPATIENT,JSTUDY,JSERIES),0)
+4 ; no image data
IF N=0
QUIT 0
+5 ;
+6 SET REPEAT=1
+7 FOR
Begin DoDot:1
+8 SET RETURN1=$$MULTIPLE("IMAGE",N)
+9 IF RETURN1=INCORRECT
QUIT
+10 ; image selected
IF RETURN1>0
SET HIT=1
+11 IF RETURN1'=0
SET REPEAT=0
QUIT
+12 QUIT
End DoDot:1
if 'REPEAT
QUIT
+13 QUIT RETURN1
+14 ;
+15 ;
+16 ;
MULTIPLE(LEVEL,N) ; display information for multiple entries
+1 NEW DONE,IBEGIN,IEND,INCREMENT,PROMPT,SELECT
+2 SET DONE=0
+3 ;
+4 IF N=1
Begin DoDot:1
+5 SET SELECT=$$SINGLE(LEVEL,1)
+6 IF SELECT=INCORRECT
SET SELECT=NOTSELECTED
+7 QUIT
End DoDot:1
+8 ; multiple matches, select one
IF '$TEST
Begin DoDot:1
+9 SET IBEGIN=1
FOR
DO MULTI
if DONE
QUIT
Begin DoDot:2
+10 SET IBEGIN=IBEGIN+INCREMENT
+11 IF IBEGIN>N
SET SELECT=NOTSELECTED
SET DONE=1
+12 QUIT
End DoDot:2
if DONE
QUIT
+13 QUIT
End DoDot:1
+14 QUIT SELECT
+15 ;
MULTI ; display one set of information
+1 NEW FIRSTLINE,FINISHED,I,OLDMODALITY,RETURN
+2 SET FINISHED=0
FOR
Begin DoDot:1
+3 IF IBEGIN=1
Begin DoDot:2
+4 DO MULTITOP
+5 SET FIRSTLINE=0
+6 QUIT
End DoDot:2
+7 IF '$TEST
Begin DoDot:2
+8 WRITE @IOF
+9 SET FIRSTLINE=1
+10 QUIT
End DoDot:2
+11 ;
+12 SET INCREMENT=(IOSL-4)-$Y
+13 IF INCREMENT<5
SET INCREMENT=22
+14 SET IEND=IBEGIN+INCREMENT-1
IF IEND>N
SET IEND=N
+15 FOR I=IBEGIN:1:IEND
DO MULTIONE
+16 WRITE !!,"Enter 1-",IEND," to see the ",PROMPT(1)," details"
+17 IF IEND<N
WRITE ", <Enter> to see more ",PROMPT(2)
+18 READ ": ",I:DTIME
IF '$TEST
DO MULTIEND
SET FINISHED=1
QUIT
+19 IF I=""
SET SELECT=NOTSELECTED
SET FINISHED=1
QUIT
+20 IF I["^"
DO MULTIEND
SET FINISHED=1
QUIT
+21 IF I?1N.N
IF I'<1
IF I'>IEND
SET SELECT=$$SINGLE(LEVEL,I)
SET DONE=1
SET FINISHED=1
QUIT
+22 READ " ???",X:DTIME
IF '$TEST
DO MULTIEND
SET FINISHED=1
QUIT
+23 QUIT
End DoDot:1
if FINISHED
QUIT
+24 QUIT
+25 ;
MULTIEND ; set loop end variables
+1 SET DONE=1
SET I=""
SET SELECT=NOTSELECTED
+2 QUIT
+3 ;
MULTITOP ; display the MULTI header
+1 IF LEVEL="PATIENT"
Begin DoDot:1
+2 WRITE @IOF,?4,"Identifier ",?17,"Patient Name",?60,"Birth Date",?75,"Sex"
+3 WRITE !?4,"-----------",?17,"------------",?60,"----------",?75,"---"
+4 SET PROMPT(1)="patient"
SET PROMPT(2)="patients"
+5 SET (JPATIENT,JSTUDY,JSERIES)=""
+6 QUIT
End DoDot:1
+7 IF '$TEST
IF LEVEL="STUDY"
Begin DoDot:1
+8 DO HEADER
+9 ; ignore RETURN
SET RETURN=$$PATIENT^MAGDSTQ6()
+10 WRITE !!?4,"Accession Number",?22,"Study Date",?34,"Description"
+11 WRITE !?4,"----------------",?22,"----------",?34,"-----------"
+12 SET PROMPT(1)="study"
SET PROMPT(2)="studies"
+13 SET (JSTUDY,JSERIES)=""
+14 QUIT
End DoDot:1
+15 IF '$TEST
IF LEVEL="SERIES"
Begin DoDot:1
+16 DO HEADER
+17 ; ignore RETURN
SET RETURN=$$STUDY^MAGDSTQ6()
+18 SET PROMPT(1)="series"
SET PROMPT(2)="series"
+19 QUIT
End DoDot:1
+20 ; image (composite SOP object)
IF '$TEST
Begin DoDot:1
+21 DO HEADER
+22 ; ignore RETURN
SET RETURN=$$SERIES^MAGDSTQ6()
+23 SET PROMPT(1)="image"
SET PROMPT(2)="images"
+24 QUIT
End DoDot:1
+25 QUIT
+26 ;
MULTIONE ; display one line of data for each patient, study, series, or image
+1 NEW VAR
+2 SET VAR=""
+3 if 'FIRSTLINE
WRITE !
+4 IF LEVEL="SERIES"
Begin DoDot:1
+5 NEW MODALITY
+6 SET MODALITY=^XTMP(MAGXTMP,HOSTNAME,$JOB,QRSTACK,"SERIES",JPATIENT,JSTUDY,I,"MODALITY")
+7 IF MODALITY=$GET(OLDMODALITY)
QUIT
+8 WRITE "Modality: ",MODALITY,!
+9 SET OLDMODALITY=MODALITY
+10 QUIT
End DoDot:1
+11 WRITE $JUSTIFY(I,3),")",?5
SET FIRSTLINE=0
+12 IF LEVEL="PATIENT"
Begin DoDot:1
+13 FOR
SET VAR=$ORDER(^XTMP(MAGXTMP,HOSTNAME,$JOB,QRSTACK,"PATIENT",I,VAR))
if VAR=""
QUIT
NEW @VAR
SET @VAR=^(VAR)
+14 WRITE PID,?17,$EXTRACT($$NAME^MAGDSTQ6(PNAME),1,40),?60,$$DATE^MAGDSTQ6(DOB,"SHORT"),?76,SEX
+15 QUIT
End DoDot:1
+16 IF '$TEST
IF LEVEL="STUDY"
Begin DoDot:1
+17 FOR
SET VAR=$ORDER(^XTMP(MAGXTMP,HOSTNAME,$JOB,QRSTACK,"STUDY",JPATIENT,I,VAR))
if VAR=""
QUIT
NEW @VAR
SET @VAR=^(VAR)
+18 WRITE ACNUMB
+19 WRITE ?22,$$DATE^MAGDSTQ6(STUDYDATE,"SHORT")
+20 ; output to end of 80 character line
WRITE ?34,$EXTRACT(DESCRIPTION,1,80-34)
+21 QUIT
End DoDot:1
+22 IF '$TEST
IF LEVEL="SERIES"
Begin DoDot:1
+23 FOR
SET VAR=$ORDER(^XTMP(MAGXTMP,HOSTNAME,$JOB,QRSTACK,"SERIES",JPATIENT,JSTUDY,I,VAR))
if VAR=""
QUIT
NEW @VAR
SET @VAR=^(VAR)
+24 IF $GET(SERIESDESC)'=""
IF SERIESDESC'="<unknown>"
WRITE SERIESDESC
+25 IF '$TEST
WRITE "Series UID: ",SERIESUID
+26 QUIT
End DoDot:1
+27 IF '$TEST
IF LEVEL="IMAGE"
Begin DoDot:1
+28 FOR
SET VAR=$ORDER(^XTMP(MAGXTMP,HOSTNAME,$JOB,QRSTACK,"IMAGE",JPATIENT,JSTUDY,JSERIES,I,VAR))
if VAR=""
QUIT
NEW @VAR
SET @VAR=^(VAR)
+29 WRITE "SOP Instance UID: ",SOPUID
+30 QUIT
End DoDot:1
+31 QUIT
+32 ;
SINGLE(LEVEL,I) ; display detailed information for one entity
+1 NEW RETURN,X
+2 DO HEADER
+3 IF LEVEL="PATIENT"
Begin DoDot:1
+4 SET JPATIENT=I
SET RETURN=$$PATIENT^MAGDSTQ6()
+5 QUIT
End DoDot:1
+6 IF '$TEST
IF LEVEL="STUDY"
Begin DoDot:1
+7 SET JSTUDY=I
SET RETURN=$$STUDY^MAGDSTQ6()
+8 QUIT
End DoDot:1
+9 IF '$TEST
IF LEVEL="SERIES"
Begin DoDot:1
+10 SET JSERIES=I
SET RETURN=$$SERIES^MAGDSTQ6()
+11 QUIT
End DoDot:1
+12 IF '$TEST
Begin DoDot:1
+13 SET JIMAGE=I
SET RETURN=$$IMAGE^MAGDSTQ6()
+14 QUIT
End DoDot:1
+15 QUIT RETURN
+16 ;
+1 NEW I,J,X
+2 SET X=$SELECT(OPTION="QR":"QUERY/RETRIEVE",1:"QUERY")_" RESULTS"
+3 SET J=80-$LENGTH(X)/2
+4 WRITE @IOF,?J,X
+5 WRITE !,?J
FOR I=1:1:$LENGTH(X)
WRITE "-"
+6 WRITE !
+7 QUIT