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

XPDR.m

Go to the documentation of this file.
  1. XPDR ;SFISC/RSD - Routine File Edit ;09/17/96 10:05
  1. ;;8.0;KERNEL;**1,2,44,393,547,713,738**;Jul 10, 1995;Build 5
  1. ;Per VHA Directive 2004-038, this routine should not be modified.
  1. Q
  1. UPDT ;update routine file
  1. N DIR,DIRUT,XPD,XPDI,XPDJ,XPDN,XPDGTM,X,X1,Y,Y1,% W !
  1. ;p738 change 8 to 16
  1. W ! S DIR(0)="FO^1:16^K:X'?.1""-""1U.15UNP X",DIR("A")="Routine Namespace",DIR("?")="Enter 1 to 16 characters, precede with ""-"" to exclude namespace"
  1. ;XPDN(0=excluded names or 1=include names, namespace)=""
  1. F D ^DIR Q:$D(DIRUT) S X=$E(Y,$L(Y))="*",%=$E(Y)="-",XPDN('%,$E(Y,%+1,$L(Y)-X))=""
  1. Q:'$D(XPDN)!$D(DTOUT)!$D(DUOUT)
  1. W !!,"NAMESPACE INCLUDE",?35,"EXCLUDE",!,?11,"-------",?35,"-------"
  1. S (X,Y)="",(X1,Y1)=1
  1. F D W !?11,X,?35,Y Q:'X1&'Y1
  1. .S:X1 X=$O(XPDN(1,X)),X1=X]"" S:Y1 Y=$O(XPDN(0,Y)),Y1=Y]""
  1. K DIR S DIR(0)="Y",DIR("A")="OK to continue",DIR("B")="YES" D ^DIR
  1. Q:'Y!$D(DIRUT) W !
  1. S DIR(0)="Y",DIR("A")="Want me to clean up the Routine File before updating",DIR("?")="YES means you want to go through the Routine file and delete any routine name that no longer exists on the system."
  1. D ^DIR Q:$D(DIRUT)
  1. D WAIT^DICD,DELRTN:Y
  1. ;if GTM, create temporary list in %ZR
  1. S XPDGTM=$G(^%ZOSF("OS"))["GT.M" I XPDGTM D SILENT^%RSEL("*")
  1. ;loop thru include list XPDN(1,XPDI)
  1. S XPDI="" F S XPDI=$O(XPDN(1,XPDI)) Q:XPDI="" S XPDJ=XPDI D
  1. . I 'XPDGTM D:$D(^$R(XPDJ)) UPDT1(XPDJ) F S XPDJ=$O(^$R(XPDJ)) Q:XPDJ=""!($P(XPDJ,XPDI)]"") D UPDT1(XPDJ)
  1. . I XPDGTM D:$D(%ZR(XPDJ)) UPDT1(XPDJ) F S XPDJ=$O(%ZR(XPDJ)) Q:XPDJ=""!($P(XPDJ,XPDI)]"") D UPDT1(XPDJ)
  1. . Q
  1. W " ...Done.",!
  1. Q
  1. ;
  1. UPDT1(XPDRT) ;check routine XPDRT
  1. ;if name XPDRT is in the exclude list, XPDN(0,XPDRT) or in Routine file, quit
  1. Q:$D(XPDN(0,XPDRT))!$O(^DIC(9.8,"B",XPDRT,0))
  1. ;check if XPDRT is refered in the namespace by checking the subscript
  1. ;before XPDRT, if sub exist and $P(XPDRT,sub)="" then it is part of the
  1. ;namespace, quit
  1. S %=$O(XPDN(0,XPDRT),-1) I $L(%),$P(XPDRT,%)="" Q
  1. N XPD S XPD(9.8,"+1,",.01)=XPDRT,XPD(9.8,"+1,",1)="R"
  1. D ADD^DICA("","XPD")
  1. Q
  1. ;
  1. VER ;verify Routine file
  1. N DIR,DIRUT,X,Y
  1. W !,"I will delete all local entries in the Routine File in which",!,"the Routine no longer exist on this system!",!
  1. S DIR(0)="Y",DIR("A")="OK to continue",DIR("B")="YES" D ^DIR
  1. Q:'Y!$D(DIRUT) D DELRTN
  1. W " ...Done.",!
  1. Q
  1. DELRTN ;delete routine file entries
  1. N DA,DIK,X,Y
  1. W !,"Routines listed as National will not be deleted!"
  1. S DIK="^DIC(9.8,",DA=0
  1. F S DA=$O(^DIC(9.8,DA)) Q:'DA S Y=$G(^(DA,0)) D ;p713
  1. . I $P(Y,U,2)="R",$G(^DIC(9.8,DA,6))<2 S X=$P(Y,U) X ^%ZOSF("TEST") E D ^DIK
  1. . Q
  1. Q
  1. PURGE ;purge file
  1. N DA,DIK,DIR,DIRUT,X,XPD,XPDF,XPDI,XPDJ,XPDL,XPDN,XPDPG,XPDS,XPDUL,Y,Z
  1. S DIR("?")="Enter the file you want to purge the data from.",DIR(0)="SM^B:Build;I:Install;ALL:Build & Install",DIR("A")="Purge from what file(s)"
  1. D ^DIR Q:$D(DIRUT)
  1. S XPDF=$S(Y="I":9.7,1:9.6) S:Y="ALL" XPDF(1)=9.7
  1. K DIR S DIR("?")="Enter the number of Versions to keep in the file, for each package",DIR(0)="N^0:100:0",DIR("A")="Versions to Retain",DIR("B")=1
  1. D ^DIR Q:$D(DIRUT) S XPDN=Y
  1. K DIR
  1. S DIR(0)="FO^3:30",DIR("?")="^D PURGEH^XPDR",DIR("A")="Package Name",DIR("B")="ALL"
  1. F D ^DIR Q:$D(DIRUT) S XPD(X)="" Q:X="ALL" K DIR("B") S DIR("A")="Another Package Name"
  1. Q:'$D(XPD)
  1. ;if they want all, make sure all is the only one
  1. I $D(XPD("ALL")) K XPD S XPD("ALL")=""
  1. ;XPDF(1) is defined if doing both files, do purge twice
  1. K ^TMP($J) D PURGE1(XPDF),PURGE1($G(XPDF(1))):$D(XPDF(1))
  1. I '$D(^TMP($J)) W !!,"No match found" Q
  1. K XPD,DIR
  1. S DIR(0)="E",$P(XPDUL,"-",IOM)=""
  1. ;if ALL, reset XPDF to next file and Do, then reset back to 9.6
  1. D I $D(XPDF(1)) D ^DIR I Y S XPDF=XPDF(1) D S XPDF=9.6
  1. .S XPD="^TMP("_$J_","_XPDF,XPDS=XPD_",",XPD=XPD_")",XPDL=$L(XPDS),XPDPG=1,Y=1
  1. .W @IOF D HDR
  1. .;loop thru ^TMP($J,file,package) & show list, quit if user "^"
  1. .F S XPD=$Q(@XPD) Q:XPD=""!($E(XPD,1,XPDL)'=XPDS) D Q:'Y
  1. ..S Z=@XPD W $P(Z,"^"),$S($P(Z,"^",3):" (duplicates)",1:""),! Q:$Y<(IOSL-4)
  1. ..D ^DIR Q:'Y
  1. ..S XPDPG=XPDPG+1 W @IOF D HDR
  1. S DIR(0)="Y",DIR("A")="OK to DELETE these entries",DIR("B")="NO"
  1. W !! D ^DIR
  1. I $D(DIRUT)!'Y W !!,"Nothing Purged" Q
  1. ;loop thru and delete
  1. D I $D(XPDF(1)) S XPDF=XPDF(1) D
  1. .S DIK="^XPD("_XPDF_",",XPD="^TMP("_$J_","_XPDF,XPDS=XPD_",",XPD=XPD_")",XPDL=$L(XPDS)
  1. .F S XPD=$Q(@XPD) Q:XPD=""!($E(XPD,1,XPDL)'=XPDS) D
  1. ..S XPDI=@XPD F XPDJ=2:1 S DA=$P(XPDI,"^",XPDJ) Q:'DA D ^DIK
  1. Q
  1. ;
  1. PURGE1(XPDF) ;XPDF=file #
  1. N XPDFL,XPDI,XPDJ,XPDP,XPDV,Y,Z
  1. W "."
  1. ;if All, loop thru B x-ref
  1. I $D(XPD("ALL")) D
  1. .S XPDI=""
  1. .F S XPDI=$O(^XPD(XPDF,"B",XPDI)) Q:XPDI="" D
  1. ..S X=$$PKG^XPDUTL(XPDI) D PURGE2(X)
  1. ..W "."
  1. E S XPDI="" F S XPDI=$O(XPD(XPDI)) Q:XPDI="" D
  1. .D PURGE2(XPDI)
  1. .W "."
  1. ;loop thru each package, XPDP=package name
  1. S XPDP="" F S XPDP=$O(^TMP($J,XPDF,XPDP)) Q:XPDP="" D
  1. .S XPDV="",XPDL=XPDN
  1. .;the last is the most recent, XPDN = number to retain, XPDV=version
  1. .;XPDS=type (T/V/Z)
  1. .F S XPDV=$O(^TMP($J,XPDF,XPDP,XPDV),-1),XPDS="" Q:'XPDV!'XPDL F S XPDS=$O(^TMP($J,XPDF,XPDP,XPDV,XPDS),-1) Q:XPDS=""!'XPDL D
  1. ..S Y="" F S Y=$O(^TMP($J,XPDF,XPDP,XPDV,XPDS,Y),-1) Q:Y=""!'XPDL D
  1. ...I $D(^TMP($J,XPDF,XPDP,XPDV,XPDS,Y))#2 K ^(Y) S XPDL=XPDL-1 Q
  1. ...S Z="" F S Z=$O(^TMP($J,XPDF,XPDP,XPDV,XPDS,Y,Z),-1) Q:Z=""!'XPDL K ^(Z) S XPDL=XPDL-1
  1. Q
  1. ;
  1. PURGE2(XPDX) ;XPDX=package name
  1. ;XPDFL=1 this is not a patch, quit when we find a patch during loop
  1. S XPDS=XPDX,XPDL=$L(XPDX),XPDFL=XPDX'["*"
  1. ;loop and find matches
  1. D F S XPDS=$O(^XPD(XPDF,"B",XPDS)) Q:XPDS=""!($E(XPDS,1,XPDL)'=XPDX)!($S(XPDFL:XPDS["*",1:0)) D
  1. .S Y=$O(^XPD(XPDF,"B",XPDS,0)) Q:'Y
  1. .Q:'$D(^XPD(XPDF,Y,0)) S Z=^(0),Y=XPDS_"^"_Y
  1. .;can't delete Installs that status isn't 'Install Completed'
  1. .I XPDF=9.7 Q:$P(Z,U,9)<3
  1. .S XPDV=$$VER^XPDUTL(XPDS)
  1. .;TMP($J,file,package name,version,"*","T/V/Z",num,patch)=NAME^DA^duplicat DAs
  1. .I XPDS["*" D Q
  1. ..I XPDV?1.2N1"."1.2N S ^TMP($J,XPDF,$$PKG^XPDUTL(XPDS),+XPDV,"*Z",0,+$P(XPDS,"*",3))=Y_$$DUP(XPDS,$P(Y,"^",2)) Q
  1. ..I XPDV["T" S ^TMP($J,XPDF,$$PKG^XPDUTL(XPDS),+XPDV,"*T",+$P(XPDV,"T",2),+$P(XPDS,"*",3))=Y_$$DUP(XPDS,$P(Y,"^",2)) Q
  1. ..I XPDV["V" S ^TMP($J,XPDF,$$PKG^XPDUTL(XPDS),+XPDV,"*V",+$P(XPDV,"V",2),+$P(XPDS,"*",3))=Y_$$DUP(XPDS,$P(Y,"^",2)) Q
  1. ..S ^TMP($J,XPDF,$$PKG^XPDUTL(XPDS),+XPDV,"*",+$P(XPDS,"*",3))=Y_$$DUP(XPDS,$P(Y,"^",2))
  1. .;TMP($J,file,package name,version,"Z",0)=NAME^DA^duplicate DAs
  1. .I XPDV?1.2N1"."1.2N S ^TMP($J,XPDF,$$PKG^XPDUTL(XPDS),+XPDV,"Z",0)=Y_$$DUP(XPDS,$P(Y,"^",2)) Q
  1. .;TMP($J,file,package name,version,"T/V",num)=NAME^DA^dup DAs
  1. .I XPDV["T" S ^TMP($J,XPDF,$$PKG^XPDUTL(XPDS),+XPDV,"T",+$P(XPDV,"T",2))=Y_$$DUP(XPDS,$P(Y,"^",2)) Q
  1. .I XPDV["V" S ^TMP($J,XPDF,$$PKG^XPDUTL(XPDS),+XPDV,"V",+$P(XPDV,"V",2))=Y_$$DUP(XPDS,$P(Y,"^",2)) Q
  1. Q
  1. PURGEH ;executable help from DIR call at PURGE+8
  1. W:$E(DIR("A"),1)="P" !,"Enter 'ALL' to purge all packages, or"
  1. W !,"Enter the name of the Package you want to Purge.",!," i.e. KERNEL 8.0 will purge version 8.0Tx and 8.0Vx",!," XU*8.0 will purge all patches for 8.0",!
  1. N DIR,X,Y
  1. S DIR(0)="Y",DIR("A")="Want to see the "_$S(XPDF=9.7:"Install File",$D(XPDF(1)):"Build & Install Files",1:"Build File")_" List",DIR("B")="Y"
  1. D ^DIR Q:'Y!$D(DIRUT)
  1. D PURGEH1("^XPD(9.6,"):XPDF=9.6,PURGEH1("^XPD(9.7,"):XPDF=9.7!$D(XPDF(1))
  1. Q
  1. ;
  1. DUP(Z,Z1) ;find duplicate, Z=NAME, Z1=last ien
  1. ;returns Y=DA^dup DA^dup DA...
  1. N Y S Y=""
  1. F S Z1=$O(^XPD(XPDF,"B",Z,Z1)) Q:'Z1 S Y=Y_"^"_Z1
  1. Q Y
  1. ;
  1. PURGEH1(DIC) ;
  1. W !!,$S(DIC[9.6:"BUILD ",1:"INSTALL ")_"File"
  1. S DIC(0)="QE",X="??" D ^DIC
  1. Q
  1. ;
  1. HDR W !,"Package(s) in ",$S(XPDF=9.7:"INSTALL",1:"BUILD")," File, "
  1. I XPDN W "Retain last ",$S(XPDN=1:"version",1:XPDN_" versions")
  1. E W "Don't retain any versions"
  1. W ?70,"PAGE ",XPDPG,!,XPDUL,!
  1. Q