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

PXVWSTAT.m

Go to the documentation of this file.
  1. PXVWSTAT ;ISP/LMT - Manage Status of ICE Interface ;12/13/17 12:24
  1. ;;1.0;PCE PATIENT CARE ENCOUNTER;**217**;Aug 12, 1996;Build 134
  1. ;
  1. ;
  1. LOGSTAT(DFN) ; Log if call succeeded or failed
  1. ;
  1. N PXNOW,PXRETCODE,PXSUB,PXSUCCESS
  1. ;
  1. S PXSUB="PXICESTAT-"_DT
  1. S PXNOW=$$NOW^XLFDT()
  1. ;
  1. S PXSUCCESS=1
  1. S PXRETCODE=$P($G(^TMP("PXICEWEB",$J,0)),U,1)
  1. ; Should we only consider fail if -2, -3, and -4?
  1. I PXRETCODE<0 S PXSUCCESS=0
  1. I PXRETCODE=-6 Q
  1. ;
  1. L +^XTMP(PXSUB):DILOCKTM
  1. ;
  1. I '$D(^XTMP(PXSUB)) D
  1. . S ^XTMP(PXSUB,0)=$$FMADD^XLFDT(PXNOW,30)_U_PXNOW_U_"ICE Web Stat Log"
  1. . ;M ^XTMP(PXSUB,"LAST")=^XTMP("PXICESTAT-"_$$FMADD^XLFDT(DT,-1),"LAST")
  1. ;
  1. I PXSUCCESS D
  1. . ;I '$$ISUP() D ENABLE
  1. . S ^XTMP(PXSUB,"TOTAL","SUCCESS")=$G(^XTMP(PXSUB,"TOTAL","SUCCESS"))+1
  1. . ;S ^XTMP(PXSUB,"LAST","SUCCESS")=PXNOW
  1. . ;K ^XTMP(PXSUB,"LAST","FAIL")
  1. . S ^XTMP(PXSUB,"LAST")=1_U_PXNOW
  1. ;
  1. I 'PXSUCCESS D
  1. . S ^XTMP(PXSUB,"TOTAL","FAIL")=$G(^XTMP(PXSUB,"TOTAL","FAIL"))+1
  1. . ;I $D(^XTMP(PXSUB,"LAST","FAIL")),DFN'=$P($G(^XTMP(PXSUB,"LAST","FAIL")),U,2) D
  1. . ;. ; if ICE is enabled, mark ICE as unavailable
  1. . ;. I $$CHKSTAT() D UNAVLBL
  1. . ;S ^XTMP(PXSUB,"LAST","FAIL")=PXNOW_U_DFN
  1. . I $P($G(^XTMP(PXSUB,"LAST")),U,1)=0,DFN'=$P($G(^XTMP(PXSUB,"LAST")),U,3) D
  1. . . ; if ICE is enabled, mark ICE as unavailable
  1. . . I $$CHKSTAT() D UNAVLBL
  1. . ;
  1. . S ^XTMP(PXSUB,"LAST")=0_U_PXNOW_U_DFN
  1. ;
  1. L -^XTMP(PXSUB)
  1. ;
  1. Q
  1. ;
  1. ;
  1. RESTORE ; Mark ICE interface as up
  1. ;
  1. ;enable interface
  1. D UPDSTAT(1)
  1. ;send bulletin
  1. D SMSGRST
  1. ;
  1. Q
  1. ;
  1. ;
  1. UNAVLBL ; Mark ICE interface as down due to too many failed attempts
  1. ;
  1. N PXDESC,PXFREQ,PXRTN,PXTASK,PXVARS,PXVOTH
  1. ;
  1. ;mark interface as unavailable
  1. D UPDSTAT(2)
  1. ;
  1. ;send bulletin
  1. D SMSGDWN
  1. ;
  1. ; Task job to run every 15 to test if ICE is back up
  1. S PXRTN="TASKTST^PXVWSTAT"
  1. S PXDESC="Test Immunization Calculation Engine (ICE)"
  1. S PXFREQ=15 ;Frequency (in min) to check if ICE is back up
  1. S PXVARS="PXFREQ"
  1. S PXVOTH("ZTDTH")=$$HADD^XLFDT($H,0,0,PXFREQ,0)
  1. S PXTASK=$$NODEV^XUTMDEVQ(PXRTN,PXDESC,PXVARS,.PXVOTH)
  1. ;
  1. Q
  1. ;
  1. ;
  1. SMSGDWN ; send a bulletin that ICE Interface connection is down.
  1. ;
  1. N PXFDB,XMB,XMBTMP,XMDF,XMDT,XMTEXT,XMY,XMYBLOB,XMV,XMDUZ
  1. ;
  1. S XMDUZ="PX ICE MANAGER"
  1. S XMB="PX ICE INTERFACE DOWN"
  1. S XMTEXT="PXFDB"
  1. S PXFDB(1)="Connection to the Immunization Calculation Engine (ICE) is down! The"
  1. S PXFDB(2)="ICE immunization recommendations will not be able to be utilized until"
  1. S PXFDB(3)="the connection is reestablished!!!"
  1. S XMY("G.PXRM MANAGER")="" ;TODO: CHANGE
  1. D ^XMB
  1. ;
  1. Q
  1. ;
  1. ;
  1. SMSGRST ; send a bulletin that ICE Interface connection is restored
  1. N PXFDB,XMB,XMBTMP,XMDF,XMDT,XMTEXT,XMY,XMYBLOB,XMV,XMDUZ
  1. S XMDUZ="PX ICE MANAGER"
  1. S XMB="PX ICE INTERFACE RESTORED"
  1. S XMTEXT="PXFDB"
  1. S PXFDB(1)="Connection to the Immunization Calculation Engine (ICE) has been restored!"
  1. S PXFDB(2)="The ICE immunization recommendations can now be utilized."
  1. S XMY("G.PXRM MANAGER")="" ;TODO: CHANGE
  1. D ^XMB
  1. Q
  1. ;
  1. ;
  1. CHKSTAT() ; Return ICE Status
  1. ; 0 - Disabled
  1. ; 1 - Enabled
  1. ; 0^1 - Enabled/Unavailable
  1. N PXSTATUS
  1. S PXSTATUS=$P($G(^PXV(920.76,1,0)),U,1)
  1. I PXSTATUS=2 S PXSTATUS="0^1"
  1. Q PXSTATUS
  1. ;
  1. ;
  1. TASKTST ; Tasked job to test ICE
  1. ;
  1. ; ZEXCEPT: PXFREQ,ZTQUEUED,ZTREQ
  1. N PXSUCCESS
  1. ;
  1. S ZTREQ="@"
  1. ;
  1. ; If ICE is enabled or disabled, quit.
  1. ; only check ICE availability when status=enabled/unavailable
  1. I $$CHKSTAT()'="0^1" Q
  1. ;
  1. S PXSUCCESS=$$TESTICE^PXVWICE()
  1. ;
  1. I PXSUCCESS D Q
  1. . D RESTORE
  1. ;
  1. S PXFREQ=$G(PXFREQ,15)
  1. I 'PXSUCCESS D
  1. . S ZTREQ=$$HADD^XLFDT($H,0,0,PXFREQ,0)
  1. ;
  1. Q
  1. ;
  1. ;
  1. UPDSTAT(PXSTATUS,PXDT,PXUSER) ;
  1. ;
  1. N PXFDA,PXIEN,PXIENS
  1. ;
  1. I $G(PXSTATUS)'?1(1"0",1"1",1"2") Q
  1. I '$G(PXDT) S PXDT=$$NOW^XLFDT()
  1. S PXUSER=$G(PXUSER)
  1. ;
  1. S PXIENS="1,"
  1. I '$D(^PXV(920.76,1,0)) D
  1. . S PXIENS="+1,"
  1. . S PXIEN(1)=1
  1. ;
  1. S PXFDA(920.76,PXIENS,.01)=PXSTATUS
  1. S PXIENS="+2,"_PXIENS
  1. S PXFDA(920.761,PXIENS,.01)=PXDT
  1. S PXFDA(920.761,PXIENS,.02)=PXUSER
  1. S PXFDA(920.761,PXIENS,.03)=PXSTATUS
  1. ;
  1. L +^PXV(920.76,1):DILOCKTM
  1. ; If interface is disabled, do not let the status be changed
  1. ; to enabled/unavailable
  1. I $P($G(^PXV(920.76,1,0)),U,1)=0,PXSTATUS=2 D Q
  1. . L -^PXV(920.76,1)
  1. D UPDATE^DIE("U","PXFDA","PXIEN")
  1. L -^PXV(920.76,1)
  1. ;
  1. Q
  1. ;
  1. ;
  1. ENCHGSTA ; Entry for a user to enable/disable the ICE interface
  1. ;
  1. N PXNEWSTAT,PXOLDSTAT,PXSUCCESS
  1. ;
  1. S PXOLDSTAT=$$CHKSTAT()
  1. I PXOLDSTAT="0^1" S PXOLDSTAT=2
  1. ;
  1. L +^PXV(920.76,1):DILOCKTM
  1. I '$T D Q
  1. . W !,"Another terminal is modifying this field!"
  1. ;
  1. S PXNEWSTAT=$$ASKCHNGE(PXOLDSTAT)
  1. ;
  1. I PXNEWSTAT'=-1,PXNEWSTAT'=PXOLDSTAT D UPDSTAT(PXNEWSTAT,$$NOW^XLFDT(),DUZ)
  1. ;
  1. I PXOLDSTAT=0,PXNEWSTAT=1 D
  1. . W !,"Please wait while we test the ICE interface..."
  1. . S PXSUCCESS=$$TESTICE^PXVWICE()
  1. . I PXSUCCESS W !!,"Connection to ICE was successful.",!!
  1. . I 'PXSUCCESS W !!,"Connection could not be made to ICE.",!!
  1. . H 1
  1. ;
  1. L -^PXV(920.76,1)
  1. ;
  1. Q
  1. ;
  1. ;
  1. ASKCHNGE(PXOLDSTAT) ; Ask the user if they want to enable/disable the ICE interface
  1. ;
  1. N DIR,DIRUT,PXNEWSTAT,Y
  1. ;
  1. S PXNEWSTAT=PXOLDSTAT
  1. ;
  1. ; Display old status
  1. W !!,"The connection to ICE is currently "_$S('PXOLDSTAT:"DISABLED",1:"ENABLED")_"."
  1. I PXOLDSTAT=2 W !,"However, the systems is currently having issues connecting to ICE."
  1. W !
  1. ;
  1. ; Ask if user wants to change status
  1. S DIR(0)="Y^A"
  1. S DIR("A")="Do you wish to "_$S('PXOLDSTAT:"ENABLE",1:"DISABLE")_" the interface to ICE"
  1. S DIR("B")=$S(PXOLDSTAT:"NO",1:"YES")
  1. S DIR("?")="Enter either 'Y' or 'N'. This will control if the interface to the Immunization Calculation Engine (ICE) is enabled or disabled."
  1. D ^DIR
  1. I $D(DIRUT)!('$G(Y)) Q -1
  1. ;
  1. ; Confirm
  1. K DIR,Y
  1. S DIR(0)="Y^A"
  1. S DIR("B")="NO"
  1. S DIR("A")="Are you sure you want to "_$S('PXOLDSTAT:"ENABLE",1:"DISABLE")_" the ICE interface"
  1. D ^DIR
  1. W !
  1. I $D(DIRUT)!('$G(Y)) Q -1
  1. ;
  1. S PXNEWSTAT='PXOLDSTAT
  1. ;
  1. Q PXNEWSTAT