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

XTVSLPR1.m

Go to the documentation of this file.
XTVSLPR1 ;Albany FO/GTS - VistA Package Sizing Manager; 18-DEC-2018
 ;;7.3;TOOLKIT;**143**;Apr 25, 1995;Build 116
 ;
 ;APIs
INCONSCK ;Check for overlaps in Forum Package file data
 ;Requires ^TMP("XTVS-PFXIDX",$J,<prefix>,<package name>) & ^TMP("XTVS-FRIDX",$J,<begin file #>,<end file #>,<package name>)
 NEW TMPROOT,PKGNME,PREFIX,ADPFXIND,OLDPKG
 SET TMPROOT="^TMP(""XTVS-PKGEDIT"","_$J_")"
 SET OLDPKG=$QSUBSCRIPT($QUERY(@TMPROOT),3)
 SET ADPFXIND=0
 FOR  SET TMPROOT=$QUERY(@TMPROOT) QUIT:TMPROOT=""  Q:$QSUBSCRIPT(TMPROOT,1)'="XTVS-PKGEDIT"  Q:$QSUBSCRIPT(TMPROOT,2)'=$JOB  DO
 . SET PKGNME=$QSUBSCRIPT(TMPROOT,3)
 . SET PREFIX=$QSUBSCRIPT(TMPROOT,4)
 . ; Execute "If" code when a new package is encountered
 . IF (OLDPKG'=PKGNME) DO
 .. ;1st loop on pkg, check primary prefix
 .. IF ('ADPFXIND) DO CHKPFX(PKGNME,PREFIX,"^TMP(""XTVS-PKGEDIT"","_$J_","""_PKGNME_""","""_PREFIX_""")",PREFIX)
 .. SET ADPFXIND=0 ;Reset the Add Prefix list found indicator after the first pass on the latest package
 . SET OLDPKG=PKGNME
 . DO FLDDATLP(TMPROOT,PKGNME,PREFIX,.ADPFXIND) ; Loop fields and data to check Prefix and File ranges
 KILL ^TMP("XTVS-PKGRPT-PFX-IDX",$J),^TMP("XTVS-PKGRPT-FRNG-IDX",$J),^TMP("XTVS-PKGRPT-CMB-IDX",$J)
 QUIT
 ;
FLDDATLP(TMPROOT,PKGNME,PREFIX,ADPFXIND) ;Check Fields and Data for 'ADDPFX' and 'FLERNG' Nodes
 ; Input: TMPROOT  - Package "XTVS-PKGEDIT" array root [^TMP("XTVS-PKGEDIT",$J,PKGNME,PREFIX)]
 ;        PKGNME   - Package Name using Prefix
 ;        PREFIX   - Additional Prefix used by Package
 ;        ADPFXIND - Indicates that prefix has been checked
 ;
 NEW FLDSUB,DATASUB,FLERNGFD
 SET FLERNGFD=0 ;Set compare file ranges by first found : FILE RANGE, *LOWEST/*HIGHEST, FILE LIST
 SET FLDSUB=""  ;Extract Field Subscript looking for Additional Prefixes and File Ranges
 FOR  SET FLDSUB=$O(@TMPROOT@(FLDSUB)) Q:FLDSUB=""  DO
 . SET DATASUB=""
 . FOR  SET DATASUB=$O(@TMPROOT@(FLDSUB,DATASUB)) Q:DATASUB=""  DO
 .. ;NOTE: To change Field Subscript, check different value of FLDSUB
 .. IF FLDSUB="ADDPFX" DO CHKPFX(PKGNME,DATASUB,TMPROOT,PREFIX) SET ADPFXIND=1
 .. IF FLDSUB="F1-FLERNG" DO  ;FILE RANGE
 ... DO CHKFILE(PKGNME,DATASUB,TMPROOT,PREFIX,"F1")
 ... SET FLERNGFD=1
 .. IF 'FLERNGFD,FLDSUB="F2-BEGFILE",$D(@TMPROOT@("F2-ENDFILE")) DO  ;*LOWEST - *HIGHEST
 ... DO CHKFILE(PKGNME,DATASUB,TMPROOT,PREFIX,"F2")
 ... IF $O(@TMPROOT@(FLDSUB,DATASUB))="" SET FLERNGFD=1
 .. IF 'FLERNGFD,FLDSUB="F3-FNUM" DO  ;FILE LIST
 ... DO CHKFILE(PKGNME,DATASUB,TMPROOT,PREFIX,"F3")
 ... IF $O(@TMPROOT@(FLDSUB,DATASUB))="" SET FLERNGFD=1
 QUIT
 ;
CHKPFX(PKGNME,PREFIX,TMPROOT,PKGPFX) ; Check Prefix for multiple use
 ; Input: PKGNME  - Package Name using Prefix
 ;        PREFIX  - Additional Prefix used by Package
 ;        TMPROOT - Package "XTVS-PKGEDIT" array root [^TMP("XTVS-PKGEDIT",J,PKGNME,PREFIX)]
 ;        PKGPFX  - Package Prefix
 ;
 ; Output: ^TMP("XTVS-ERROR",$J,"PREFIX") array
 ;
 NEW IDXROOT,PKGSUB,ERRARYCT,FILERPRT,ADDREMPX
 SET FILERPRT=0
 SET IDXROOT="^TMP(""XTVS-PFXIDX"","_$J_","""_PREFIX_""")"  ;Use "PFXIDX" index
 SET ADDREMPX=@IDXROOT@(PKGNME)
 SET ERRARYCT=+$O(^TMP("XTVS-ERROR",$J,"PREFIX",""),-1)
 FOR  SET IDXROOT=$QUERY(@IDXROOT) Q:IDXROOT=""  Q:$QSUBSCRIPT(IDXROOT,1)'="XTVS-PFXIDX"  Q:$QSUBSCRIPT(IDXROOT,3)'[PREFIX  Q:$QSUBSCRIPT(IDXROOT,2)'=$JOB  DO
 . SET PKGSUB=$QSUBSCRIPT(IDXROOT,4)
 . IF PKGSUB'=PKGNME DO
 .. NEW IDXRT3
 .. SET IDXRT3=$QSUBSCRIPT(IDXROOT,3)
 .. IF IDXRT3=PREFIX DO MLTPFX(TMPROOT,PKGSUB,PKGNME,IDXRT3,.ERRARYCT,.FILERPRT)
 .. IF (IDXRT3'=PREFIX),(ADDREMPX'[IDXRT3) DO MLTPFX(TMPROOT,PKGSUB,PKGNME,IDXRT3,.ERRARYCT,.FILERPRT)
 ;
 QUIT
 ;
CHKFILE(PKGNME,FLERNG,TMPROOT,PKGPFX,FSRC) ; Check File range for multiple use
 ; Input: PKGNME  - Package Name using Prefix
 ;        FILRNG  - File Range used by Package Name
 ;        TMPROOT - Package "XTVS-PKGEDIT" array root
 ;        PKGPFX  - Package Prefix
 ;        FSRC    - File Source
 ;                    F1 : File Range multiple
 ;                    F2 : *LOW/*HIGH fields
 ;                    F3 : File List multiple
 ;
 ; Output: ^TMP("XTVS-ERROR",$J,"FILERNG") array
 ;
 NEW IDXROOT,STARTSUB,ENDSUB,PKGSUB,ERRARYCT,RNGBEG,RNGEND,PKGRPRT,RNGIND,PARENT,PREFIX
 NEW NODETXT,CMBARCT,NDTXTCMB,FTYPE,OPFTCODE,OPFTYPE
 SET PKGRPRT=0
 SET FTYPE=$S(FSRC="F1":"File Range:",FSRC="F2":"LOW/HIGH range:",FSRC="F3":"File #",1:"")
 SET RNGBEG=$P(FLERNG,"-")
 SET RNGEND=$P(FLERNG,"-",2)
 SET ERRARYCT=+$O(^TMP("XTVS-ERROR",$J,"FILERNG",""),-1)
 SET IDXROOT="^TMP(""XTVS-FRIDX"","_$J_")"
 FOR  SET IDXROOT=$QUERY(@IDXROOT) Q:IDXROOT=""  Q:$QSUBSCRIPT(IDXROOT,1)'="XTVS-FRIDX"  Q:$QSUBSCRIPT(IDXROOT,2)'=$JOB  DO
 . SET STARTSUB=$QSUBSCRIPT(IDXROOT,3)
 . SET ENDSUB=$QSUBSCRIPT(IDXROOT,4)
 . SET PKGSUB=$QSUBSCRIPT(IDXROOT,5)
 . IF PKGSUB'=PKGNME DO
 .. SET RNGIND=$$RNGCHK(RNGBEG,RNGEND,STARTSUB,ENDSUB)
 .. IF RNGIND DO
 ... SET ERRARYCT=ERRARYCT+1
 ... IF ERRARYCT=1 DO SETFLHDR("FILERNG",.ERRARYCT)
 ... ;
 ... SET CMBARCT=+$O(^TMP("XTVS-ERROR",$J,"COMB-PFX-FLRNG",""),-1)
 ... IF +CMBARCT=0 DO CMBARST(.CMBARCT)
 ... ;
 ... IF 'PKGRPRT DO NOPKGRT(TMPROOT,PKGNME,PKGPFX,FTYPE,.ERRARYCT,.CMBARCT,.PKGRPRT) ;Output Package being reported
 ... SET PREFIX=$O(^TMP("XTVS-PKGEDIT",$J,PKGSUB,""))
 ... SET PARENT=^TMP("XTVS-PKGEDIT",$J,PKGSUB,PREFIX,"PARENT")
 ... SET OPFTCODE=@IDXROOT
 ... SET OPFTYPE=$S(OPFTCODE="FR":"File Range: ",OPFTCODE="LH":"LOW/HIGH range: ",OPFTCODE="FL":"File List number: ",1:"")
 ... SET NODETXT="    . "_PKGSUB_" ["_OPFTYPE_$S(OPFTCODE="FL":STARTSUB,1:STARTSUB_"-"_ENDSUB)_"]"_$S(PARENT]"":" (Parent: "_PARENT_")",1:"")
 ... SET NDTXTCMB=NODETXT
 ... IF ($L(NODETXT)>79),(NODETXT["(Parent") SET NODETXT=$$SPLITNDE(NODETXT,"FILERNG",.ERRARYCT,"(Parent")
 ... SET ^TMP("XTVS-ERROR",$J,"FILERNG",ERRARYCT)=NODETXT
 ... SET CMBARCT=CMBARCT+1
 ... IF ($L(NDTXTCMB)>79),(NDTXTCMB["(Parent") SET NODETXT=$$SPLITNDE(NDTXTCMB,"COMB-PFX-FLRNG",.CMBARCT,"(Parent")
 ... SET ^TMP("XTVS-ERROR",$J,"COMB-PFX-FLRNG",CMBARCT)=NODETXT
 QUIT
 ;
MLTPFX(TMPROOT,PKGSUB,PKGNME,SUBPFX,ERRARYCT,FILERPRT) ; Report multiple use of prefix
 NEW PARENT,CMBARCT,NODETXT,CMBHDR
 SET (CMBHDR,PKGHDOUT)=0
 SET PARENT=""
 SET ERRARYCT=ERRARYCT+1
 IF ERRARYCT=1 DO
 . SET ^TMP("XTVS-ERROR",$J,"PREFIX",1)="The Package Prefixes are overlapped by the subsequent package(s) listed:"
 . SET ERRARYCT=2
 ;
 SET CMBARCT=+$O(^TMP("XTVS-ERROR",$J,"COMB-PFX-FLRNG",""),-1)
 IF +CMBARCT=0 DO CMBARST(.CMBARCT)
 ;
 SET PKGPFX=$O(^TMP("XTVS-PKGEDIT",$J,PKGSUB,""))
 ;
 ; IF not printed package header, print header
 IF 'FILERPRT DO
 . SET ^TMP("XTVS-ERROR",$J,"PREFIX",ERRARYCT)=" "
 . SET CMBARCT=CMBARCT+1
 . SET ^TMP("XTVS-ERROR",$J,"XTVS-PKGRPT-CMB-IDX",ERRARYCT)=" "
 . SET ERRARYCT=ERRARYCT+1
 . IF '$D(^TMP("XTVS-PKGRPT-PFX-IDX",$J,PKGNME)) DO PKGERHDR(TMPROOT,"^TMP(""XTVS-ERROR"","_$J_",""PREFIX"")",PKGNME,.ERRARYCT)
 . IF '$D(^TMP("XTVS-PKGRPT-CMB-IDX",$J,PKGNME)) DO
 .. SET CMBARCT=CMBARCT+1
 .. SET ^TMP("XTVS-ERROR",$J,"COMB-PFX-FLRNG",CMBARCT)=" "
 .. SET CMBARCT=CMBARCT+1
 .. DO PKGERHDR(TMPROOT,"^TMP(""XTVS-ERROR"","_$J_",""COMB-PFX-FLRNG"")",PKGNME,.CMBARCT)
 .. SET CMBHDR=1
 . ; 
 . IF 'CMBHDR DO
 .. SET CMBARCT=CMBARCT+1
 .. SET ^TMP("XTVS-ERROR",$J,"COMB-PFX-FLRNG",CMBARCT)=" "
 . ;
 . SET NODETXT="   Prefix: "_PREFIX_" ; intersects the following package prefix assignments..."
 . SET ^TMP("XTVS-ERROR",$J,"PREFIX",ERRARYCT)=NODETXT
 . SET ERRARYCT=ERRARYCT+1
 . SET CMBARCT=CMBARCT+1
 . SET ^TMP("XTVS-ERROR",$J,"COMB-PFX-FLRNG",CMBARCT)=NODETXT
 . SET FILERPRT=1
 SET PARENT=^TMP("XTVS-PKGEDIT",$J,PKGSUB,PKGPFX,"PARENT")
 ;
 SET NODETXT="        .  "_PKGSUB_" ["_SUBPFX_"] "_$S(PARENT]"":" (Parent: "_PARENT_")",1:"")
 SET CMBARCT=CMBARCT+1
 IF ($L(NODETXT)>79),(NODETXT["(Parent") DO
 . NEW NDTXTCMB
 . SET NDTXTCMB=NODETXT
 . SET NODETXT=$$SPLITNDE(NODETXT,"PREFIX",.ERRARYCT,"(Parent")
 . SET NODETXT=$$SPLITNDE(NDTXTCMB,"COMB-PFX-FLRNG",.CMBARCT,"(Parent")
 SET ^TMP("XTVS-ERROR",$J,"PREFIX",ERRARYCT)=NODETXT
 SET ^TMP("XTVS-ERROR",$J,"COMB-PFX-FLRNG",CMBARCT)=NODETXT
 QUIT
 ;
 ;
PKGERHDR(TMPROOT,ERRAYRT,PKGNME,ERRARYCT) ; Output Header info for PREFIX and FILE RANGE overlap arrays
 NEW PKGPFX
 SET:$QSUBSCRIPT(ERRAYRT,3)="PREFIX" ^TMP("XTVS-PKGRPT-PFX-IDX",$J,PKGNME)="" ;Temporary index of Prefix overlap packages reported
 SET:$QSUBSCRIPT(ERRAYRT,3)="FILERNG" ^TMP("XTVS-PKGRPT-FRNG-IDX",$J,PKGNME)="" ;Temporary index of File overlap packages reported
 SET:$QSUBSCRIPT(ERRAYRT,3)="COMB-PFX-FLRNG" ^TMP("XTVS-PKGRPT-CMB-IDX",$J,PKGNME)="" ;Temporary index of File overlap packages reported
 ;
 SET PKGPFX=$QSUBSCRIPT(TMPROOT,4)
 SET @ERRAYRT@(ERRARYCT)=" "
 SET ERRARYCT=ERRARYCT+1
 SET @ERRAYRT@(ERRARYCT)=" "_PKGNME_" [Primary Prefix: "_PKGPFX_"]"
 SET PARENT=@TMPROOT@("PARENT")
 SET ERRARYCT=ERRARYCT+1
 SET @ERRAYRT@(ERRARYCT)="   Parent: "_$S(PARENT]"":PARENT,1:"None indicated")
 SET ERRARYCT=ERRARYCT+1
 QUIT
 ;
CMBARST(CMBARCT) ;Add Header to Combined Prefix and File Range overlap error array
 SET ^TMP("XTVS-ERROR",$J,"COMB-PFX-FLRNG",1)="The Package Prefixes are overlapped by the subsequent package(s) listed."
 SET CMBARCT=2
 DO SETFLHDR("COMB-PFX-FLRNG",.CMBARCT)
 QUIT
 ;
SETFLHDR(NODETYPE,ERRARYCT) ;Set File Header
 SET ^TMP("XTVS-ERROR",$J,NODETYPE,ERRARYCT)="The Packages Files overlapping the reported package are listed and identified"
 SET ERRARYCT=ERRARYCT+1
 SET ^TMP("XTVS-ERROR",$J,NODETYPE,ERRARYCT)=" by comparing assigned files for the reported package to the overlap package."
 SET ERRARYCT=ERRARYCT+1
 SET ^TMP("XTVS-ERROR",$J,NODETYPE,ERRARYCT)=" The VistA Size Report tool uses File assignments to count files in a package."
 SET ERRARYCT=ERRARYCT+1
 SET ^TMP("XTVS-ERROR",$J,NODETYPE,ERRARYCT)=" The Parameter File defines file assignments in 'File Ranges', '*Lowest File#'"
 SET ERRARYCT=ERRARYCT+1
 SET ^TMP("XTVS-ERROR",$J,NODETYPE,ERRARYCT)=" to '*Highest File#, and 'File Numbers' (List). Only one of these data elements"
 SET ERRARYCT=ERRARYCT+1
 SET ^TMP("XTVS-ERROR",$J,NODETYPE,ERRARYCT)=" is used to count files in a package and package file overlap as follows:"
 SET ERRARYCT=ERRARYCT+1
 SET ^TMP("XTVS-ERROR",$J,NODETYPE,ERRARYCT)=" 1) File Ranges ; 2) *Low/*High file numbers ; 3) File Numbers (List)"
 SET ERRARYCT=ERRARYCT+1
 SET ^TMP("XTVS-ERROR",$J,NODETYPE,ERRARYCT)=" The data element used is indicated in the File Overlap portion of this report."
 SET ERRARYCT=ERRARYCT+1
 QUIT
 ;
SPLITNDE(TEXT,NODESUB,ERRARYCT,SPTEXT) ;Split Error Node
 NEW SPLITPLC,TXTSLICE,NODETXTG
 SET SPLITPLC=$FIND(TEXT,SPTEXT)-$L(SPTEXT)
 SET TXTSLICE=$E(TEXT,1,SPLITPLC-1)
 SET ^TMP("XTVS-ERROR",$J,NODESUB,ERRARYCT)=TXTSLICE
 SET ERRARYCT=ERRARYCT+1
 SET NODETXT="              "_$E(TEXT,SPLITPLC,$L(TEXT))
 QUIT NODETXT
 ;
NOPKGRT(TMPROOT,PKGNME,PKGPFX,FTYPE,ERRARYCT,CMBARCT,PKGRPRT) ;Report Package for File section
 NEW NODETXT,FLEHDR,NDTXTCMB
 SET FLEHDR=0
 SET ^TMP("XTVS-ERROR",$J,"FILERNG",ERRARYCT)=" "
 SET ERRARYCT=ERRARYCT+1
 SET CMBARCT=CMBARCT+1
 IF ('$D(^TMP("XTVS-PKGRPT-FRNG-IDX",$J,PKGNME))) DO PKGERHDR(TMPROOT,"^TMP(""XTVS-ERROR"","_$J_",""FILERNG"")",PKGNME,.ERRARYCT)
 IF ('$D(^TMP("XTVS-PKGRPT-CMB-IDX",$J,PKGNME))) DO 
 . SET ^TMP("XTVS-ERROR",$J,"COMB-PFX-FLRNG",CMBARCT)=" "
 . SET CMBARCT=CMBARCT+1
 . DO PKGERHDR(TMPROOT,"^TMP(""XTVS-ERROR"","_$J_",""COMB-PFX-FLRNG"")",PKGNME,.CMBARCT)
 . SET FLEHDR=1
 ; 
 IF 'FLEHDR DO
 . SET ^TMP("XTVS-ERROR",$J,"COMB-PFX-FLRNG",CMBARCT)=" "
 . SET CMBARCT=CMBARCT+1
 ;
 SET NODETXT="   "_FTYPE_" "_$S(FTYPE="File #":$P(FLERNG,"-"),1:FLERNG)_$S(FTYPE="File #":" (in File List)",1:"")_", assignment intersects the following packages..."
 SET NDTXTCMB=NODETXT
 SET ERRARYCT=ERRARYCT+1
 IF ($L(NODETXT)>79),(NODETXT["intersects") SET NODETXT=$$SPLITNDE(NODETXT,"FILERNG",.ERRARYCT,"intersects")
 SET ^TMP("XTVS-ERROR",$J,"FILERNG",ERRARYCT)=NODETXT
 SET CMBARCT=CMBARCT+1
 IF ($L(NDTXTCMB)>79),(NDTXTCMB["intersects") SET NODETXT=$$SPLITNDE(NDTXTCMB,"COMB-PFX-FLRNG",.CMBARCT,"intersects")
 SET ERRARYCT=ERRARYCT+1
 SET ^TMP("XTVS-ERROR",$J,"COMB-PFX-FLRNG",CMBARCT)=NODETXT
 SET CMBARCT=CMBARCT+1
 ;
 SET PKGRPRT=1
 QUIT
 ;
RNGCHK(RNGBEG,RNGEND,STARTSUB,ENDSUB) ;Check Package file ranges against Range index
 ;Input:
 ;  RNGBEG   - Package File begin range to check
 ;  RNGEND   - Package File end range to check
 ;  STARTSUB - Range Index - Start file Subscript
 ;  ENDSUB   - Range Index - End file Subscript
 ;
 ;Output:
 ;  1: Package file number OVERLAPS range
 ;  0: Package file number out of range
 ;
 NEW INRNG
 SET INRNG=0
 IF RNGBEG'<STARTSUB,RNGBEG'>ENDSUB SET INRNG=1
 IF RNGEND'<STARTSUB,RNGEND'>ENDSUB SET INRNG=1
 IF RNGBEG<STARTSUB,RNGEND>ENDSUB SET INRNG=1
 IF RNGBEG=STARTSUB,RNGEND=ENDSUB SET INRNG=1
 QUIT INRNG