BQIRMREG ;PRXM/HC/ALA-Reminders by Register ; 30 Oct 2007 5:25 PM
;;2.4;ICARE MANAGEMENT SYSTEM;;Apr 01, 2015;Build 41
;
Q
;
EN(DATA,OWNR,PLIEN,REG,PLIST) ;EP -- BQI REGISTER REMIND BY PANEL
;Description - Entry point for the panel
;Input Parameters
; OWNR - Owner of panel
; PLIEN - Panel IEN
; REG - Register
; PLIST - List of DFNs (optional)
NEW UID,II,X,BQIRM,VAL,DFN,HIEN,E,J,K,L,MAX,MIN,NAFLG,STVWCD,RGIEN
NEW CODE,NCODE,RMIEN
S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
S DATA=$NA(^TMP("BQIRMPL",UID))
K @DATA
;
S II=0
NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIRMPL D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
;
I $G(REG)="" S BMXSEC="No register selected" Q
;
S RGIEN=$O(^BQI(90507,"B",REG,"")) I RGIEN="" S BMXSEC=REG_" register does not exist" Q
;
; If a list of DFNs, process them instead of entire panel
I $D(PLIST)>0 D G DONE
. I $D(PLIST)>1 D
.. S LIST="",BN=""
.. F S BN=$O(PLIST(BN)) Q:BN="" S LIST=LIST_PLIST(BN)
.. K PLIST S PLIST=LIST
. F BQI=1:1 S DFN=$P(PLIST,$C(28),BQI) Q:DFN="" D
.. I $P($G(^BQICARE(OWNR,1,PLIEN,40,DFN,0)),"^",2)="R" Q
.. D PAT(.DATA,OWNR,PLIEN,DFN)
;
S DFN=0
I $O(^BQICARE(OWNR,1,PLIEN,40,DFN))="" D PAT(.DATA,OWNR,PLIEN,"") G DONE
;
F S DFN=$O(^BQICARE(OWNR,1,PLIEN,40,DFN)) Q:'DFN D
. I $P($G(^BQICARE(OWNR,1,PLIEN,40,DFN,0)),"^",2)="R" Q
. D PAT(.DATA,OWNR,PLIEN,DFN)
;
DONE ;
I II=0,'$D(@DATA) D PAT(.DATA,OWNR,PLIEN,"")
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
;
PAT(DATA,OWNR,PLIEN,DFN) ;EP - Build record by patient
NEW GMET,GHDR
D STAND()
;
EXIT ;
Q
;
STAND() ;EP - Get standard display
NEW IEN,HDR,VALUE,HEADR,SENS,HDOB,Y,STVW,TEXT,ORD,KEY
S VALUE=""
I DFN'="" S Y=$$GET1^DIQ(9000001,DFN_",",1102.2,"I"),HDOB=$$FMTE^BQIUL1(Y)
I DFN'="" S VALUE=DFN_U_$$FLG^BTPWPPAT(DFN)_U_$$FLG^BQIULPT(DUZ,PLIEN,DFN)_U_$$SENS^BQIULPT(DFN)_U_$$CALR^BQIULPT(DFN)_U_$$MFLAG^BQIULPT(OWNR,PLIEN,DFN)_U_HDOB_U
S HEADR="I00010DFN^T00001TICKLER_INDICATOR^T00001FLAG_INDICATOR^T00001SENS_FLAG^T00001COMM_FLAG^T00001HIDE_MANUAL^D00030HIDE_DOB^"
S IEN=""
F S IEN=$O(^BQI(90506.1,"AC","D",IEN)) Q:IEN="" D
. I $$GET1^DIQ(90506.1,IEN_",",.1,"I")=1 Q
. I $$GET1^DIQ(90506.1,IEN_",",.04,"I")'="R" Q
. S KEY=$$GET1^DIQ(90506.1,IEN_",",3.1,"E")
. I KEY'="",'$$KEYCHK^BQIULSC(KEY,DUZ) Q
. S STVW=IEN
. D CVAL
. S VALUE=VALUE_VAL_"^"
. S HEADR=HEADR_HDR_"^"
;
S NCODE="REG_"_RGIEN,ORD=""
F S ORD=$O(^BQI(90507,RGIEN,15,"AC",ORD)) Q:ORD="" D
. S RMIEN=""
. F S RMIEN=$O(^BQI(90507,RGIEN,15,"AC",ORD,RMIEN)) Q:RMIEN="" D
.. S CODE=NCODE_"_"_RMIEN
.. S IEN=""
.. F S IEN=$O(^BQI(90506.1,"B",CODE,IEN)) Q:IEN="" D
... I $$GET1^DIQ(90506.1,IEN_",",.1,"I")=1 Q
... S KEY=$$GET1^DIQ(90506.1,IEN_",",3.1,"E")
... I KEY'="",'$$KEYCHK^BQIULSC(KEY,DUZ) Q
... S STVW=$P(^BQI(90506.1,IEN,0),U,1)
... S HDR=$$GET1^DIQ(90506.1,IEN_",",.08,"E")
... D RMVL
... I VAL="" S VAL="1/1/0001 12:01:00 AM"
... S VALUE=VALUE_VAL_"^"
... S HEADR=HEADR_HDR_"^"
S HEADR=$$TKO^BQIUL1(HEADR,"^")
S VALUE=$$TKO^BQIUL1(VALUE,"^")
;
I DFN="" S VALUE=""
;
I II=0 S @DATA@(II)=HEADR_$C(30)
I VALUE'="" S II=II+1,@DATA@(II)=VALUE_$C(30)
Q
;
CVAL ; Get demographic values
;Parameters
; FIL = FileMan file number
; FLD = FileMan field number
; EXEC = If an executable is needed to determine value
; HDR = Header value
;the executable expects the value to be returned in variable VAL
NEW FIL,FLD,EXEC
S FIL=$$GET1^DIQ(90506.1,STVW_",",.05,"E")
S FLD=$$GET1^DIQ(90506.1,STVW_",",.06,"E")
S EXEC=$$GET1^DIQ(90506.1,STVW_",",1,"E")
S HDR=$$GET1^DIQ(90506.1,STVW_",",.08,"E")
I $G(DFN)="" S VAL="" Q
;
I $G(EXEC)'="" X EXEC Q
;
I FIL'="",FLD'="" S VAL=$$GET1^DIQ(FIL,DFN_",",FLD,"E")
Q
;
RMVL ; Reminder value
NEW RDATA,CT,I,RIEN,REG,CMIEN,BQIDOD,DUE
S CMIEN=""
I DFN="" S VAL="",HDR="T00025"_STVW Q
; If patient is deceased
S BQIDOD=$$GET1^DIQ(2,DFN_",",.351,"I") I BQIDOD'="" S VAL="1/1/0001 12:00:00 AM" Q
; if patient has no reminders, then No Data Available (NDA)
I $O(^BQIPAT(DFN,40,0))="" S VAL="1/1/0001 12:00:00 AM" Q
S REG=$P(STVW,"_",2) I REG'="" D
. S CMIEN=$O(^BQI(90506.5,"D",REG,""))
; if patient does not meet denominator, then Not Applicable (N/A)
I CMIEN'="",'$$NRPC^BQICMDNM(DFN,CMIEN) S VAL="1/1/0001 12:01:00 AM" Q
; if patient has no data for this particular reminder, then Not Applicable (N/A)
S RIEN=$O(^BQIPAT(DFN,40,"B",STVW,"")) I RIEN="" S VAL="1/1/0001 12:01:00 AM" Q
S RDATA=$G(^BQIPAT(DFN,40,RIEN,0))
S CT=0
F I=2:1:4 S:$P(RDATA,U,I)'="" CT=CT+1
S HDR="T00025"_STVW
;I CT=0 S VAL="N/A" Q
I CT=0 S VAL="1/1/0001 12:01:00 AM" Q
S DUE=$P(RDATA,U,4)
I $P(RDATA,U,3)'="",DUE="" S DUE=DT
;I DUE>DT S VAL="F" Q
;S ODT=$$FMADD^XLFDT(DT,-30)
;I DUE<ODT S VAL="O" Q
;S VAL="C"
S VAL=$$FMTE^BQIUL1(DUE)
Q
BQIRMREG ;PRXM/HC/ALA-Reminders by Register ; 30 Oct 2007 5:25 PM
+1 ;;2.4;ICARE MANAGEMENT SYSTEM;;Apr 01, 2015;Build 41
+2 ;
+3 QUIT
+4 ;
EN(DATA,OWNR,PLIEN,REG,PLIST) ;EP -- BQI REGISTER REMIND BY PANEL
+1 ;Description - Entry point for the panel
+2 ;Input Parameters
+3 ; OWNR - Owner of panel
+4 ; PLIEN - Panel IEN
+5 ; REG - Register
+6 ; PLIST - List of DFNs (optional)
+7 NEW UID,II,X,BQIRM,VAL,DFN,HIEN,E,J,K,L,MAX,MIN,NAFLG,STVWCD,RGIEN
+8 NEW CODE,NCODE,RMIEN
+9 SET UID=$SELECT($GET(ZTSK):"Z"_ZTSK,1:$JOB)
+10 SET DATA=$NAME(^TMP("BQIRMPL",UID))
+11 KILL @DATA
+12 ;
+13 SET II=0
+14 ; SAC 2006 2.2.3.3.2
NEW $ESTACK,$ETRAP
SET $ETRAP="D ERR^BQIRMPL D UNWIND^%ZTER"
+15 ;
+16 IF $GET(REG)=""
SET BMXSEC="No register selected"
QUIT
+17 ;
+18 SET RGIEN=$ORDER(^BQI(90507,"B",REG,""))
IF RGIEN=""
SET BMXSEC=REG_" register does not exist"
QUIT
+19 ;
+20 ; If a list of DFNs, process them instead of entire panel
+21 IF $DATA(PLIST)>0
Begin DoDot:1
+22 IF $DATA(PLIST)>1
Begin DoDot:2
+23 SET LIST=""
SET BN=""
+24 FOR
SET BN=$ORDER(PLIST(BN))
IF BN=""
QUIT
SET LIST=LIST_PLIST(BN)
+25 KILL PLIST
SET PLIST=LIST
End DoDot:2
+26 FOR BQI=1:1
SET DFN=$PIECE(PLIST,$CHAR(28),BQI)
IF DFN=""
QUIT
Begin DoDot:2
+27 IF $PIECE($GET(^BQICARE(OWNR,1,PLIEN,40,DFN,0)),"^",2)="R"
QUIT
+28 DO PAT(.DATA,OWNR,PLIEN,DFN)
End DoDot:2
End DoDot:1
GOTO DONE
+29 ;
+30 SET DFN=0
+31 IF $ORDER(^BQICARE(OWNR,1,PLIEN,40,DFN))=""
DO PAT(.DATA,OWNR,PLIEN,"")
GOTO DONE
+32 ;
+33 FOR
SET DFN=$ORDER(^BQICARE(OWNR,1,PLIEN,40,DFN))
IF 'DFN
QUIT
Begin DoDot:1
+34 IF $PIECE($GET(^BQICARE(OWNR,1,PLIEN,40,DFN,0)),"^",2)="R"
QUIT
+35 DO PAT(.DATA,OWNR,PLIEN,DFN)
End DoDot:1
+36 ;
DONE ;
+1 IF II=0
IF '$DATA(@DATA)
DO PAT(.DATA,OWNR,PLIEN,"")
+2 SET II=II+1
SET @DATA@(II)=$CHAR(31)
+3 QUIT
+4 ;
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
+7 ;
PAT(DATA,OWNR,PLIEN,DFN) ;EP - Build record by patient
+1 NEW GMET,GHDR
+2 DO STAND()
+3 ;
EXIT ;
+1 QUIT
+2 ;
STAND() ;EP - Get standard display
+1 NEW IEN,HDR,VALUE,HEADR,SENS,HDOB,Y,STVW,TEXT,ORD,KEY
+2 SET VALUE=""
+3 IF DFN'=""
SET Y=$$GET1^DIQ(9000001,DFN_",",1102.2,"I")
SET HDOB=$$FMTE^BQIUL1(Y)
+4 IF DFN'=""
SET VALUE=DFN_U_$$FLG^BTPWPPAT(DFN)_U_$$FLG^BQIULPT(DUZ,PLIEN,DFN)_U_$$SENS^BQIULPT(DFN)_U_$$CALR^BQIULPT(DFN)_U_$$MFLAG^BQIULPT(OWNR,PLIEN,DFN)_U_HDOB_U
+5 SET HEADR="I00010DFN^T00001TICKLER_INDICATOR^T00001FLAG_INDICATOR^T00001SENS_FLAG^T00001COMM_FLAG^T00001HIDE_MANUAL^D00030HIDE_DOB^"
+6 SET IEN=""
+7 FOR
SET IEN=$ORDER(^BQI(90506.1,"AC","D",IEN))
IF IEN=""
QUIT
Begin DoDot:1
+8 IF $$GET1^DIQ(90506.1,IEN_",",.1,"I")=1
QUIT
+9 IF $$GET1^DIQ(90506.1,IEN_",",.04,"I")'="R"
QUIT
+10 SET KEY=$$GET1^DIQ(90506.1,IEN_",",3.1,"E")
+11 IF KEY'=""
IF '$$KEYCHK^BQIULSC(KEY,DUZ)
QUIT
+12 SET STVW=IEN
+13 DO CVAL
+14 SET VALUE=VALUE_VAL_"^"
+15 SET HEADR=HEADR_HDR_"^"
End DoDot:1
+16 ;
+17 SET NCODE="REG_"_RGIEN
SET ORD=""
+18 FOR
SET ORD=$ORDER(^BQI(90507,RGIEN,15,"AC",ORD))
IF ORD=""
QUIT
Begin DoDot:1
+19 SET RMIEN=""
+20 FOR
SET RMIEN=$ORDER(^BQI(90507,RGIEN,15,"AC",ORD,RMIEN))
IF RMIEN=""
QUIT
Begin DoDot:2
+21 SET CODE=NCODE_"_"_RMIEN
+22 SET IEN=""
+23 FOR
SET IEN=$ORDER(^BQI(90506.1,"B",CODE,IEN))
IF IEN=""
QUIT
Begin DoDot:3
+24 IF $$GET1^DIQ(90506.1,IEN_",",.1,"I")=1
QUIT
+25 SET KEY=$$GET1^DIQ(90506.1,IEN_",",3.1,"E")
+26 IF KEY'=""
IF '$$KEYCHK^BQIULSC(KEY,DUZ)
QUIT
+27 SET STVW=$PIECE(^BQI(90506.1,IEN,0),U,1)
+28 SET HDR=$$GET1^DIQ(90506.1,IEN_",",.08,"E")
+29 DO RMVL
+30 IF VAL=""
SET VAL="1/1/0001 12:01:00 AM"
+31 SET VALUE=VALUE_VAL_"^"
+32 SET HEADR=HEADR_HDR_"^"
End DoDot:3
End DoDot:2
End DoDot:1
+33 SET HEADR=$$TKO^BQIUL1(HEADR,"^")
+34 SET VALUE=$$TKO^BQIUL1(VALUE,"^")
+35 ;
+36 IF DFN=""
SET VALUE=""
+37 ;
+38 IF II=0
SET @DATA@(II)=HEADR_$CHAR(30)
+39 IF VALUE'=""
SET II=II+1
SET @DATA@(II)=VALUE_$CHAR(30)
+40 QUIT
+41 ;
CVAL ; Get demographic values
+1 ;Parameters
+2 ; FIL = FileMan file number
+3 ; FLD = FileMan field number
+4 ; EXEC = If an executable is needed to determine value
+5 ; HDR = Header value
+6 ;the executable expects the value to be returned in variable VAL
+7 NEW FIL,FLD,EXEC
+8 SET FIL=$$GET1^DIQ(90506.1,STVW_",",.05,"E")
+9 SET FLD=$$GET1^DIQ(90506.1,STVW_",",.06,"E")
+10 SET EXEC=$$GET1^DIQ(90506.1,STVW_",",1,"E")
+11 SET HDR=$$GET1^DIQ(90506.1,STVW_",",.08,"E")
+12 IF $GET(DFN)=""
SET VAL=""
QUIT
+13 ;
+14 IF $GET(EXEC)'=""
XECUTE EXEC
QUIT
+15 ;
+16 IF FIL'=""
IF FLD'=""
SET VAL=$$GET1^DIQ(FIL,DFN_",",FLD,"E")
+17 QUIT
+18 ;
RMVL ; Reminder value
+1 NEW RDATA,CT,I,RIEN,REG,CMIEN,BQIDOD,DUE
+2 SET CMIEN=""
+3 IF DFN=""
SET VAL=""
SET HDR="T00025"_STVW
QUIT
+4 ; If patient is deceased
+5 SET BQIDOD=$$GET1^DIQ(2,DFN_",",.351,"I")
IF BQIDOD'=""
SET VAL="1/1/0001 12:00:00 AM"
QUIT
+6 ; if patient has no reminders, then No Data Available (NDA)
+7 IF $ORDER(^BQIPAT(DFN,40,0))=""
SET VAL="1/1/0001 12:00:00 AM"
QUIT
+8 SET REG=$PIECE(STVW,"_",2)
IF REG'=""
Begin DoDot:1
+9 SET CMIEN=$ORDER(^BQI(90506.5,"D",REG,""))
End DoDot:1
+10 ; if patient does not meet denominator, then Not Applicable (N/A)
+11 IF CMIEN'=""
IF '$$NRPC^BQICMDNM(DFN,CMIEN)
SET VAL="1/1/0001 12:01:00 AM"
QUIT
+12 ; if patient has no data for this particular reminder, then Not Applicable (N/A)
+13 SET RIEN=$ORDER(^BQIPAT(DFN,40,"B",STVW,""))
IF RIEN=""
SET VAL="1/1/0001 12:01:00 AM"
QUIT
+14 SET RDATA=$GET(^BQIPAT(DFN,40,RIEN,0))
+15 SET CT=0
+16 FOR I=2:1:4
IF $PIECE(RDATA,U,I)'=""
SET CT=CT+1
+17 SET HDR="T00025"_STVW
+18 ;I CT=0 S VAL="N/A" Q
+19 IF CT=0
SET VAL="1/1/0001 12:01:00 AM"
QUIT
+20 SET DUE=$PIECE(RDATA,U,4)
+21 IF $PIECE(RDATA,U,3)'=""
IF DUE=""
SET DUE=DT
+22 ;I DUE>DT S VAL="F" Q
+23 ;S ODT=$$FMADD^XLFDT(DT,-30)
+24 ;I DUE<ODT S VAL="O" Q
+25 ;S VAL="C"
+26 SET VAL=$$FMTE^BQIUL1(DUE)
+27 QUIT