GMRVORDG ;HIRMFO/RM-DGOERR EVENT DRIVER INTERFACE. ;4/2/96
;;4.0;Vitals/Measurements;**2**;Apr 25, 1997
EN4 ; ENTRY FROM DGPM MOVEMENT EVENTS PROTOCOL
G Q4:$G(DGPMA)=""!("^1^2^3^22^23^24^25^"[("^"_$P($G(DGPMA),"^",18)_"^")) S GMRVDGZN=$P($G(DGPMA),"^")_"^"_$P($G(DGPMA),"^",6),GMRVDGZN(0)=$P($G(DGPMP),"^")_"^"_$P($G(DGPMP),"^",6) G Q4:GMRVDGZN=GMRVDGZN(0)
S GMRVDGDT=$P($G(DGPMA),"^"),GMRVOE=$S("^1^3^4^5^"[("^"_$P($G(DGPMA),"^",2)_"^")&($P($G(DGPMA),"^",18)'=41):1,$P($G(DGPMA),"^",2)=2!($P($G(DGPMA),"^",18)=41):0,1:"") G:GMRVOE="" Q4
D DCALL:GMRVOE,DCHK:'GMRVOE
Q4 K GMRVDGZN,GMRVDGDT,GMRVOE D KVAR^VADPT
Q
DCALL ; DC ALL NON-DC'D ORDERS
S ORUPKG=$O(^ORD(100.98,"B","VITALS/MEASUREMENTS",0)) G Q4:'ORUPKG
S GMRVP=DFN_";DPT("
F GMRX=0:0 S GMRX=$O(^OR(100,"AO",GMRVP,GMRX)) Q:GMRX'>0 F GMRVORDA=0:0 S GMRVORDA=$O(^OR(100,"AO",GMRVP,GMRX,ORUPKG,GMRVORDA)) Q:GMRVORDA'>0 D DC
K GMRVORDA,GMRVP,GMRVSTAT,GMRVX,GMRVSTDT,ORIFN,ORUPKG
Q
DC ; CHANGE ORDER STATUS IF NECESSARY
K ORUPCHUK
D EN^ORX8(GMRVORDA)
S GMRVSTDT=+ORUPCHUK("ORSTRT"),GMRVSTAT=+ORUPCHUK("ORSTS")
K ORUPCHUK
Q:GMRVSTAT=1!(GMRVSTAT=2)!(GMRVSTDT>GMRVDGDT&(GMRVSTAT'=8)) S ORIFN=GMRVORDA
I GMRVSTAT'=8 D NOW^%DTC S ORETURN("ORSTS")=1,ORETURN("ORSTOP")=%,ORETURN("OREVENT")="" D:GMRVSTAT'=11 RETURN^ORX K %,%H,ORETURN
I GMRVSTAT=8 S ORSTS="K" D ST^ORX K ORSTS
Q
DCHK ; CHECK TO SEE IF ORDERS NEED TO BE DC'D
S GMRVSITE=$O(^GMRD(120.57,"B","HOSPITAL",0)),GMRVSITE(0)=$S($D(^GMRD(120.57,+GMRVSITE,0)):^(0),1:"") G QCHK:'$P(GMRVSITE(0),"^",3)&'$P(GMRVSITE(0),"^",4)
S X=GMRVDGDT D H^%DTC S %H=%H_","_(%T-1) D YMD^%DTC S VAINDT=X_$S(%:%,1:"")
D INP^VADPT S GMRVWRD(0)=VAIN(4) S VAINDT=GMRVDGDT D INP^VADPT S GMRVWRD(1)=VAIN(4)
I $P(GMRVSITE(0),"^",3),+GMRVWRD(0)'=+GMRVWRD(1) D DCALL G QCHK
I $P(GMRVSITE(0),"^",4) S GMRVSRV(0)=$S($D(^DIC(42,+GMRVWRD(0),0)):$P(^(0),"^",3),1:""),GMRVSRV(1)=$S($D(^DIC(42,+GMRVWRD(1),0)):$P(^(0),"^",3),1:"") I GMRVSRV(0)'=GMRVSRV(1) D DCALL
QCHK K GMRVSITE,GMRVWRD,GMRVSRV
Q
GMRVORDG ;HIRMFO/RM-DGOERR EVENT DRIVER INTERFACE. ;4/2/96
+1 ;;4.0;Vitals/Measurements;**2**;Apr 25, 1997
EN4 ; ENTRY FROM DGPM MOVEMENT EVENTS PROTOCOL
+1 IF $GET(DGPMA)=""!("^1^2^3^22^23^24^25^"[("^"_$PIECE($GET(DGPMA),"^",18)_"^"))
GOTO Q4
SET GMRVDGZN=$PIECE($GET(DGPMA),"^")_"^"_$PIECE($GET(DGPMA),"^",6)
SET GMRVDGZN(0)=$PIECE($GET(DGPMP),"^")_"^"_$PIECE($GET(DGPMP),"^",6)
IF GMRVDGZN=GMRVDGZN(0)
GOTO Q4
+2 SET GMRVDGDT=$PIECE($GET(DGPMA),"^")
SET GMRVOE=$SELECT("^1^3^4^5^"[("^"_$PIECE($GET(DGPMA),"^",2)_"^")&($PIECE($GET(DGPMA),"^",18)'=41):1,$PIECE($GET(DGPMA),"^",2)=2!($PIECE($GET(DGPMA),"^",18)=41):0,1:"")
IF GMRVOE=""
GOTO Q4
+3 IF GMRVOE
DO DCALL
IF 'GMRVOE
DO DCHK
Q4 KILL GMRVDGZN,GMRVDGDT,GMRVOE
DO KVAR^VADPT
+1 QUIT
DCALL ; DC ALL NON-DC'D ORDERS
+1 SET ORUPKG=$ORDER(^ORD(100.98,"B","VITALS/MEASUREMENTS",0))
IF 'ORUPKG
GOTO Q4
+2 SET GMRVP=DFN_";DPT("
+3 FOR GMRX=0:0
SET GMRX=$ORDER(^OR(100,"AO",GMRVP,GMRX))
IF GMRX'>0
QUIT
FOR GMRVORDA=0:0
SET GMRVORDA=$ORDER(^OR(100,"AO",GMRVP,GMRX,ORUPKG,GMRVORDA))
IF GMRVORDA'>0
QUIT
DO DC
+4 KILL GMRVORDA,GMRVP,GMRVSTAT,GMRVX,GMRVSTDT,ORIFN,ORUPKG
+5 QUIT
DC ; CHANGE ORDER STATUS IF NECESSARY
+1 KILL ORUPCHUK
+2 DO EN^ORX8(GMRVORDA)
+3 SET GMRVSTDT=+ORUPCHUK("ORSTRT")
SET GMRVSTAT=+ORUPCHUK("ORSTS")
+4 KILL ORUPCHUK
+5 IF GMRVSTAT=1!(GMRVSTAT=2)!(GMRVSTDT>GMRVDGDT&(GMRVSTAT'=8))
QUIT
SET ORIFN=GMRVORDA
+6 IF GMRVSTAT'=8
DO NOW^%DTC
SET ORETURN("ORSTS")=1
SET ORETURN("ORSTOP")=%
SET ORETURN("OREVENT")=""
IF GMRVSTAT'=11
DO RETURN^ORX
KILL %,%H,ORETURN
+7 IF GMRVSTAT=8
SET ORSTS="K"
DO ST^ORX
KILL ORSTS
+8 QUIT
DCHK ; CHECK TO SEE IF ORDERS NEED TO BE DC'D
+1 SET GMRVSITE=$ORDER(^GMRD(120.57,"B","HOSPITAL",0))
SET GMRVSITE(0)=$SELECT($DATA(^GMRD(120.57,+GMRVSITE,0)):^(0),1:"")
IF '$PIECE(GMRVSITE(0),"^",3)&'$PIECE(GMRVSITE(0),"^",4)
GOTO QCHK
+2 SET X=GMRVDGDT
DO H^%DTC
SET %H=%H_","_(%T-1)
DO YMD^%DTC
SET VAINDT=X_$SELECT(%:%,1:"")
+3 DO INP^VADPT
SET GMRVWRD(0)=VAIN(4)
SET VAINDT=GMRVDGDT
DO INP^VADPT
SET GMRVWRD(1)=VAIN(4)
+4 IF $PIECE(GMRVSITE(0),"^",3)
IF +GMRVWRD(0)'=+GMRVWRD(1)
DO DCALL
GOTO QCHK
+5 IF $PIECE(GMRVSITE(0),"^",4)
SET GMRVSRV(0)=$SELECT($DATA(^DIC(42,+GMRVWRD(0),0)):$PIECE(^(0),"^",3),1:"")
SET GMRVSRV(1)=$SELECT($DATA(^DIC(42,+GMRVWRD(1),0)):$PIECE(^(0),"^",3),1:"")
IF GMRVSRV(0)'=GMRVSRV(1)
DO DCALL
QCHK KILL GMRVSITE,GMRVWRD,GMRVSRV
+1 QUIT