BQICMRUN ;VNGT/HS/BEE - Care Management - Calculate Last Run Date ; 7 Apr 2009 10:35 AM
;;2.1;ICARE MANAGEMENT SYSTEM;;Feb 07, 2011
;
Q
;
EN(DATA,DFN,SOURCE) ; EP - BQI GET LAST CARE MGT RUN
;
; Input
; DFN - Patient Internal ID
; SOURCE - Lookup (either NAME or IEN) to File #90506.5
;
; Get the Care Manager Last Run Information
;
NEW UID,II,HDR,DA,NEDT,WEDT,LRDT,SEDT,SIEN
S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
S DATA=$NA(^TMP("BQICMRUN",UID))
K @DATA
;
S DFN=$G(DFN,""),SOURCE=$G(SOURCE,"")
;
S II=0
NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIGPRUN D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
;
S HDR="D00030LAST_RUN_DATETIME"
S @DATA@(II)=HDR_$C(30)
;
S DA=$O(^BQI(90508,0)) I 'DA G DONE
;
;Pull Nightly/Weekly Run Completion Times - Determine most recent
S NEDT=$$GET1^DIQ(90508,DA_",",3.23,"I")
S WEDT=$$GET1^DIQ(90508,DA_",",4.02,"I")
S LRDT=WEDT S:NEDT>LRDT LRDT=NEDT
;
;Handle Individual Patient/SOURCE, if provided
I DFN]"",SOURCE]"" D
.;
.;Check for valid iCare Patient
.I '$D(^BQIPAT(DFN)) Q
.;
.;Convert SOURCE to IEN if necessary
.I SOURCE'?1N.N S SOURCE=$O(^BQI(90506.5,"B",SOURCE,"")) Q:SOURCE'?1N.N
.;
.;Look up entry
.S SIEN=$O(^BQIPAT(DFN,60,"B",SOURCE,"")) Q:SIEN=""
.S SEDT=$$GET1^DIQ(90507.56,SIEN_","_DFN_",",".02","I")
.S:SEDT]"" LRDT=SEDT
;
;Convert to external date
S:LRDT]"" LRDT=$$FMTE^BQIUL1(LRDT)
;
S II=II+1,@DATA@(II)=LRDT_$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
BQICMRUN ;VNGT/HS/BEE - Care Management - Calculate Last Run Date ; 7 Apr 2009 10:35 AM
+1 ;;2.1;ICARE MANAGEMENT SYSTEM;;Feb 07, 2011
+2 ;
+3 QUIT
+4 ;
EN(DATA,DFN,SOURCE) ; EP - BQI GET LAST CARE MGT RUN
+1 ;
+2 ; Input
+3 ; DFN - Patient Internal ID
+4 ; SOURCE - Lookup (either NAME or IEN) to File #90506.5
+5 ;
+6 ; Get the Care Manager Last Run Information
+7 ;
+8 NEW UID,II,HDR,DA,NEDT,WEDT,LRDT,SEDT,SIEN
+9 SET UID=$SELECT($GET(ZTSK):"Z"_ZTSK,1:$JOB)
+10 SET DATA=$NAME(^TMP("BQICMRUN",UID))
+11 KILL @DATA
+12 ;
+13 SET DFN=$GET(DFN,"")
SET SOURCE=$GET(SOURCE,"")
+14 ;
+15 SET II=0
+16 ; SAC 2006 2.2.3.3.2
NEW $ESTACK,$ETRAP
SET $ETRAP="D ERR^BQIGPRUN D UNWIND^%ZTER"
+17 ;
+18 SET HDR="D00030LAST_RUN_DATETIME"
+19 SET @DATA@(II)=HDR_$CHAR(30)
+20 ;
+21 SET DA=$ORDER(^BQI(90508,0))
IF 'DA
GOTO DONE
+22 ;
+23 ;Pull Nightly/Weekly Run Completion Times - Determine most recent
+24 SET NEDT=$$GET1^DIQ(90508,DA_",",3.23,"I")
+25 SET WEDT=$$GET1^DIQ(90508,DA_",",4.02,"I")
+26 SET LRDT=WEDT
IF NEDT>LRDT
SET LRDT=NEDT
+27 ;
+28 ;Handle Individual Patient/SOURCE, if provided
+29 IF DFN]""
IF SOURCE]""
Begin DoDot:1
+30 ;
+31 ;Check for valid iCare Patient
+32 IF '$DATA(^BQIPAT(DFN))
QUIT
+33 ;
+34 ;Convert SOURCE to IEN if necessary
+35 IF SOURCE'?1N.N
SET SOURCE=$ORDER(^BQI(90506.5,"B",SOURCE,""))
IF SOURCE'?1N.N
QUIT
+36 ;
+37 ;Look up entry
+38 SET SIEN=$ORDER(^BQIPAT(DFN,60,"B",SOURCE,""))
IF SIEN=""
QUIT
+39 SET SEDT=$$GET1^DIQ(90507.56,SIEN_","_DFN_",",".02","I")
+40 IF SEDT]""
SET LRDT=SEDT
End DoDot:1
+41 ;
+42 ;Convert to external date
+43 IF LRDT]""
SET LRDT=$$FMTE^BQIUL1(LRDT)
+44 ;
+45 SET II=II+1
SET @DATA@(II)=LRDT_$CHAR(30)
+46 ;
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