BGP2GNST ; IHS/CMI/LAB - IHS Diabetes Audit 2003 ;
;;12.1;IHS CLINICAL REPORTING;;MAY 17, 2012;Build 66
;
;
TESTNTL ;
S ERR=""
S BGPND(4)="",BGPND(3)=""
F X=2:1:5 S BGPINDL(3,X)=""
F X=6:1:9 S BGPINDL(4,X)=""
D EP(.ERR,1,2522,"BGP 12 NATIONAL PAT LISTS",338,.BGPND,.BGPINDL,1,3040000,"A","","","B",$$NOW^XLFDT)
W !,ERR
Q
EP(BGPRET,BGPUSER,BGPDUZ2,BGPOPTN,BGPTAXI,BGPIND,BGPINDL,BGPQTR,BGPPER,BGPLIST,BGPLPRV,BGPLPROV,BGPROT,BGPRTIME,BGPMFITI,BGPVDT,BGPBEN,BGPFILE) ;EP - called from GUI to produce national gpra report (NTL-GP)
; SEE ROUTINE BGP2NPL if you have questions about any of these variables
; BGPUSER - DUZ
; BGPDUZ2 - DUZ(2)
; BGPOPTN - OPTION NAME
; BGPTAXI - IEN OF COMMUNITY TAXONOMY NAME
; BGPIND - array containing iens of the measures selected by the user
; for example, BGPIND(3)=""
; BGPIND(6)="" if the user selected measures
; 1 and 6 from the BGP 12 INDICATORS file. When
; you present them to the user for selection use the
; ^BGPINDW("AGPRA",1,ien) xref as the ones with a second
; subscript of 1 are the GPRA measures. Or you can set
; DIC("S")="I $P(^(0),U,7)=1" , if the 7th piece is one
; then show that measure to the user.
; BGPINDL - array containing the lists wanted for each measure selected
; and put in array BGPIND, you will loop through the measures they
; selected and you put in BGPIND and then display to the user the
; entries from BGP 12 NATIONAL PATIENT LISTS that point to that
; measure by using the "B" index on ^BGPNPLW(. ^BGPNPLW("B",measure ien,ien)
; For example, measure 3 Nephropathy assessment has 4 lists available:
; Documented A1c, No Documented A1c, Poor Glycemic Control, Ideal Glycemic Control
; If the user wants lists 1 and 2 the array would look like:
; BGPINDL(3,2)=""
; BGPINDL(3,3)=""
;
; BGPQTR - this is equal to 1,2,3,4 or 5 depending on how the user answers the following
; DIR call:
; Select one of the following:
;
; 1 January 1 - December 31
; 2 April 1 - March 31
; 3 July 1 - June 30
; 4 October 1 - September 30
; 5 User-Defined Report Period
; Enter the date range for your report:
;
; BGPPER - this is the year they select if they answered the above question
; with a 1 through 4 e.g 305000 (fileman imprecise date for 2010)
; If they chose 5 then this would be the end date they entered, e.g.
; 3050301
;
; BGPLIST - this contains the answer to the following DIR call:
;
; Select one of the following:
; P Patient List by Provider
; A All Patients
;
; Choose report type for the Lists: R//
;
; BGPLPRV - will equal ien of provider if they picked "P" above
; BGPLPROV - will equal provider name if they picked "P" above
;
; BGPROT - type of output P for printed, D For Delimited, B for both
; BGPRTIME - report will be queued automatically, this variable
; contains the time it will run, internal fileman format
; must be date and time
;
; BGPRET - return value is ien^error message^export file name. a zero (0) is
; passed as ien if error occurred, display the filename back to the user
; if they chose to export to area
;
;create entry in gui output file
;queue report to run with/GUIR
D EP1
S Y=BGPRET
;D EN^XBVK("BGP") S:$D(ZTQUEUED) ZTREQ="@"
S BGPRET=Y
Q
EP1 ;
S U="^"
I $G(BGPUSER)="" S BGPRET=0_"^USER NOT PASSED" Q
I $G(BGPDUZ2)="" S BGPRET=0_"^DUZ(2) NOT PASSED" Q
I $G(BGPOPTN)="" S BGPRET=0_"^OPTION NAME NOT PASSED" Q
I $G(BGPTAXI)="" S BGPRET=0_"^IEN OF COMMUNITY TAXONOMY NOT PASSED" Q
I '$D(^ATXAX(BGPTAXI)) S BGPRET=0_"^INVALID COMMUNITY TAXONOMY IEN PASSED" Q
I '$D(BGPIND) S BGPRET=0_"^INDICATOR ARRAY NOT PASSED" Q
I '$O(BGPIND(0)) S BGPRET=0_"^INDICATOR ARRAY NOT PASSED" Q
I '$D(BGPINDL) S BGPRET=0_"^REPORT LISTS ARRAY NOT PASSED" Q
I '$O(BGPINDL(0)) S BGPRET=0_"^REPORT LISTS ARRAY NOT PASSED" Q
I $G(BGPPER)="" S BGPRET=0_"^YEAR VARIABLE NOT PASSED" Q
I $G(BGPQTR)="" S BGPRET=0_"^QUARTER/DATE TYPE NOT PASSED" Q
I "PDB"'[$G(BGPROT) S BGPRET=0_"^REPORT OUTPUT TYPE NOT PASSED" Q
I $G(BGPLIST)="" S BGPRET=0_"^LIST TYPE NOT PASSED" Q
I $G(BGPLIST)="P",$G(BGPLPRV)="" S BGPRET=0_"^PROVIDER NOT PASSED FOR LIST TYPE P" Q
S BGPRTIME=$G(BGPRTIME)
;S DUZ=BGPUSER
S DUZ(2)=BGPDUZ2
S:'$D(DT) DT=$$DT^XLFDT
D ^XBKVAR
S BGPGUI=1
S IOM=80,BGPIOSL=55
S BGPRTYPE=1,BGPYRPTH="",BGPNPL=1,BGPINDW="G",BGPYGPU=1,BGPYNPLT=1
K BGPTAX S X=0
F S X=$O(^ATXAX(BGPTAXI,21,X)) Q:'X D
.S BGPTAX($P(^ATXAX(BGPTAXI,21,X,0),U))=""
.Q
;S BGPVDT=BGPPER
I BGPQTR=1 S BGPBD=$E(BGPPER,1,3)_"0101",BGPED=$E(BGPPER,1,3)_"1231"
I BGPQTR=2 S BGPBD=($E(BGPPER,1,3)-1)_"0401",BGPED=$E(BGPPER,1,3)_"0331"
I BGPQTR=3 S BGPBD=($E(BGPPER,1,3)-1)_"0701",BGPED=$E(BGPPER,1,3)_"0630"
I BGPQTR=4 S BGPBD=($E(BGPPER,1,3)-1)_"1001",BGPED=$E(BGPPER,1,3)_"0930"
I BGPQTR=5 S BGPBD=$$FMADD^XLFDT(BGPPER,-364),BGPED=BGPPER,BGPPER=$E(BGPED,1,3)_"0000"
BY ;get baseline year
S X=$E(BGPPER,1,3)-$E(BGPVDT,1,3)
S X=X_"0000"
S BGPBBD=BGPBD-X,BGPBBD=$E(BGPBBD,1,3)_$E(BGPBD,4,7)
S BGPBED=BGPED-X,BGPBED=$E(BGPBED,1,3)_$E(BGPED,4,7)
S BGPPBD=($E(BGPBD,1,3)-1)_$E(BGPBD,4,7)
S BGPPED=($E(BGPED,1,3)-1)_$E(BGPED,4,7)
S BGPBEN=1
S BGPHOME=$P($G(^BGPSITE(DUZ(2),0)),U,2)
S BGPINDW="G"
D REPORT^BGP2UTL
I $G(BGPQUIT) S BGPRET=0_"^COULD NOT CREATE REPORT ENTRY" Q
I BGPRPT="" S BGPRET=0_"^COULD NOT CREATE REPORT ENTRY" Q
S BGPDELT=""
;create entry in GUI file
D ^XBFMK
S X=BGPFILE ;cmi /maw 9.0 p1
;S X=BGPUSER_$$NOW^XLFDT
S DIC="^BGPGUIW(",DIC(0)="L",DIADD=1,DLAYGO=90546.19,DIC("DR")=".02////"_BGPUSER_";.03////"_$S(BGPRTIME]"":BGPRTIME,1:$$NOW^XLFDT)_";.05///"_BGPOPTN_";.06///R;.07///"_$G(BGPROT)
K DD,D0,DO D FILE^DICN K DLAYGO,DIADD,DD,D0,DO
I Y=-1 S BGPRET=0_"^UNABLE TO CREATE ENTRY IN GUI OUTPUT FILE" Q
S BGPGIEN=+Y
;SEND THE REPORT PROCESS OFF TO THE BACKGROUND USING TASKMAN CALL
D TSKMN
S BGPRET=BGPGIEN
Q
;
TSKMN ;
S ZTIO=""
K ZTSAVE S ZTSAVE("*")=""
S ZTCPU=$G(IOCPU),ZTRTN="NTLGP^BGP2GNPL",ZTDTH=$S(BGPRTIME]"":BGPRTIME,1:$$NOW^XLFDT),ZTDESC="GUI NATIONAL GPRA REPORT LISTS 05" D ^%ZTLOAD Q
Q
NTLGP ;
D ^BGP2D1
K ^TMP($J,"BGPGUI")
S IOM=80,BGPIOSL=55
D GUIR^BGPXBLM("^BGP2DP","^TMP($J,""BGPGUI"",")
;cmi/anch/maw added 5/12/2009 for word output
S X=0,C=0 F S X=$O(^TMP($J,"BGPGUI",X)) Q:X'=+X D
. S C=C+1
. N BGPDATA
. S BGPDATA=$G(^TMP($J,"BGPGUI",X))
. I BGPDATA="ZZZZZZZ" S BGPDATA=$C(12)
. S ^BGPGUIW(BGPGIEN,11,C,0)=BGPDATA
S ^BGPGUIW(BGPGIEN,11,0)="^90546.1911^"_C_"^"_C_"^"_DT
K ^TMP($J,"BGPGUI")
;cmi/anch/maw end of mods
D ENDLOG
D XIT
Q
;
XIT ;
K ^TMP($J)
D EN^XBVK("BGP") S:$D(ZTQUEUED) ZTREQ="@"
K DIRUT,DUOUT,DIR,DOD
K DIADD,DLAYGO
D KILL^AUPNPAT
K X,X1,X2,X3,X4,X5,X6
K A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,V,W,X,Y,Z
K N,N1,N2,N3,N4,N5,N6
K BD,ED
D KILL^AUPNPAT
D ^XBFMK
L -^BGPDATA
Q
;
ENDLOG ;-- UPDATE LOG AT END
S DIE="^BGPGUIW(",DA=BGPGIEN,DR=".04////"_$$NOW^XLFDT_";.06///C"
D ^DIE
K DIE,DR,DA
Q
BGP2GNST ; IHS/CMI/LAB - IHS Diabetes Audit 2003 ;
+1 ;;12.1;IHS CLINICAL REPORTING;;MAY 17, 2012;Build 66
+2 ;
+3 ;
TESTNTL ;
+1 SET ERR=""
+2 SET BGPND(4)=""
SET BGPND(3)=""
+3 FOR X=2:1:5
SET BGPINDL(3,X)=""
+4 FOR X=6:1:9
SET BGPINDL(4,X)=""
+5 DO EP(.ERR,1,2522,"BGP 12 NATIONAL PAT LISTS",338,.BGPND,.BGPINDL,1,3040000,"A","","","B",$$NOW^XLFDT)
+6 WRITE !,ERR
+7 QUIT
EP(BGPRET,BGPUSER,BGPDUZ2,BGPOPTN,BGPTAXI,BGPIND,BGPINDL,BGPQTR,BGPPER,BGPLIST,BGPLPRV,BGPLPROV,BGPROT,BGPRTIME,BGPMFITI,BGPVDT,BGPBEN,BGPFILE) ;EP - called from GUI to produce national gpra report (NTL-GP)
+1 ; SEE ROUTINE BGP2NPL if you have questions about any of these variables
+2 ; BGPUSER - DUZ
+3 ; BGPDUZ2 - DUZ(2)
+4 ; BGPOPTN - OPTION NAME
+5 ; BGPTAXI - IEN OF COMMUNITY TAXONOMY NAME
+6 ; BGPIND - array containing iens of the measures selected by the user
+7 ; for example, BGPIND(3)=""
+8 ; BGPIND(6)="" if the user selected measures
+9 ; 1 and 6 from the BGP 12 INDICATORS file. When
+10 ; you present them to the user for selection use the
+11 ; ^BGPINDW("AGPRA",1,ien) xref as the ones with a second
+12 ; subscript of 1 are the GPRA measures. Or you can set
+13 ; DIC("S")="I $P(^(0),U,7)=1" , if the 7th piece is one
+14 ; then show that measure to the user.
+15 ; BGPINDL - array containing the lists wanted for each measure selected
+16 ; and put in array BGPIND, you will loop through the measures they
+17 ; selected and you put in BGPIND and then display to the user the
+18 ; entries from BGP 12 NATIONAL PATIENT LISTS that point to that
+19 ; measure by using the "B" index on ^BGPNPLW(. ^BGPNPLW("B",measure ien,ien)
+20 ; For example, measure 3 Nephropathy assessment has 4 lists available:
+21 ; Documented A1c, No Documented A1c, Poor Glycemic Control, Ideal Glycemic Control
+22 ; If the user wants lists 1 and 2 the array would look like:
+23 ; BGPINDL(3,2)=""
+24 ; BGPINDL(3,3)=""
+25 ;
+26 ; BGPQTR - this is equal to 1,2,3,4 or 5 depending on how the user answers the following
+27 ; DIR call:
+28 ; Select one of the following:
+29 ;
+30 ; 1 January 1 - December 31
+31 ; 2 April 1 - March 31
+32 ; 3 July 1 - June 30
+33 ; 4 October 1 - September 30
+34 ; 5 User-Defined Report Period
+35 ; Enter the date range for your report:
+36 ;
+37 ; BGPPER - this is the year they select if they answered the above question
+38 ; with a 1 through 4 e.g 305000 (fileman imprecise date for 2010)
+39 ; If they chose 5 then this would be the end date they entered, e.g.
+40 ; 3050301
+41 ;
+42 ; BGPLIST - this contains the answer to the following DIR call:
+43 ;
+44 ; Select one of the following:
+45 ; P Patient List by Provider
+46 ; A All Patients
+47 ;
+48 ; Choose report type for the Lists: R//
+49 ;
+50 ; BGPLPRV - will equal ien of provider if they picked "P" above
+51 ; BGPLPROV - will equal provider name if they picked "P" above
+52 ;
+53 ; BGPROT - type of output P for printed, D For Delimited, B for both
+54 ; BGPRTIME - report will be queued automatically, this variable
+55 ; contains the time it will run, internal fileman format
+56 ; must be date and time
+57 ;
+58 ; BGPRET - return value is ien^error message^export file name. a zero (0) is
+59 ; passed as ien if error occurred, display the filename back to the user
+60 ; if they chose to export to area
+61 ;
+62 ;create entry in gui output file
+63 ;queue report to run with/GUIR
+64 DO EP1
+65 SET Y=BGPRET
+66 ;D EN^XBVK("BGP") S:$D(ZTQUEUED) ZTREQ="@"
+67 SET BGPRET=Y
+68 QUIT
EP1 ;
+1 SET U="^"
+2 IF $GET(BGPUSER)=""
SET BGPRET=0_"^USER NOT PASSED"
QUIT
+3 IF $GET(BGPDUZ2)=""
SET BGPRET=0_"^DUZ(2) NOT PASSED"
QUIT
+4 IF $GET(BGPOPTN)=""
SET BGPRET=0_"^OPTION NAME NOT PASSED"
QUIT
+5 IF $GET(BGPTAXI)=""
SET BGPRET=0_"^IEN OF COMMUNITY TAXONOMY NOT PASSED"
QUIT
+6 IF '$DATA(^ATXAX(BGPTAXI))
SET BGPRET=0_"^INVALID COMMUNITY TAXONOMY IEN PASSED"
QUIT
+7 IF '$DATA(BGPIND)
SET BGPRET=0_"^INDICATOR ARRAY NOT PASSED"
QUIT
+8 IF '$ORDER(BGPIND(0))
SET BGPRET=0_"^INDICATOR ARRAY NOT PASSED"
QUIT
+9 IF '$DATA(BGPINDL)
SET BGPRET=0_"^REPORT LISTS ARRAY NOT PASSED"
QUIT
+10 IF '$ORDER(BGPINDL(0))
SET BGPRET=0_"^REPORT LISTS ARRAY NOT PASSED"
QUIT
+11 IF $GET(BGPPER)=""
SET BGPRET=0_"^YEAR VARIABLE NOT PASSED"
QUIT
+12 IF $GET(BGPQTR)=""
SET BGPRET=0_"^QUARTER/DATE TYPE NOT PASSED"
QUIT
+13 IF "PDB"'[$GET(BGPROT)
SET BGPRET=0_"^REPORT OUTPUT TYPE NOT PASSED"
QUIT
+14 IF $GET(BGPLIST)=""
SET BGPRET=0_"^LIST TYPE NOT PASSED"
QUIT
+15 IF $GET(BGPLIST)="P"
IF $GET(BGPLPRV)=""
SET BGPRET=0_"^PROVIDER NOT PASSED FOR LIST TYPE P"
QUIT
+16 SET BGPRTIME=$GET(BGPRTIME)
+17 ;S DUZ=BGPUSER
+18 SET DUZ(2)=BGPDUZ2
+19 IF '$DATA(DT)
SET DT=$$DT^XLFDT
+20 DO ^XBKVAR
+21 SET BGPGUI=1
+22 SET IOM=80
SET BGPIOSL=55
+23 SET BGPRTYPE=1
SET BGPYRPTH=""
SET BGPNPL=1
SET BGPINDW="G"
SET BGPYGPU=1
SET BGPYNPLT=1
+24 KILL BGPTAX
SET X=0
+25 FOR
SET X=$ORDER(^ATXAX(BGPTAXI,21,X))
IF 'X
QUIT
Begin DoDot:1
+26 SET BGPTAX($PIECE(^ATXAX(BGPTAXI,21,X,0),U))=""
+27 QUIT
End DoDot:1
+28 ;S BGPVDT=BGPPER
+29 IF BGPQTR=1
SET BGPBD=$EXTRACT(BGPPER,1,3)_"0101"
SET BGPED=$EXTRACT(BGPPER,1,3)_"1231"
+30 IF BGPQTR=2
SET BGPBD=($EXTRACT(BGPPER,1,3)-1)_"0401"
SET BGPED=$EXTRACT(BGPPER,1,3)_"0331"
+31 IF BGPQTR=3
SET BGPBD=($EXTRACT(BGPPER,1,3)-1)_"0701"
SET BGPED=$EXTRACT(BGPPER,1,3)_"0630"
+32 IF BGPQTR=4
SET BGPBD=($EXTRACT(BGPPER,1,3)-1)_"1001"
SET BGPED=$EXTRACT(BGPPER,1,3)_"0930"
+33 IF BGPQTR=5
SET BGPBD=$$FMADD^XLFDT(BGPPER,-364)
SET BGPED=BGPPER
SET BGPPER=$EXTRACT(BGPED,1,3)_"0000"
BY ;get baseline year
+1 SET X=$EXTRACT(BGPPER,1,3)-$EXTRACT(BGPVDT,1,3)
+2 SET X=X_"0000"
+3 SET BGPBBD=BGPBD-X
SET BGPBBD=$EXTRACT(BGPBBD,1,3)_$EXTRACT(BGPBD,4,7)
+4 SET BGPBED=BGPED-X
SET BGPBED=$EXTRACT(BGPBED,1,3)_$EXTRACT(BGPED,4,7)
+5 SET BGPPBD=($EXTRACT(BGPBD,1,3)-1)_$EXTRACT(BGPBD,4,7)
+6 SET BGPPED=($EXTRACT(BGPED,1,3)-1)_$EXTRACT(BGPED,4,7)
+7 SET BGPBEN=1
+8 SET BGPHOME=$PIECE($GET(^BGPSITE(DUZ(2),0)),U,2)
+9 SET BGPINDW="G"
+10 DO REPORT^BGP2UTL
+11 IF $GET(BGPQUIT)
SET BGPRET=0_"^COULD NOT CREATE REPORT ENTRY"
QUIT
+12 IF BGPRPT=""
SET BGPRET=0_"^COULD NOT CREATE REPORT ENTRY"
QUIT
+13 SET BGPDELT=""
+14 ;create entry in GUI file
+15 DO ^XBFMK
+16 ;cmi /maw 9.0 p1
SET X=BGPFILE
+17 ;S X=BGPUSER_$$NOW^XLFDT
+18 SET DIC="^BGPGUIW("
SET DIC(0)="L"
SET DIADD=1
SET DLAYGO=90546.19
SET DIC("DR")=".02////"_BGPUSER_";.03////"_$SELECT(BGPRTIME]"":BGPRTIME,1:$$NOW^XLFDT)_";.05///"_BGPOPTN_";.06///R;.07///"_$G(BGPROT)
+19 KILL DD,D0,DO
DO FILE^DICN
KILL DLAYGO,DIADD,DD,D0,DO
+20 IF Y=-1
SET BGPRET=0_"^UNABLE TO CREATE ENTRY IN GUI OUTPUT FILE"
QUIT
+21 SET BGPGIEN=+Y
+22 ;SEND THE REPORT PROCESS OFF TO THE BACKGROUND USING TASKMAN CALL
+23 DO TSKMN
+24 SET BGPRET=BGPGIEN
+25 QUIT
+26 ;
TSKMN ;
+1 SET ZTIO=""
+2 KILL ZTSAVE
SET ZTSAVE("*")=""
+3 SET ZTCPU=$GET(IOCPU)
SET ZTRTN="NTLGP^BGP2GNPL"
SET ZTDTH=$SELECT(BGPRTIME]"":BGPRTIME,1:$$NOW^XLFDT)
SET ZTDESC="GUI NATIONAL GPRA REPORT LISTS 05"
DO ^%ZTLOAD
QUIT
+4 QUIT
NTLGP ;
+1 DO ^BGP2D1
+2 KILL ^TMP($JOB,"BGPGUI")
+3 SET IOM=80
SET BGPIOSL=55
+4 DO GUIR^BGPXBLM("^BGP2DP","^TMP($J,""BGPGUI"",")
+5 ;cmi/anch/maw added 5/12/2009 for word output
+6 SET X=0
SET C=0
FOR
SET X=$ORDER(^TMP($JOB,"BGPGUI",X))
IF X'=+X
QUIT
Begin DoDot:1
+7 SET C=C+1
+8 NEW BGPDATA
+9 SET BGPDATA=$GET(^TMP($JOB,"BGPGUI",X))
+10 IF BGPDATA="ZZZZZZZ"
SET BGPDATA=$CHAR(12)
+11 SET ^BGPGUIW(BGPGIEN,11,C,0)=BGPDATA
End DoDot:1
+12 SET ^BGPGUIW(BGPGIEN,11,0)="^90546.1911^"_C_"^"_C_"^"_DT
+13 KILL ^TMP($JOB,"BGPGUI")
+14 ;cmi/anch/maw end of mods
+15 DO ENDLOG
+16 DO XIT
+17 QUIT
+18 ;
XIT ;
+1 KILL ^TMP($JOB)
+2 DO EN^XBVK("BGP")
IF $DATA(ZTQUEUED)
SET ZTREQ="@"
+3 KILL DIRUT,DUOUT,DIR,DOD
+4 KILL DIADD,DLAYGO
+5 DO KILL^AUPNPAT
+6 KILL X,X1,X2,X3,X4,X5,X6
+7 KILL A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,V,W,X,Y,Z
+8 KILL N,N1,N2,N3,N4,N5,N6
+9 KILL BD,ED
+10 DO KILL^AUPNPAT
+11 DO ^XBFMK
+12 LOCK -^BGPDATA
+13 QUIT
+14 ;
ENDLOG ;-- UPDATE LOG AT END
+1 SET DIE="^BGPGUIW("
SET DA=BGPGIEN
SET DR=".04////"_$$NOW^XLFDT_";.06///C"
+2 DO ^DIE
+3 KILL DIE,DR,DA
+4 QUIT