BNPENV ;IHS/OIT/ENM - ENVIRONMENT CHECK
;;1.0;NATIONAL SITE TRACKING SYSTEM;**1**;07/31/2009
;BNP*1.0*1 10/27/2011 IHS.OIT.GAB ADDED CK FOR INCOMPLETE PKG & RESET TMP GLOBAL
ALLPKG ;LOOP ON PACKAGE FILE "B" XREF
;S AZFMSITE="",PKRN="",AZASUFAC="",AZFMCT=1,BNPOS="",LOCNUM=""
;BNP*1.0*1 10/27/2011 IHS.OIT.GAB ADDED PKG NOT INSTALLED VAR BELOW (PKGNI & AZDIST)
S AZFMSITE="",PKRN="",AZASUFAC="",AZFMCT=1,BNPOS="",LOCNUM="",PKGNI="",AZDIST=""
;BNP*1.0*1 10/27/2011 IHS.OIT.GAB ADDED NEXT 2 LINES TO KILL OFF TEMP GLOBAL
S BNP=0
F S BNP=$O(^BNPENV(BNP)) Q:BNP="" K ^BNPENV(BNP)
;GET LOCNAM
S LOCNUM=$P($G(^AUTTSITE(1,0)),"^",1)
;
I $G(LOCNUM)>0 S AZFMSITE=$P($G(^DIC(4,LOCNUM,0)),"^",1),AZASUFAC=$P($G(^AUTTLOC(LOCNUM,0)),"^",10)
;
S AZFM="",LPATCH="",LPAT="",DINSLV="",INSDT="",HL7PDT="",HL7IDT=""
F NA=0:0 S AZFM=$O(^DIC(9.4,"B",AZFM)) Q:AZFM="" D PKGWR
;MOVE XTMP GBL TO UNIX
D XBC
;KILL OFF TMP VARIABLES
D OUT
Q
PKGWR S AZVER=$$VERSION^XPDUTL(AZFM)
S LPATCH=$$LAST^BNPENV2(AZFM,AZVER)
;BNP*1.0*1 11/30/2011 IHS.OIT.GAB ADDED QUIT IF INCOMPLETE PKG INSTALL
Q:(PKGNI)=""
S LPATCH=$S(LPATCH'[-1:LPATCH,1:"") D DTFIX
;
I LPATCH="" S LPAT="",HL7DT="",LLPAT="^"
;BNP*1.0*1 10/27/2011 IHS.OIT.GAB CHANGED BELOW LINE TO ADD DATE DISTRIBUTED FIELD
;I LPATCH]"" S LPAT=$P(LPATCH,"^",1)_" / "_$P(LPATCH,"^",2)
I LPATCH]"" S AZDIST=$P(LPATCH,"^",3) S LPAT=$P(LPATCH,"^",1)_" / "_$P(LPATCH,"^",2)
;BNP*1.0*1 10/27/2011 IHS.OIT.GAB ADDED BELOW 2 LINES FOR LAST PATCH DISTRIBUTE DATE
S LPDIST=$P(LPATCH,"^",4) D DTFIX3
I (LPDIST="") ! (LPDIST=0) S LPDIST="^"
;GRAB THE PREFIX
S PKRN=$O(^DIC(9.4,"B",AZFM,"")) S:'PKRN PKRN=""
S PREFIX=$P($G(^DIC(9.4,PKRN,0)),"^",2)
I AZVER]"" S DINSLV=$O(^DIC(9.4,PKRN,22,"B",AZVER,"")) S:'DINSLV DINSLV=""
I DINSLV]"" S INSDT=$P($G(^DIC(9.4,PKRN,22,DINSLV,0)),"^",3) D DTFIX1
;BNP*1.0*1 10/27/2011 IHS.OIT.GAB ADDED QUIT IF NO INSTALL DATE
Q:INSDT=""
;BNP*1.0*1 10/27/2011 IHS.OIT.GAB ADDED BELOW LINE TO PULL DATE DISTRIBUTED FIELD
S AZDIST=$P($G(^DIC(9.4,PKRN,22,DINSLV,0)),"^",2) D DTFIX2
;GET OS
S BNPOS=$ZV
;S ^BNPENV(AZFMCT)=AZASUFAC_"^"_AZFMSITE_"^"_AZFM_"^"_PREFIX_"^"_AZVER_"^"_LLPAT_"^"_$S(INSDT]"":INSDT,1:"")_"^"_BNPOS
;BNP*1.0*1 10/27/2011 IHS.OIT.GAB CHANGED BELOW FOR DATE DISTRIBUTED FIELD
S ^BNPENV(AZFMCT)=AZASUFAC_"^"_AZFMSITE_"^"_AZFM_"^"_PREFIX_"^"_AZVER_"^"_LLPAT_"^"_$S(INSDT]"":INSDT,1:"")_"^"_BNPOS_"^"_AZDIST_"^"_LPDIST
S AZFMCT=AZFMCT+1
Q
PCC2 S PCCF200=$P($G(^AUTTSITE(1,0)),"^",22) I PCCF200="" S PCCF200="No"
I PCCF200=1 S PCCF200="YES"
;W !,?30,"IHS V Files 200 Conversion Done?// ",PCCF200
Q
DOONE ;DO ONE RECORD FOR TESTING ONLY
S AZFM="ADVERSE REACTION TRACKING" D PKGWR
D OUT
Q
DTFIX Q:'+LPATCH
;BNP*1.0*1 10/27/2011 IHS.OIT.GAB ADDED BELOW 2 LINES TO CORRECT FOR TIME ADDED TO PATCH INSTALL DATE
I $P(LPATCH,"^",2)]"" S LPD=$P(LPATCH,"^",2)
I $P(LPD,".") S $P(LPATCH,"^",2)=$P(LPD,".")
I $P(LPATCH,"^",2)]"" S HL7PDT=$P(LPATCH,"^",2),X=$$FMTHL7^XLFDT(HL7PDT),LLPAT=$P(LPATCH,"^",1)_"^"_X ;SET HL7 PATCH INSTALL DATE
I $P(LPATCH,"^",2)']"" S LLPAT=$P(LPATCH,"^",1)_"^"_""
I $P(LPATCH,"^",2)]"" S Y=$P(LPATCH,"^",2) X ^DD("DD") S $P(LPATCH,"^",2)=" "_Y
Q
DTFIX1 Q:'+INSDT
I INSDT]"" S HL7IDT=INSDT,X=$$FMTHL7^XLFDT(HL7IDT),INSDT=X
I INSDT']"" S INSDT=""
Q
DTFIX2 Q:'+AZDIST
I AZDIST]"" S HL7IDT=AZDIST,X=$$FMTHL7^XLFDT(HL7IDT),AZDIST=X
I AZDIST']"" S AZDIST=""
Q
DTFIX3 Q:'+LPDIST
I LPDIST]"" S HL7IDT=LPDIST,X=$$FMTHL7^XLFDT(HL7IDT),LPDIST=X
I LPDIST']"" S LPDIST=""
Q
OUT ;
;W !!,"END OF PACKAGE FILE PROFILE CHECK!"
K NA,AZFM,AZVER,LPATCH,PCCF200,AZASUFAC
Q
PFIX S AZFMSITE="",PKRN=""
;
S AZFM="",LPATCH="",LPAT=""
F NA=0:0 S AZFM=$O(^DIC(9.4,"B",AZFM)) Q:AZFM="" D PGWR
D OP2
D OUT
Q
PGWR S AZVER=$$VERSION^XPDUTL(AZFM),LPATCH=$$LAST^BNPENV2(AZFM,AZVER),LPATCH=$S(LPATCH'[-1:LPATCH,1:"") D DTFIX
I LPATCH="" S LPAT=""
I LPATCH]"" S LPAT=$P(LPATCH,"^",1)_" / "_$P(LPATCH,"^",2)
;GRAB THE PREFIX
S PKRN=$O(^DIC(9.4,"B",AZFM,"")) S:'PKRN PKRN=""
S PREFIX=$P($G(^DIC(9.4,PKRN,0)),"^",2)
;
S ENM(PREFIX)=AZFM_"^"_AZVER_"^"_LPAT
Q
OP2 ;
S PFX="",AZFM1="",AZVER1="",APAT1=""
F S PFX=$O(ENM(PFX)) Q:'PFX S AZFM1=$P($G(ENM(PFX)),"^",1),AZVER1=$P($G(ENM(PFX)),"^",2),APAT1=$P($G(ENM(PFX)),"^",3) D LS
Q
LS ;
;W !,AZFM1_"-("_PFX_")",?40,AZVER1,?50,LPAT1 I AZFM1="IHS V FILES 200 CONVERSION" D PCC2
Q
;SAVE PACKAGE STATUS DATA TO A UNIX FILE
XBC ;XBGL=GLOBAL NAME,XBUF=UNIX DIRECTORY,XBFN=UNIX FILE NAME
;Next line will try to send file to 92.145 with ftpsend
;
;S XBGL="AZFMENV",XBUF="161.223.92.145",XBFN="AZFMENV"_AZASUFAC_".G",XBMED="F"
;S XBUF="/usr2/ihs/emoore",XBFLT=1 ;note this line has not been tested!!!!
;S XBGL="BNPENV(",XBFN="BNPENV"_AZASUFAC_".G",XBMED="F"
;S XBS1="AZFMSITETRACK"
;S XBGL="BNPENV",XBUF="/usr2/ihs/emoore",XBFN="BNPENV"_AZASUFAC_".G",XBMED="F"
;D ^XBGSAVE
D ^BNPENHT ;CALL MIKE PIKES ROUTINE
Q
BNPENV ;IHS/OIT/ENM - ENVIRONMENT CHECK
+1 ;;1.0;NATIONAL SITE TRACKING SYSTEM;**1**;07/31/2009
+2 ;BNP*1.0*1 10/27/2011 IHS.OIT.GAB ADDED CK FOR INCOMPLETE PKG & RESET TMP GLOBAL
ALLPKG ;LOOP ON PACKAGE FILE "B" XREF
+1 ;S AZFMSITE="",PKRN="",AZASUFAC="",AZFMCT=1,BNPOS="",LOCNUM=""
+2 ;BNP*1.0*1 10/27/2011 IHS.OIT.GAB ADDED PKG NOT INSTALLED VAR BELOW (PKGNI & AZDIST)
+3 SET AZFMSITE=""
SET PKRN=""
SET AZASUFAC=""
SET AZFMCT=1
SET BNPOS=""
SET LOCNUM=""
SET PKGNI=""
SET AZDIST=""
+4 ;BNP*1.0*1 10/27/2011 IHS.OIT.GAB ADDED NEXT 2 LINES TO KILL OFF TEMP GLOBAL
+5 SET BNP=0
+6 FOR
SET BNP=$ORDER(^BNPENV(BNP))
IF BNP=""
QUIT
KILL ^BNPENV(BNP)
+7 ;GET LOCNAM
+8 SET LOCNUM=$PIECE($GET(^AUTTSITE(1,0)),"^",1)
+9 ;
+10 IF $GET(LOCNUM)>0
SET AZFMSITE=$PIECE($GET(^DIC(4,LOCNUM,0)),"^",1)
SET AZASUFAC=$PIECE($GET(^AUTTLOC(LOCNUM,0)),"^",10)
+11 ;
+12 SET AZFM=""
SET LPATCH=""
SET LPAT=""
SET DINSLV=""
SET INSDT=""
SET HL7PDT=""
SET HL7IDT=""
+13 FOR NA=0:0
SET AZFM=$ORDER(^DIC(9.4,"B",AZFM))
IF AZFM=""
QUIT
DO PKGWR
+14 ;MOVE XTMP GBL TO UNIX
+15 DO XBC
+16 ;KILL OFF TMP VARIABLES
+17 DO OUT
+18 QUIT
PKGWR SET AZVER=$$VERSION^XPDUTL(AZFM)
+1 SET LPATCH=$$LAST^BNPENV2(AZFM,AZVER)
+2 ;BNP*1.0*1 11/30/2011 IHS.OIT.GAB ADDED QUIT IF INCOMPLETE PKG INSTALL
+3 IF (PKGNI)=""
QUIT
+4 SET LPATCH=$SELECT(LPATCH'[-1:LPATCH,1:"")
DO DTFIX
+5 ;
+6 IF LPATCH=""
SET LPAT=""
SET HL7DT=""
SET LLPAT="^"
+7 ;BNP*1.0*1 10/27/2011 IHS.OIT.GAB CHANGED BELOW LINE TO ADD DATE DISTRIBUTED FIELD
+8 ;I LPATCH]"" S LPAT=$P(LPATCH,"^",1)_" / "_$P(LPATCH,"^",2)
+9 IF LPATCH]""
SET AZDIST=$PIECE(LPATCH,"^",3)
SET LPAT=$PIECE(LPATCH,"^",1)_" / "_$PIECE(LPATCH,"^",2)
+10 ;BNP*1.0*1 10/27/2011 IHS.OIT.GAB ADDED BELOW 2 LINES FOR LAST PATCH DISTRIBUTE DATE
+11 SET LPDIST=$PIECE(LPATCH,"^",4)
DO DTFIX3
+12 IF (LPDIST="")