- SDPAWS ;MS/SJA - UPDATE LLP, 'TMP_SEND' TO USE AWS SERVERS;July 05, 2018
- ;;5.3;Scheduling;**765**;May 29, 2018;Build 13
- ;
- ; Reference to ^HLCS(870, supported by IA#6409
- ;
- Q
- POST ; Entry point
- ;Output:
- ; ^XTMP("SDPAWS",0) = purge date ^ today's date ^ patch
- ; ^XTMP("SDPAWS",1) = Link name ^ DNS ^ Port Number ^ DNS DOMAIN ^ TCP/IP PORT (OPTIMIZED)
- ; ^XTMP global will be deleted after 30 days from installation
- ;
- N SDENV,X,Y
- D MES^XPDUTL(" Start Logical Link updates...")
- I $G(SDRLBK) G STBK
- ;
- ENV ; install environment
- ; Output: P = Production, T = Test (Pre-Prod), Q = SQA Test, D = Development
- S SDENV=$$PROD^XUPROD()
- N DIR,DIRUT,DTOUT,DUOUT,DIROUT
- S DIR("B")=$S($G(SDENV)=1:"P",$G(SDENV)=0:"Q",1:"T")
- S DIR(0)="S^P:Production;T:Pre-Prod(Test);Q:SQA Test;D:Development"
- S DIR("A")="Select Environment"
- S DIR("?")="Select the Environment associated with this install"
- D ^DIR K DIR I $D(DTOUT)!$D(DUOUT) D BMES^XPDUTL("Aborted. No Updates made.") Q
- S SDENV=Y
- ;
- ; AWS HealthShare servers (DNS name, IP address, and port number)
- N DNS,SDDNS,SDIP,SDPORT,OPTI
- S DNS("P")="vac10cluhl7r201-hl7.domain.ext^127.0.0.1^7950"
- S DNS("T")="vac10cluhshhl7rtr401.domain.ext^127.0.0.1^6950"
- S DNS("Q")="vac10apphsh924.domain.ext^127.0.0.1^54619"
- S DNS("D")="vac10apphsh804.domain.ext^127.0.0.1^54619"
- S SDDNS=$P(DNS(SDENV),U),SDIP=$P(DNS(SDENV),U,2),SDPORT=$P(DNS(SDENV),U,3),OPTI=SDPORT
- ;
- STBK ;
- N FDA,SDA,SDACTV,SDDP,SDLNK,SDP0,SDDAPP,SDP4,SDER,SDLLN
- S SDLLN="TMP_SEND",(SDDP,SDLNK)=+$$FIND1^DIC(870,"","MX",SDLLN)
- I SDLNK=0 D BMES^XPDUTL("Link '"_SDLLN_"' does not exist. Update aborted.") Q
- L +^HLCS(870,SDLNK):10 I '$T D BMES^XPDUTL("Logical Link '"_SDLLN_"' was locked and unable to access. Update aborted.") Q
- S SDP0=$G(^HLCS(870,SDDP,0)),SDDAPP=$P(SDP0,"^"),SDP4=$G(^HLCS(870,SDDP,400))
- ;
- ; Save current LLP, Link Name ^ IP ^ Port# ^ DNS, to XTMP
- I '$G(SDRLBK) D
- . S ^XTMP("SDPAWS",0)=$$FMADD^XLFDT(DT,30)_U_DT_U_"SD*5.3*765"
- . S ^XTMP("SDPAWS",1)=$P(SDP0,U)_U_$P(SDP4,U)_U_$P(SDP4,U,2)_U_$P(SDP0,"^",8)_U_$P(SDP4,U,8)
- ;
- ; Shutdown LLP
- ; 4=status,10=Time Stopped,9=Time Started,11=Task Number, 14=Shutdown LLP
- ; DD14(P15)=0 means LLP was ON, OK to shutdown, piece 12=DD11 above
- ;
- S SDACTV=1
- I $P(SDP0,U,15) D BMES^XPDUTL("Logical Link '"_SDLLN_"' status was already shutdown.") S SDACTV=0
- N SDER
- I '$P(SDP0,U,15) D Q:$D(SDER)
- . S X="FDA(870,"""_SDDP_","")",@X@(4)="Halting",@X@(10)=$$NOW^XLFDT,(@X@(11),@X@(9))="@",@X@(14)=1
- . ; SDP4-P3="C"LIENT, P4="N"ON-PERSISTANT, No task number
- . I $P(SDP4,U,3)="C"&("N"[$P(SDP4,U,4)),'$P(SDP0,U,12) S @X@(4)="Shutdown"
- . D FILE^DIE("","FDA","SDER")
- . I $D(SDER) D Q
- .. D BMES^XPDUTL("Logical Link '"_SDLLN_"' was NOT able to Shutdown!")
- .. D BMES^XPDUTL("Error: "_$G(SDER("DIERR",1,"TEXT",1)))
- .. D BMES^XPDUTL("Please log a ticket to report this error")
- . ;
- . D BMES^XPDUTL("Logical Link '"_SDLLN_"' has been shutdown!")
- ;
- ; If Roll Back, retrieve previous saved Link data
- S SDA=0 I $G(SDRLBK) D Q:SDA
- . S X=$G(^XTMP("SDPAWS",1))
- . I X="" S SDA=1 D BMES^XPDUTL("No rollback data stored in ^XTMP('SDPAWS') global") Q
- . S SDIP=$P(X,U,2),SDDNS=$P(X,U,4),SDPORT=$P(X,U,3),OPTI=$P(X,U,5)
- . S:SDIP="" SDIP="@" S:SDDNS="" SDDNS="@" S:SDPORT="" SDPORT="@" S:OPTI="" OPTI="@"
- . D NOW^%DTC
- . S ^XTMP("SDPAWS",2)="Roll back performed: "_+$E(%,1,12)
- ;
- ; Update LINK
- S DIE="^HLCS(870,",DA=SDLNK,DR="400.01///"_SDIP_";400.02///"_SDPORT_";.08///"_SDDNS_";400.08///"_OPTI
- D ^DIE K DIE,DA,DR
- D BMES^XPDUTL("SD link 'TMP_SEND' "_$S($G(SDRLBK):"rolled back",1:"updated with new data"))
- D BMES^XPDUTL(" - Logical Link "_SDLLN_", DNS: "_SDDNS)
- D BMES^XPDUTL(" - TCP/IP Address: "_SDIP_", PORT: "_SDPORT)
- I SDACTV=0 D END Q
- ;
- ; Activate LLP
- K SDER
- I $P(SDP4,U,3)="C"&("N"[$P(SDP4,U,4)) D Q:$D(SDER)
- . ;4=state 9=Time Started, 14=Shutdown LLP
- . K FDA S X="FDA(870,"""_SDDP_","")",@X@(4)="Enabled",@X@(9)=$$NOW^XLFDT,@X@(14)=0
- . D FILE^DIE("","FDA","SDER")
- . ;
- . ; if DIE unable to enable LINK, EXIT
- . I $D(SDER) D Q
- .. D BMES^XPDUTL("Logical Link '"_SDLLN_"' was NOT enabled!")
- .. D BMES^XPDUTL("Error: "_$G(SDER("DIERR",1,"TEXT",1)))
- .. D BMES^XPDUTL("Please log a ticket to report this error")
- .. Q
- .. ;
- . D BMES^XPDUTL("Logical Link: '"_SDLLN_"' has been enabled!")
- . Q
- ;
- END L -^HLCS(870,SDLNK)
- I '$G(SDRLBK) D BMES^XPDUTL("Logical Link '"_SDLLN_"' now pointing to the new AWS server.")
- Q
- ;
- ROLLBAK ; rolled back
- N SDRLBK S SDRLBK=1 D POST
- Q
- --- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDPAWS 4574 printed Feb 19, 2025@00:25:56 Page 2
- SDPAWS ;MS/SJA - UPDATE LLP, 'TMP_SEND' TO USE AWS SERVERS;July 05, 2018
- +1 ;;5.3;Scheduling;**765**;May 29, 2018;Build 13
- +2 ;
- +3 ; Reference to ^HLCS(870, supported by IA#6409
- +4 ;
- +5 QUIT
- POST ; Entry point
- +1 ;Output:
- +2 ; ^XTMP("SDPAWS",0) = purge date ^ today's date ^ patch
- +3 ; ^XTMP("SDPAWS",1) = Link name ^ DNS ^ Port Number ^ DNS DOMAIN ^ TCP/IP PORT (OPTIMIZED)
- +4 ; ^XTMP global will be deleted after 30 days from installation
- +5 ;
- +6 NEW SDENV,X,Y
- +7 DO MES^XPDUTL(" Start Logical Link updates...")
- +8 IF $GET(SDRLBK)
- GOTO STBK
- +9 ;
- ENV ; install environment
- +1 ; Output: P = Production, T = Test (Pre-Prod), Q = SQA Test, D = Development
- +2 SET SDENV=$$PROD^XUPROD()
- +3 NEW DIR,DIRUT,DTOUT,DUOUT,DIROUT
- +4 SET DIR("B")=$SELECT($GET(SDENV)=1:"P",$GET(SDENV)=0:"Q",1:"T")
- +5 SET DIR(0)="S^P:Production;T:Pre-Prod(Test);Q:SQA Test;D:Development"
- +6 SET DIR("A")="Select Environment"
- +7 SET DIR("?")="Select the Environment associated with this install"
- +8 DO ^DIR
- KILL DIR
- IF $DATA(DTOUT)!$DATA(DUOUT)
- DO BMES^XPDUTL("Aborted. No Updates made.")
- QUIT
- +9 SET SDENV=Y
- +10 ;
- +11 ; AWS HealthShare servers (DNS name, IP address, and port number)
- +12 NEW DNS,SDDNS,SDIP,SDPORT,OPTI
- +13 SET DNS("P")="vac10cluhl7r201-hl7.domain.ext^127.0.0.1^7950"
- +14 SET DNS("T")="vac10cluhshhl7rtr401.domain.ext^127.0.0.1^6950"
- +15 SET DNS("Q")="vac10apphsh924.domain.ext^127.0.0.1^54619"
- +16 SET DNS("D")="vac10apphsh804.domain.ext^127.0.0.1^54619"
- +17 SET SDDNS=$PIECE(DNS(SDENV),U)
- SET SDIP=$PIECE(DNS(SDENV),U,2)
- SET SDPORT=$PIECE(DNS(SDENV),U,3)
- SET OPTI=SDPORT
- +18 ;
- STBK ;
- +1 NEW FDA,SDA,SDACTV,SDDP,SDLNK,SDP0,SDDAPP,SDP4,SDER,SDLLN
- +2 SET SDLLN="TMP_SEND"
- SET (SDDP,SDLNK)=+$$FIND1^DIC(870,"","MX",SDLLN)
- +3 IF SDLNK=0
- DO BMES^XPDUTL("Link '"_SDLLN_"' does not exist. Update aborted.")
- QUIT
- +4 LOCK +^HLCS(870,SDLNK):10
- IF '$TEST
- DO BMES^XPDUTL("Logical Link '"_SDLLN_"' was locked and unable to access. Update aborted.")
- QUIT
- +5 SET SDP0=$GET(^HLCS(870,SDDP,0))
- SET SDDAPP=$PIECE(SDP0,"^")
- SET SDP4=$GET(^HLCS(870,SDDP,400))
- +6 ;
- +7 ; Save current LLP, Link Name ^ IP ^ Port# ^ DNS, to XTMP
- +8 IF '$GET(SDRLBK)
- Begin DoDot:1
- +9 SET ^XTMP("SDPAWS",0)=$$FMADD^XLFDT(DT,30)_U_DT_U_"SD*5.3*765"
- +10 SET ^XTMP("SDPAWS",1)=$PIECE(SDP0,U)_U_$PIECE(SDP4,U)_U_$PIECE(SDP4,U,2)_U_$PIECE(SDP0,"^",8)_U_$PIECE(SDP4,U,8)
- End DoDot:1
- +11 ;
- +12 ; Shutdown LLP
- +13 ; 4=status,10=Time Stopped,9=Time Started,11=Task Number, 14=Shutdown LLP
- +14 ; DD14(P15)=0 means LLP was ON, OK to shutdown, piece 12=DD11 above
- +15 ;
- +16 SET SDACTV=1
- +17 IF $PIECE(SDP0,U,15)
- DO BMES^XPDUTL("Logical Link '"_SDLLN_"' status was already shutdown.")
- SET SDACTV=0
- +18 NEW SDER
- +19 IF '$PIECE(SDP0,U,15)
- Begin DoDot:1
- +20 SET X="FDA(870,"""_SDDP_","")"
- SET @X@(4)="Halting"
- SET @X@(10)=$$NOW^XLFDT
- SET (@X@(11),@X@(9))="@"
- SET @X@(14)=1
- +21 ; SDP4-P3="C"LIENT, P4="N"ON-PERSISTANT, No task number
- +22 IF $PIECE(SDP4,U,3)="C"&("N"[$PIECE(SDP4,U,4))
- IF '$PIECE(SDP0,U,12)
- SET @X@(4)="Shutdown"
- +23 DO FILE^DIE("","FDA","SDER")
- +24 IF $DATA(SDER)
- Begin DoDot:2
- +25 DO BMES^XPDUTL("Logical Link '"_SDLLN_"' was NOT able to Shutdown!")
- +26 DO BMES^XPDUTL("Error: "_$GET(SDER("DIERR",1,"TEXT",1)))
- +27 DO BMES^XPDUTL("Please log a ticket to report this error")
- End DoDot:2
- QUIT
- +28 ;
- +29 DO BMES^XPDUTL("Logical Link '"_SDLLN_"' has been shutdown!")
- End DoDot:1
- if $DATA(SDER)
- QUIT
- +30 ;
- +31 ; If Roll Back, retrieve previous saved Link data
- +32 SET SDA=0
- IF $GET(SDRLBK)
- Begin DoDot:1
- +33 SET X=$GET(^XTMP("SDPAWS",1))
- +34 IF X=""
- SET SDA=1
- DO BMES^XPDUTL("No rollback data stored in ^XTMP('SDPAWS') global")
- QUIT
- +35 SET SDIP=$PIECE(X,U,2)
- SET SDDNS=$PIECE(X,U,4)
- SET SDPORT=$PIECE(X,U,3)
- SET OPTI=$PIECE(X,U,5)
- +36 if SDIP=""
- SET SDIP="@"
- if SDDNS=""
- SET SDDNS="@"
- if SDPORT=""
- SET SDPORT="@"
- if OPTI=""
- SET OPTI="@"
- +37 DO NOW^%DTC
- +38 SET ^XTMP("SDPAWS",2)="Roll back performed: "_+$EXTRACT(%,1,12)
- End DoDot:1
- if SDA
- QUIT
- +39 ;
- +40 ; Update LINK
- +41 SET DIE="^HLCS(870,"
- SET DA=SDLNK
- SET DR="400.01///"_SDIP_";400.02///"_SDPORT_";.08///"_SDDNS_";400.08///"_OPTI
- +42 DO ^DIE
- KILL DIE,DA,DR
- +43 DO BMES^XPDUTL("SD link 'TMP_SEND' "_$SELECT($GET(SDRLBK):"rolled back",1:"updated with new data"))
- +44 DO BMES^XPDUTL(" - Logical Link "_SDLLN_", DNS: "_SDDNS)
- +45 DO BMES^XPDUTL(" - TCP/IP Address: "_SDIP_", PORT: "_SDPORT)
- +46 IF SDACTV=0
- DO END
- QUIT
- +47 ;
- +48 ; Activate LLP
- +49 KILL SDER
- +50 IF $PIECE(SDP4,U,3)="C"&("N"[$PIECE(SDP4,U,4))
- Begin DoDot:1
- +51 ;4=state 9=Time Started, 14=Shutdown LLP
- +52 KILL FDA
- SET X="FDA(870,"""_SDDP_","")"
- SET @X@(4)="Enabled"
- SET @X@(9)=$$NOW^XLFDT
- SET @X@(14)=0
- +53 DO FILE^DIE("","FDA","SDER")
- +54 ;
- +55 ; if DIE unable to enable LINK, EXIT
- +56 IF $DATA(SDER)
- Begin DoDot:2
- +57 DO BMES^XPDUTL("Logical Link '"_SDLLN_"' was NOT enabled!")
- +58 DO BMES^XPDUTL("Error: "_$GET(SDER("DIERR",1,"TEXT",1)))
- +59 DO BMES^XPDUTL("Please log a ticket to report this error")
- +60 QUIT
- +61 ;
- End DoDot:2
- QUIT
- +62 DO BMES^XPDUTL("Logical Link: '"_SDLLN_"' has been enabled!")
- +63 QUIT
- End DoDot:1
- if $DATA(SDER)
- QUIT
- +64 ;
- END LOCK -^HLCS(870,SDLNK)
- +1 IF '$GET(SDRLBK)
- DO BMES^XPDUTL("Logical Link '"_SDLLN_"' now pointing to the new AWS server.")
- +2 QUIT
- +3 ;
- ROLLBAK ; rolled back
- +1 NEW SDRLBK
- SET SDRLBK=1
- DO POST
- +2 QUIT