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

BOPMTR.m

Go to the documentation of this file.
  1. BOPMTR ;IHS/ILC/ALG/CIA/PLS - ILC Job Monitor;16-Aug-2005 10:56;SM
  1. ;;1.0;AUTOMATED DISPENSING INTERFACE;**1**;Jul 26, 2005
  1. ;This routine should be started immediately when MUMPs is started
  1. ;Consider it to run in the Automatic partition startup at reboot.
  1. N V,X,Y,QFLG
  1. D INIT
  1. S BOPWHO=$$INTFACE^BOPTU(1)
  1. S BOPWHO=$S(BOPWHO="O":"Omnicell",1:"Pyxis")
  1. ;
  1. ;Stop the Monitor running / Schedule Monitor Task
  1. START G ENQUE2:'$P($G(^BOP(90355,1,4)),U) D ENQUE2
  1. ;
  1. CHECK ;Start a Listener/Sender pair for each Facility
  1. ;
  1. ;Make sure another monitor is not running and hold lock if not
  1. K BOPTOP L ^BOP(90355,"L","MONITOR"):1 E S BOPTOP=1 Q
  1. ;
  1. S BOPI=0 F S BOPI=$O(^BOP(90355,1,3,BOPI)) Q:BOPI<1 D
  1. .S BOPD0=$G(^BOP(90355,1,3,BOPI,0)) Q:'BOPD0 Q:'$P(BOPD0,U,2)
  1. .S (V,BOPDIV)=$P(BOPD0,U),BOPIP=$P(BOPD0,U,3)
  1. .S BOPOCK=$P(BOPD0,U,4),BOPLSOC=$P(BOPD0,U,5)
  1. .S BOPPCPU=$P(BOPD0,U,7)
  1. .L +^BOP(90355,"S",V):1 D QUESEND:$T L -^BOP(90355,"S",V)
  1. .;
  1. .L +^BOP(90355,"L",V):1 D QUEREC:$T L -^BOP(90355,"L",V)
  1. ;
  1. ;Check to see if HL-7 messages are being processed.
  1. L +^BOP(90355.1,"FILER"):1 E G CHQ
  1. ;
  1. ;Check queue for records that require processing - Start Task?
  1. ;Must be a "Filable" Transaction. $P(^BOP(90355.1,X,99),U)=1
  1. ;Transaction ready to process. $P(^BOP(90355.1,X,99),U,2)=0
  1. S (QFLG,X)=0 F S X=$O(^BOP(90355.1,"AC",0,X)) Q:'X!QFLG D
  1. .S Y=$G(^BOP(90355.1,X,99))
  1. .I Y,$P(Y,U)=1,'$P(Y,U,2) D QUEFILE S QFLG=1
  1. FQ ;
  1. L -^BOP(90355.1,"FILER")
  1. ;
  1. ;Start the BOP interface
  1. ;
  1. ; Quit if the STOP flag is set
  1. G CHQ:'$P($G(^BOP(90355,1,"IP-MCK")),U,2)
  1. ;
  1. ; Quit if not active
  1. G CHQ:$L($P($G(^BOP(90355,1,"IP-MCK")),U))=0
  1. ;
  1. ; Quit if the interface is already running -- Lock lock
  1. L +^BOP(90355,"IP-MCK"):3 E G CHQ
  1. ;
  1. ; Schedule the interface
  1. D QUEMCK
  1. ;
  1. ; Unlock the lock
  1. L -^BOP(90355,"IP-MCK")
  1. Q
  1. ;
  1. CHQ ;Set the Monitor Stop flag and quit
  1. S BOPTOP=+$G(^BOP(90355,1,12))
  1. I '$G(ZTQUEUED) W !!,"Background Monitor Queued."
  1. Q
  1. QUEFILE ;Schedule Transaction Filer
  1. S ZTRTN="GO^BOPRNEW1",ZTDESC=$G(BOPWHO)_" Interface Filer"
  1. G QUE
  1. QUESEND ;Schedule Transmit Tasks
  1. I 'BOPIP!'BOPOCK!'BOPIP G ERROR
  1. S ZTRTN="GO^BOPT1",ZTDESC=$G(BOPWHO)_" Queue Transmitter"
  1. F I="BOPDIV","BOPOCK","BOPIP" S ZTSAVE(I)=""
  1. G QUE
  1. QUEREC ;Schedule Standard Receiver
  1. I 'BOPLSOC!'BOPIP G ERROR
  1. S ZTRTN="GO^BOPRNEW",ZTDESC=$G(BOPWHO)_" TCP/IP HL-7 Receiver"
  1. S ZTSAVE("BOPDIV")="",ZTSAVE("BOPLSOC")="",ZTSAVE("BOPIP")=""
  1. G QUE
  1. QUEMCK ;Schedule the Interface
  1. S ZTRTN="GO^BOPRMC",ZTDESC=$G(BOPWHO)_" / BOP Interface Receiver"
  1. G QUE
  1. CHK(X) ;Do not schedule another task if one is already running
  1. N ZTSK S ZTSK=$P($G(^BOP(90355,1,4)),U,3)
  1. I 'ZTSK Q 0
  1. D STAT^%ZTLOAD I $G(ZTSK(0)),$G(ZTSK(1))=1 Q 1
  1. Q 0
  1. ENQUE ;BOP Start Monitor option (BOP MONITOR)
  1. Q:$$CHK() S $P(^BOP(90355,1,12),U,1)=0 D MON,QUE,DIE
  1. Q
  1. DIE Q:'$G(ZTSK) N DA,DIE,DR S DA=1,DIE=90355,DR="4.2///"_ZTSK D ^DIE
  1. Q
  1. QUE S ZTDTH=$$NOW^XLFDT
  1. QUEA S ZTIO="" D ^%ZTLOAD
  1. Q
  1. TASK ;For Monitor option
  1. D ENQUE
  1. W !!,"Task #"_$S($G(ZTSK):ZTSK,1:$P($G(^BOP(90355,1,4)),U,3))
  1. W " has been scheduled to start the Monitor."
  1. Q
  1. ENQUE2 ;Schedule task to run Monitor according to field 4.1, "Monitor
  1. ;Rescheduling Frequency", in file 90355, "BOP Site Parameters".
  1. Q:$$CHK() S X=$P($G(^BOP(90355,1,4)),U,2) ;Reschedule frequency in seconds
  1. S ZTDTH=$$FMADD^XLFDT($$NOW^XLFDT(),,,,X)
  1. S $P(^BOP(90355,1,12),U,1)=0 D MON,QUEA,DIE
  1. Q
  1. MON S ZTRTN="BOPMTR",ZTDESC="Start "_$G(BOPWHO)_" Monitor"
  1. Q
  1. ERROR ;Send message on error
  1. S XMSUB=$G(BOPWHO)_" Site Parameters Problem",XMY(.5)=""
  1. I $G(DUZ) S XMY(DUZ)=""
  1. S XMTEXT="X(",X(1)="Review BOP Site Parameters."
  1. S X(2)="The socket or IP address may be missing."
  1. S X(3)="There may not be a Division defined."
  1. D ^XMD
  1. Q
  1. JOBGO D INIT
  1. F D CHECK H 120 Q:'$P($G(^BOP(90355,1,4)),U)!$G(BOPTOP)
  1. Q
  1. ;The following tag is to be "jobbed" out manually if
  1. ;a site desires to start a monitor that runs all of the time.
  1. JOB N ZTIO,ZTDESC,ZTDTH,ZTRTN,ZTSAVE,ZTSK
  1. S ZTIO="",ZTDTH=$H,ZTRTN="JOBGO^BOPMTR",ZTDESC="BOP MONITOR"
  1. D ^%ZTLOAD
  1. Q
  1. INIT ;Initialize an environment
  1. D GETENV^%ZOSV S DIQUIET=1 D DT^DICRW
  1. Q