MAGNVQ06 ;WOIFO/NST - List images for Reports ; 05 Feb 2018 3:59 PM
;;3.0;IMAGING;**185,197**;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
;
;***** List Images for Rad Exams or TIU Notes by CPRS context
;
; Input Parameters
; ================
;
; DATA - Array holds Windows message received from CPRS in format
; e.g. 'RPT^CPRS^29027^RA^79029185.9998-1~2'
; or
; RPT^CPRS^4658^TIU^2243408^^^^^^^^1~2
; [IMGLESS] flag to speed up queries: if=1 (true), just get study-level data
;
; Return Values
; =============
;
; if error MAGRY(0) = 0 ^Error message^
; if success MAGRY(0) = 1
; MAGRY(1..n) = CONTEXTID | 0 or 1 | images in format defined in
; RPC [MAGG CPRS RAD EXAM] or [MAG3 CPRS TIU NOTE]
;
IMAGEL(MAGRY,DATA,IMGLESS) ;called by RPC [MAGN CPRS IMAGE LIST]
N MAGNCXT,MAGNI,MAGNCNT,MAGNX,REFIEN,REFTYPE
N MAGZRY,MAGRYNEW
N $ETRAP,$ESTACK S $ETRAP="D AERRA^MAGGTERR"
S IMGLESS=$S($D(IMGLESS):+IMGLESS,1:1) ; Defualt is IMAGELESS
S MAGRY=$NA(^TMP("MAGNVQ06",$J))
K @MAGRY
S @MAGRY@(0)=0
S MAGNCNT=0
S MAGNI=""
F S MAGNI=$O(DATA(MAGNI)) Q:MAGNI="" D
. S MAGNCXT=$P(DATA(MAGNI),"~") ; CPRS contextID
. S MAGNX=$P(MAGNCXT,"^",4)
. I (MAGNX'="RA")&(MAGNX'="TIU") D Q
. . S MAGNCNT=MAGNCNT+1
. . S @MAGRY@(MAGNCNT)="NEXT_CONTEXTID|"_MAGNCXT_"|0|"_"Invalid ContextId Type"
. . Q
. S REFTYPE=$S(MAGNX="RA":"RAD",MAGNX="TIU":"TIU",1:"")
. I REFTYPE="RAD" D
. . D IMAGEC(.MAGZRY,MAGNCXT,IMGLESS,.REFIEN) ; Get image list for a single contextID
. . Q
. I REFTYPE="TIU" D
. . S REFIEN=$P(MAGNCXT,"^",5)
. . D IMAGETIU(.MAGZRY,MAGNCXT,IMGLESS)
. . Q
. K @MAGZRY@(1) ; delete counter node
. D GSTUDY^MAGNVQ01(MAGZRY,REFTYPE,REFIEN,MAGNCXT,IMGLESS) ; Get imagage from new image data structure (P34)
. D APPEND(MAGRY,.MAGNCNT,MAGNCXT,MAGZRY,REFTYPE,REFIEN) ; Append individual contextID image list to final list
. Q
S @MAGRY@(0)=1
Q
;
IMAGETIU(MAGZRY,DATA,IMGLESS) ; Get 2005 Images by TIU Note
N I,OUT,GROUPS,IMGIEN,MAGOUT1,DFN,MAGNTIU
;
K MAGZRY
S DFN=+$P(DATA,U,3)
S MAGNTIU=$P(DATA,U,5)
D IMAGES^MAGGNTI(.MAGOUT1,MAGNTIU)
;
S I=0
F S I=$O(MAGOUT1(I)) Q:'I D
. S IMGIEN=$P(MAGOUT1(I),"^",25) ; IEN of the group
. S:'IMGIEN IMGIEN=$P(MAGOUT1(I),"^",2) ; Ien of the image
. S GROUPS(I)=IMGIEN
. Q
D STUDY2^MAGDQR21(.OUT,.GROUPS,DFN,IMGLESS) ; MAG DOD GET STUDIES IEN
;
S MAGZRY=OUT
S @MAGZRY@(0)=1
;
Q
;
IMAGEC(MAGZRY,DATA,IMGLESS,RARPT) ;A copy from MAGGTRAI
; Call to list Images for a Rad Exam that was selected from CPRS
; and Imaging Window was notified via windows messaging
; INPUT : DATA is in format of Windows message received from CPRS
; example 'RPT^CPRS^29027^RA^i79029185.9998-1'
N DFN,ENT,INVDTTM,INVDT,INVTM
S MAGZRY=$NA(^TMP("MAGGTRAI",$J))
K @MAGZRY
S DFN=+$P(DATA,U,3)
S ENT=+$P($P(DATA,U,5),"-",2)
S INVDTTM=$P($P(DATA,U,5),"-",1)
S INVDT=$P(INVDTTM,".",1)
S INVTM=$P(INVDTTM,".",2)
F Q:($L(INVDT)<8) S INVDT=$E(INVDT,2,$L(INVDT))
S INVDTTM=INVDT_"."_INVTM
S RARPT=0
I '$D(^RADPT(DFN,"DT",INVDTTM,"P",ENT,0)) S @MAGZRY@(0)="0^INVALID Data : Attempt to access Exam failed." Q
S RARPT=$P(^RADPT(DFN,"DT",INVDTTM,"P",ENT,0),U,17)
I 'RARPT S @MAGZRY@(0)="1^No Report for selected Exam" Q
; MAGQI 8/22/01
I $P($G(^RARPT(RARPT,0)),U,2)'=DFN S @MAGZRY@(0)="-2^Patient Mismatch. Radiology File" Q
D GETSTUDY(.MAGZRY,RARPT,IMGLESS) ; Pass input parameters
Q
;
GETSTUDY(MAGZRY,RARPT,IMGLESS) ; Private call. From other points in this routine, when RARPT is defined
; RARPT -- Radiology report IEN
; and returns a list in MAGZRY(1..n).
; We'll make a tmp list of just the image IEN's
; splitting groups into individual image entries.
; If more than 1 Image group points to this report, we
; will prefix the Image Description with (G1), (G2) etc
; We call GROUP^MAGGTIG to get the images for the group, this call
; sorts the images in Dicom Series, Dicom Image number order.
;
N GROUPS,OUT,REQDFN
;
N CT,OI,IGCT,MAGIEN1,MAGQI,MAGX
S IGCT=+$P($G(^RARPT(RARPT,2005,0)),U,4)
; Quit if no images for RARPT
I IGCT=0 S @MAGZRY@(0)="0^0 Images for Radiology Report." Q
;
; Check all Image entries in RARPT 2005 NODE. for Patient match Pointer match, from both
; RARPT end, and Imaging end.
S MAGQI=1
S OI=0,CT=1 F S OI=$O(^RARPT(RARPT,2005,OI)) Q:'OI D Q:(MAGQI<1)
. S MAGIEN1=$P(^RARPT(RARPT,2005,OI,0),U)
. ; Assure magdfn = rarpt dfn
. I $P($G(^RARPT(RARPT,0)),U,2)'=$P($G(^MAG(2005,MAGIEN1,0)),U,7) S MAGQI="-2^Patient Mismatch. Radiology Report" Q
. ; Assure magien1 is pointing to this rarpt
. I $P($G(^MAG(2005,MAGIEN1,2)),U,7)'=RARPT S MAGQI="-2^Pointer Mismatch. Radiology Report" Q
. ; Now run the Imaging integrity check
. D CHK^MAGGSQI(.MAGX,MAGIEN1) I 'MAGX(0) S MAGQI="-2^"_$P(MAGX(0),U,2,99) Q
;
I MAGQI<1 S @MAGZRY@(0)=MAGQI Q
S CT=0
;
S OI=0,CT=1 F S OI=$O(^RARPT(RARPT,2005,OI)) Q:'OI D
. S MAGIEN1=$P(^RARPT(RARPT,2005,OI,0),U) S GROUPS(OI)=MAGIEN1
. Q
;
S REQDFN=$P($G(^RARPT(RARPT,0)),U,2)
D STUDY2^MAGDQR21(.OUT,.GROUPS,REQDFN,IMGLESS) ; MAG DOD GET STUDIES IEN
;
S MAGZRY=OUT
S @MAGZRY@(0)=1
;
Q
;
APPEND(MAGOUT,MAGNCNT,MAGNCXT,MAGIN,REFTYPE,REFIEN) ;
; Append individual contextID image list to final list
; and add more data
; MAGOUT - destination image list array
; .MAGNCNT -- Start position in the array
; MAGNCXT -- context ID
; MAGIN -- Image list to be appended - reference to a global
;
N I,IMGIEN,MAGNCNTN,MAGSTUDY,OLDSTUDY
S @MAGIN@(0)=$G(@MAGIN@(0))
I '@MAGIN@(0) D Q
. S MAGNCNT=MAGNCNT+1
. S @MAGOUT@(MAGNCNT)="NEXT_CONTEXTID|"_MAGNCXT_"|0|"_$P(@MAGIN@(0),"^",2)
. Q
;
S MAGNCNTN=MAGNCNT
S MAGNCNT=MAGNCNT+1
;
S OLDSTUDY=0
S I=0
F S I=$O(@MAGIN@(I)) Q:'I D
. S MAGNCNT=MAGNCNT+1
. S @MAGOUT@(MAGNCNT)=@MAGIN@(I)
. I $P(@MAGIN@(I),"|")="NEXT_STUDY" S OLDSTUDY=$P(@MAGIN@(I),"|",3)'="NEW"
. I OLDSTUDY,$P(@MAGIN@(I),"|")="STUDY_IEN" D ; Add STUDY_INFO. Better place will be MAGDQR21
. . S MAGNCNT=MAGNCNT+1
. . S IMGIEN=$P(@MAGIN@(I),"|",2) ; IEN of the group
. . S @MAGOUT@(MAGNCNT)="STUDY_INFO|"_$$STDINFO^MAGNU003(IMGIEN,REFTYPE,REFIEN,MAGNCXT)
. . S MAGSTUDY=@MAGIN@(I)
. . Q
. I OLDSTUDY,IMGLESS,($P(@MAGIN@(I),"|")="STUDY_PAT") D INSFIMG^MAGNU003(MAGSTUDY,.MAGNCNT,MAGOUT) ; Append First Image Info
. Q
S @MAGOUT@(MAGNCNTN+1)="NEXT_CONTEXTID|"_MAGNCXT_"|1|"_(MAGNCNT-MAGNCNTN) ; @MAGIN@(1) is a result lines count
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGNVQ06 7644 printed Oct 16, 2024@18:08:20 Page 2
MAGNVQ06 ;WOIFO/NST - List images for Reports ; 05 Feb 2018 3:59 PM
+1 ;;3.0;IMAGING;**185,197**;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 ;***** List Images for Rad Exams or TIU Notes by CPRS context
+20 ;
+21 ; Input Parameters
+22 ; ================
+23 ;
+24 ; DATA - Array holds Windows message received from CPRS in format
+25 ; e.g. 'RPT^CPRS^29027^RA^79029185.9998-1~2'
+26 ; or
+27 ; RPT^CPRS^4658^TIU^2243408^^^^^^^^1~2
+28 ; [IMGLESS] flag to speed up queries: if=1 (true), just get study-level data
+29 ;
+30 ; Return Values
+31 ; =============
+32 ;
+33 ; if error MAGRY(0) = 0 ^Error message^
+34 ; if success MAGRY(0) = 1
+35 ; MAGRY(1..n) = CONTEXTID | 0 or 1 | images in format defined in
+36 ; RPC [MAGG CPRS RAD EXAM] or [MAG3 CPRS TIU NOTE]
+37 ;
IMAGEL(MAGRY,DATA,IMGLESS) ;called by RPC [MAGN CPRS IMAGE LIST]
+1 NEW MAGNCXT,MAGNI,MAGNCNT,MAGNX,REFIEN,REFTYPE
+2 NEW MAGZRY,MAGRYNEW
+3 NEW $ETRAP,$ESTACK
SET $ETRAP="D AERRA^MAGGTERR"
+4 ; Defualt is IMAGELESS
SET IMGLESS=$SELECT($DATA(IMGLESS):+IMGLESS,1:1)
+5 SET MAGRY=$NAME(^TMP("MAGNVQ06",$JOB))
+6 KILL @MAGRY
+7 SET @MAGRY@(0)=0
+8 SET MAGNCNT=0
+9 SET MAGNI=""
+10 FOR
SET MAGNI=$ORDER(DATA(MAGNI))
if MAGNI=""
QUIT
Begin DoDot:1
+11 ; CPRS contextID
SET MAGNCXT=$PIECE(DATA(MAGNI),"~")
+12 SET MAGNX=$PIECE(MAGNCXT,"^",4)
+13 IF (MAGNX'="RA")&(MAGNX'="TIU")
Begin DoDot:2
+14 SET MAGNCNT=MAGNCNT+1
+15 SET @MAGRY@(MAGNCNT)="NEXT_CONTEXTID|"_MAGNCXT_"|0|"_"Invalid ContextId Type"
+16 QUIT
End DoDot:2
QUIT
+17 SET REFTYPE=$SELECT(MAGNX="RA":"RAD",MAGNX="TIU":"TIU",1:"")
+18 IF REFTYPE="RAD"
Begin DoDot:2
+19 ; Get image list for a single contextID
DO IMAGEC(.MAGZRY,MAGNCXT,IMGLESS,.REFIEN)
+20 QUIT
End DoDot:2
+21 IF REFTYPE="TIU"
Begin DoDot:2
+22 SET REFIEN=$PIECE(MAGNCXT,"^",5)
+23 DO IMAGETIU(.MAGZRY,MAGNCXT,IMGLESS)
+24 QUIT
End DoDot:2
+25 ; delete counter node
KILL @MAGZRY@(1)
+26 ; Get imagage from new image data structure (P34)
DO GSTUDY^MAGNVQ01(MAGZRY,REFTYPE,REFIEN,MAGNCXT,IMGLESS)
+27 ; Append individual contextID image list to final list
DO APPEND(MAGRY,.MAGNCNT,MAGNCXT,MAGZRY,REFTYPE,REFIEN)
+28 QUIT
End DoDot:1
+29 SET @MAGRY@(0)=1
+30 QUIT
+31 ;
IMAGETIU(MAGZRY,DATA,IMGLESS) ; Get 2005 Images by TIU Note
+1 NEW I,OUT,GROUPS,IMGIEN,MAGOUT1,DFN,MAGNTIU
+2 ;
+3 KILL MAGZRY
+4 SET DFN=+$PIECE(DATA,U,3)
+5 SET MAGNTIU=$PIECE(DATA,U,5)
+6 DO IMAGES^MAGGNTI(.MAGOUT1,MAGNTIU)
+7 ;
+8 SET I=0
+9 FOR
SET I=$ORDER(MAGOUT1(I))
if 'I
QUIT
Begin DoDot:1
+10 ; IEN of the group
SET IMGIEN=$PIECE(MAGOUT1(I),"^",25)
+11 ; Ien of the image
if 'IMGIEN
SET IMGIEN=$PIECE(MAGOUT1(I),"^",2)
+12 SET GROUPS(I)=IMGIEN
+13 QUIT
End DoDot:1
+14 ; MAG DOD GET STUDIES IEN
DO STUDY2^MAGDQR21(.OUT,.GROUPS,DFN,IMGLESS)
+15 ;
+16 SET MAGZRY=OUT
+17 SET @MAGZRY@(0)=1
+18 ;
+19 QUIT
+20 ;
IMAGEC(MAGZRY,DATA,IMGLESS,RARPT) ;A copy from MAGGTRAI
+1 ; Call to list Images for a Rad Exam that was selected from CPRS
+2 ; and Imaging Window was notified via windows messaging
+3 ; INPUT : DATA is in format of Windows message received from CPRS
+4 ; example 'RPT^CPRS^29027^RA^i79029185.9998-1'
+5 NEW DFN,ENT,INVDTTM,INVDT,INVTM
+6 SET MAGZRY=$NAME(^TMP("MAGGTRAI",$JOB))
+7 KILL @MAGZRY
+8 SET DFN=+$PIECE(DATA,U,3)
+9 SET ENT=+$PIECE($PIECE(DATA,U,5),"-",2)
+10 SET INVDTTM=$PIECE($PIECE(DATA,U,5),"-",1)
+11 SET INVDT=$PIECE(INVDTTM,".",1)
+12 SET INVTM=$PIECE(INVDTTM,".",2)
+13 FOR
if ($LENGTH(INVDT)<8)
QUIT
SET INVDT=$EXTRACT(INVDT,2,$LENGTH(INVDT))
+14 SET INVDTTM=INVDT_"."_INVTM
+15 SET RARPT=0
+16 IF '$DATA(^RADPT(DFN,"DT",INVDTTM,"P",ENT,0))
SET @MAGZRY@(0)="0^INVALID Data : Attempt to access Exam failed."
QUIT
+17 SET RARPT=$PIECE(^RADPT(DFN,"DT",INVDTTM,"P",ENT,0),U,17)
+18 IF 'RARPT
SET @MAGZRY@(0)="1^No Report for selected Exam"
QUIT
+19 ; MAGQI 8/22/01
+20 IF $PIECE($GET(^RARPT(RARPT,0)),U,2)'=DFN
SET @MAGZRY@(0)="-2^Patient Mismatch. Radiology File"
QUIT
+21 ; Pass input parameters
DO GETSTUDY(.MAGZRY,RARPT,IMGLESS)
+22 QUIT
+23 ;
GETSTUDY(MAGZRY,RARPT,IMGLESS) ; Private call. From other points in this routine, when RARPT is defined
+1 ; RARPT -- Radiology report IEN
+2 ; and returns a list in MAGZRY(1..n).
+3 ; We'll make a tmp list of just the image IEN's
+4 ; splitting groups into individual image entries.
+5 ; If more than 1 Image group points to this report, we
+6 ; will prefix the Image Description with (G1), (G2) etc
+7 ; We call GROUP^MAGGTIG to get the images for the group, this call
+8 ; sorts the images in Dicom Series, Dicom Image number order.
+9 ;
+10 NEW GROUPS,OUT,REQDFN
+11 ;
+12 NEW CT,OI,IGCT,MAGIEN1,MAGQI,MAGX
+13 SET IGCT=+$PIECE($GET(^RARPT(RARPT,2005,0)),U,4)
+14 ; Quit if no images for RARPT
+15 IF IGCT=0
SET @MAGZRY@(0)="0^0 Images for Radiology Report."
QUIT
+16 ;
+17 ; Check all Image entries in RARPT 2005 NODE. for Patient match Pointer match, from both
+18 ; RARPT end, and Imaging end.
+19 SET MAGQI=1
+20 SET OI=0
SET CT=1
FOR
SET OI=$ORDER(^RARPT(RARPT,2005,OI))
if 'OI
QUIT
Begin DoDot:1
+21 SET MAGIEN1=$PIECE(^RARPT(RARPT,2005,OI,0),U)
+22 ; Assure magdfn = rarpt dfn
+23 IF $PIECE($GET(^RARPT(RARPT,0)),U,2)'=$PIECE($GET(^MAG(2005,MAGIEN1,0)),U,7)
SET MAGQI="-2^Patient Mismatch. Radiology Report"
QUIT
+24 ; Assure magien1 is pointing to this rarpt
+25 IF $PIECE($GET(^MAG(2005,MAGIEN1,2)),U,7)'=RARPT
SET MAGQI="-2^Pointer Mismatch. Radiology Report"
QUIT
+26 ; Now run the Imaging integrity check
+27 DO CHK^MAGGSQI(.MAGX,MAGIEN1)
IF 'MAGX(0)
SET MAGQI="-2^"_$PIECE(MAGX(0),U,2,99)
QUIT
End DoDot:1
if (MAGQI<1)
QUIT
+28 ;
+29 IF MAGQI<1
SET @MAGZRY@(0)=MAGQI
QUIT
+30 SET CT=0
+31 ;
+32 SET OI=0
SET CT=1
FOR
SET OI=$ORDER(^RARPT(RARPT,2005,OI))
if 'OI
QUIT
Begin DoDot:1
+33 SET MAGIEN1=$PIECE(^RARPT(RARPT,2005,OI,0),U)
SET GROUPS(OI)=MAGIEN1
+34 QUIT
End DoDot:1
+35 ;
+36 SET REQDFN=$PIECE($GET(^RARPT(RARPT,0)),U,2)
+37 ; MAG DOD GET STUDIES IEN
DO STUDY2^MAGDQR21(.OUT,.GROUPS,REQDFN,IMGLESS)
+38 ;
+39 SET MAGZRY=OUT
+40 SET @MAGZRY@(0)=1
+41 ;
+42 QUIT
+43 ;
APPEND(MAGOUT,MAGNCNT,MAGNCXT,MAGIN,REFTYPE,REFIEN) ;
+1 ; Append individual contextID image list to final list
+2 ; and add more data
+3 ; MAGOUT - destination image list array
+4 ; .MAGNCNT -- Start position in the array
+5 ; MAGNCXT -- context ID
+6 ; MAGIN -- Image list to be appended - reference to a global
+7 ;
+8 NEW I,IMGIEN,MAGNCNTN,MAGSTUDY,OLDSTUDY
+9 SET @MAGIN@(0)=$GET(@MAGIN@(0))
+10 IF '@MAGIN@(0)
Begin DoDot:1
+11 SET MAGNCNT=MAGNCNT+1
+12 SET @MAGOUT@(MAGNCNT)="NEXT_CONTEXTID|"_MAGNCXT_"|0|"_$PIECE(@MAGIN@(0),"^",2)
+13 QUIT
End DoDot:1
QUIT
+14 ;
+15 SET MAGNCNTN=MAGNCNT
+16 SET MAGNCNT=MAGNCNT+1
+17 ;
+18 SET OLDSTUDY=0
+19 SET I=0
+20 FOR
SET I=$ORDER(@MAGIN@(I))
if 'I
QUIT
Begin DoDot:1
+21 SET MAGNCNT=MAGNCNT+1
+22 SET @MAGOUT@(MAGNCNT)=@MAGIN@(I)
+23 IF $PIECE(@MAGIN@(I),"|")="NEXT_STUDY"
SET OLDSTUDY=$PIECE(@MAGIN@(I),"|",3)'="NEW"
+24 ; Add STUDY_INFO. Better place will be MAGDQR21
IF OLDSTUDY
IF $PIECE(@MAGIN@(I),"|")="STUDY_IEN"
Begin DoDot:2
+25 SET MAGNCNT=MAGNCNT+1
+26 ; IEN of the group
SET IMGIEN=$PIECE(@MAGIN@(I),"|",2)
+27 SET @MAGOUT@(MAGNCNT)="STUDY_INFO|"_$$STDINFO^MAGNU003(IMGIEN,REFTYPE,REFIEN,MAGNCXT)
+28 SET MAGSTUDY=@MAGIN@(I)
+29 QUIT
End DoDot:2
+30 ; Append First Image Info
IF OLDSTUDY
IF IMGLESS
IF ($PIECE(@MAGIN@(I),"|")="STUDY_PAT")
DO INSFIMG^MAGNU003(MAGSTUDY,.MAGNCNT,MAGOUT)
+31 QUIT
End DoDot:1
+32 ; @MAGIN@(1) is a result lines count
SET @MAGOUT@(MAGNCNTN+1)="NEXT_CONTEXTID|"_MAGNCXT_"|1|"_(MAGNCNT-MAGNCNTN)
+33 QUIT