MAGQE2 ;WOIFO/RMP - Support for MAG Enterprise ; 08/22/2003  13:44
 ;;3.0;IMAGING;**27,29,20,39**;Mar 19, 2002;Build 2010;Mar 08, 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
 ;
AHISU(START,STOP) ;
 N ADHOC
 S ADHOC=1
 ;
ISU ;IMAGING SITE USAGE - SERVER
 N INST,LOC,PLACE,TMP
 I $$CONSOLID^MAGQE5() D
 . S INST="" F  S INST=$O(^MAG(2006.1,"B",INST)) Q:INST=""  D
 . . S PLACE=$O(^MAG(2006.1,"B",INST,"")) Q:'PLACE
 . . Q:($P($G(^MAG(2006.1,PLACE,0)),U)'=INST)  ;Screen Associated Institutions
 . . D ISU1(PLACE,INST)
 . . Q
 . Q
 E  D ISU1($O(^MAG(2006.1," "),-1),$$KSP^XUPARAM("INST"))
 D:'$G(ADHOC) TASK^MAGQE4
 K ^TMP($J,"MAGQ")
 Q
 ;
ISU1(PLACE,INST) ;
 I '$G(ADHOC) D TASK Q  ; We are already in a TaskMan task...
 ;
 S ZTDTH=$$NOW^XLFDT()
 S ZTRTN="TASK^"_$T(+0)
 S ZTDESC="Ad-Hoc Imaging Usage Report ("_$$FMTE^XLFDT(START\1)_" - "_$$FMTE^XLFDT(STOP\1)_")"
 S ZTIO=""
 S ZTSAVE("START")=START
 S ZTSAVE("STOP")=STOP
 S ZTSAVE("PLACE")=PLACE
 S ZTSAVE("INST")=INST
 S:$G(ADHOC) ZTSAVE("ADHOC")=1
 S:$D(MAGDUZ) ZTSAVE("MAGDUZ")=MAGDUZ
 D ^%ZTLOAD
 K ZTDTH,ZTRTN,ZTDESC,ZTIO,ZTSAVE
 Q
 ;
MSG(TXT) N I
 S I=$O(^TMP($J,"MAGQ",PLACE,"SITE_REPORT"," "),-1)+1
 S ^TMP($J,"MAGQ",PLACE,"SITE_REPORT",I)=TXT
 Q
 ;
TASK N DM,I,LOC,OCONS,PCNT,REC,VR,XMSUB,Y,X
 S:'$D(INST) INST=$$KSP^XUPARAM("INST")
 K ^TMP($J,"MAGQ")
 I '$G(START)!'$G(STOP) D
 . S STOP=$$FMADD^XLFDT($$NOW^XLFDT()\100_"01",-1)
 . S START=STOP\100_"01"
 . Q
 S Y=$$NOW^XLFDT,Y=$$FMTE^XLFDT(Y)
 S U="^",LOC=$$GET1^DIQ(4,INST,.01)_"^"_INST
 D MSG("            SITE: "_LOC)
 D MSG("Reporting Period: "_$$FMTE^XLFDT(START\1)_" - "_$$FMTE^XLFDT(STOP\1))
 D MSG("            DATE: "_Y_" "_$G(^XMB("TIMEZONE")))
 D MSG("          DOMAIN: "_$$KSP^XUPARAM("WHERE"))
 D MSG("    2005 ENTRIES: "_$P($G(^MAG(2005,0)),"^",4))
 D MSG(" 2006.81 ENTRIES: "_$$WSP^MAGQE5(PLACE))
 D MSG(" Production Account: "_$$PROD^XUPROD("1"))
 ; Distribute an array each of the capture and display versions
 D IWSV^MAGQE1(PLACE)
 ; VistaRad version
 S VR=$$VERSION^XPDUTL("MAGJ RADIOLOGY") D:VR'="" MSG("VistaRad Version: "_VR)
 I $D(^MAGD(2006.599,0)) D MSG("DICOM Error Log:"_+$P(^MAGD(2006.599,0),"^",4))
 I $D(^MAGD(2006.575,0)) D MSG("DICOM FAILED IMAGES:"_+$P(^MAGD(2006.575,0),"^",4))
 ; Queue File count & Unprocessed Queue entries
 D MSG("Queue File count: "_$$QCNT^MAGQE5(.PCNT,PLACE))
 D MSG("Unprocessed Queue entries: "_PCNT)
 D ISU2^MAGQE5
 S X=""
 S:'$G(ADHOC) X=" ("_$P("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec"," ",START\100#100)_" "_(START\10000+1700)_")"
 S XMSUB=$S($G(ADHOC):"Ad Hoc",1:"Monthly")_" Image Site Usage: "_LOC_X
 D MAILSHR^MAGQBUT1(PLACE,"SITE_REPORT",XMSUB)
 Q
 ;
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGQE2   3676     printed  Sep 23, 2025@19:44:19                                                                                                                                                                                                      Page 2
MAGQE2    ;WOIFO/RMP - Support for MAG Enterprise ; 08/22/2003  13:44
 +1       ;;3.0;IMAGING;**27,29,20,39**;Mar 19, 2002;Build 2010;Mar 08, 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      ;
AHISU(START,STOP) ;
 +1        NEW ADHOC
 +2        SET ADHOC=1
 +3       ;
ISU       ;IMAGING SITE USAGE - SERVER
 +1        NEW INST,LOC,PLACE,TMP
 +2        IF $$CONSOLID^MAGQE5()
               Begin DoDot:1
 +3                SET INST=""
                   FOR 
                       SET INST=$ORDER(^MAG(2006.1,"B",INST))
                       if INST=""
                           QUIT 
                       Begin DoDot:2
 +4                        SET PLACE=$ORDER(^MAG(2006.1,"B",INST,""))
                           if 'PLACE
                               QUIT 
 +5       ;Screen Associated Institutions
                           if ($PIECE($GET(^MAG(2006.1,PLACE,0)),U)'=INST)
                               QUIT 
 +6                        DO ISU1(PLACE,INST)
 +7                        QUIT 
                       End DoDot:2
 +8                QUIT 
               End DoDot:1
 +9       IF '$TEST
               DO ISU1($ORDER(^MAG(2006.1," "),-1),$$KSP^XUPARAM("INST"))
 +10       if '$GET(ADHOC)
               DO TASK^MAGQE4
 +11       KILL ^TMP($JOB,"MAGQ")
 +12       QUIT 
 +13      ;
ISU1(PLACE,INST) ;
 +1       ; We are already in a TaskMan task...
           IF '$GET(ADHOC)
               DO TASK
               QUIT 
 +2       ;
 +3        SET ZTDTH=$$NOW^XLFDT()
 +4        SET ZTRTN="TASK^"_$TEXT(+0)
 +5        SET ZTDESC="Ad-Hoc Imaging Usage Report ("_$$FMTE^XLFDT(START\1)_" - "_$$FMTE^XLFDT(STOP\1)_")"
 +6        SET ZTIO=""
 +7        SET ZTSAVE("START")=START
 +8        SET ZTSAVE("STOP")=STOP
 +9        SET ZTSAVE("PLACE")=PLACE
 +10       SET ZTSAVE("INST")=INST
 +11       if $GET(ADHOC)
               SET ZTSAVE("ADHOC")=1
 +12       if $DATA(MAGDUZ)
               SET ZTSAVE("MAGDUZ")=MAGDUZ
 +13       DO ^%ZTLOAD
 +14       KILL ZTDTH,ZTRTN,ZTDESC,ZTIO,ZTSAVE
 +15       QUIT 
 +16      ;
MSG(TXT)   NEW I
 +1        SET I=$ORDER(^TMP($JOB,"MAGQ",PLACE,"SITE_REPORT"," "),-1)+1
 +2        SET ^TMP($JOB,"MAGQ",PLACE,"SITE_REPORT",I)=TXT
 +3        QUIT 
 +4       ;
TASK       NEW DM,I,LOC,OCONS,PCNT,REC,VR,XMSUB,Y,X
 +1        if '$DATA(INST)
               SET INST=$$KSP^XUPARAM("INST")
 +2        KILL ^TMP($JOB,"MAGQ")
 +3        IF '$GET(START)!'$GET(STOP)
               Begin DoDot:1
 +4                SET STOP=$$FMADD^XLFDT($$NOW^XLFDT()\100_"01",-1)
 +5                SET START=STOP\100_"01"
 +6                QUIT 
               End DoDot:1
 +7        SET Y=$$NOW^XLFDT
           SET Y=$$FMTE^XLFDT(Y)
 +8        SET U="^"
           SET LOC=$$GET1^DIQ(4,INST,.01)_"^"_INST
 +9        DO MSG("            SITE: "_LOC)
 +10       DO MSG("Reporting Period: "_$$FMTE^XLFDT(START\1)_" - "_$$FMTE^XLFDT(STOP\1))
 +11       DO MSG("            DATE: "_Y_" "_$GET(^XMB("TIMEZONE")))
 +12       DO MSG("          DOMAIN: "_$$KSP^XUPARAM("WHERE"))
 +13       DO MSG("    2005 ENTRIES: "_$PIECE($GET(^MAG(2005,0)),"^",4))
 +14       DO MSG(" 2006.81 ENTRIES: "_$$WSP^MAGQE5(PLACE))
 +15       DO MSG(" Production Account: "_$$PROD^XUPROD("1"))
 +16      ; Distribute an array each of the capture and display versions
 +17       DO IWSV^MAGQE1(PLACE)
 +18      ; VistaRad version
 +19       SET VR=$$VERSION^XPDUTL("MAGJ RADIOLOGY")
           if VR'=""
               DO MSG("VistaRad Version: "_VR)
 +20       IF $DATA(^MAGD(2006.599,0))
               DO MSG("DICOM Error Log:"_+$PIECE(^MAGD(2006.599,0),"^",4))
 +21       IF $DATA(^MAGD(2006.575,0))
               DO MSG("DICOM FAILED IMAGES:"_+$PIECE(^MAGD(2006.575,0),"^",4))
 +22      ; Queue File count & Unprocessed Queue entries
 +23       DO MSG("Queue File count: "_$$QCNT^MAGQE5(.PCNT,PLACE))
 +24       DO MSG("Unprocessed Queue entries: "_PCNT)
 +25       DO ISU2^MAGQE5
 +26       SET X=""
 +27       if '$GET(ADHOC)
               SET X=" ("_$PIECE("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec"," ",START\100#100)_" "_(START\10000+1700)_")"
 +28       SET XMSUB=$SELECT($GET(ADHOC):"Ad Hoc",1:"Monthly")_" Image Site Usage: "_LOC_X
 +29       DO MAILSHR^MAGQBUT1(PLACE,"SITE_REPORT",XMSUB)
 +30       QUIT 
 +31      ;