MAGSIXG4 ;WOIFO/SG - LIST OF IMAGES RPCS (POST-PROCESSING) ; 4/6/09 1:49pm
;;3.0;IMAGING;**93**;Dec 02, 2009;Build 163
;;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. |
;; +---------------------------------------------------------------+
;;
;
; LOCAL VARIABLE ------ DESCRIPTION
;
; MAGDATA( Closed root of the result array
;
; "MAXNUM") If the value of this node is greater than 0,
; then it determines the maximum number of
; images returned by the query. See the MAXNUM
; parameter of the GETIMGS^MAGSIXG1.
;
; "RESCNT") Counter of image entries in the result array
;
; "CAPTAPP",...)
; "CLS",...)
; "EVT",...)
; "FLAGS")
; "GDESC",...)
; "IDFN")
; "ISTAT",...)
; "ORIG",...)
; "PKG",...)
;
; "PREVPT") IEN of the patient who the previous image was
; associated with.
;
; "SAVEDBY")
; "SENSIMG",...)
; "SPEC",...)
;
; "SUBSET%") Percentage of preselected image entries
; returned by the sparse subset query. See the
; S flag of the GETIMGS^MAGSIXG1 for details.
;
; "TCNT") Total number of preselected image entries.
;
; "TYPE",...)
;
; Nodes PREVPT, SUBSET%, and TCNT exist only during sparse subset
; queries. See the S flag of the GETIMGS^MAGSIXG1 for details.
;
; TEMPORARY GLOBAL ---- DESCRIPTION
;
; ^TMP("MAGSIXG3",$J,
;
; "P", BUFFER FOR "PRIORITY" IMAGE ENTRIES
; Counter, Image info
; |01: Counter
; |02: Image IEN
; |03: Group counters ($$GRPCT^MAGGI14)
; 0) Image descriptor
;
; "R", BUFFER FOR REGULAR IMAGE ENTRIES
; Seq#, Image info
; |01: Counter
; |02: Image IEN
; |03: Group counters ($$GRPCT^MAGGI14)
; 0) Image descriptor
;
Q
;
;+++++ POST-PROCESSING FOR THE SPARSE SUBSET QUERY
;
; Input Variables
; ===============
; MAGDATA, ^TMP("MAGSIXG3",$J,...)
;
; Output Variables
; ================
; MAGDATA, MAGOUT
;
; Return Values
; =============
; <0 Error descriptor (see the $$ERROR^MAGUERR)
; 0 Success
; >0 Success; not all "priority" records are returned
;
SUBSET() ;
Q:$G(MAGDATA("TCNT"))'>0 0
N FLTX,I,IIFLAGS,MORE,PCNT,RC,RCNT,TMP
S RC=0
;
;--- Get the nuber of images in temporary buffers
S RCNT=+$O(^TMP("MAGSIXG3",$J,"R",""),-1) ; Regular
S PCNT=MAGDATA("TCNT")-RCNT ; "Priority"
;
;--- Calculate the maximum number of images (requested percentage)
S TMP=MAGDATA("TCNT")*$G(MAGDATA("SUBSET%"))/100
S MAGDATA("MAXNUM")=$J(TMP,0,0)
S:MAGDATA("MAXNUM")<1 MAGDATA("MAXNUM")=1
S MORE=(PCNT>MAGDATA("MAXNUM"))
;
;--- Merge images from the regular buffer to the "priority" one
;--- to fill the latter up to MAXNUM entries.
I PCNT<MAGDATA("MAXNUM"),RCNT>0 D Q:RC<0 RC
. N RSV,STEP
. S STEP=RCNT/(MAGDATA("MAXNUM")-PCNT) S:STEP<1 STEP=1
. F RSV=1:STEP:RCNT S I=RSV\1 D Q:RC
. . S TMP=$P($G(^TMP("MAGSIXG3",$J,"R",I)),"|")
. . I TMP>0,'$D(^TMP("MAGSIXG3",$J,"P",TMP)) D Q
. . . M ^TMP("MAGSIXG3",$J,"P",TMP)=^TMP("MAGSIXG3",$J,"R",I)
. . . K ^TMP("MAGSIXG3",$J,"R",I)
. . . Q
. . S RC=$$ERROR^MAGUERR(-47) ; This should never happen!
. . Q
. Q
;
;--- Copy selected image entries to the result array
S IIFLAGS=$$TRFLAGS^MAGUTL05(MAGDATA("FLAGS"),"DE")
S I=""
F S I=$O(^TMP("MAGSIXG3",$J,"P",I)) Q:I="" D Q:RC
. I MAGDATA("RESCNT")'<MAGDATA("MAXNUM") S RC=1 Q
. S TMP=^TMP("MAGSIXG3",$J,"P",I),FLTX=^(I,0)
. S RC=$$APPEND^MAGSIXG3($P(TMP,"|",2),FLTX,$P(TMP,"|",3),IIFLAGS)
. Q
;---
Q $S(RC<0:RC,1:MORE)
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGSIXG4 4956 printed Dec 13, 2024@02:08:24 Page 2
MAGSIXG4 ;WOIFO/SG - LIST OF IMAGES RPCS (POST-PROCESSING) ; 4/6/09 1:49pm
+1 ;;3.0;IMAGING;**93**;Dec 02, 2009;Build 163
+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 ;
+19 ; LOCAL VARIABLE ------ DESCRIPTION
+20 ;
+21 ; MAGDATA( Closed root of the result array
+22 ;
+23 ; "MAXNUM") If the value of this node is greater than 0,
+24 ; then it determines the maximum number of
+25 ; images returned by the query. See the MAXNUM
+26 ; parameter of the GETIMGS^MAGSIXG1.
+27 ;
+28 ; "RESCNT") Counter of image entries in the result array
+29 ;
+30 ; "CAPTAPP",...)
+31 ; "CLS",...)
+32 ; "EVT",...)
+33 ; "FLAGS")
+34 ; "GDESC",...)
+35 ; "IDFN")
+36 ; "ISTAT",...)
+37 ; "ORIG",...)
+38 ; "PKG",...)
+39 ;
+40 ; "PREVPT") IEN of the patient who the previous image was
+41 ; associated with.
+42 ;
+43 ; "SAVEDBY")
+44 ; "SENSIMG",...)
+45 ; "SPEC",...)
+46 ;
+47 ; "SUBSET%") Percentage of preselected image entries
+48 ; returned by the sparse subset query. See the
+49 ; S flag of the GETIMGS^MAGSIXG1 for details.
+50 ;
+51 ; "TCNT") Total number of preselected image entries.
+52 ;
+53 ; "TYPE",...)
+54 ;
+55 ; Nodes PREVPT, SUBSET%, and TCNT exist only during sparse subset
+56 ; queries. See the S flag of the GETIMGS^MAGSIXG1 for details.
+57 ;
+58 ; TEMPORARY GLOBAL ---- DESCRIPTION
+59 ;
+60 ; ^TMP("MAGSIXG3",$J,
+61 ;
+62 ; "P", BUFFER FOR "PRIORITY" IMAGE ENTRIES
+63 ; Counter, Image info
+64 ; |01: Counter
+65 ; |02: Image IEN
+66 ; |03: Group counters ($$GRPCT^MAGGI14)
+67 ; 0) Image descriptor
+68 ;
+69 ; "R", BUFFER FOR REGULAR IMAGE ENTRIES
+70 ; Seq#, Image info
+71 ; |01: Counter
+72 ; |02: Image IEN
+73 ; |03: Group counters ($$GRPCT^MAGGI14)
+74 ; 0) Image descriptor
+75 ;
+76 QUIT
+77 ;
+78 ;+++++ POST-PROCESSING FOR THE SPARSE SUBSET QUERY
+79 ;
+80 ; Input Variables
+81 ; ===============
+82 ; MAGDATA, ^TMP("MAGSIXG3",$J,...)
+83 ;
+84 ; Output Variables
+85 ; ================
+86 ; MAGDATA, MAGOUT
+87 ;
+88 ; Return Values
+89 ; =============
+90 ; <0 Error descriptor (see the $$ERROR^MAGUERR)
+91 ; 0 Success
+92 ; >0 Success; not all "priority" records are returned
+93 ;
SUBSET() ;
+1 if $GET(MAGDATA("TCNT"))'>0
QUIT 0
+2 NEW FLTX,I,IIFLAGS,MORE,PCNT,RC,RCNT,TMP
+3 SET RC=0
+4 ;
+5 ;--- Get the nuber of images in temporary buffers
+6 ; Regular
SET RCNT=+$ORDER(^TMP("MAGSIXG3",$JOB,"R",""),-1)
+7 ; "Priority"
SET PCNT=MAGDATA("TCNT")-RCNT
+8 ;
+9 ;--- Calculate the maximum number of images (requested percentage)
+10 SET TMP=MAGDATA("TCNT")*$GET(MAGDATA("SUBSET%"))/100
+11 SET MAGDATA("MAXNUM")=$JUSTIFY(TMP,0,0)
+12 if MAGDATA("MAXNUM")<1
SET MAGDATA("MAXNUM")=1
+13 SET MORE=(PCNT>MAGDATA("MAXNUM"))
+14 ;
+15 ;--- Merge images from the regular buffer to the "priority" one
+16 ;--- to fill the latter up to MAXNUM entries.
+17 IF PCNT<MAGDATA("MAXNUM")
IF RCNT>0
Begin DoDot:1
+18 NEW RSV,STEP
+19 SET STEP=RCNT/(MAGDATA("MAXNUM")-PCNT)
if STEP<1
SET STEP=1
+20 FOR RSV=1:STEP:RCNT
SET I=RSV\1
Begin DoDot:2
+21 SET TMP=$PIECE($GET(^TMP("MAGSIXG3",$JOB,"R",I)),"|")
+22 IF TMP>0
IF '$DATA(^TMP("MAGSIXG3",$JOB,"P",TMP))
Begin DoDot:3
+23 MERGE ^TMP("MAGSIXG3",$JOB,"P",TMP)=^TMP("MAGSIXG3",$JOB,"R",I)
+24 KILL ^TMP("MAGSIXG3",$JOB,"R",I)
+25 QUIT
End DoDot:3
QUIT
+26 ; This should never happen!
SET RC=$$ERROR^MAGUERR(-47)
+27 QUIT
End DoDot:2
if RC
QUIT
+28 QUIT
End DoDot:1
if RC<0
QUIT RC
+29 ;
+30 ;--- Copy selected image entries to the result array
+31 SET IIFLAGS=$$TRFLAGS^MAGUTL05(MAGDATA("FLAGS"),"DE")
+32 SET I=""
+33 FOR
SET I=$ORDER(^TMP("MAGSIXG3",$JOB,"P",I))
if I=""
QUIT
Begin DoDot:1
+34 IF MAGDATA("RESCNT")'<MAGDATA("MAXNUM")
SET RC=1
QUIT
+35 SET TMP=^TMP("MAGSIXG3",$JOB,"P",I)
SET FLTX=^(I,0)
+36 SET RC=$$APPEND^MAGSIXG3($PIECE(TMP,"|",2),FLTX,$PIECE(TMP,"|",3),IIFLAGS)
+37 QUIT
End DoDot:1
if RC
QUIT
+38 ;---
+39 QUIT $SELECT(RC<0:RC,1:MORE)