MAGGA03U ;WOIFO/GEK,MLH - USERS CAPTURED IMAGES IN DATE RANGE ; 6/6/2011 5:23 PM
;;3.0;IMAGING;**93,117**;Mar 19, 2002;Build 2238;Jul 15, 2011
;; 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
;***** RETURNS USERS THAT HAVE CAPTURED IMAGES IN THE DATE RANGE
; RPC: MAGG CAPTURE USERS
; .MAGRY Reference to a local variable where the results
; are returned to.
;
; FLAGS Controls which users are returned.
; FLAGS refers to field #8.1 CAPTURE APPLICATION
; That field tells which device captured this image.
; C = Capture Application
; Images that were captured by VI Capture Client
; I = Import API
; Images that were captured by VI Import API
; If Flags is 'null' it defaults to 'CI'
; So, it returns Users that have capture C and/or
; I images, in the date range.
;
; [FROMDATE] Date range for image selection. Dates can be in
; [TODATE] internal or external FileMan format. If a date
; parameter is not defined or empty, then an error
; is returned.
;
; Time parts of parameter values are ignored and both
; ends of the date range are included in the search.
; For example, in order to search images for May 21,
; 2008, the internal value of both parameters should
; be 3080521.
;
; If the FROMDATE is after the TODATE, then values of
; the parameters are swapped.
;
; Return Values
; =============
;
; MAGRY(0) is in the format: 0^<error message> if error during execution
; or 1^<success message>
; MAGRY(1..n) are in the format: Last First Middle ^ DUZ
; Notes
; =====
;
; Temporary global nodes ^TMP("MAGGA03U",$J) and ^TMP($J,"MAGUSERS"
; and ^TMP($J,"MAGDUZ" are used by this procedure.
;
USERS(MAGRY,FROMDATE,TODATE,FLAGS) ; [RPC MAGG CAPTURE USERS]
N I,EDT,N0,N2,CT,TMP,MERR,CAPAPP,IDUZ,INM,MSG,X,Y
S MAGRY=$NA(^TMP("MAGGA03U",$J))
K @MAGRY,^TMP($J,"MAGUSERS"),^TMP($J,"MAGDUZ")
;
; Validate parameters.
S MERR=0
D
. S FLAGS=$G(FLAGS) I FLAGS="" S FLAGS="CI"
. I $TR(FLAGS,"CI")'="" S MERR=1,MSG="Invalid Flags: '"_FLAGS_"'. Only 'C' and/or 'I'" Q
. S X=$G(FROMDATE) D ^%DT I Y=-1 S MERR=1,MSG="Invalid date "_FROMDATE Q
. S FROMDATE=Y
. S X=$G(TODATE) D ^%DT I Y=-1 S MERR=1,MSG="Invalid date "_TODATE Q
. S TODATE=Y
I MERR S @MAGRY@(0)="0^"_MSG Q
;
; Swap the dates if necessary
K TMP I FROMDATE>TODATE S TMP=FROMDATE,FROMDATE=TODATE,TODATE=TMP
;
; Loop through ADTDUZ Cross ref and find users that have captured images.
;
F I=1:1 S CAPAPP=$E(FLAGS,I) Q:CAPAPP="" D
. S EDT=$$FMADD^XLFDT(TODATE,1)
. F S EDT=$O(^MAG(2005,"ADTDUZ",CAPAPP,EDT),-1) Q:EDT<FROMDATE D
. . S IDUZ="" F S IDUZ=$O(^MAG(2005,"ADTDUZ",CAPAPP,EDT,IDUZ)) Q:IDUZ="" D
. . . S ^TMP($J,"MAGDUZ",IDUZ)=""
. . . Q
. . Q
. Q
; convert DUZ to Names using Kernel API
I '$D(^TMP($J,"MAGDUZ")) S @MAGRY@(0)="0^No users found." Q
S IDUZ="" F S IDUZ=$O(^TMP($J,"MAGDUZ",IDUZ)) Q:'IDUZ D
. S INM=$$GETNAME(IDUZ)
. S ^TMP($J,"MAGUSERS",INM,IDUZ)=""
. Q
;
; Result array from Names and DUZs
S CT=0,(INM,IDUZ)=""
F S INM=$O(^TMP($J,"MAGUSERS",INM)) Q:INM="" D
. F S IDUZ=$O(^TMP($J,"MAGUSERS",INM,IDUZ)) Q:IDUZ="" D
. . S CT=CT+1,@MAGRY@(CT)=INM_"^"_IDUZ
S @MAGRY@(0)=1_"^Success: "_CT_" users found"
K ^TMP($J,"MAGUSERS"),^TMP($J,"MAGDUZ")
Q
;
;***** RETURN NAME FROM NAME COMPONENTS
; IDUZ is the DUZ of the User.
; Uses supported API #3065 to call $$NAMEFMT^XLFNAME()
; ===== Return values
; Returns the name in mixed case "Last,First Middle" format
GETNAME(IDUZ) ;
N MAGN,MN
; set the needed parameters for the API Call.
S MAGN("FILE")=200
S MAGN("IENS")=IDUZ_","
S MAGN("FIELD")=".01"
; make the call
S MN=$$NAMEFMT^XLFNAME(.MAGN,"F","FMC")
; handle problems with call
I MN="" S MN="Undefined User "_IDUZ
Q MN
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGGA03U 5131 printed Nov 22, 2024@17:12:30 Page 2
MAGGA03U ;WOIFO/GEK,MLH - USERS CAPTURED IMAGES IN DATE RANGE ; 6/6/2011 5:23 PM
+1 ;;3.0;IMAGING;**93,117**;Mar 19, 2002;Build 2238;Jul 15, 2011
+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 ;***** RETURNS USERS THAT HAVE CAPTURED IMAGES IN THE DATE RANGE
+19 ; RPC: MAGG CAPTURE USERS
+20 ; .MAGRY Reference to a local variable where the results
+21 ; are returned to.
+22 ;
+23 ; FLAGS Controls which users are returned.
+24 ; FLAGS refers to field #8.1 CAPTURE APPLICATION
+25 ; That field tells which device captured this image.
+26 ; C = Capture Application
+27 ; Images that were captured by VI Capture Client
+28 ; I = Import API
+29 ; Images that were captured by VI Import API
+30 ; If Flags is 'null' it defaults to 'CI'
+31 ; So, it returns Users that have capture C and/or
+32 ; I images, in the date range.
+33 ;
+34 ; [FROMDATE] Date range for image selection. Dates can be in
+35 ; [TODATE] internal or external FileMan format. If a date
+36 ; parameter is not defined or empty, then an error
+37 ; is returned.
+38 ;
+39 ; Time parts of parameter values are ignored and both
+40 ; ends of the date range are included in the search.
+41 ; For example, in order to search images for May 21,
+42 ; 2008, the internal value of both parameters should
+43 ; be 3080521.
+44 ;
+45 ; If the FROMDATE is after the TODATE, then values of
+46 ; the parameters are swapped.
+47 ;
+48 ; Return Values
+49 ; =============
+50 ;
+51 ; MAGRY(0) is in the format: 0^<error message> if error during execution
+52 ; or 1^<success message>
+53 ; MAGRY(1..n) are in the format: Last First Middle ^ DUZ
+54 ; Notes
+55 ; =====
+56 ;
+57 ; Temporary global nodes ^TMP("MAGGA03U",$J) and ^TMP($J,"MAGUSERS"
+58 ; and ^TMP($J,"MAGDUZ" are used by this procedure.
+59 ;
USERS(MAGRY,FROMDATE,TODATE,FLAGS) ; [RPC MAGG CAPTURE USERS]
+1 NEW I,EDT,N0,N2,CT,TMP,MERR,CAPAPP,IDUZ,INM,MSG,X,Y
+2 SET MAGRY=$NAME(^TMP("MAGGA03U",$JOB))
+3 KILL @MAGRY,^TMP($JOB,"MAGUSERS"),^TMP($JOB,"MAGDUZ")
+4 ;
+5 ; Validate parameters.
+6 SET MERR=0
+7 Begin DoDot:1
+8 SET FLAGS=$GET(FLAGS)
IF FLAGS=""
SET FLAGS="CI"
+9 IF $TRANSLATE(FLAGS,"CI")'=""
SET MERR=1
SET MSG="Invalid Flags: '"_FLAGS_"'. Only 'C' and/or 'I'"
QUIT
+10 SET X=$GET(FROMDATE)
DO ^%DT
IF Y=-1
SET MERR=1
SET MSG="Invalid date "_FROMDATE
QUIT
+11 SET FROMDATE=Y
+12 SET X=$GET(TODATE)
DO ^%DT
IF Y=-1
SET MERR=1
SET MSG="Invalid date "_TODATE
QUIT
+13 SET TODATE=Y
End DoDot:1
+14 IF MERR
SET @MAGRY@(0)="0^"_MSG
QUIT
+15 ;
+16 ; Swap the dates if necessary
+17 KILL TMP
IF FROMDATE>TODATE
SET TMP=FROMDATE
SET FROMDATE=TODATE
SET TODATE=TMP
+18 ;
+19 ; Loop through ADTDUZ Cross ref and find users that have captured images.
+20 ;
+21 FOR I=1:1
SET CAPAPP=$EXTRACT(FLAGS,I)
if CAPAPP=""
QUIT
Begin DoDot:1
+22 SET EDT=$$FMADD^XLFDT(TODATE,1)
+23 FOR
SET EDT=$ORDER(^MAG(2005,"ADTDUZ",CAPAPP,EDT),-1)
if EDT<FROMDATE
QUIT
Begin DoDot:2
+24 SET IDUZ=""
FOR
SET IDUZ=$ORDER(^MAG(2005,"ADTDUZ",CAPAPP,EDT,IDUZ))
if IDUZ=""
QUIT
Begin DoDot:3
+25 SET ^TMP($JOB,"MAGDUZ",IDUZ)=""
+26 QUIT
End DoDot:3
+27 QUIT
End DoDot:2
+28 QUIT
End DoDot:1
+29 ; convert DUZ to Names using Kernel API
+30 IF '$DATA(^TMP($JOB,"MAGDUZ"))
SET @MAGRY@(0)="0^No users found."
QUIT
+31 SET IDUZ=""
FOR
SET IDUZ=$ORDER(^TMP($JOB,"MAGDUZ",IDUZ))
if 'IDUZ
QUIT
Begin DoDot:1
+32 SET INM=$$GETNAME(IDUZ)
+33 SET ^TMP($JOB,"MAGUSERS",INM,IDUZ)=""
+34 QUIT
End DoDot:1
+35 ;
+36 ; Result array from Names and DUZs
+37 SET CT=0
SET (INM,IDUZ)=""
+38 FOR
SET INM=$ORDER(^TMP($JOB,"MAGUSERS",INM))
if INM=""
QUIT
Begin DoDot:1
+39 FOR
SET IDUZ=$ORDER(^TMP($JOB,"MAGUSERS",INM,IDUZ))
if IDUZ=""
QUIT
Begin DoDot:2
+40 SET CT=CT+1
SET @MAGRY@(CT)=INM_"^"_IDUZ
End DoDot:2
End DoDot:1
+41 SET @MAGRY@(0)=1_"^Success: "_CT_" users found"
+42 KILL ^TMP($JOB,"MAGUSERS"),^TMP($JOB,"MAGDUZ")
+43 QUIT
+44 ;
+45 ;***** RETURN NAME FROM NAME COMPONENTS
+46 ; IDUZ is the DUZ of the User.
+47 ; Uses supported API #3065 to call $$NAMEFMT^XLFNAME()
+48 ; ===== Return values
+49 ; Returns the name in mixed case "Last,First Middle" format
GETNAME(IDUZ) ;
+1 NEW MAGN,MN
+2 ; set the needed parameters for the API Call.
+3 SET MAGN("FILE")=200
+4 SET MAGN("IENS")=IDUZ_","
+5 SET MAGN("FIELD")=".01"
+6 ; make the call
+7 SET MN=$$NAMEFMT^XLFNAME(.MAGN,"F","FMC")
+8 ; handle problems with call
+9 IF MN=""
SET MN="Undefined User "_IDUZ
+10 QUIT MN