Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: MAGGTU42

MAGGTU42.m

Go to the documentation of this file.
  1. MAGGTU42 ;WOIFO/SG/NST - WORKSTATION-CLIENT VERSION REPORTS ; 30 Apr 2010 11:07 AM
  1. ;;3.0;IMAGING;**93,94**;Mar 19, 2002;Build 1744;May 26, 2010
  1. ;; Per VHA Directive 2004-038, this routine should not be modified.
  1. ;; +---------------------------------------------------------------+
  1. ;; | Property of the US Government. |
  1. ;; | No permission to copy or redistribute this software is given. |
  1. ;; | Use of unreleased versions of this software requires the user |
  1. ;; | to execute a written test agreement with the VistA Imaging |
  1. ;; | Development Office of the Department of Veterans Affairs, |
  1. ;; | telephone (301) 734-0100. |
  1. ;; | The Food and Drug Administration classifies this software as |
  1. ;; | a medical device. As such, it may not be changed in any way. |
  1. ;; | Modifications to this software may result in an adulterated |
  1. ;; | medical device under 21CFR820, the use of which is considered |
  1. ;; | to be a violation of US Federal Statutes. |
  1. ;; +---------------------------------------------------------------+
  1. ;;
  1. Q
  1. ;
  1. ;+++++ PRINTS THE ERROR MESSAGE
  1. ;
  1. ; ERR Error descriptor (see $$ERROR^MAGUERR)
  1. ;
  1. ERROR(ERR) ;
  1. Q:$G(ERR)'<0
  1. W !!,"ERROR: "_$P(ERR,U,2)
  1. W !,"Location: "_$TR($P(ERR,U,3),"~","^")
  1. Q
  1. ;
  1. ;+++++ PRINTS THE REPORT TABLE FOR THE XREF SUBTREE
  1. ;
  1. ; NODE Closed reference (name) of the xref subtree
  1. ;
  1. ; IQS Position of the sequential number in a closed
  1. ; reference of a cross-reference entry.
  1. ;
  1. ; Input Variables
  1. ; ===============
  1. ; MAGRAW, MAGSORT
  1. ;
  1. PRINT(NODE,IQS) ;
  1. N BUF,FLT,FLTL,I,PI,PREVCL,PREVWSNAME,RC,SEQN,TMP
  1. S (PI,FLT)=NODE,FLTL=$L(FLT)-1,FLT=$E(FLT,1,FLTL)
  1. ;---
  1. S (PREVCL,PREVWSNAME)="",RC=0
  1. F S PI=$Q(@PI) Q:$E(PI,1,FLTL)'=FLT D Q:RC<0
  1. . S SEQN=+$QS(PI,IQS),BUF=$G(@MAGRAW@(SEQN)) Q:BUF=""
  1. . ;--- Check if a new page should be started
  1. . S RC=$$PAGE^MAGUTL05(1) Q:RC<0
  1. . D:RC PRTBLH
  1. . ;--- Do not repeat the workstation name for its subsequent
  1. . ;--- clients unless this is the beginning of a new page.
  1. . D:MAGSORT="W"
  1. . . I $P(BUF,U,5)=PREVWSNAME S:'RC $P(BUF,U,5)=""
  1. . . E S PREVWSNAME=$P(BUF,U,5)
  1. . . Q
  1. . ;--- Do not repeat the client name and version for subsequent
  1. . ;--- workstations unless this is the beginning of a new page.
  1. . D:MAGSORT="V"
  1. . . I $P(BUF,U,2,3)=PREVCL S:'RC $P(BUF,U,2,3)=U
  1. . . E S PREVCL=$P(BUF,U,2,3)
  1. . . Q
  1. . ;--- Print the report line
  1. . D PRINT1(BUF)
  1. . Q
  1. ;---
  1. Q $S(RC<0:RC,1:0)
  1. ;
  1. ;+++++ PRINTS THE LINE OF THE REPORT
  1. ;
  1. ; BUF Column values in the same format as those
  1. ; returned by the $$WSCVCHCK^MAGGTU42.
  1. ;
  1. ; If the value of this parameter does not contain
  1. ; the '^' delimiter, then the first character is
  1. ; used to print a separator line.
  1. ;
  1. ; [BUF1] Headers for additional columns (not loaded by the
  1. ; $$WSCVCHCK^MAGGTU42).
  1. ;
  1. ; Input Variables
  1. ; ===============
  1. ; MAGRAW, MAGSORT
  1. ;
  1. PRINT1(BUF,BUF1) ;
  1. N FLDW,SP S SP=" "
  1. ;=== Load additional data from IMAGING WINDOWS WORKSTATIONS file
  1. I BUF>0 D
  1. . N I,IENS,MAGBUF,MAGMSG S IENS=+BUF_","
  1. . D GETS^DIQ(2006.81,IENS,"2;10.5","EI","MAGBUF","MAGMSG")
  1. . S $P(BUF1,U,1)=$G(MAGBUF(2006.81,IENS,2,"I"))
  1. . S $P(BUF1,U,2)=$G(MAGBUF(2006.81,IENS,10.5,"I"))
  1. . ;--- Convert dates to external format
  1. . F I=7 S TMP=$P(BUF,U,I) D:TMP>0
  1. . . S $P(BUF,U,I)=$$FMTE^XLFDT(TMP,"2DZ")
  1. . . Q
  1. . F I=1 S TMP=$P(BUF1,U,I) D:TMP>0
  1. . . S $P(BUF1,U,I)=$$FMTE^XLFDT(TMP,"2DZ")
  1. . . Q
  1. . Q
  1. E S:BUF'[U SP=$E(BUF,1),(BUF,BUF1)=""
  1. ;
  1. ;=== Print the line
  1. I MAGSORT="W" D Q
  1. . W !,$$LJ^XLFSTR($P(BUF,U,5),25,SP) ; Workstation Name
  1. . W " "_$$LJ^XLFSTR($P(BUF,U,2),10,SP) ; Client Application
  1. . W " "_$$LJ^XLFSTR($P(BUF,U,3),14,SP) ; Client Version
  1. . W " "_$$CJ^XLFSTR($P(BUF,U,7),8,SP) ; Client Date
  1. . W " "_$$CJ^XLFSTR($P(BUF1,U,1),8,SP) ; Last Logon
  1. . W " "_$$CJ^XLFSTR($P(BUF1,U,2),4,SP) ; Session Type
  1. . Q
  1. ;---
  1. W !,$$LJ^XLFSTR($P(BUF,U,2),10,SP) ; Client Application
  1. W " "_$$LJ^XLFSTR($P(BUF,U,3),14,SP) ; Client Version
  1. W " "_$$LJ^XLFSTR($P(BUF,U,5),25,SP) ; Workstation Name
  1. W " "_$$CJ^XLFSTR($P(BUF,U,7),8,SP) ; Client Date
  1. W " "_$$CJ^XLFSTR($P(BUF1,U,1),8,SP) ; Last Logon
  1. W " "_$$CJ^XLFSTR($P(BUF1,U,2),4,SP) ; Session Type
  1. Q
  1. ;
  1. ;+++++ PRINTS THE TABLE HEADER
  1. ;
  1. ; Input Variables
  1. ; ===============
  1. ; MAGPAGE
  1. ;
  1. ; Output Variables
  1. ; ================
  1. ; MAGPAGE
  1. ;
  1. PRTBLH ;
  1. N TMP
  1. S MAGPAGE=MAGPAGE+1
  1. W:MAGPAGE>1 !,$$RJ^XLFSTR("Page "_MAGPAGE,IOM-1)
  1. ;--- 1st line of the table headers
  1. S TMP="^^^^^^Client"
  1. D PRINT1(TMP,"Last^")
  1. ;--- 2nd line of the table headers
  1. S TMP="^Client^Client Version^^Workstation Name^^Date"
  1. D PRINT1(TMP,"Logon^Type")
  1. ;--- Separator
  1. D PRINT1("-")
  1. Q
  1. ;
  1. ;##### CHECKS VERSIONS OF CLIENTS THAT RAN ON THE WORKSTATIONS
  1. ;
  1. ; MAG8DST Closed reference (name) of a parent node where
  1. ; the list of workstations is returned to.
  1. ;
  1. ; @MAG8DST@(
  1. ;
  1. ; 0) Result descriptor
  1. ; ^01: Number of fields in the data record
  1. ;
  1. ; Seq#) Workstation-Client data
  1. ; ^01: Workstation IEN (file #2006.81)
  1. ; ^02: Client application name (see the
  1. ; $$CLADESC^MAGGTU41 for details)
  1. ; ^03: Client version (from the last run)
  1. ; ^04: Version check code returned by
  1. ; the $$CHKVER1^MAGGTU41
  1. ; ^05: Workstation name (value of the .01 field)
  1. ; ^06: External value of the PLACE field (.04)
  1. ; ^07: Client application date/time (internal)
  1. ;
  1. ; "CPW", Number of subscripts in the Client-Place-Workstation
  1. ; index (see the "C" flag below).
  1. ; ClientName,PlaceName,WSName,Seq#)=""
  1. ;
  1. ; "PCVW", Number of subscripts in the Place-Client-Version-
  1. ; Patch-Build-Workstation ("PCVW") index in the result
  1. ; array (see the "V" flag below).
  1. ; PlaceName,ClientName,Version,Patch,Build,WSName,Seq#)=""
  1. ;
  1. ; "PWC", Number of subscripts in the Place-Workstation-Client
  1. ; index (see the "W" flag below).
  1. ; PlaceName,WSName,ClientName,Seq#)=""
  1. ;
  1. ; "TOTALS" Count total workstations processed and how many have to updated
  1. ; ^01: Total workstations processed
  1. ; ^02: Total workstations need to be updated
  1. ;
  1. ; [FLAGS] Flags that control the execution (can be combined):
  1. ;
  1. ; C Create the Client-Place-Workstation ("CPW")
  1. ; index in the result array.
  1. ;
  1. ; V Create the Place-Client-Version-Patch-Build-
  1. ; Workstation ("PCVW") index in the result array.
  1. ;
  1. ; W Create the Place-Workstation-Client ("PWC")
  1. ; index in the result array.
  1. ;
  1. ; [CVRCTRSH] Threshold number for the version check code (0-4).
  1. ; If the version check code is not less than the
  1. ; threshold, then the workstation-client pair is
  1. ; added to the result list.
  1. ;
  1. ; If this parameter is not defined or empty, then
  1. ; the value of 3 is assumed (see $$CHKVER1^MAGGTU41
  1. ; for details).
  1. ;
  1. ; [CLALST] List of client names (see the $$CLADESC^MAGGTU41
  1. ; for details)) separated by commas.
  1. ;
  1. ; By default ($G(CLALST)=""), all supported clients
  1. ; are checked.
  1. ;
  1. ; MAGLLGDT Workstation Last Login date
  1. ;
  1. ; MAGWNMB Workstation name contains
  1. ;
  1. ; MAGALLW Include all workstations in the report (0/1)
  1. ;
  1. ;
  1. ; Return Values
  1. ; =============
  1. ; <0 Error descriptor (see $$ERROR^MAGUERR)
  1. ; 0 Ok
  1. ;
  1. WSCVCHCK(MAG8DST,FLAGS,CVRCTRSH,CLALST,MAGLLGDT,MAGWNMB,MAGALLW) ;
  1. N MAGVCD ; Version control data
  1. ;
  1. N CLNAME,CLVER,CVRC,FLDLST,I,IENS,MAG8BUF,MAG8I
  1. N MAGMSG,N,PLACE,TMP,WSIEN,WSNAME
  1. N FUPDWS ; Should I update the workstation
  1. N FRPTWS ; Workstation has at least one version check
  1. ;
  1. ;=== Validate parameters and initialize variables
  1. Q:$G(MAG8DST)?." " $$ERROR^MAGUERR(-8,,"MAG8DST")
  1. K @MAG8DST S MAG8I=0
  1. ;--- Client name(s)
  1. S CLALST=$TR($G(CLALST)," ")
  1. S:CLALST="" CLALST=$$CLADESC^MAGGTU41()
  1. ;--- Version check threshold
  1. I $G(CVRCTRSH)="" S CVRCTRSH=3
  1. E D Q:TMP $$IPVE^MAGUERR("CVRCTRSH")
  1. . S TMP=$S(+CVRCTRSH'=CVRCTRSH:1,CVRCTRSH<0:1,CVRCTRSH>4:1,1:0)
  1. . Q
  1. ;--- Flags
  1. S FLAGS=$G(FLAGS)
  1. ;
  1. ;=== Client applications and version field numbers
  1. S FLDLST="",N=$L(CLALST,",")
  1. F I=1:1:N S CLNAME=$P(CLALST,",",I) D
  1. . S MAG8BUF=$$CLADESC^MAGGTU41(CLNAME) Q:MAG8BUF<0
  1. . ;--- Version field number
  1. . S TMP=+$P(MAG8BUF,U,2)
  1. . S:TMP>0 $P(FLDLST(CLNAME),U,1)=TMP,FLDLST=FLDLST_";"_TMP
  1. . ;--- Date/time field number
  1. . S TMP=+$P(MAG8BUF,U,3)
  1. . S:TMP>0 $P(FLDLST(CLNAME),U,2)=TMP,FLDLST=FLDLST_";"_TMP
  1. . Q
  1. ;---
  1. Q:FLDLST="" $$ERROR^MAGUERR(-26,,"FLDLST")
  1. S FLDLST=".01;.04;2"_FLDLST
  1. ;
  1. S WSIEN=0
  1. F S WSIEN=$O(^MAG(2006.81,WSIEN)) Q:WSIEN'>0 D
  1. . K MAG8BUF,MAGMSG
  1. . ;=== Get the workstation data
  1. . S IENS=WSIEN_","
  1. . D GETS^DIQ(2006.81,IENS,FLDLST,"EI","MAG8BUF","MAGMSG")
  1. . I MAGLLGDT>$G(MAG8BUF(2006.81,IENS,2,"I")) Q ; Last login date is older than requested
  1. . S WSNAME=$G(MAG8BUF(2006.81,IENS,.01,"E")) ; NAME
  1. . S:WSNAME="" WSNAME="#"_WSIEN ; Just in case ;-)
  1. . I '(WSNAME[MAGWNMB) Q ; Skip. Machine name does not contain MAGWNMB
  1. . S PLACE=$G(MAG8BUF(2006.81,IENS,.04,"E")) ; PLACE
  1. . S:PLACE="" PLACE=" "
  1. . ;
  1. . ;=== Check the clients
  1. . S CLNAME=""
  1. . S FRPTWS=0
  1. . F S CLNAME=$O(FLDLST(CLNAME)) Q:CLNAME="" D
  1. . . S CLVER=$G(MAG8BUF(2006.81,IENS,+FLDLST(CLNAME),"E")) Q:CLVER=""
  1. . . ;--- Check the version
  1. . . S CVRC=$$CHKVER1^MAGGTU41(.MAGVCD,CLNAME,.CLVER)
  1. . . Q:CVRC<0 ; Skip values with errors
  1. . . S FRPTWS=1 ; at least one client version is checked
  1. . . S FUPDWS=1
  1. . . I CVRC<CVRCTRSH Q:'MAGALLW S FUPDWS=0,CLVER="*"_CLVER ; Skip values below threshold or add them we report all workstations
  1. . . ;--- Store the result
  1. . . S MAG8BUF=WSIEN_U_CLNAME_U_CLVER_U_CVRC_U_WSNAME_U_PLACE
  1. . . S TMP=+$P(FLDLST(CLNAME),U,2)
  1. . . S:TMP $P(MAG8BUF,U,7)=$G(MAG8BUF(2006.81,IENS,TMP,"I"))
  1. . . S MAG8I=MAG8I+1,@MAG8DST@(MAG8I)=MAG8BUF
  1. . . ;--- Create indexes
  1. . . S:FLAGS["C" @MAG8DST@("CPW",CLNAME,PLACE,WSNAME,MAG8I)=""
  1. . . D:FLAGS["V"
  1. . . . S TMP=$NA(@MAG8DST@("PCVW",PLACE,CLNAME,+$P(CLVER,".",1,2)))
  1. . . . S @TMP@(+$P(CLVER,".",3),+$P(CLVER,".",4),WSNAME,MAG8I)=""
  1. . . . Q
  1. . . S:FLAGS["W" @MAG8DST@("PWC",PLACE,WSNAME,CLNAME,MAG8I)=""
  1. . . I FUPDWS,'$D(@MAG8DST@("TOTALSU",WSNAME)) D
  1. . . . S @MAG8DST@("TOTALSU",WSNAME)=""
  1. . . . S $P(@MAG8DST@("TOTALS"),U,2)=$P($G(@MAG8DST@("TOTALS")),U,2)+1
  1. . . . Q
  1. . . Q
  1. . I FRPTWS,'$D(@MAG8DST@("TOTALS",WSNAME)) D
  1. . . S @MAG8DST@("TOTALS",WSNAME)=""
  1. . . S $P(@MAG8DST@("TOTALS"),U)=$P($G(@MAG8DST@("TOTALS")),U)+1
  1. . . Q
  1. . Q
  1. ;
  1. ;=== Store the result characteristics
  1. D:$D(@MAG8DST)>0
  1. . ;--- Numbers of subscripts in the indexes
  1. . S:FLAGS["C" @MAG8DST@("CPW")=7
  1. . S:FLAGS["V" @MAG8DST@("PCVW")=10
  1. . S:FLAGS["W" @MAG8DST@("PWC")=7
  1. . ;--- Number of fields in the data record
  1. . S @MAG8DST@(0)=7
  1. . Q
  1. ;===
  1. Q 0
  1. ;
  1. ;***** PRINTS THE WORKSTATION-CLIENT VERSION CHECK REPORT
  1. ;
  1. ; Input Variables
  1. ; ===============
  1. ; MAGSORT ; Sort mode for the report
  1. ; MAGLLGDT ; Workstation Last Login date
  1. ; MAGWNMB ; Workstation name contains
  1. ;
  1. ;
  1. ; Notes
  1. ; =====
  1. ;
  1. ; The ^TMP("MAGGTU42",$J) global node is used by this entry point to
  1. ; store the raw report data.
  1. ;
  1. WSCVCRPT ;
  1. N MAGPAGE ; Current page number
  1. N MAGRAW ; Closed reference (name) of the raw report data
  1. ;
  1. N RC
  1. N PRINTHDR ; If the header is printed already
  1. S MAGRAW=$NA(^TMP("MAGGTU42",$J))
  1. S (MAGPAGE,RC)=0
  1. ;
  1. D
  1. . N BUF,FLAGS,IQS,PLACE,XREF
  1. . S FLAGS=$S($G(MAGSORT)'="":MAGSORT,1:"V")
  1. . S MAGLLGDT=$S($G(MAGLLGDT)="":$P($$FMADD^XLFDT($$NOW^XLFDT,-30),"."),1:MAGLLGDT)
  1. . S MAGWNMB=$G(MAGWNMB)
  1. . S MAGALLW=$S($G(MAGALLW)="":"N",1:MAGALLW)
  1. . S XREF=$S(FLAGS="V":"PCVW",FLAGS="W":"PWC",1:"")
  1. . I XREF="" S RC=$$IPVE^MAGUERR("MAGSORT") Q
  1. . ;
  1. . ;=== Compile the list of workstations and clients
  1. . S RC=$$WSCVCHCK(MAGRAW,FLAGS,"","",MAGLLGDT,MAGWNMB,MAGALLW) Q:RC<0
  1. . S IQS=+$G(@MAGRAW@(XREF))
  1. . I IQS<0 S RC=$$ERROR^MAGUERR(-26,,$NA(@MAGRAW@(XREF))) Q
  1. . ;
  1. . ;=== Print the report for each site
  1. . S PRINTHDR=1 ; will print report header if there is no data to print
  1. . S PLACE="",$Y=0
  1. . F S PLACE=$O(@MAGRAW@(XREF,PLACE)) Q:PLACE="" D Q:RC<0
  1. . . W:$E(IOST,1,2)="C-" @IOF
  1. . . ;--- Print the header
  1. . . S PRINTHDR=0
  1. . . D PRTRHDR(MAGALLW,MAGLLGDT,MAGWNMB,IOM)
  1. . . W !,$$CJ^XLFSTR(PLACE,IOM),!
  1. . . D PRTBLH
  1. . . ;--- Print the table
  1. . . S RC=$$PRINT($NA(@MAGRAW@(XREF,PLACE)),IQS) Q:RC<0
  1. . . ;--- Force the new page after the end of each section
  1. . . S RC=$$PAGE^MAGUTL05(1,1) Q:RC<0
  1. . . Q
  1. . D:PRINTHDR PRTRHDR(MAGALLW,MAGLLGDT,MAGWNMB,IOM)
  1. . S BUF="Workstation(s) found: "_$P(@MAGRAW@("TOTALS"),U)
  1. . W !!,$$LJ^XLFSTR(BUF,IOM)
  1. . S BUF="Workstation(s) to be updated: "_+$P(@MAGRAW@("TOTALS"),U,2)
  1. . W !,$$LJ^XLFSTR(BUF,IOM)
  1. . Q
  1. ;
  1. ;=== Error handling and cleanup
  1. D ERROR(RC):RC<-2,^%ZISC
  1. S:$D(ZTQUEUED) ZTREQ="@"
  1. K @MAGRAW
  1. Q
  1. ;
  1. PRTRHDR(MAGALLW,MAGLLGDT,MAGWNMB,IOM) ;--- Print report the header
  1. N BUF
  1. S BUF=$S(MAGALLW:"LIST OF ALL WORKSTATIONS AND CLIENTS",1:"LIST OF WORKSTATIONS AND CLIENTS THAT HAVE TO BE UPDATED")
  1. W !,$$CJ^XLFSTR(BUF,IOM)
  1. S BUF="LAST LOGIN DATE: "_$$FMTE^XLFDT(MAGLLGDT)
  1. S BUF=BUF_$S(MAGWNMB'="":" WS NAME CONTAINS: "_MAGWNMB,1:"")
  1. W !,$$CJ^XLFSTR(BUF,IOM)
  1. W !,$$CJ^XLFSTR($$REPEAT^XLFSTR("=",$L(BUF)),IOM)
  1. Q