Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: LA66

LA66.m

Go to the documentation of this file.
  1. LA66 ;DALOI/JMC - LA*5.2*66 PATCH ENVIRONMENT CHECK ROUTINE ;May 7, 2008
  1. ;;5.2;AUTOMATED LAB INSTRUMENTS;**66**;Sep 27, 1994;Build 30
  1. ;
  1. ; Pre, Post, and Environment checks for LA*5.2*66
  1. ;
  1. ENV ;
  1. ; Environment checks
  1. S XPDNOQUE=1 ; no queuing
  1. N LAERR,LAADL
  1. K ^TMP($$RTNNM(),$J)
  1. I '$G(XPDENV) D ;
  1. . N MSG
  1. . S MSG="Transport global for patch "_$G(XPDNM,"Unknown patch")_" loaded on "_$$HTE^XLFDT($H)
  1. . D ALERT(MSG)
  1. . D BMES("Sending transport global loaded alert to mail group G.LMI")
  1. ;
  1. I $G(XPDENV) D ;
  1. . N MSG
  1. . S MSG="Installation of patch "_$G(XPDNM,"Unknown patch")_" started on "_$$HTE^XLFDT($H)
  1. . D ALERT(MSG)
  1. . D BMES("Sending install started alert to mail group G.LMI")
  1. ;
  1. S LAERR=0
  1. I $S('$G(IOM):1,'$G(IOSL):1,$G(U)'="^":1,1:0) D ;
  1. . D BMES("Terminal Device is not defined.")
  1. . S LAERR=2
  1. ;
  1. I $S('$G(DUZ):1,$D(DUZ)[0:1,$D(DUZ(0))[0:1,1:0) D ;
  1. . D BMES("Please login to set local DUZ variables.")
  1. . S LAERR=2
  1. ;
  1. I 'LAERR,$P($$ACTIVE^XUSER(DUZ),"^")'=1 D ;
  1. . D BMES("You are not a valid user on this system.")
  1. . S LAERR=2
  1. ;
  1. ; If installing, run system config
  1. I 'LAERR,$G(XPDENV) D ;
  1. . S LAADL=$G(^LA("ADL","STOP"))
  1. . D ENV2
  1. . I $P(LAADL,"^")=0 D ;
  1. . . D BMES("N O T E: If you abort this installation")
  1. . . D MES("restart the Lab Universal Interface background job.")
  1. ;
  1. I LAERR!$D(XPDABORT)!$D(XPDQUIT) D ;
  1. . S LAERR=1
  1. . S XPDABORT=2 S XPDQUIT=2
  1. . W !,$C(7) W ! D BMES("* * * Environment check FAILED * * *")
  1. ;
  1. I 'LAERR W ! D BMES("--- Environment is okay ---")
  1. ;
  1. I $G(XPDENV) S XPDDIQ("XPZ1","B")="NO"
  1. Q
  1. ;
  1. ;
  1. PRE ;
  1. ; Pre install
  1. D BMES("*** Pre install started ***")
  1. D BMES("--- No action required for pre-install ---")
  1. D BMES("*** Pre install completed ***")
  1. Q
  1. ;
  1. ;
  1. POST ;
  1. ; Post install
  1. N LAERR,LAFDA,LA7DIE,LA7FAC,LA7I,LA7X,LA7Y,LAMSG,LAPOST,DIERR
  1. S (LAERR,LAPOST)=0
  1. D BMES("*** Post install started ***")
  1. ;
  1. ; Set facility station number into FACILITY NAME field in file #771.
  1. S LA7FAC=$P($$SITE^VASITE(DT),"^",3)
  1. I 'LA7FAC D ;
  1. . S LAERR=1
  1. . D BMES("ERROR: Could not determine Facility Number.")
  1. . D BMES("Edit file #771, FACILITY NAME field for LA7UI*")
  1. I LA7FAC'="" D
  1. . D BMES("*** Updating facility name for LA7UI* entries in file #771 ***")
  1. . ; Okayed by Thomas Grohowski
  1. . F LA7I=1:1:10 D ;
  1. . . I LA7I S LA7X="LA7UI"_LA7I
  1. . . K DIERR
  1. . . S LA7Y=$$FIND1^DIC(771,"","OX",LA7X,"B")
  1. . . I LA7Y<1 D Q
  1. . . . S LAERR=1
  1. . . . D BMES("ERROR: "_LA7X_" not found in file #771")
  1. . . K LAFDA,DIERR,LAMSG
  1. . . S LAFDA(1,771,LA7Y_",",3)=LA7FAC
  1. . . D FILE^DIE("","LAFDA(1)","LAMSG")
  1. . . ; notify if could not update
  1. . . S LAERR=$$FMERR("LAMSG","ERROR: unable to update "_LA7X_" in file #771")
  1. . ; delete facility ID for LA7LAB
  1. . K LAFDA,LAMSG,DIERR
  1. . S LA7Y=$$FIND1^DIC(771,"","OX","LA7LAB","B")
  1. . I 'LA7Y D
  1. . . S LAERR=1
  1. . . D BMES("*** Missing 'LA7LAB' entry in HL7 APPLICATION PARAMETER (#771) file ***")
  1. . I LA7Y D
  1. . . K DIERR,LAFDA,LAMSG
  1. . . S LAFDA(1,771,LA7Y_",",3)="@"
  1. . . D FILE^DIE("","LAFDA(1)","LAMSG")
  1. . . S LAERR=$$FMERR("LAMSG","ERROR: Failed to update LA7LAB entry in file #771.")
  1. . S LAPOST=1
  1. . D BMES("*** Updating facility name completed"_$S(LAERR:" but with errors",1:"")_" ***")
  1. ;
  1. ;
  1. I $D(^TMP("LA66",$J,"62.48")) D
  1. . D BMES("*** Restoring existing LA7UI* entries to ACTIVE in file #62.48 ***")
  1. . S LA7I=0,LAPOST=1
  1. . F S LA7I=$O(^TMP("LA66",$J,"62.48",LA7I)) Q:'LA7I D
  1. . . K DIERR,LAFDA,LAMSG
  1. . . S LA7Y=$P(^LAHM(62.48,LA7I,0),"^")
  1. . . D BMES("*** Updating entry "_LA7Y_" to ACTIVE in file #62.48 ***")
  1. . . S LAFDA(2,62.48,LA7I_",",2)=^TMP("LA66",$J,"62.48",LA7I)
  1. . . D FILE^DIE("","LAFDA(2)","LAMSG")
  1. . . S LAERR=$$FMERR("LAMSG","ERROR: Failed to update "_LA7Y_" entry in file #62.48.")
  1. . D BMES("*** Updating existing LA7UI* entries to ACTIVE completed ***")
  1. ;
  1. I 'LAERR,'LAPOST D BMES("--- No actions required for post install ---")
  1. ;
  1. D RESTORE
  1. D BMES("*** Post install completed"_$S(LAERR:" but with errors",1:"")_" ***")
  1. ;
  1. N MSG
  1. S MSG="Installation of patch "_$G(XPDNM,"Unknown patch")_" completed on "_$$HTE^XLFDT($H)
  1. D ALERT(MSG)
  1. D BMES("Sending install completion alert to mail group G.LMI")
  1. ;
  1. K ^TMP($$RTNNM(),$J),^TMP("LA66",$J)
  1. Q
  1. ;
  1. ;
  1. BMES(STR,POS) ;
  1. ; Display messages using BMES^XPDUTL or MES^XPDUTL
  1. ; Accepts single string or string array
  1. ; Input
  1. ; STR The string to display (byRef or byValue)
  1. ; POS <opt> value for $$CJ^XLFSTR (80=default)
  1. ;
  1. N I,X
  1. S POS=$G(POS,80)
  1. ; If an array, step through it and pass each node to MES since $$CJ^XLFSTR can't handle arrays
  1. I $D(STR)>9 D
  1. . S I=0
  1. . F S I=$O(STR(I)) Q:'I S X=STR(I) D MES^XPDUTL($$TRIM^XLFSTR($$CJ^XLFSTR(X,POS),"R"," "))
  1. ;
  1. I $D(STR)<2 D MES^XPDUTL($$TRIM^XLFSTR($$CJ^XLFSTR(STR,POS),"R"," "))
  1. Q
  1. ;
  1. ;
  1. MES(STR,CJ,LM) ;
  1. ; Displays a string using MES^XPDUTL
  1. ; Inputs
  1. ; STR: String to display
  1. ; CJ: Center text? 1=yes 0=1 <dflt=1>
  1. ; LM: Left Margin (padding)
  1. N X
  1. S STR=$G(STR)
  1. S CJ=$G(CJ,1)
  1. S LM=$G(LM)
  1. I LM<0 S LM=0
  1. I CJ S STR=$$TRIM^XLFSTR($$CJ^XLFSTR(STR,$G(IOM,80)),"R"," ")
  1. I 'CJ I LM S X="" S $P(X," ",LM)=" " S STR=X_STR
  1. D MES^XPDUTL(STR)
  1. Q
  1. ;
  1. ;
  1. FMERR(LAREF,MSG) ;
  1. ; Checks if a FileMan error occurred and displays help message
  1. ; and error text message.
  1. ; Input
  1. ; LAREF Name of array that has the FM DIERR subscripts
  1. ; ie FILE^DIE msg_root variable
  1. ; MSG <opt> Additional help text
  1. ; Output
  1. ; 1 if an error occurred, 0 if no error
  1. ; Also writes the messages to the device
  1. N LAERRMSG,OK,FMERR
  1. S LAREF=$G(LAREF)
  1. S MSG=$G(MSG)
  1. S FMERR=0
  1. D MSG^DIALOG("AE",.LAERRMSG,,,LAREF)
  1. I $D(LAERRMSG) D ;
  1. . I MSG'="" D BMES(MSG)
  1. . D BMES(.LAERRMSG)
  1. . S FMERR=1
  1. Q FMERR
  1. ;
  1. ;
  1. ENV2 ;
  1. ; Secondary Environment checks
  1. N X,I
  1. ; check and shutdown Auto Download job.
  1. S X=$G(^LA("ADL","STOP"))
  1. I $P(X,"^")=0 D ;
  1. . D SETSTOP^LA7ADL1(2,DUZ)
  1. . D BMES("Shutting down Lab Universal Interface Auto Download Job")
  1. . S ^TMP($$RTNNM(),$J,"ADL")=1
  1. . F I=1:1:10 W "." H 1
  1. ;
  1. ;
  1. ; If previously installed then save current ACTIVE LA7UI* entries.
  1. K ^TMP("LA66",$J,"62.48")
  1. S I=0
  1. F S I=$O(^LAHM(62.48,I)) Q:'I I $E($P(^LAHM(62.48,I,0),"^"),1,5)="LA7UI",$P(^LAHM(62.48,I,0),"^",3)=1 S ^TMP("LA66",$J,"62.48",I)=1
  1. Q
  1. ;
  1. ;
  1. RESTORE ;
  1. ; Restore system after install
  1. N LAADL,X
  1. ; Restart auto download process status if stopped by install
  1. S LAADL=$G(^TMP($$RTNNM(),$J,"ADL"))
  1. I LAADL=1 D ;
  1. . D ZTSK^LA7ADL
  1. . D SETSTOP^LA7ADL1(1,DUZ)
  1. . D BMES("Restarting Lab Universal Interface Auto Download Job")
  1. . K ^TMP($$RTNNM(),$J,"ADL")
  1. . H 3
  1. ;
  1. ; If ADL not started, notify user to restart
  1. S X=$G(^LA("ADL","STOP"))
  1. S X=$P(X,"^")
  1. I X'=0 D BMES("Be sure to restart the Lab Universal Interface Auto Download Job")
  1. K ^TMP($$RTNNM(),$J)
  1. Q
  1. ;
  1. ;
  1. ALERT(MSG,RECIPS) ;
  1. N DA,DIK,XQA,XQAMSG
  1. S XQAMSG=$G(MSG)
  1. S XQA("G.LMI")=""
  1. I $D(RECIPS) M XQA=RECIPS
  1. D SETUP^XQALERT
  1. Q
  1. ;
  1. ;
  1. RTNNM() ;
  1. Q $T(+0)