PSORRVIE ;WISC/AS UPDATE LLP, PSORRXSEND ; 7/05/2018 4:57pm
;;7.0;OUTPATIENT PHARMACY;**534**;JULY 2018;Build 352
;
Q
;
PST ;POST INSTALL
;Reference to ^HLCS(870, supported by IA#6409
;
;Output:
; - ^XTMP("PSORRVIE",0)=purge date_U_today's date_U_patch
; - ^XTMP("PSORRVIE",1) = Link name ^ DNS ^ Port Number
; Do not delete XTMP file until 30 days from now
;
; By region number, Get LINK name, DNS name, and port number.
N PSOA,PSOLNK,PSOPORT,PSODNS,PSOIP
S U="^",PSOLNK="PSORRXSEND",PSOPORT=2200
S PSODNS="vaausvrsprdlb1.aac.domain.ext",PSOIP="127.0.0.1"
;
;
; 1. If link is up, stop the link.
; 2. Save existing DNS, IP address, and Port
; 3. Update logical link.
; 4. If the link was shutdown by this patch, bring it up
;
N X,PSOLLK,PSODP,PSOP4,PSOP0,PSOACTV,PSODAPP,X1,X2,HLJ
S (PSODP,PSOLLK)=+$$FIND1^DIC(870,"","MX",PSOLNK)
;
; If link is not defined in the HL LOGICAL LINK (#870) file
; *** Exit ***
I PSOLLK=0 D Q
. D BMES^XPDUTL("Link '"_PSOLNK_"' does not exist. Update aborted.")
. Q
;
; If link is locked by other process,
; *** Exit ***
L +^HLCS(870,PSOLLK):10 I '$T D Q
. D BMES^XPDUTL("Link '"_PSOLNK_"' was locked and unable to access. Update aborted.")
. Q
;
S PSOP4=$G(^HLCS(870,PSODP,400)),PSOP0=$G(^HLCS(870,PSODP,0))
S PSODAPP=$P(PSOP0,"^",1)
;
;
; Save current LLP, Link Name^IP^Port#^DNS, to XTMP
;
I '$G(PSORLBK) D
. S DT=$$DT^XLFDT,X1=DT,X2=30 D C^%DTC
. S ^XTMP("PSORRVIE",0)=X_U_DT_U_"PSO*7.0*534"
. S ^XTMP("PSORRVIE",1)=$P(PSOP0,"^")_U_$P(PSOP4,U)_U_$P(PSOP4,U,2)
. S ^XTMP("PSORRVIE",1)=^XTMP("PSORRVIE",1)_U_$P(PSOP0,"^",8)
;
; Shut Down LLP
;
;4=status,10=Time Stopped,9=Time Started,11=Task Number,3=Device Type
;DD14(P15)=0 means LLP was ON, OK to shutdown, piece 12=DD11 above
;
; If LLP status is SHUTDOWN, do nothing
S PSOACTV=1
I $P(PSOP0,U,15) D
. D BMES^XPDUTL("LINK '"_PSOLNK_"' status was already shutdown.")
. S PSOACTV=0
;
; If LLP status is ENABLED, shutdown the LLP
N PSOER
I '$P(PSOP0,U,15) D Q:$D(PSOER)
. S X="HLJ(870,"""_PSODP_","")",@X@(4)="Halting",@X@(10)=$$NOW^XLFDT
. S (@X@(11),@X@(9))="@",@X@(14)=1
. ; PSOP4 P3="C"LIENT, P4="N"ON-PERSISTANT, No task number
. I $P(PSOP4,U,3)="C"&("N"[$P(PSOP4,U,4)),'$P(PSOP0,U,12) S @X@(4)="Shutdown"
. D FILE^DIE("","HLJ","PSOER")
. ;
. ; if DIE unable to Shutdown LINK, EXIT
. I $D(PSOER) D Q
.. D BMES^XPDUTL("LINK '"_PSOLNK_"' was NOT able to Shutdown!")
.. D BMES^XPDUTL("Error: "_$G(PSOER("DIERR",1,"TEXT",1)))
.. D BMES^XPDUTL("Please log a ticket to report this error")
.. Q
.. ;
. D BMES^XPDUTL("LINK '"_PSOLNK_"' has been shutdown!")
;
; If Roll Back, retrieve previous saved Link data
;
S PSOA=0 I $G(PSORLBK) D Q:PSOA
. S X=$G(^XTMP("PSORRVIE",1)) I X="" D Q
.. S PSOA=1
.. D BMES^XPDUTL("PSO, no rollback data stored in ^XTMP('PSORRVIE') global")
. S PSOIP=$P(X,U,2),PSODNS=$P(X,U,4),PSOPORT=$P(X,U,3)
. I PSODNS="" S PSODNS="@"
. I PSOPORT="" S PSOPORT="@"
. I PSOIP="" S PSOIP="@"
. S ^XTMP("PSORRVIE",2)="Roll back performed "_$$DT^XLFDT
;
; Update LINK
;
S DIE="^HLCS(870,",DA=PSOLLK
S DR="400.01///"_PSOIP
S DR=DR_";400.02///"_PSOPORT_";.08///"_PSODNS
D ^DIE
K DIE,DA,DR
S X="PSO, LINK PSORRXSEND "_$S($G(PSORLBK):"rolled back",1:"updated with VIERS data")
D BMES^XPDUTL(X)
S X=" - LOGICAL LINK "_PSOLNK_", DNS: "_PSODNS
D BMES^XPDUTL(X)
S X=" - TCP/IP ADDRESS: "_PSOIP_", PORT: "_PSOPORT
D BMES^XPDUTL(X)
;
I PSOACTV=0 D PSTEND Q
;
; Activate LLP
;
K PSOER
I $P(PSOP4,U,3)="C"&("N"[$P(PSOP4,U,4)) D Q:$D(PSOER)
. ;4=status 9=Time Started, 10=Time Stopped, 11=Task Number
. ;14=Shutdown LLP, 3=Device Type, 18=Gross Errors
. K HLJ
. S X="HLJ(870,"""_PSODP_","")"
. S @X@(4)="Enabled",@X@(9)=$$NOW^XLFDT,@X@(14)=0
. D FILE^DIE("","HLJ","PSOER")
. ;
. ; if DIE unable to enable LINK, EXIT
. I $D(PSOER) D Q
.. D BMES^XPDUTL("LINK '"_PSOLNK_"' was NOT enabled!")
.. D BMES^XPDUTL("Error: "_$G(PSOER("DIERR",1,"TEXT",1)))
.. D BMES^XPDUTL("Please log a ticket to report this error")
.. Q
.. ;
. D BMES^XPDUTL("LINK '"_PSOLNK_"' has been enabled!")
. Q
;
PSTEND L -^HLCS(870,PSOLLK)
I '$G(PSORLBK) D BMES^XPDUTL("PSO, LOGICAL LINK '"_PSOLNK_"' NOW POINT TO VIERS SERVER.")
;
Q
;
ROLLBAK ;
N PSORLBK S PSORLBK=1
D PST
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSORRVIE 4412 printed Nov 22, 2024@17:44:18 Page 2
PSORRVIE ;WISC/AS UPDATE LLP, PSORRXSEND ; 7/05/2018 4:57pm
+1 ;;7.0;OUTPATIENT PHARMACY;**534**;JULY 2018;Build 352
+2 ;
+3 QUIT
+4 ;
PST ;POST INSTALL
+1 ;Reference to ^HLCS(870, supported by IA#6409
+2 ;
+3 ;Output:
+4 ; - ^XTMP("PSORRVIE",0)=purge date_U_today's date_U_patch
+5 ; - ^XTMP("PSORRVIE",1) = Link name ^ DNS ^ Port Number
+6 ; Do not delete XTMP file until 30 days from now
+7 ;
+8 ; By region number, Get LINK name, DNS name, and port number.
+9 NEW PSOA,PSOLNK,PSOPORT,PSODNS,PSOIP
+10 SET U="^"
SET PSOLNK="PSORRXSEND"
SET PSOPORT=2200
+11 SET PSODNS="vaausvrsprdlb1.aac.domain.ext"
SET PSOIP="127.0.0.1"
+12 ;
+13 ;
+14 ; 1. If link is up, stop the link.
+15 ; 2. Save existing DNS, IP address, and Port
+16 ; 3. Update logical link.
+17 ; 4. If the link was shutdown by this patch, bring it up
+18 ;
+19 NEW X,PSOLLK,PSODP,PSOP4,PSOP0,PSOACTV,PSODAPP,X1,X2,HLJ
+20 SET (PSODP,PSOLLK)=+$$FIND1^DIC(870,"","MX",PSOLNK)
+21 ;
+22 ; If link is not defined in the HL LOGICAL LINK (#870) file
+23 ; *** Exit ***
+24 IF PSOLLK=0
Begin DoDot:1
+25 DO BMES^XPDUTL("Link '"_PSOLNK_"' does not exist. Update aborted.")
+26 QUIT
End DoDot:1
QUIT
+27 ;
+28 ; If link is locked by other process,
+29 ; *** Exit ***
+30 LOCK +^HLCS(870,PSOLLK):10
IF '$TEST
Begin DoDot:1
+31 DO BMES^XPDUTL("Link '"_PSOLNK_"' was locked and unable to access. Update aborted.")
+32 QUIT
End DoDot:1
QUIT
+33 ;
+34 SET PSOP4=$GET(^HLCS(870,PSODP,400))
SET PSOP0=$GET(^HLCS(870,PSODP,0))
+35 SET PSODAPP=$PIECE(PSOP0,"^",1)
+36 ;
+37 ;
+38 ; Save current LLP, Link Name^IP^Port#^DNS, to XTMP
+39 ;
+40 IF '$GET(PSORLBK)
Begin DoDot:1
+41 SET DT=$$DT^XLFDT
SET X1=DT
SET X2=30
DO C^%DTC
+42 SET ^XTMP("PSORRVIE",0)=X_U_DT_U_"PSO*7.0*534"
+43 SET ^XTMP("PSORRVIE",1)=$PIECE(PSOP0,"^")_U_$PIECE(PSOP4,U)_U_$PIECE(PSOP4,U,2)
+44 SET ^XTMP("PSORRVIE",1)=^XTMP("PSORRVIE",1)_U_$PIECE(PSOP0,"^",8)
End DoDot:1
+45 ;
+46 ; Shut Down LLP
+47 ;
+48 ;4=status,10=Time Stopped,9=Time Started,11=Task Number,3=Device Type
+49 ;DD14(P15)=0 means LLP was ON, OK to shutdown, piece 12=DD11 above
+50 ;
+51 ; If LLP status is SHUTDOWN, do nothing
+52 SET PSOACTV=1
+53 IF $PIECE(PSOP0,U,15)
Begin DoDot:1
+54 DO BMES^XPDUTL("LINK '"_PSOLNK_"' status was already shutdown.")
+55 SET PSOACTV=0
End DoDot:1
+56 ;
+57 ; If LLP status is ENABLED, shutdown the LLP
+58 NEW PSOER
+59 IF '$PIECE(PSOP0,U,15)
Begin DoDot:1
+60 SET X="HLJ(870,"""_PSODP_","")"
SET @X@(4)="Halting"
SET @X@(10)=$$NOW^XLFDT
+61 SET (@X@(11),@X@(9))="@"
SET @X@(14)=1
+62 ; PSOP4 P3="C"LIENT, P4="N"ON-PERSISTANT, No task number
+63 IF $PIECE(PSOP4,U,3)="C"&("N"[$PIECE(PSOP4,U,4))
IF '$PIECE(PSOP0,U,12)
SET @X@(4)="Shutdown"
+64 DO FILE^DIE("","HLJ","PSOER")
+65 ;
+66 ; if DIE unable to Shutdown LINK, EXIT
+67 IF $DATA(PSOER)
Begin DoDot:2
+68 DO BMES^XPDUTL("LINK '"_PSOLNK_"' was NOT able to Shutdown!")
+69 DO BMES^XPDUTL("Error: "_$GET(PSOER("DIERR",1,"TEXT",1)))
+70 DO BMES^XPDUTL("Please log a ticket to report this error")
+71 QUIT
+72 ;
End DoDot:2
QUIT
+73 DO BMES^XPDUTL("LINK '"_PSOLNK_"' has been shutdown!")
End DoDot:1
if $DATA(PSOER)
QUIT
+74 ;
+75 ; If Roll Back, retrieve previous saved Link data
+76 ;
+77 SET PSOA=0
IF $GET(PSORLBK)
Begin DoDot:1
+78 SET X=$GET(^XTMP("PSORRVIE",1))
IF X=""
Begin DoDot:2
+79 SET PSOA=1
+80 DO BMES^XPDUTL("PSO, no rollback data stored in ^XTMP('PSORRVIE') global")
End DoDot:2
QUIT
+81 SET PSOIP=$PIECE(X,U,2)
SET PSODNS=$PIECE(X,U,4)
SET PSOPORT=$PIECE(X,U,3)
+82 IF PSODNS=""
SET PSODNS="@"
+83 IF PSOPORT=""
SET PSOPORT="@"
+84 IF PSOIP=""
SET PSOIP="@"
+85 SET ^XTMP("PSORRVIE",2)="Roll back performed "_$$DT^XLFDT
End DoDot:1
if PSOA
QUIT
+86 ;
+87 ; Update LINK
+88 ;
+89 SET DIE="^HLCS(870,"
SET DA=PSOLLK
+90 SET DR="400.01///"_PSOIP
+91 SET DR=DR_";400.02///"_PSOPORT_";.08///"_PSODNS
+92 DO ^DIE
+93 KILL DIE,DA,DR
+94 SET X="PSO, LINK PSORRXSEND "_$SELECT($GET(PSORLBK):"rolled back",1:"updated with VIERS data")
+95 DO BMES^XPDUTL(X)
+96 SET X=" - LOGICAL LINK "_PSOLNK_", DNS: "_PSODNS
+97 DO BMES^XPDUTL(X)
+98 SET X=" - TCP/IP ADDRESS: "_PSOIP_", PORT: "_PSOPORT
+99 DO BMES^XPDUTL(X)
+100 ;
+101 IF PSOACTV=0
DO PSTEND
QUIT
+102 ;
+103 ; Activate LLP
+104 ;
+105 KILL PSOER
+106 IF $PIECE(PSOP4,U,3)="C"&("N"[$PIECE(PSOP4,U,4))
Begin DoDot:1
+107 ;4=status 9=Time Started, 10=Time Stopped, 11=Task Number
+108 ;14=Shutdown LLP, 3=Device Type, 18=Gross Errors
+109 KILL HLJ
+110 SET X="HLJ(870,"""_PSODP_","")"
+111 SET @X@(4)="Enabled"
SET @X@(9)=$$NOW^XLFDT
SET @X@(14)=0
+112 DO FILE^DIE("","HLJ","PSOER")
+113 ;
+114 ; if DIE unable to enable LINK, EXIT
+115 IF $DATA(PSOER)
Begin DoDot:2
+116 DO BMES^XPDUTL("LINK '"_PSOLNK_"' was NOT enabled!")
+117 DO BMES^XPDUTL("Error: "_$GET(PSOER("DIERR",1,"TEXT",1)))
+118 DO BMES^XPDUTL("Please log a ticket to report this error")
+119 QUIT
+120 ;
End DoDot:2
QUIT
+121 DO BMES^XPDUTL("LINK '"_PSOLNK_"' has been enabled!")
+122 QUIT
End DoDot:1
if $DATA(PSOER)
QUIT
+123 ;
PSTEND LOCK -^HLCS(870,PSOLLK)
+1 IF '$GET(PSORLBK)
DO BMES^XPDUTL("PSO, LOGICAL LINK '"_PSOLNK_"' NOW POINT TO VIERS SERVER.")
+2 ;
+3 QUIT
+4 ;
ROLLBAK ;
+1 NEW PSORLBK
SET PSORLBK=1
+2 DO PST
+3 QUIT