BQITRRUN ;VNGT/HS/ALA-Get last Treatment Prompt Run ; 08 Aug 2008 12:14 PM
;;2.1;ICARE MANAGEMENT SYSTEM;;Feb 07, 2011
;
Q
;
EN(DATA,BQIDFN) ; EP - BQI GET LAST TRMT RUN
;
; Input
; BQIDFN - Patient internal entry number
;
; Get the beginning and ending times of the Flag run
NEW UID,II,BDT,EDT,X,DA
S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
S DATA=$NA(^TMP("BQITRRUN",UID))
S BQIDFN=$G(BQIDFN,"")
K @DATA
;
S II=0
NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQITRRUN D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
;
S HDR="D00030LAST_UPDATE_DATETIME"
;S HDR="D00030LAST_NIGHT_RUN_START_DATETIME^D00030LAST_NIGHT_RUN_END_DATETIME^"
;S HDR=HDR_"D00030LAST_UPDATE_START_DATETIME^D00030LAST_UPDATE_END_DATETIME"
S @DATA@(II)=HDR_$C(30)
;
S DA=$O(^BQI(90508,0)) I 'DA G DONE
;
;S BDT=$$FMTE^BQIUL1($$GET1^DIQ(90508,DA_",",3.13,"I"))
;S EDT=$$FMTE^BQIUL1($$GET1^DIQ(90508,DA_",",3.14,"I"))
;S BUDT=$$FMTE^BQIUL1($$GET1^DIQ(90508,DA_",",4.1,"I"))
S BUEDT=$$FMTE^BQIUL1($$GET1^DIQ(90508,DA_",",4.11,"I"))
I BQIDFN="" S DTLCHK=BUEDT
I BQIDFN'="" D
. I $G(^BQIPAT(BQIDFN,0))="" S DTLCHK="" Q
. S DTLCHK=$S($P(^BQIPAT(BQIDFN,0),U,7)\1>(BUEDT\1):$P(^BQIPAT(BQIDFN,0),U,7),1:BUEDT)
S II=II+1,@DATA@(II)=$$FMTE^BQIUL1(DTLCHK)_$C(30)
;
DONE ;
S II=II+1,@DATA@(II)=$C(31)
Q
;
ERR ;
D ^%ZTER
NEW Y,ERRDTM
S Y=$$NOW^XLFDT() X ^DD("DD") S ERRDTM=Y
S BMXSEC="Recording that an error occurred at "_ERRDTM
I $D(II),$D(DATA) S II=II+1,@DATA@(II)=$C(31)
Q
BQITRRUN ;VNGT/HS/ALA-Get last Treatment Prompt Run ; 08 Aug 2008 12:14 PM
+1 ;;2.1;ICARE MANAGEMENT SYSTEM;;Feb 07, 2011
+2 ;
+3 QUIT
+4 ;
EN(DATA,BQIDFN) ; EP - BQI GET LAST TRMT RUN
+1 ;
+2 ; Input
+3 ; BQIDFN - Patient internal entry number
+4 ;
+5 ; Get the beginning and ending times of the Flag run
+6 NEW UID,II,BDT,EDT,X,DA
+7 SET UID=$SELECT($GET(ZTSK):"Z"_ZTSK,1:$JOB)
+8 SET DATA=$NAME(^TMP("BQITRRUN",UID))
+9 SET BQIDFN=$GET(BQIDFN,"")
+10 KILL @DATA
+11 ;
+12 SET II=0
+13 ; SAC 2006 2.2.3.3.2
NEW $ESTACK,$ETRAP
SET $ETRAP="D ERR^BQITRRUN D UNWIND^%ZTER"
+14 ;
+15 SET HDR="D00030LAST_UPDATE_DATETIME"
+16 ;S HDR="D00030LAST_NIGHT_RUN_START_DATETIME^D00030LAST_NIGHT_RUN_END_DATETIME^"
+17 ;S HDR=HDR_"D00030LAST_UPDATE_START_DATETIME^D00030LAST_UPDATE_END_DATETIME"
+18 SET @DATA@(II)=HDR_$CHAR(30)
+19 ;
+20 SET DA=$ORDER(^BQI(90508,0))
IF 'DA
GOTO DONE
+21 ;
+22 ;S BDT=$$FMTE^BQIUL1($$GET1^DIQ(90508,DA_",",3.13,"I"))
+23 ;S EDT=$$FMTE^BQIUL1($$GET1^DIQ(90508,DA_",",3.14,"I"))
+24 ;S BUDT=$$FMTE^BQIUL1($$GET1^DIQ(90508,DA_",",4.1,"I"))
+25 SET BUEDT=$$FMTE^BQIUL1($$GET1^DIQ(90508,DA_",",4.11,"I"))
+26 IF BQIDFN=""
SET DTLCHK=BUEDT
+27 IF BQIDFN'=""
Begin DoDot:1
+28 IF $GET(^BQIPAT(BQIDFN,0))=""
SET DTLCHK=""
QUIT
+29 SET DTLCHK=$SELECT($PIECE(^BQIPAT(BQIDFN,0),U,7)\1>(BUEDT\1):$PIECE(^BQIPAT(BQIDFN,0),U,7),1:BUEDT)
End DoDot:1
+30 SET II=II+1
SET @DATA@(II)=$$FMTE^BQIUL1(DTLCHK)_$CHAR(30)
+31 ;
DONE ;
+1 SET II=II+1
SET @DATA@(II)=$CHAR(31)
+2 QUIT
+3 ;
ERR ;
+1 DO ^%ZTER
+2 NEW Y,ERRDTM
+3 SET Y=$$NOW^XLFDT()
XECUTE ^DD("DD")
SET ERRDTM=Y
+4 SET BMXSEC="Recording that an error occurred at "_ERRDTM
+5 IF $DATA(II)
IF $DATA(DATA)
SET II=II+1
SET @DATA@(II)=$CHAR(31)
+6 QUIT