EC2P134 ;ALB/DAN - Installation activities ;4/19/17 11:04
;;2.0;EVENT CAPTURE;**134**;8 May 96;Build 12
;
ENV ;Environment check to make sure old file 722 isn't there
;
N DIU
I '$D(^ECC(722,0)) W !,"Environment is ready for installation." Q
I $D(^ECC(722,0)) D ;If old file 722 exists, delete it.
.W !,"Old file encountered during check..."
.W !,"Removing 'EVENT CAPTURE EXTRACTS' file (#722) as it's obsolete."
.S DIU="^ECC(722,"
.S DIU(0)="DT" ;Remove data and templates as well as the file
.D EN^DIU2
.Q
Q
;
POST ;Post-install activities
D DTPD ;Delete test patient data
D CHKLOC ;Check location names to see if they're correct
D DELLOC ;Del "LOC" xref and then rebuild so it uses current names
Q
;
DTPD ;Delete test patient data from file 721 if this is a production install
N PROD,RESULTS,DIK
S PROD=$$PROD^XUPROD
I PROD D
.D BMES^XPDUTL("Starting task in background to delete test patient data from the")
.D MES^XPDUTL("EVENT CAPTURE PATIENT file (#721). An email will be sent upon completion.")
.D DTPD^ECUMRPC2(.RESULTS,"D")
.D BMES^XPDUTL($S(@RESULTS@(0):"Task queued successfully.",1:"Error setting up task - contact national help desk."))
.Q
I 'PROD D BMES^XPDUTL("Not a production environment - no test patient data deleted.")
Q
;
CHKLOC ;Check "LOC" index against actual names and report differences
N NAME,REC,CHG,DEL,NEWNM
S NAME="" F S NAME=$O(^DIC(4,"LOC",NAME)) Q:NAME="" D
.S REC=0 F S REC=$O(^DIC(4,"LOC",NAME,REC)) Q:'+REC D
..I '$D(^DIC(4,REC)) S DEL(NAME,REC)="" Q
..S NEWNM=$P($G(^DIC(4,REC,0)),U) ;Current name of location
..I NEWNM'=NAME S CHG(NAME,REC)=NEWNM ;Note name change
D MAIL
Q
;
DELLOC ;Fix "LOC" table in file 4
D BMES^XPDUTL("Deleting 'LOC' cross-reference in file 4...")
K ^DIC(4,"LOC") ;One-time IA 6723 allows for this deletion
D MES^XPDUTL("Done")
D BMES^XPDUTL("Rebuilding 'LOC' cross-reference in file 4")
S DIK="^DIC(4,",DIK(1)=720 D ENALL^DIK
D MES^XPDUTL("Done")
Q
;
MAIL ;Send email with results to holders of the ECMGR key
N XMSUB,XMTEXT,XMDUZ,XMY,XMZ,CNT,DIFROM,ECTEXT,NUM,NAME
S XMDUZ="PATCH EC*2*134 POST-INSTALL"
D GETXMY("ECMGR",.XMY)
S CNT=1
S ECTEXT(CNT)="A review of Event Capture Location names has completed.",CNT=CNT+1,ECTEXT(CNT)="Event Capture Location names were checked to make sure they are using the",CNT=CNT+1
S ECTEXT(CNT)="correct name as found in the INSTITUTION file (#4).",CNT=CNT+1
S ECTEXT(CNT)="",CNT=CNT+1
I '$D(CHG),'$D(DEL) S ECTEXT(CNT)="No differences were found between your Event Capture Locations and the",CNT=CNT+1,ECTEXT(CNT)="INSTITUTION file. No further action is required.",CNT=CNT+1
I $D(CHG)!($D(DEL)) D
.S ECTEXT(CNT)="Changes to your Event Capture Location names were required.",CNT=CNT+1
.S ECTEXT(CNT)="Entries are identified by NAME(IEN), where IEN is the record number in the",CNT=CNT+1
.S ECTEXT(CNT)="INSTITUTION file (file #4).",CNT=CNT+1
.S ECTEXT(CNT)="",CNT=CNT+1
I $D(CHG) D S ECTEXT(CNT)="",CNT=CNT+1
.S ECTEXT(CNT)="The following locations had their name updated:",CNT=CNT+1,ECTEXT(CNT)="",CNT=CNT+1
.S NAME="" F S NAME=$O(CHG(NAME)) Q:NAME="" S NUM=0 F S NUM=$O(CHG(NAME,NUM)) Q:'+NUM D
..S ECTEXT(CNT)=NAME_" ("_NUM_") is now "_$G(CHG(NAME,NUM)),CNT=CNT+1
I $D(DEL) D S ECTEXT(CNT)="",CNT=CNT+1
.S ECTEXT(CNT)="The following locations are no longer available:",CNT=CNT+1,ECTEXT(CNT)="",CNT=CNT+1
.S NAME="" F S NAME=$O(DEL(NAME)) Q:NAME="" S NUM=0 F S NUM=$O(DEL(NAME,NUM)) Q:'+NUM S ECTEXT(CNT)=NAME_" ("_NUM_") is no longer available.",CNT=CNT+1
I $D(CHG)!($D(DEL)) D
.S ECTEXT(CNT)="These updates were done to get your Event Capture Location names",CNT=CNT+1,ECTEXT(CNT)="back in sync with the INSTITUTION file. You should review your Event",CNT=CNT+1
.S ECTEXT(CNT)="Capture Locations to make sure that locations identified for use in Event",CNT=CNT+1,ECTEXT(CNT)="Capture are correct. No other action is required."
S XMTEXT="ECTEXT(",XMSUB="Event Capture Location review"
D ^XMD
Q
;
GETXMY(KEY,XMY) ;Put holders of the KEY into the XMY array to be recipients of the email
I $G(KEY)'="" M XMY=^XUSEC(KEY)
S:$G(DUZ) XMY(DUZ)="" ;Make sure there's at least one recipient
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HEC2P134 4268 printed Dec 13, 2024@01:54:58 Page 2
EC2P134 ;ALB/DAN - Installation activities ;4/19/17 11:04
+1 ;;2.0;EVENT CAPTURE;**134**;8 May 96;Build 12
+2 ;
ENV ;Environment check to make sure old file 722 isn't there
+1 ;
+2 NEW DIU
+3 IF '$DATA(^ECC(722,0))
WRITE !,"Environment is ready for installation."
QUIT
+4 ;If old file 722 exists, delete it.
IF $DATA(^ECC(722,0))
Begin DoDot:1
+5 WRITE !,"Old file encountered during check..."
+6 WRITE !,"Removing 'EVENT CAPTURE EXTRACTS' file (#722) as it's obsolete."
+7 SET DIU="^ECC(722,"
+8 ;Remove data and templates as well as the file
SET DIU(0)="DT"
+9 DO EN^DIU2
+10 QUIT
End DoDot:1
+11 QUIT
+12 ;
POST ;Post-install activities
+1 ;Delete test patient data
DO DTPD
+2 ;Check location names to see if they're correct
DO CHKLOC
+3 ;Del "LOC" xref and then rebuild so it uses current names
DO DELLOC
+4 QUIT
+5 ;
DTPD ;Delete test patient data from file 721 if this is a production install
+1 NEW PROD,RESULTS,DIK
+2 SET PROD=$$PROD^XUPROD
+3 IF PROD
Begin DoDot:1
+4 DO BMES^XPDUTL("Starting task in background to delete test patient data from the")
+5 DO MES^XPDUTL("EVENT CAPTURE PATIENT file (#721). An email will be sent upon completion.")
+6 DO DTPD^ECUMRPC2(.RESULTS,"D")
+7 DO BMES^XPDUTL($SELECT(@RESULTS@(0):"Task queued successfully.",1:"Error setting up task - contact national help desk."))
+8 QUIT
End DoDot:1
+9 IF 'PROD
DO BMES^XPDUTL("Not a production environment - no test patient data deleted.")
+10 QUIT
+11 ;
CHKLOC ;Check "LOC" index against actual names and report differences
+1 NEW NAME,REC,CHG,DEL,NEWNM
+2 SET NAME=""
FOR
SET NAME=$ORDER(^DIC(4,"LOC",NAME))
if NAME=""
QUIT
Begin DoDot:1
+3 SET REC=0
FOR
SET REC=$ORDER(^DIC(4,"LOC",NAME,REC))
if '+REC
QUIT
Begin DoDot:2
+4 IF '$DATA(^DIC(4,REC))
SET DEL(NAME,REC)=""
QUIT
+5 ;Current name of location
SET NEWNM=$PIECE($GET(^DIC(4,REC,0)),U)
+6 ;Note name change
IF NEWNM'=NAME
SET CHG(NAME,REC)=NEWNM
End DoDot:2
End DoDot:1
+7 DO MAIL
+8 QUIT
+9 ;
DELLOC ;Fix "LOC" table in file 4
+1 DO BMES^XPDUTL("Deleting 'LOC' cross-reference in file 4...")
+2 ;One-time IA 6723 allows for this deletion
KILL ^DIC(4,"LOC")
+3 DO MES^XPDUTL("Done")
+4 DO BMES^XPDUTL("Rebuilding 'LOC' cross-reference in file 4")
+5 SET DIK="^DIC(4,"
SET DIK(1)=720
DO ENALL^DIK
+6 DO MES^XPDUTL("Done")
+7 QUIT
+8 ;
MAIL ;Send email with results to holders of the ECMGR key
+1 NEW XMSUB,XMTEXT,XMDUZ,XMY,XMZ,CNT,DIFROM,ECTEXT,NUM,NAME
+2 SET XMDUZ="PATCH EC*2*134 POST-INSTALL"
+3 DO GETXMY("ECMGR",.XMY)
+4 SET CNT=1
+5 SET ECTEXT(CNT)="A review of Event Capture Location names has completed."
SET CNT=CNT+1
SET ECTEXT(CNT)="Event Capture Location names were checked to make sure they are using the"
SET CNT=CNT+1
+6 SET ECTEXT(CNT)="correct name as found in the INSTITUTION file (#4)."
SET CNT=CNT+1
+7 SET ECTEXT(CNT)=""
SET CNT=CNT+1
+8 IF '$DATA(CHG)
IF '$DATA(DEL)
SET ECTEXT(CNT)="No differences were found between your Event Capture Locations and the"
SET CNT=CNT+1
SET ECTEXT(CNT)="INSTITUTION file. No further action is required."
SET CNT=CNT+1
+9 IF $DATA(CHG)!($DATA(DEL))
Begin DoDot:1
+10 SET ECTEXT(CNT)="Changes to your Event Capture Location names were required."
SET CNT=CNT+1
+11 SET ECTEXT(CNT)="Entries are identified by NAME(IEN), where IEN is the record number in the"
SET CNT=CNT+1
+12 SET ECTEXT(CNT)="INSTITUTION file (file #4)."
SET CNT=CNT+1
+13 SET ECTEXT(CNT)=""
SET CNT=CNT+1
End DoDot:1
+14 IF $DATA(CHG)
Begin DoDot:1
+15 SET ECTEXT(CNT)="The following locations had their name updated:"
SET CNT=CNT+1
SET ECTEXT(CNT)=""
SET CNT=CNT+1
+16 SET NAME=""
FOR
SET NAME=$ORDER(CHG(NAME))
if NAME=""
QUIT
SET NUM=0
FOR
SET NUM=$ORDER(CHG(NAME,NUM))
if '+NUM
QUIT
Begin DoDot:2
+17 SET ECTEXT(CNT)=NAME_" ("_NUM_") is now "_$GET(CHG(NAME,NUM))
SET CNT=CNT+1
End DoDot:2
End DoDot:1
SET ECTEXT(CNT)=""
SET CNT=CNT+1
+18 IF $DATA(DEL)
Begin DoDot:1
+19 SET ECTEXT(CNT)="The following locations are no longer available:"
SET CNT=CNT+1
SET ECTEXT(CNT)=""
SET CNT=CNT+1
+20 SET NAME=""
FOR
SET NAME=$ORDER(DEL(NAME))
if NAME=""
QUIT
SET NUM=0
FOR
SET NUM=$ORDER(DEL(NAME,NUM))
if '+NUM
QUIT
SET ECTEXT(CNT)=NAME_" ("_NUM_") is no longer available."
SET CNT=CNT+1
End DoDot:1
SET ECTEXT(CNT)=""
SET CNT=CNT+1
+21 IF $DATA(CHG)!($DATA(DEL))
Begin DoDot:1
+22 SET ECTEXT(CNT)="These updates were done to get your Event Capture Location names"
SET CNT=CNT+1
SET ECTEXT(CNT)="back in sync with the INSTITUTION file. You should review your Event"
SET CNT=CNT+1
+23 SET ECTEXT(CNT)="Capture Locations to make sure that locations identified for use in Event"
SET CNT=CNT+1
SET ECTEXT(CNT)="Capture are correct. No other action is required."
End DoDot:1
+24 SET XMTEXT="ECTEXT("
SET XMSUB="Event Capture Location review"
+25 DO ^XMD
+26 QUIT
+27 ;
GETXMY(KEY,XMY) ;Put holders of the KEY into the XMY array to be recipients of the email
+1 IF $GET(KEY)'=""
MERGE XMY=^XUSEC(KEY)
+2 ;Make sure there's at least one recipient
if $GET(DUZ)
SET XMY(DUZ)=""
+3 QUIT
+4 ;