BNPENV2 ;IHS/OIT/ENM - ENVIRONMENT CHECK 2
;;1.0;NATIONAL SITE TRACKING SYSTEM;**1**;07/31/2009
;BNP*1.0*1 11/30/2011 IHS.OIT.GAB
LAST(PKG,VER) ;returns last patch applied for a Package, PATCH^DATE
; Patch includes Seq # if Released
;BNP*1.0*1 10/27/2011 IHS.OIT.GAB ADDED DTDIST,PKGNI,LASTP,LASTPD TO TEST FOR PACKAGE INSTALL & DT DISTRIBUTED
N PKGIEN,VERIEN,LATEST,PATCH,SUBIEN,DTDIST
S PKGNI="",LASTP=0,LASTPD=0
I $G(VER)="" S VER=$$VERSION^XPDUTL(PKG) Q:'VER -1
S PKGIEN=$O(^DIC(9.4,"B",PKG,"")) Q:'PKGIEN -1
S VERIEN=$O(^DIC(9.4,PKGIEN,22,"B",VER,"")) Q:'VERIEN -1
;BNP*1.0*1 10/27/2011 IHS.OIT.GAB ADDED NEXT 2 LINES TO CK FOR PKG INSTALLED
S PKGNI=^DIC(9.4,PKGIEN,22,0)
Q:$D(PKGNI)=""
S LATEST=-1,PATCH=-1,SUBIEN=0
F S SUBIEN=$O(^DIC(9.4,PKGIEN,22,VERIEN,"PAH",SUBIEN)) Q:SUBIEN'>0 D
. S LATEST=$P(^DIC(9.4,PKGIEN,22,VERIEN,"PAH",SUBIEN,0),U,2),PATCH=$P(^(0),U)
;BNP*1.0*1 10/27/2011 IHS.OIT.GAB ADDED NEXT 3 LINES FOR DATE DISTRIBUTED FIELD
S DTDIST=$P(^DIC(9.4,PKGIEN,22,VERIEN,0),U,2)
D PDISTDT
I LASTP>0 S LASTPD=$P($G(^XPD(9.6,LASTP,0)),U,4)
Q PATCH_U_LATEST_U_DTDIST_U_LASTPD
PDISTDT ;BNP*1.0*1 11/18/2011 IHS.OIT.GAB ADDED TO FIND LAST PATCH DISTRIBUTION DATE USING BUILD GLOBAL
S YIEN="",IEN="",PKIEN="",X="",Y="",Z="",Z1="",Z2=0
F NA=0:0 S X=$O(^XPD(9.6,"B",X)) Q:X="" D
. S Y=$O(^XPD(9.6,"B",X,""))
. Q:'Y
. S Z=$P(^XPD(9.6,Y,0),U,2)
. I Z'=PKGIEN Q
. I Z=PKGIEN S Z1=Y D PDISTCK
;
I Z2>0 S LASTP=Z2
Q
PDISTCK ;BNP*1.0*1 11/30/2011 IHS.OIT.GAB ADDED TO COMPARE PATCH DISTRIBUTION DATES
I Z1>Z2 S Z2=Z1
Q
BNPENV2 ;IHS/OIT/ENM - ENVIRONMENT CHECK 2
+1 ;;1.0;NATIONAL SITE TRACKING SYSTEM;**1**;07/31/2009
+2 ;BNP*1.0*1 11/30/2011 IHS.OIT.GAB
LAST(PKG,VER) ;returns last patch applied for a Package, PATCH^DATE
+1 ; Patch includes Seq # if Released
+2 ;BNP*1.0*1 10/27/2011 IHS.OIT.GAB ADDED DTDIST,PKGNI,LASTP,LASTPD TO TEST FOR PACKAGE INSTALL & DT DISTRIBUTED
+3 NEW PKGIEN,VERIEN,LATEST,PATCH,SUBIEN,DTDIST
+4 SET PKGNI=""
SET LASTP=0
SET LASTPD=0
+5 IF $GET(VER)=""
SET VER=$$VERSION^XPDUTL(PKG)
IF 'VER
QUIT -1
+6 SET PKGIEN=$ORDER(^DIC(9.4,"B",PKG,""))
IF 'PKGIEN
QUIT -1
+7 SET VERIEN=$ORDER(^DIC(9.4,PKGIEN,22,"B",VER,""))
IF 'VERIEN
QUIT -1
+8 ;BNP*1.0*1 10/27/2011 IHS.OIT.GAB ADDED NEXT 2 LINES TO CK FOR PKG INSTALLED
+9 SET PKGNI=^DIC(9.4,PKGIEN,22,0)
+10 IF $DATA(PKGNI)=""
QUIT
+11 SET LATEST=-1
SET PATCH=-1
SET SUBIEN=0
+12 FOR
SET SUBIEN=$ORDER(^DIC(9.4,PKGIEN,22,VERIEN,"PAH",SUBIEN))
IF SUBIEN'>0
QUIT
Begin DoDot:1
+13 SET LATEST=$PIECE(^DIC(9.4,PKGIEN,22,VERIEN,"PAH",SUBIEN,0),U,2)
SET PATCH=$PIECE(^(0),U)
End DoDot:1
+14 ;BNP*1.0*1 10/27/2011 IHS.OIT.GAB ADDED NEXT 3 LINES FOR DATE DISTRIBUTED FIELD
+15 SET DTDIST=$PIECE(^DIC(9.4,PKGIEN,22,VERIEN,0),U,2)
+16 DO PDISTDT
+17 IF LASTP>0
SET LASTPD=$PIECE($GET(^XPD(9.6,LASTP,0)),U,4)
+18 QUIT PATCH_U_LATEST_U_DTDIST_U_LASTPD
PDISTDT ;BNP*1.0*1 11/18/2011 IHS.OIT.GAB ADDED TO FIND LAST PATCH DISTRIBUTION DATE USING BUILD GLOBAL
+1 SET YIEN=""
SET IEN=""
SET PKIEN=""
SET X=""
SET Y=""
SET Z=""
SET Z1=""
SET Z2=0
+2 FOR NA=0:0
SET X=$ORDER(^XPD(9.6,"B",X))
IF X=""
QUIT
Begin DoDot:1
+3 SET Y=$ORDER(^XPD(9.6,"B",X,""))
+4 IF 'Y
QUIT
+5 SET Z=$PIECE(^XPD(9.6,Y,0),U,2)
+6 IF Z'=PKGIEN
QUIT
+7 IF Z=PKGIEN
SET Z1=Y
DO PDISTCK
End DoDot:1
+8 ;
+9 IF Z2>0
SET LASTP=Z2
+10 QUIT
PDISTCK ;BNP*1.0*1 11/30/2011 IHS.OIT.GAB ADDED TO COMPARE PATCH DISTRIBUTION DATES
+1 IF Z1>Z2
SET Z2=Z1
+2 QUIT