BQIGPPL ;VNGT/HS/ALA-GPRA by Panel ; 10 Jul 2009 1:30 PM
;;2.6;ICARE MANAGEMENT SYSTEM;;Jul 07, 2017;Build 72
;
Q
;
PNL(DATA,OWNR,PLIEN,PLIST) ;EP - BQI GET GPRA RESULTS BY PANEL
;Description - Entry point for the panel
;Input Parameters
; OWNR - Owner of panel
; PLIEN - Panel IEN
; PLIST - List of DFNs (optional)
NEW UID,II,X,PGIEN,STVWCD,VALUE,HEADR,BQIYR,BQIH,BQIY,DFN,NAFLG,QFL,TQFL
S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
S DATA=$NA(^TMP("BQIGPPL",UID))
K @DATA
;
S II=0
NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIGPPL D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
;
; get the current GPRA year for this panel
NEW DA,IENS
S DA(1)=OWNR,DA=PLIEN,IENS=$$IENS^DILF(.DA)
S BQIYR=$$GET1^DIQ(90505.01,IENS,3.3,"E")
S BQIH=$$SPM^BQIGPUTL()
I BQIYR="" S BQIYR=$$GET1^DIQ(90508,BQIH_",",2,"E")
S BQIY=$$LKP^BQIGPUTL(BQIYR)
; get the global references for the corresponding CRS year
D GFN^BQIGPUTL(BQIH,BQIY)
S CTYP="G"
;
; 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 ;
; If no data was found, generate the header
;I II=0,'$D(@DATA) D DEF S @DATA@(II)=$$TKO^BQIUL1(HEADR,"^")_$C(30)
I II=0,$G(@DATA@(II))="" D PAT(.DATA,OWNR,PLIEN,"")
S II=II+1,@DATA@(II)=$C(31)
Q
;
PAT(DATA,OWNR,PLIEN,DFN) ;EP - Build record by patient
NEW IEN,HDR,DORD,HDOB,Y,VAL,BQIH,BQIYR
S VALUE=""
I $G(BQIH)="" S BQIH=$$SPM^BQIGPUTL()
I $G(BQIYR)="" S BQIYR=$$GET1^DIQ(90508,BQIH_",",2,"E")
I DFN'="" S Y=$$GET1^DIQ(9000001,DFN_",",1102.2,"I"),HDOB=$$FMTE^BQIUL1(Y)
I DFN'="" S VALUE=DFN_"^"_$$FLG^BTPWPPAT(DFN)_U_$$FLG^BQIULPT(DUZ,PLIEN,DFN)_"^"_$$SENS^BQIULPT(DFN)_"^"_$$CALR^BQIULPT(DFN)_"^"_$$MFLAG^BQIULPT(OWNR,PLIEN,DFN)_"^"_HDOB_"^"_BQIYR_"^"
S HEADR="I00010DFN^T00001TICKLER_INDICATOR^T00001FLAG_INDICATOR^T00001SENS_FLAG^T00001COMM_FLAG^T00001HIDE_MANUAL^D00030HIDE_DOB^T00004HIDE_YEAR^"
;
; Check for template
NEW DA,IENS,TEMPL,LYIEN,QFL
S TEMPL=""
I OWNR'=DUZ D
. S DA=$O(^BQICARE(OWNR,1,PLIEN,30,DUZ,4,"C",CTYP,""))
. I DA="" Q
. S DA(3)=OWNR,DA(2)=PLIEN,DA(1)=DUZ,IENS=$$IENS^DILF(.DA)
. S TEMPL=$$GET1^DIQ(90505.34,IENS,.01,"E")
I OWNR=DUZ D
. S DA=$O(^BQICARE(OWNR,1,PLIEN,4,"C",CTYP,""))
. I DA="" Q
. S DA(2)=OWNR,DA(1)=PLIEN,IENS=$$IENS^DILF(.DA)
. S TEMPL=$$GET1^DIQ(90505.14,IENS,.01,"E")
;
; If template, use it
I TEMPL'="" S TQFL=0 D G FIN:'TQFL
. ;S LYIEN=$$DEF^BQILYUTL(OWNR,"M")
. S LYIEN=$$TPN^BQILYUTL(DUZ,TEMPL)
. I LYIEN="" S TQFL=1 Q
. S DOR=""
. F S DOR=$O(^BQICARE(DUZ,15,LYIEN,1,"C",DOR)) Q:DOR="" D
.. S IEN=""
.. F S IEN=$O(^BQICARE(DUZ,15,LYIEN,1,"C",DOR,IEN)) Q:IEN="" D
... S CODE=$P(^BQICARE(DUZ,15,LYIEN,1,IEN,0),U,1),STVWCD=CODE
... S GIEN=$O(^BQI(90506.1,"B",CODE,"")) I GIEN="" Q
... S STVW=GIEN
... I $P($G(^BQI(90506.1,GIEN,0)),U,10)=1 Q
... I $$GET1^DIQ(90506.1,GIEN_",",3.01,"E")="Patient" S STVW=GIEN D CVAL
... I $$GET1^DIQ(90506.1,GIEN_",",3.01,"E")="Performance" S STVW=STVWCD D GVAL
... S VALUE=VALUE_VAL_"^"
... S HEADR=HEADR_HDR_"^"
;
; If no template, check for customized
I OWNR=DUZ D
. S IEN=0,CIEN=$O(^BQICARE(OWNR,1,PLIEN,25,IEN))
. I CIEN'="" D
.. F S IEN=$O(^BQICARE(OWNR,1,PLIEN,25,IEN)) Q:'IEN D
... S CODE=$P(^BQICARE(OWNR,1,PLIEN,25,IEN,0),"^",1),STVWCD=CODE
... S SIEN=$O(^BQI(90506.1,"B",CODE,"")) I SIEN="" Q
... S STVW=SIEN
... I $P($G(^BQI(90506.1,SIEN,0)),U,10)=1 Q
... I $$GET1^DIQ(90506.1,SIEN_",",3.01,"E")="Patient" S STVW=SIEN D CVAL
... I $$GET1^DIQ(90506.1,SIEN_",",3.01,"E")="Performance" S STVW=STVWCD D GVAL
... S VALUE=VALUE_VAL_"^"
... S HEADR=HEADR_HDR_"^"
. ;
. ; If no customized found, use default
. I CIEN="" D DEF
;
I OWNR'=DUZ D
. S IEN=0,CIEN=$O(^BQICARE(OWNR,1,PLIEN,30,DUZ,25,IEN))
. I CIEN'="" D
.. F S IEN=$O(^BQICARE(OWNR,1,PLIEN,30,DUZ,25,IEN)) Q:'IEN D
... S CODE=$P(^BQICARE(OWNR,1,PLIEN,30,DUZ,25,IEN,0),"^",1),STVWCD=CODE
... S SIEN=$O(^BQI(90506.1,"B",CODE,"")) I SIEN="" Q
... I $P($G(^BQI(90506.1,SIEN,0)),U,10)=1 Q
... I $$GET1^DIQ(90506.1,SIEN_",",3.01,"E")="Patient" S STVW=SIEN D CVAL
... I $$GET1^DIQ(90506.1,SIEN_",",3.01,"E")="Performance" S STVW=STVWCD D GVAL
... S VALUE=VALUE_VAL_"^"
... S HEADR=HEADR_HDR_"^"
. ;
. ; If no customized found, use default
. I CIEN="" D DEF
;
FIN ; Finish
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'="",$P($G(@DATA@(II)),$C(30),1)'=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
;
GVAL ;EP - Get GPRA value for patient
NEW PIEN,DEN,NUM,SPVW,SPIEN,VER,BQIDOD
I $G(BQIMEASF)="" D INP^BQINIGHT
I $G(DFN)="" S VAL="",HDR="T00003"_STVW,GMET="" Q
S BQIDOD=$$GET1^DIQ(2,DFN_",",.351,"I") ; Is patient deceased?
S PIEN=$O(^BQIPAT(DFN,30,"B",STVW,""))
I PIEN="" S VAL=$S(BQIDOD'="":"{D}",1:"NDA"),HDR="T00003"_STVW,GMET="" Q
;
I $G(BQIH)="" S BQIH=$$SPM^BQIGPUTL()
I $G(BQIYR)="" S BQIYR=$$GET1^DIQ(90508,BQIH_",",2,"E")
S BQIY=$$LKP^BQIGPUTL(BQIYR)
;
S VER=$$VERSION^XPDUTL("BGP")
S SPVW=$P(STVW,"_",2),NAFLG=0
I VER<8.0 D
. S SPIEN=$O(^BQI(90508,BQIH,20,BQIY,20,"B",SPVW,"")) I SPIEN="" Q
. S NAFLG=+$P(^BQI(90508,BQIH,20,BQIY,20,SPIEN,0),"^",4)
;
I VER>7.0 D
. S NAFLG=$$GET1^DIQ(BQIMEASF,SPVW_",",1704,"I")
. S NAFLG=$S(NAFLG="Y":1,1:0)
;
S DEN=$P(^BQIPAT(DFN,30,PIEN,0),U,4)
S NUM=+$P(^BQIPAT(DFN,30,PIEN,0),U,3)
;
I DEN="" D
. I NAFLG'=1 S VAL="N/A" Q
. I 'NUM S VAL=0,GMET=0 Q
. S VAL=NUM
I DEN D
. I 'NUM S VAL="NO",GMET=0 Q
. S VAL="YES"
S HDR="T00003"_STVW
I BQIDOD'="" S VAL="{D}"
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
;
DEF ; Default list of fields
S IEN=0
F S IEN=$O(^BQI(90506.1,"AC","D",IEN)) Q:IEN="" D
. S STVW=IEN
. I $P($G(^BQI(90506.1,IEN,0)),U,10)=1 Q
. ; For a standard display, only display the 'R'equired fields.
. I $$GET1^DIQ(90506.1,STVW_",",3.04,"I")'="O" D
.. D CVAL
.. S VALUE=$G(VALUE)_VAL_"^"
.. S HEADR=$G(HEADR)_HDR_"^"
;
I $G(BQIMEASF)="" D INP^BQINIGHT
S IEN=0
F S IEN=$O(^BQI(90506.1,"AC","G",IEN)) Q:IEN="" D
. S STVW=$P(^BQI(90506.1,IEN,0),U,1)
. I $P(STVW,"_",1)'=BQIYR Q
. I $P(^BQI(90506.1,IEN,0),U,10)=1 Q
. S GIEN=$P(STVW,"_",2)
. S VER=$$VERSION^XPDUTL("BGP")
. I $P($G(^BQI(90506.1,IEN,0)),U,10)=1 Q
. I $$GET1^DIQ(90506.1,IEN_",",3.04,"I")'="O" D
.. I VER<8.0 D
... S PGIEN=$O(^BQI(90508,BQIH,20,BQIY,20,"B",GIEN,"")) I PGIEN="" Q
... S NAFLG=+$P(^BQI(90508,BQIH,20,BQIY,20,PGIEN,0),U,4)
.. I VER>7.0 D
... S NAFLG=$$GET1^DIQ(BQIMEASF,GIEN_",",1704,"I")
... S NAFLG=$S(NAFLG="Y":1,1:0)
.. D GVAL
.. S VALUE=VALUE_VAL_"^"
.. S HEADR=HEADR_HDR_"^"
Q
BQIGPPL ;VNGT/HS/ALA-GPRA by Panel ; 10 Jul 2009 1:30 PM
+1 ;;2.6;ICARE MANAGEMENT SYSTEM;;Jul 07, 2017;Build 72
+2 ;
+3 QUIT
+4 ;
PNL(DATA,OWNR,PLIEN,PLIST) ;EP - BQI GET GPRA RESULTS BY PANEL
+1 ;Description - Entry point for the panel
+2 ;Input Parameters
+3 ; OWNR - Owner of panel
+4 ; PLIEN - Panel IEN
+5 ; PLIST - List of DFNs (optional)
+6 NEW UID,II,X,PGIEN,STVWCD,VALUE,HEADR,BQIYR,BQIH,BQIY,DFN,NAFLG,QFL,TQFL
+7 SET UID=$SELECT($GET(ZTSK):"Z"_ZTSK,1:$JOB)
+8 SET DATA=$NAME(^TMP("BQIGPPL",UID))
+9 KILL @DATA
+10 ;
+11 SET II=0
+12 ; SAC 2006 2.2.3.3.2
NEW $ESTACK,$ETRAP
SET $ETRAP="D ERR^BQIGPPL D UNWIND^%ZTER"
+13 ;
+14 ; get the current GPRA year for this panel
+15 NEW DA,IENS
+16 SET DA(1)=OWNR
SET DA=PLIEN
SET IENS=$$IENS^DILF(.DA)
+17 SET BQIYR=$$GET1^DIQ(90505.01,IENS,3.3,"E")
+18 SET BQIH=$$SPM^BQIGPUTL()
+19 IF BQIYR=""
SET BQIYR=$$GET1^DIQ(90508,BQIH_",",2,"E")
+20 SET BQIY=$$LKP^BQIGPUTL(BQIYR)
+21 ; get the global references for the corresponding CRS year
+22 DO GFN^BQIGPUTL(BQIH,BQIY)
+23 SET CTYP="G"
+24 ;
+25 ; If a list of DFNs, process them instead of entire panel
+26 IF $DATA(PLIST)>0
Begin DoDot:1
+27 IF $DATA(PLIST)>1
Begin DoDot:2
+28 SET LIST=""
SET BN=""
+29 FOR
SET BN=$ORDER(PLIST(BN))
IF BN=""
QUIT
SET LIST=LIST_PLIST(BN)
+30 KILL PLIST
SET PLIST=LIST
End DoDot:2
+31 FOR BQI=1:1
SET DFN=$PIECE(PLIST,$CHAR(28),BQI)
IF DFN=""
QUIT
Begin DoDot:2
+32 IF $PIECE($GET(^BQICARE(OWNR,1,PLIEN,40,DFN,0)),"^",2)="R"
QUIT
+33 DO PAT(.DATA,OWNR,PLIEN,DFN)
End DoDot:2
End DoDot:1
GOTO DONE
+34 ;
+35 SET DFN=0
+36 IF $ORDER(^BQICARE(OWNR,1,PLIEN,40,DFN))=""
DO PAT(.DATA,OWNR,PLIEN,"")
GOTO DONE
+37 ;
+38 FOR
SET DFN=$ORDER(^BQICARE(OWNR,1,PLIEN,40,DFN))
IF 'DFN
QUIT
Begin DoDot:1
+39 IF $PIECE($GET(^BQICARE(OWNR,1,PLIEN,40,DFN,0)),"^",2)="R"
QUIT
+40 DO PAT(.DATA,OWNR,PLIEN,DFN)
End DoDot:1
+41 ;
DONE ;
+1 ; If no data was found, generate the header
+2 ;I II=0,'$D(@DATA) D DEF S @DATA@(II)=$$TKO^BQIUL1(HEADR,"^")_$C(30)
+3 IF II=0
IF $GET(@DATA@(II))=""
DO PAT(.DATA,OWNR,PLIEN,"")
+4 SET II=II+1
SET @DATA@(II)=$CHAR(31)
+5 QUIT
+6 ;
PAT(DATA,OWNR,PLIEN,DFN) ;EP - Build record by patient
+1 NEW IEN,HDR,DORD,HDOB,Y,VAL,BQIH,BQIYR
+2 SET VALUE=""
+3 IF $GET(BQIH)=""
SET BQIH=$$SPM^BQIGPUTL()
+4 IF $GET(BQIYR)=""
SET BQIYR=$$GET1^DIQ(90508,BQIH_",",2,"E")
+5 IF DFN'=""
SET Y=$$GET1^DIQ(9000001,DFN_",",1102.2,"I")
SET HDOB=$$FMTE^BQIUL1(Y)
+6 IF DFN'=""
SET VALUE=DFN_"^"_$$FLG^BTPWPPAT(DFN)_U_$$FLG^BQIULPT(DUZ,PLIEN,DFN)_"^"_$$SENS^BQIULPT(DFN)_"^"_$$CALR^BQIULPT(DFN)_"^"_$$MFLAG^BQIULPT(OWNR,PLIEN,DFN)_"^"_HDOB_"^"_BQIYR_"^"
+7 SET HEADR="I00010DFN^T00001TICKLER_INDICATOR^T00001FLAG_INDICATOR^T00001SENS_FLAG^T00001COMM_FLAG^T00001HIDE_MANUAL^D00030HIDE_DOB^T00004HIDE_YEAR^"
+8 ;
+9 ; Check for template
+10 NEW DA,IENS,TEMPL,LYIEN,QFL
+11 SET TEMPL=""
+12 IF OWNR'=DUZ
Begin DoDot:1
+13 SET DA=$ORDER(^BQICARE(OWNR,1,PLIEN,30,DUZ,4,"C",CTYP,""))
+14 IF DA=""
QUIT
+15 SET DA(3)=OWNR
SET DA(2)=PLIEN
SET DA(1)=DUZ
SET IENS=$$IENS^DILF(.DA)
+16 SET TEMPL=$$GET1^DIQ(90505.34,IENS,.01,"E")
End DoDot:1
+17 IF OWNR=DUZ
Begin DoDot:1
+18 SET DA=$ORDER(^BQICARE(OWNR,1,PLIEN,4,"C",CTYP,""))
+19 IF DA=""
QUIT
+20 SET DA(2)=OWNR
SET DA(1)=PLIEN
SET IENS=$$IENS^DILF(.DA)
+21 SET TEMPL=$$GET1^DIQ(90505.14,IENS,.01,"E")
End DoDot:1
+22 ;
+23 ; If template, use it
+24 IF TEMPL'=""
SET TQFL=0
Begin DoDot:1
+25 ;S LYIEN=$$DEF^BQILYUTL(OWNR,"M")
+26 SET LYIEN=$$TPN^BQILYUTL(DUZ,TEMPL)
+27 IF LYIEN=""
SET TQFL=1
QUIT
+28 SET DOR=""
+29 FOR
SET DOR=$ORDER(^BQICARE(DUZ,15,LYIEN,1,"C",DOR))
IF DOR=""
QUIT
Begin DoDot:2
+30 SET IEN=""
+31 FOR
SET IEN=$ORDER(^BQICARE(DUZ,15,LYIEN,1,"C",DOR,IEN))
IF IEN=""
QUIT
Begin DoDot:3
+32 SET CODE=$PIECE(^BQICARE(DUZ,15,LYIEN,1,IEN,0),U,1)
SET STVWCD=CODE
+33 SET GIEN=$ORDER(^BQI(90506.1,"B",CODE,""))
IF GIEN=""
QUIT
+34 SET STVW=GIEN
+35 IF $PIECE($GET(^BQI(90506.1,GIEN,0)),U,10)=1
QUIT
+36 IF $$GET1^DIQ(90506.1,GIEN_",",3.01,"E")="Patient"
SET STVW=GIEN
DO CVAL
+37 IF $$GET1^DIQ(90506.1,GIEN_",",3.01,"E")="Performance"
SET STVW=STVWCD
DO GVAL
+38 SET VALUE=VALUE_VAL_"^"
+39 SET HEADR=HEADR_HDR_"^"
End DoDot:3
End DoDot:2
End DoDot:1
IF 'TQFL
GOTO FIN
+40 ;
+41 ; If no template, check for customized
+42 IF OWNR=DUZ
Begin DoDot:1
+43 SET IEN=0
SET CIEN=$ORDER(^BQICARE(OWNR,1,PLIEN,25,IEN))
+44 IF CIEN'=""
Begin DoDot:2
+45 FOR
SET IEN=$ORDER(^BQICARE(OWNR,1,PLIEN,25,IEN))
IF 'IEN
QUIT
Begin DoDot:3
+46 SET CODE=$PIECE(^BQICARE(OWNR,1,PLIEN,25,IEN,0),"^",1)
SET STVWCD=CODE
+47 SET SIEN=$ORDER(^BQI(90506.1,"B",CODE,""))
IF SIEN=""
QUIT
+48 SET STVW=SIEN
+49 IF $PIECE($GET(^BQI(90506.1,SIEN,0)),U,10)=1
QUIT
+50 IF $$GET1^DIQ(90506.1,SIEN_",",3.01,"E")="Patient"
SET STVW=SIEN
DO CVAL
+51 IF $$GET1^DIQ(90506.1,SIEN_",",3.01,"E")="Performance"
SET STVW=STVWCD
DO GVAL
+52 SET VALUE=VALUE_VAL_"^"
+53 SET HEADR=HEADR_HDR_"^"
End DoDot:3
End DoDot:2
+54 ;
+55 ; If no customized found, use default
+56 IF CIEN=""
DO DEF
End DoDot:1
+57 ;
+58 IF OWNR'=DUZ
Begin DoDot:1
+59 SET IEN=0
SET CIEN=$ORDER(^BQICARE(OWNR,1,PLIEN,30,DUZ,25,IEN))
+60 IF CIEN'=""
Begin DoDot:2
+61 FOR
SET IEN=$ORDER(^BQICARE(OWNR,1,PLIEN,30,DUZ,25,IEN))
IF 'IEN
QUIT
Begin DoDot:3
+62 SET CODE=$PIECE(^BQICARE(OWNR,1,PLIEN,30,DUZ,25,IEN,0),"^",1)
SET STVWCD=CODE
+63 SET SIEN=$ORDER(^BQI(90506.1,"B",CODE,""))
IF SIEN=""
QUIT
+64 IF $PIECE($GET(^BQI(90506.1,SIEN,0)),U,10)=1
QUIT
+65 IF $$GET1^DIQ(90506.1,SIEN_",",3.01,"E")="Patient"
SET STVW=SIEN
DO CVAL
+66 IF $$GET1^DIQ(90506.1,SIEN_",",3.01,"E")="Performance"
SET STVW=STVWCD
DO GVAL
+67 SET VALUE=VALUE_VAL_"^"
+68 SET HEADR=HEADR_HDR_"^"
End DoDot:3
End DoDot:2
+69 ;
+70 ; If no customized found, use default
+71 IF CIEN=""
DO DEF
End DoDot:1
+72 ;
FIN ; Finish
+1 SET HEADR=$$TKO^BQIUL1(HEADR,"^")
+2 SET VALUE=$$TKO^BQIUL1(VALUE,"^")
+3 ;
+4 IF DFN=""
SET VALUE=""
+5 ;
+6 IF II=0
SET @DATA@(II)=HEADR_$CHAR(30)
+7 IF VALUE'=""
IF $PIECE($GET(@DATA@(II)),$CHAR(30),1)'=VALUE
SET II=II+1
SET @DATA@(II)=VALUE_$CHAR(30)
+8 QUIT
+9 ;
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 ;
GVAL ;EP - Get GPRA value for patient
+1 NEW PIEN,DEN,NUM,SPVW,SPIEN,VER,BQIDOD
+2 IF $GET(BQIMEASF)=""
DO INP^BQINIGHT
+3 IF $GET(DFN)=""
SET VAL=""
SET HDR="T00003"_STVW
SET GMET=""
QUIT
+4 ; Is patient deceased?
SET BQIDOD=$$GET1^DIQ(2,DFN_",",.351,"I")
+5 SET PIEN=$ORDER(^BQIPAT(DFN,30,"B",STVW,""))
+6 IF PIEN=""
SET VAL=$SELECT(BQIDOD'="":"{D}",1:"NDA")
SET HDR="T00003"_STVW
SET GMET=""
QUIT
+7 ;
+8 IF $GET(BQIH)=""
SET BQIH=$$SPM^BQIGPUTL()
+9 IF $GET(BQIYR)=""
SET BQIYR=$$GET1^DIQ(90508,BQIH_",",2,"E")
+10 SET BQIY=$$LKP^BQIGPUTL(BQIYR)
+11 ;
+12 SET VER=$$VERSION^XPDUTL("BGP")
+13 SET SPVW=$PIECE(STVW,"_",2)
SET NAFLG=0
+14 IF VER<8.0
Begin DoDot:1
+15 SET SPIEN=$ORDER(^BQI(90508,BQIH,20,BQIY,20,"B",SPVW,""))
IF SPIEN=""
QUIT
+16 SET NAFLG=+$PIECE(^BQI(90508,BQIH,20,BQIY,20,SPIEN,0),"^",4)
End DoDot:1
+17 ;
+18 IF VER>7.0
Begin DoDot:1
+19 SET NAFLG=$$GET1^DIQ(BQIMEASF,SPVW_",",1704,"I")
+20 SET NAFLG=$SELECT(NAFLG="Y":1,1:0)
End DoDot:1
+21 ;
+22 SET DEN=$PIECE(^BQIPAT(DFN,30,PIEN,0),U,4)
+23 SET NUM=+$PIECE(^BQIPAT(DFN,30,PIEN,0),U,3)
+24 ;
+25 IF DEN=""
Begin DoDot:1
+26 IF NAFLG'=1
SET VAL="N/A"
QUIT
+27 IF 'NUM
SET VAL=0
SET GMET=0
QUIT
+28 SET VAL=NUM
End DoDot:1
+29 IF DEN
Begin DoDot:1
+30 IF 'NUM
SET VAL="NO"
SET GMET=0
QUIT
+31 SET VAL="YES"
End DoDot:1
+32 SET HDR="T00003"_STVW
+33 IF BQIDOD'=""
SET VAL="{D}"
+34 QUIT
+35 ;
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 ;
DEF ; Default list of fields
+1 SET IEN=0
+2 FOR
SET IEN=$ORDER(^BQI(90506.1,"AC","D",IEN))
IF IEN=""
QUIT
Begin DoDot:1
+3 SET STVW=IEN
+4 IF $PIECE($GET(^BQI(90506.1,IEN,0)),U,10)=1
QUIT
+5 ; For a standard display, only display the 'R'equired fields.
+6 IF $$GET1^DIQ(90506.1,STVW_",",3.04,"I")'="O"
Begin DoDot:2
+7 DO CVAL
+8 SET VALUE=$GET(VALUE)_VAL_"^"
+9 SET HEADR=$GET(HEADR)_HDR_"^"
End DoDot:2
End DoDot:1
+10 ;
+11 IF $GET(BQIMEASF)=""
DO INP^BQINIGHT
+12 SET IEN=0
+13 FOR
SET IEN=$ORDER(^BQI(90506.1,"AC","G",IEN))
IF IEN=""
QUIT
Begin DoDot:1
+14 SET STVW=$PIECE(^BQI(90506.1,IEN,0),U,1)
+15 IF $PIECE(STVW,"_",1)'=BQIYR
QUIT
+16 IF $PIECE(^BQI(90506.1,IEN,0),U,10)=1
QUIT
+17 SET GIEN=$PIECE(STVW,"_",2)
+18 SET VER=$$VERSION^XPDUTL("BGP")
+19 IF $PIECE($GET(^BQI(90506.1,IEN,0)),U,10)=1
QUIT
+20 IF $$GET1^DIQ(90506.1,IEN_",",3.04,"I")'="O"
Begin DoDot:2
+21 IF VER<8.0
Begin DoDot:3
+22 SET PGIEN=$ORDER(^BQI(90508,BQIH,20,BQIY,20,"B",GIEN,""))
IF PGIEN=""
QUIT
+23 SET NAFLG=+$PIECE(^BQI(90508,BQIH,20,BQIY,20,PGIEN,0),U,4)
End DoDot:3
+24 IF VER>7.0
Begin DoDot:3
+25 SET NAFLG=$$GET1^DIQ(BQIMEASF,GIEN_",",1704,"I")
+26 SET NAFLG=$SELECT(NAFLG="Y":1,1:0)
End DoDot:3
+27 DO GVAL
+28 SET VALUE=VALUE_VAL_"^"
+29 SET HEADR=HEADR_HDR_"^"
End DoDot:2
End DoDot:1
+30 QUIT