MAGGI14 ;WOIFO/SG/ZEB - IMAGE FILE API (GROUP PROPERTIES) ; 5/1/09 2:48pm
;;3.0;IMAGING;**93,365**;Dec 02, 2009;Build 19
;;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
;
;##### FINDS REFERENCE TO "CHILD" IMAGE IN OBJECT GROUP MULTIPLE
;
; GRPIEN Internal Entry Number of the group.
;
; IMGIEN Internal Entry Number of the image.
;
; Return Values
; =============
; <0 Error descriptor (see the $$ERROR^MAGUERR)
; 0 The multiple does not reference the image
; >0 IEN of the record of the OBJECT GROUP multiple (#4)
; that references the image.
;
FINDCHLD(GRPIEN,IMGIEN) ;
N IEN,NODE,RC
S NODE=$$NODE^MAGGI11(GRPIEN,.RC)
I NODE="" D STORE^MAGUERR(RC) Q RC
S IEN=0
F S IEN=$O(@NODE@(1,IEN)) Q:IEN'>0 Q:$P($G(^(IEN,0)),U)=IMGIEN
Q $S(IEN>0:IEN,1:0)
;
;##### RETURNS THE 1ST IMAGE OF THE GROUP
;
; GRPIEN Internal Entry Number of the image record
;
; FLAGS Flags that control the execution (can be combined):
;
; D Consider deleted images (file #2005.1)
; E Consider existing images (file #2005)
;
; If neither 'E' nor 'D' flag is provided, then an
; error code is returned.
;
; Return Values
; =============
; <0 Error descriptor (see the $$ERROR^MAGUERR)
; 0 Group contains no images of requested kind(s)
; >0 IEN of the 1st image of the group
;
; Notes
; =====
;
; This function does not return an error code when it encounters an
; invalid image reference in the OBJECT GROUP multiple (4); it just
; skips the entry.
;
GRPCH1(GRPIEN,FLAGS) ;
N CH1IEN,ERR,I,IEN,NODE
S FLAGS=$G(FLAGS),CH1IEN=0
;--- Unknown/Unsupported flag(s)
;*zeb *365 add support for O flag
Q:$TR(FLAGS,"ODE")'="" $$IPVE^MAGUERR("FLAGS")
;--- Missing required flag
Q:$TR(FLAGS,"DE")=FLAGS $$ERROR^MAGUERR(-6,,"D,E")
;
;--- Get the global node of the record
S NODE=$$NODE^MAGGI11(GRPIEN,.ERR)
I NODE="" D STORE^MAGUERR(ERR) Q ERR
;
;--- Check the existing (non-deleted) group memebers
I FLAGS["E" D I IEN>0 S:'CH1IEN!(IEN<CH1IEN) CH1IEN=IEN
. S (I,IEN)=0
. F S I=$O(@NODE@(1,I)) Q:I'>0 D Q:IEN>0
. . S IEN=+@NODE@(1,I,0) ; OBJECT GROUP (.01)
. . I IEN>0,$D(^MAG(2005,IEN))>1 Q
. . S IEN=0 ; Skip the bad entry
. . Q
. Q
;
;--- Check the deleted group memebers
I FLAGS["D" D I IEN>0 S:'CH1IEN!(IEN<CH1IEN) CH1IEN=IEN
. S IEN=0
. F D Q:IEN'>0 Q:$D(^MAG(2005,IEN))>1
. . S IEN=$O(^MAG(2005,"AGPD",GRPIEN,IEN))
. . Q
. ;~~~ Delete this comment and the following lines of code when
. ;~~~ the IMAGE AUDIT file (#2005.1) is completely eliminated.
. Q:IEN>0
. S IEN=0
. F D Q:IEN'>0 Q:$D(^MAG(2005.1,IEN))>1
. . S IEN=$O(^MAG(2005.1,"AGP",GRPIEN,IEN))
. . Q
. ;~~~
. Q
;
;---
Q CH1IEN
;
;##### RETURNS NUMBERS OF IMAGES AND PAGES IN THE GROUP
;
; GRPIEN Internal Entry Number of the image record
;
; [FLAGS] Flags that control the execution (can be combined):
;
; P Include page counts (see the NUMBER OF PAGES
; field (114) for details).
;
; S Return image counts grouped by image status in
; the array defined by the DETAILS parameter.
;
; U Return image counts grouped by users in
; the array defined by the DETAILS parameter.
;
; [.DETAILS] Reference to a local array where detailed image
; counts are returned.
;
; DETAILS(
; "S",
; Status) Counts of images with this internal value of the
; STATUS field (112). Zero subscript is used if the
; field is empty.
; ^01: Number of existing entries
; ^02: Number of deleted entries
; ^03: Number of existing images (pages)
; ^04: Number of deleted images (pages)
;
; This list is compiled only if the "S" flag is
; provided (see the FLAGS parameter above).
; "U",
; UserIEN, Counts of images captured by this user (see the
; IMAGE SAVE BY field (8). Zero subscript is used
; if the field is empty.
; ^01: Number of existing entries
; ^02: Number of deleted entries
; ^03: Number of existing images (pages)
; ^04: Number of deleted images (pages)
;
; Status) Counts of images with this internal value of the
; STATUS field (112) captured by the user. Zero
; subscript is used if the field is empty.
; ^01: Number of existing entries
; ^02: Number of deleted entries
; ^03: Number of existing images (pages)
; ^04: Number of deleted images (pages)
;
; This list is compiled only if the "U" flag is
; provided (see the FLAGS parameter above).
;
; Return Values
; =============
; <0 Error descriptor (see the $$ERROR^MAGUERR)
; '<0 Numbers of images in the group
; ^01: Number of existing entries
; ^02: Number of deleted entries
; ^03: Number of existing images (pages)
; ^04: Number of deleted images (pages)
;
; Notes
; =====
;
; Pieces 3 and 4 of the function result and nodes of the DETAILS are
; populated only if the P flag is provided (see the FLAGS parameter).
;
; This function does not return an error code when it encounters an
; invalid image reference in the OBJECT GROUP multiple (4); it just
; skips the entry.
;
GRPCT(GRPIEN,FLAGS,DETAILS) ;
N I,IEN,MAGF,NT,TMP,TOTALS
K DETAILS("S"),DETAILS("U")
;--- Validate control flags
S FLAGS=$G(FLAGS),NT=2
Q:$TR(FLAGS,"PSU")'="" $$IPVE^MAGUERR("FLAGS")
S:FLAGS["P" MAGF("P")="",NT=4
S:FLAGS["S" MAGF("D","S")=""
S:FLAGS["U" MAGF("D","U")=""
;--- Validate the record IEN
I '$$ISVALID^MAGGI11(GRPIEN,.TMP) D STORE^MAGUERR(TMP) Q TMP
;
;--- Count existing (non-deleted) members and pages
I $D(MAGF)>1 D
. N CHIEN
. S CHIEN=0
. F S CHIEN=$O(^MAG(2005,GRPIEN,1,CHIEN)) Q:CHIEN'>0 D
. . S IEN=+$G(^MAG(2005,GRPIEN,1,CHIEN,0)) ; OBJECT GROUP (.01)
. . Q:IEN'>0 Q:$D(^MAG(2005,IEN))<10
. . S TOTALS(1)=$G(TOTALS(1))+1
. . D GRPCT1(2005,IEN,1)
. . Q
. Q
E D
. S TOTALS(1)=+$P($G(^MAG(2005,GRPIEN,1,0)),U,4)
. Q
;
;--- Count deleted members and pages
S IEN=0
F S IEN=$O(^MAG(2005,"AGPD",GRPIEN,IEN)) Q:IEN'>0 D
. Q:$D(^MAG(2005,IEN))<10
. S TOTALS(2)=$G(TOTALS(2))+1
. D:$D(MAGF)>1 GRPCT1(2005,IEN,2)
. Q
;
;~~~ Delete this comment and the following lines of code when
;~~~ the IMAGE AUDIT file (#2005.1) is completely eliminated.
S IEN=0
F S IEN=$O(^MAG(2005.1,"AGP",GRPIEN,IEN)) Q:IEN'>0 D
. Q:$D(^MAG(2005.1,IEN))<10
. S TOTALS(2)=$G(TOTALS(2))+1
. D:$D(MAGF)>1 GRPCT1(2005.1,IEN,2)
. Q
;
;--- Calculate users' totals
D:$D(MAGF("D","U"))
. N STC,USRIEN
. S USRIEN=""
. F S USRIEN=$O(DETAILS("U",USRIEN)) Q:USRIEN="" D
. . S STC="" K TMP
. . F S STC=$O(DETAILS("U",USRIEN,STC)) Q:STC="" D
. . . S TMP=DETAILS("U",USRIEN,STC)
. . . F I=1:1:NT S TMP(I)=$G(TMP(I))+$P(TMP,U,I)
. . . Q
. . F I=1:1:NT S $P(DETAILS("U",USRIEN),U,I)=+$G(TMP(I))
. . Q
. Q
;
;--- Return group totals
S TMP=""
F I=1:1:NT S $P(TMP,U,I)=+$G(TOTALS(I))
Q TMP
;
;+++++ DETAILED COUNTS FOR THE IMAGE
;
; FILE File number (2005 or 2005.1)
; IEN IEN of the image entry
; CP Piece number for the entry count (1 or 2)
;
; Input Variables
; ===============
; DETAILS, MAGF, TOTALS
;
; Output Variables
; ================
; DETAILS, TOTALS
;
GRPCT1(FILE,IEN,CP) ;
N NP,STC,TMP,USRIEN
;--- Count the pages
D:$D(MAGF("P"))
. S NP=+$P($G(^MAG(FILE,IEN,100)),U,10) ; NUMBER OF PAGES (114)
. S:NP'>0 NP=1
. S TOTALS(CP+2)=$G(TOTALS(CP+2))+NP
. Q
;--- Get the image status code for detailed counts
Q:$D(MAGF("D"))<10
S STC=+$$IMGST^MAGGI11(IEN,.TMP) Q:TMP<0
;--- Counts by image statuses
D:$D(MAGF("D","S"))
. S TMP=$G(DETAILS("S",STC))
. S $P(DETAILS("S",STC),U,CP)=$P(TMP,U,CP)+1
. S:$G(NP)>0 $P(DETAILS("S",STC),U,CP+2)=$P(TMP,U,CP+2)+NP
. Q
;--- Counts by users
D:$D(MAGF("D","U"))
. S USRIEN=+$P($G(^MAG(FILE,IEN,2)),U,2) ; IMAGE SAVE BY (8)
. S TMP=$G(DETAILS("U",USRIEN,STC))
. S $P(DETAILS("U",USRIEN,STC),U,CP)=$P(TMP,U,CP)+1
. S:$G(NP)>0 $P(DETAILS("U",USRIEN,STC),U,CP+2)=$P(TMP,U,CP+2)+NP
. Q
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGGI14 9804 printed May 25, 2026@12:06:23 Page 2
MAGGI14 ;WOIFO/SG/ZEB - IMAGE FILE API (GROUP PROPERTIES) ; 5/1/09 2:48pm
+1 ;;3.0;IMAGING;**93,365**;Dec 02, 2009;Build 19
+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 ;; | |
+11 ;; | The Food and Drug Administration classifies this software as |
+12 ;; | a medical device. As such, it may not be changed in any way. |
+13 ;; | Modifications to this software may result in an adulterated |
+14 ;; | medical device under 21CFR820, the use of which is considered |
+15 ;; | to be a violation of US Federal Statutes. |
+16 ;; +---------------------------------------------------------------+
+17 ;;
+18 QUIT
+19 ;
+20 ;##### FINDS REFERENCE TO "CHILD" IMAGE IN OBJECT GROUP MULTIPLE
+21 ;
+22 ; GRPIEN Internal Entry Number of the group.
+23 ;
+24 ; IMGIEN Internal Entry Number of the image.
+25 ;
+26 ; Return Values
+27 ; =============
+28 ; <0 Error descriptor (see the $$ERROR^MAGUERR)
+29 ; 0 The multiple does not reference the image
+30 ; >0 IEN of the record of the OBJECT GROUP multiple (#4)
+31 ; that references the image.
+32 ;
FINDCHLD(GRPIEN,IMGIEN) ;
+1 NEW IEN,NODE,RC
+2 SET NODE=$$NODE^MAGGI11(GRPIEN,.RC)
+3 IF NODE=""
DO STORE^MAGUERR(RC)
QUIT RC
+4 SET IEN=0
+5 FOR
SET IEN=$ORDER(@NODE@(1,IEN))
if IEN'>0
QUIT
if $PIECE($GET(^(IEN,0)),U)=IMGIEN
QUIT
+6 QUIT $SELECT(IEN>0:IEN,1:0)
+7 ;
+8 ;##### RETURNS THE 1ST IMAGE OF THE GROUP
+9 ;
+10 ; GRPIEN Internal Entry Number of the image record
+11 ;
+12 ; FLAGS Flags that control the execution (can be combined):
+13 ;
+14 ; D Consider deleted images (file #2005.1)
+15 ; E Consider existing images (file #2005)
+16 ;
+17 ; If neither 'E' nor 'D' flag is provided, then an
+18 ; error code is returned.
+19 ;
+20 ; Return Values
+21 ; =============
+22 ; <0 Error descriptor (see the $$ERROR^MAGUERR)
+23 ; 0 Group contains no images of requested kind(s)
+24 ; >0 IEN of the 1st image of the group
+25 ;
+26 ; Notes
+27 ; =====
+28 ;
+29 ; This function does not return an error code when it encounters an
+30 ; invalid image reference in the OBJECT GROUP multiple (4); it just
+31 ; skips the entry.
+32 ;
GRPCH1(GRPIEN,FLAGS) ;
+1 NEW CH1IEN,ERR,I,IEN,NODE
+2 SET FLAGS=$GET(FLAGS)
SET CH1IEN=0
+3 ;--- Unknown/Unsupported flag(s)
+4 ;*zeb *365 add support for O flag
+5 if $TRANSLATE(FLAGS,"ODE")'=""
QUIT $$IPVE^MAGUERR("FLAGS")
+6 ;--- Missing required flag
+7 if $TRANSLATE(FLAGS,"DE")=FLAGS
QUIT $$ERROR^MAGUERR(-6,,"D,E")
+8 ;
+9 ;--- Get the global node of the record
+10 SET NODE=$$NODE^MAGGI11(GRPIEN,.ERR)
+11 IF NODE=""
DO STORE^MAGUERR(ERR)
QUIT ERR
+12 ;
+13 ;--- Check the existing (non-deleted) group memebers
+14 IF FLAGS["E"
Begin DoDot:1
+15 SET (I,IEN)=0
+16 FOR
SET I=$ORDER(@NODE@(1,I))
if I'>0
QUIT
Begin DoDot:2
+17 ; OBJECT GROUP (.01)
SET IEN=+@NODE@(1,I,0)
+18 IF IEN>0
IF $DATA(^MAG(2005,IEN))>1
QUIT
+19 ; Skip the bad entry
SET IEN=0
+20 QUIT
End DoDot:2
if IEN>0
QUIT
+21 QUIT
End DoDot:1
IF IEN>0
if 'CH1IEN!(IEN<CH1IEN)
SET CH1IEN=IEN
+22 ;
+23 ;--- Check the deleted group memebers
+24 IF FLAGS["D"
Begin DoDot:1
+25 SET IEN=0
+26 FOR
Begin DoDot:2
+27 SET IEN=$ORDER(^MAG(2005,"AGPD",GRPIEN,IEN))
+28 QUIT
End DoDot:2
if IEN'>0
QUIT
if $DATA(^MAG(2005,IEN))>1
QUIT
+29 ;~~~ Delete this comment and the following lines of code when
+30 ;~~~ the IMAGE AUDIT file (#2005.1) is completely eliminated.
+31 if IEN>0
QUIT
+32 SET IEN=0
+33 FOR
Begin DoDot:2
+34 SET IEN=$ORDER(^MAG(2005.1,"AGP",GRPIEN,IEN))
+35 QUIT
End DoDot:2
if IEN'>0
QUIT
if $DATA(^MAG(2005.1,IEN))>1
QUIT
+36 ;~~~
+37 QUIT
End DoDot:1
IF IEN>0
if 'CH1IEN!(IEN<CH1IEN)
SET CH1IEN=IEN
+38 ;
+39 ;---
+40 QUIT CH1IEN
+41 ;
+42 ;##### RETURNS NUMBERS OF IMAGES AND PAGES IN THE GROUP
+43 ;
+44 ; GRPIEN Internal Entry Number of the image record
+45 ;
+46 ; [FLAGS] Flags that control the execution (can be combined):
+47 ;
+48 ; P Include page counts (see the NUMBER OF PAGES
+49 ; field (114) for details).
+50 ;
+51 ; S Return image counts grouped by image status in
+52 ; the array defined by the DETAILS parameter.
+53 ;
+54 ; U Return image counts grouped by users in
+55 ; the array defined by the DETAILS parameter.
+56 ;
+57 ; [.DETAILS] Reference to a local array where detailed image
+58 ; counts are returned.
+59 ;
+60 ; DETAILS(
+61 ; "S",
+62 ; Status) Counts of images with this internal value of the
+63 ; STATUS field (112). Zero subscript is used if the
+64 ; field is empty.
+65 ; ^01: Number of existing entries
+66 ; ^02: Number of deleted entries
+67 ; ^03: Number of existing images (pages)
+68 ; ^04: Number of deleted images (pages)
+69 ;
+70 ; This list is compiled only if the "S" flag is
+71 ; provided (see the FLAGS parameter above).
+72 ; "U",
+73 ; UserIEN, Counts of images captured by this user (see the
+74 ; IMAGE SAVE BY field (8). Zero subscript is used
+75 ; if the field is empty.
+76 ; ^01: Number of existing entries
+77 ; ^02: Number of deleted entries
+78 ; ^03: Number of existing images (pages)
+79 ; ^04: Number of deleted images (pages)
+80 ;
+81 ; Status) Counts of images with this internal value of the
+82 ; STATUS field (112) captured by the user. Zero
+83 ; subscript is used if the field is empty.
+84 ; ^01: Number of existing entries
+85 ; ^02: Number of deleted entries
+86 ; ^03: Number of existing images (pages)
+87 ; ^04: Number of deleted images (pages)
+88 ;
+89 ; This list is compiled only if the "U" flag is
+90 ; provided (see the FLAGS parameter above).
+91 ;
+92 ; Return Values
+93 ; =============
+94 ; <0 Error descriptor (see the $$ERROR^MAGUERR)
+95 ; '<0 Numbers of images in the group
+96 ; ^01: Number of existing entries
+97 ; ^02: Number of deleted entries
+98 ; ^03: Number of existing images (pages)
+99 ; ^04: Number of deleted images (pages)
+100 ;
+101 ; Notes
+102 ; =====
+103 ;
+104 ; Pieces 3 and 4 of the function result and nodes of the DETAILS are
+105 ; populated only if the P flag is provided (see the FLAGS parameter).
+106 ;
+107 ; This function does not return an error code when it encounters an
+108 ; invalid image reference in the OBJECT GROUP multiple (4); it just
+109 ; skips the entry.
+110 ;
GRPCT(GRPIEN,FLAGS,DETAILS) ;
+1 NEW I,IEN,MAGF,NT,TMP,TOTALS
+2 KILL DETAILS("S"),DETAILS("U")
+3 ;--- Validate control flags
+4 SET FLAGS=$GET(FLAGS)
SET NT=2
+5 if $TRANSLATE(FLAGS,"PSU")'=""
QUIT $$IPVE^MAGUERR("FLAGS")
+6 if FLAGS["P"
SET MAGF("P")=""
SET NT=4
+7 if FLAGS["S"
SET MAGF("D","S")=""
+8 if FLAGS["U"
SET MAGF("D","U")=""
+9 ;--- Validate the record IEN
+10 IF '$$ISVALID^MAGGI11(GRPIEN,.TMP)
DO STORE^MAGUERR(TMP)
QUIT TMP
+11 ;
+12 ;--- Count existing (non-deleted) members and pages
+13 IF $DATA(MAGF)>1
Begin DoDot:1
+14 NEW CHIEN
+15 SET CHIEN=0
+16 FOR
SET CHIEN=$ORDER(^MAG(2005,GRPIEN,1,CHIEN))
if CHIEN'>0
QUIT
Begin DoDot:2
+17 ; OBJECT GROUP (.01)
SET IEN=+$GET(^MAG(2005,GRPIEN,1,CHIEN,0))
+18 if IEN'>0
QUIT
if $DATA(^MAG(2005,IEN))<10
QUIT
+19 SET TOTALS(1)=$GET(TOTALS(1))+1
+20 DO GRPCT1(2005,IEN,1)
+21 QUIT
End DoDot:2
+22 QUIT
End DoDot:1
+23 IF '$TEST
Begin DoDot:1
+24 SET TOTALS(1)=+$PIECE($GET(^MAG(2005,GRPIEN,1,0)),U,4)
+25 QUIT
End DoDot:1
+26 ;
+27 ;--- Count deleted members and pages
+28 SET IEN=0
+29 FOR
SET IEN=$ORDER(^MAG(2005,"AGPD",GRPIEN,IEN))
if IEN'>0
QUIT
Begin DoDot:1
+30 if $DATA(^MAG(2005,IEN))<10
QUIT
+31 SET TOTALS(2)=$GET(TOTALS(2))+1
+32 if $DATA(MAGF)>1
DO GRPCT1(2005,IEN,2)
+33 QUIT
End DoDot:1
+34 ;
+35 ;~~~ Delete this comment and the following lines of code when
+36 ;~~~ the IMAGE AUDIT file (#2005.1) is completely eliminated.
+37 SET IEN=0
+38 FOR
SET IEN=$ORDER(^MAG(2005.1,"AGP",GRPIEN,IEN))
if IEN'>0
QUIT
Begin DoDot:1
+39 if $DATA(^MAG(2005.1,IEN))<10
QUIT
+40 SET TOTALS(2)=$GET(TOTALS(2))+1
+41 if $DATA(MAGF)>1
DO GRPCT1(2005.1,IEN,2)
+42 QUIT
End DoDot:1
+43 ;
+44 ;--- Calculate users' totals
+45 if $DATA(MAGF("D","U"))
Begin DoDot:1
+46 NEW STC,USRIEN
+47 SET USRIEN=""
+48 FOR
SET USRIEN=$ORDER(DETAILS("U",USRIEN))
if USRIEN=""
QUIT
Begin DoDot:2
+49 SET STC=""
KILL TMP
+50 FOR
SET STC=$ORDER(DETAILS("U",USRIEN,STC))
if STC=""
QUIT
Begin DoDot:3
+51 SET TMP=DETAILS("U",USRIEN,STC)
+52 FOR I=1:1:NT
SET TMP(I)=$GET(TMP(I))+$PIECE(TMP,U,I)
+53 QUIT
End DoDot:3
+54 FOR I=1:1:NT
SET $PIECE(DETAILS("U",USRIEN),U,I)=+$GET(TMP(I))
+55 QUIT
End DoDot:2
+56 QUIT
End DoDot:1
+57 ;
+58 ;--- Return group totals
+59 SET TMP=""
+60 FOR I=1:1:NT
SET $PIECE(TMP,U,I)=+$GET(TOTALS(I))
+61 QUIT TMP
+62 ;
+63 ;+++++ DETAILED COUNTS FOR THE IMAGE
+64 ;
+65 ; FILE File number (2005 or 2005.1)
+66 ; IEN IEN of the image entry
+67 ; CP Piece number for the entry count (1 or 2)
+68 ;
+69 ; Input Variables
+70 ; ===============
+71 ; DETAILS, MAGF, TOTALS
+72 ;
+73 ; Output Variables
+74 ; ================
+75 ; DETAILS, TOTALS
+76 ;
GRPCT1(FILE,IEN,CP) ;
+1 NEW NP,STC,TMP,USRIEN
+2 ;--- Count the pages
+3 if $DATA(MAGF("P"))
Begin DoDot:1
+4 ; NUMBER OF PAGES (114)
SET NP=+$PIECE($GET(^MAG(FILE,IEN,100)),U,10)
+5 if NP'>0
SET NP=1
+6 SET TOTALS(CP+2)=$GET(TOTALS(CP+2))+NP
+7 QUIT
End DoDot:1
+8 ;--- Get the image status code for detailed counts
+9 if $DATA(MAGF("D"))<10
QUIT
+10 SET STC=+$$IMGST^MAGGI11(IEN,.TMP)
if TMP<0
QUIT
+11 ;--- Counts by image statuses
+12 if $DATA(MAGF("D","S"))
Begin DoDot:1
+13 SET TMP=$GET(DETAILS("S",STC))
+14 SET $PIECE(DETAILS("S",STC),U,CP)=$PIECE(TMP,U,CP)+1
+15 if $GET(NP)>0
SET $PIECE(DETAILS("S",STC),U,CP+2)=$PIECE(TMP,U,CP+2)+NP
+16 QUIT
End DoDot:1
+17 ;--- Counts by users
+18 if $DATA(MAGF("D","U"))
Begin DoDot:1
+19 ; IMAGE SAVE BY (8)
SET USRIEN=+$PIECE($GET(^MAG(FILE,IEN,2)),U,2)
+20 SET TMP=$GET(DETAILS("U",USRIEN,STC))
+21 SET $PIECE(DETAILS("U",USRIEN,STC),U,CP)=$PIECE(TMP,U,CP)+1
+22 if $GET(NP)>0
SET $PIECE(DETAILS("U",USRIEN,STC),U,CP+2)=$PIECE(TMP,U,CP+2)+NP
+23 QUIT
End DoDot:1
+24 QUIT