GMRAPST3 ;HIRMFO/WAA- PRINT FREQUENCY OF DIST OVR DT BY REACT ;3/5/97 15:14
;;4.0;Adverse Reaction Tracking;**7,33**;Mar 29, 1996;Build 5
EN1 ; This routine will loop through the ADT entry point to get all
; the entries in that date range.
S GMRAOUT=0
W !,"Select an Observed date range for this report."
D DT^GMRAPL G:GMRAOUT EXIT
D PRINTER
EXIT ; Exit of program kill cleanup
D KILL^XUSCLEAN
K ^TMP($J,"GMRAPST3B")
K ^TMP($J,"GMRAPST3A")
Q
PRINTER ;Select printer
W ! K GMRAZIS D DEV^GMRAUTL I POP W !,"PLEASE TRY LATER" S GMRAOUT=1 Q
I $D(IO("Q")) D Q
. S ZTRTN="PRINT^GMRAPST3",(ZTSAVE("GMRAOUT"),ZTSAVE("GMAST"),ZTSAVE("GMAEN"))=""
. S ZTDESC="Frequency Distribution of Causative Agents" D ^%ZTLOAD
. W !!,$S($D(ZTSK):"Request queued...",1:"Request NOT queued please try Later.")
. Q
U IO D PRINT U IO(0)
Q
PRINT ;Queue point for report
;loop through the 120.85 file and look for the field that
D NOW^%DTC S GMRADPDT=X
S GMRADATE=GMAST-.0001,GMRAPG=1
K ^TMP($J,"GMRAPST3A")
S GMRATOT=0
F S GMRADATE=$O(^GMR(120.85,"B",GMRADATE)) Q:GMRADATE<1 Q:GMRADATE>GMAEN D
.S GMRAPA1=0 F S GMRAPA1=$O(^GMR(120.85,"B",GMRADATE,GMRAPA1)) Q:GMRAPA1<1 D
..S GMRAPA1(0)=$G(^GMR(120.85,GMRAPA1,0)) Q:GMRAPA1(0)="" ;Bad Node
..Q:+$G(^GMR(120.8,$P(GMRAPA1(0),U,15),"ER")) ;Entered in error data
..Q:'$$PRDTST^GMRAUTL1($P(GMRAPA1(0),U,2)) ;GMRA*4*33 Exclude test patient from report if production or legacy environment.
..S GMRATOT=GMRATOT+1
..S GMRAPA=$P(GMRAPA1(0),U,15) Q:'GMRAPA
..S GMRAPA(0)=$G(^GMR(120.8,GMRAPA,0)) Q:GMRAPA(0)=""
..S GMRAREC=$P(GMRAPA(0),U,2)
..S ^TMP($J,"GMRAPST3A",GMRAREC)=$G(^TMP($J,"GMRAPST3A",GMRAREC))+1
..Q
.Q
Q:GMRAOUT
Q:'$D(^TMP($J,"GMRAPST3A"))
K ^TMP($J,"GMRAPST3B")
S GMRAREC=""
F S GMRAREC=$O(^TMP($J,"GMRAPST3A",GMRAREC)) Q:GMRAREC="" D
.S GMRARECN=$G(^TMP($J,"GMRAPST3A",GMRAREC)) Q:GMRARECN=""
.S ^TMP($J,"GMRAPST3B",GMRARECN,GMRAREC)=""
.Q
D HEAD
S GMRARECN=""
F S GMRARECN=$O(^TMP($J,"GMRAPST3B",GMRARECN),-1) Q:GMRARECN<1 D Q:GMRAOUT
.S GMRAREC=""
.F S GMRAREC=$O(^TMP($J,"GMRAPST3B",GMRARECN,GMRAREC)) Q:GMRAREC="" D Q:GMRAOUT
..S GMRATAB=30-$L($E(GMRAREC,1,30))
..W !,?GMRATAB,$E(GMRAREC,1,30)," :",$J(GMRARECN,5)
..D HEAD Q:GMRAOUT
..Q
.Q
W !!,?22,"Total number of records processed ",GMRATOT
D CLOSE^GMRAUTL
Q
;has the patient died within the date
HEAD ; Print header information
I GMRAPG'=1 Q:$Y<(IOSL-4)
I $E(IOST,1)="C" D Q:GMRAOUT
.I GMRAPG=1 W @IOF Q
.I GMRAPG'=1 D Q:GMRAOUT
..N DIR S DIR(0)="E" D ^DIR I 'Y S GMRAOUT=1
..K Y
..Q
.Q
Q:GMRAOUT
I GMRAPG'=1 W @IOF
W "Report Date: ",$P($$FMTE^XLFDT(GMRADPDT),"@"),?70,"Page: ",GMRAPG
W !,?20,"Frequency Distribution of Causative Agents"
W !,?25,"From: ",$$FMTE^XLFDT(GMAST,"2D")," To: ",$$FMTE^XLFDT(GMAEN,"2D")
W !,"Causative Agents",?34,"Number"
W !,$$REPEAT^XLFSTR("-",79)
S GMRAPG=GMRAPG+1
I $D(ZTQUEUED) S:$$STPCK^GMRAUTL1 GMRAOUT=1 ; Check if stopped by user
Q
GMRAPST3 ;HIRMFO/WAA- PRINT FREQUENCY OF DIST OVR DT BY REACT ;3/5/97 15:14
+1 ;;4.0;Adverse Reaction Tracking;**7,33**;Mar 29, 1996;Build 5
EN1 ; This routine will loop through the ADT entry point to get all
+1 ; the entries in that date range.
+2 SET GMRAOUT=0
+3 WRITE !,"Select an Observed date range for this report."
+4 DO DT^GMRAPL
IF GMRAOUT
GOTO EXIT
+5 DO PRINTER
EXIT ; Exit of program kill cleanup
+1 DO KILL^XUSCLEAN
+2 KILL ^TMP($JOB,"GMRAPST3B")
+3 KILL ^TMP($JOB,"GMRAPST3A")
+4 QUIT
PRINTER ;Select printer
+1 WRITE !
KILL GMRAZIS
DO DEV^GMRAUTL
IF POP
WRITE !,"PLEASE TRY LATER"
SET GMRAOUT=1
QUIT
+2 IF $DATA(IO("Q"))
Begin DoDot:1
+3 SET ZTRTN="PRINT^GMRAPST3"
SET (ZTSAVE("GMRAOUT"),ZTSAVE("GMAST"),ZTSAVE("GMAEN"))=""
+4 SET ZTDESC="Frequency Distribution of Causative Agents"
DO ^%ZTLOAD
+5 WRITE !!,$SELECT($DATA(ZTSK):"Request queued...",1:"Request NOT queued please try Later.")
+6 QUIT
End DoDot:1
QUIT
+7 USE IO
DO PRINT
USE IO(0)
+8 QUIT
PRINT ;Queue point for report
+1 ;loop through the 120.85 file and look for the field that
+2 DO NOW^%DTC
SET GMRADPDT=X
+3 SET GMRADATE=GMAST-.0001
SET GMRAPG=1
+4 KILL ^TMP($JOB,"GMRAPST3A")
+5 SET GMRATOT=0
+6 FOR
SET GMRADATE=$ORDER(^GMR(120.85,"B",GMRADATE))
IF GMRADATE<1
QUIT
IF GMRADATE>GMAEN
QUIT
Begin DoDot:1
+7 SET GMRAPA1=0
FOR
SET GMRAPA1=$ORDER(^GMR(120.85,"B",GMRADATE,GMRAPA1))
IF GMRAPA1<1
QUIT
Begin DoDot:2
+8 ;Bad Node
SET GMRAPA1(0)=$GET(^GMR(120.85,GMRAPA1,0))
IF GMRAPA1(0)=""
QUIT
+9 ;Entered in error data
IF +$GET(^GMR(120.8,$PIECE(GMRAPA1(0),U,15),"ER"))
QUIT
+10 ;GMRA*4*33 Exclude test patient from report if production or legacy environment.
IF '$$PRDTST^GMRAUTL1($PIECE(GMRAPA1(0),U,2))
QUIT
+11 SET GMRATOT=GMRATOT+1
+12 SET GMRAPA=$PIECE(GMRAPA1(0),U,15)
IF 'GMRAPA
QUIT
+13 SET GMRAPA(0)=$GET(^GMR(120.8,GMRAPA,0))
IF GMRAPA(0)=""
QUIT
+14 SET GMRAREC=$PIECE(GMRAPA(0),U,2)
+15 SET ^TMP($JOB,"GMRAPST3A",GMRAREC)=$GET(^TMP($JOB,"GMRAPST3A",GMRAREC))+1
+16 QUIT
End DoDot:2
+17 QUIT
End DoDot:1
+18 IF GMRAOUT
QUIT
+19 IF '$DATA(^TMP($JOB,"GMRAPST3A"))
QUIT
+20 KILL ^TMP($JOB,"GMRAPST3B")
+21 SET GMRAREC=""
+22 FOR
SET GMRAREC=$ORDER(^TMP($JOB,"GMRAPST3A",GMRAREC))
IF GMRAREC=""
QUIT
Begin DoDot:1
+23 SET GMRARECN=$GET(^TMP($JOB,"GMRAPST3A",GMRAREC))
IF GMRARECN=""
QUIT
+24 SET ^TMP($JOB,"GMRAPST3B",GMRARECN,GMRAREC)=""
+25 QUIT
End DoDot:1
+26 DO HEAD
+27 SET GMRARECN=""
+28 FOR
SET GMRARECN=$ORDER(^TMP($JOB,"GMRAPST3B",GMRARECN),-1)
IF GMRARECN<1
QUIT
Begin DoDot:1
+29 SET GMRAREC=""
+30 FOR
SET GMRAREC=$ORDER(^TMP($JOB,"GMRAPST3B",GMRARECN,GMRAREC))
IF GMRAREC=""
QUIT
Begin DoDot:2
+31 SET GMRATAB=30-$LENGTH($EXTRACT(GMRAREC,1,30))
+32 WRITE !,?GMRATAB,$EXTRACT(GMRAREC,1,30)," :",$JUSTIFY(GMRARECN,5)
+33 DO HEAD
IF GMRAOUT
QUIT
+34 QUIT
End DoDot:2
IF GMRAOUT
QUIT
+35 QUIT
End DoDot:1
IF GMRAOUT
QUIT
+36 WRITE !!,?22,"Total number of records processed ",GMRATOT
+37 DO CLOSE^GMRAUTL
+38 QUIT
+39 ;has the patient died within the date
HEAD ; Print header information
+1 IF GMRAPG'=1
IF $Y<(IOSL-4)
QUIT
+2 IF $EXTRACT(IOST,1)="C"
Begin DoDot:1
+3 IF GMRAPG=1
WRITE @IOF
QUIT
+4 IF GMRAPG'=1
Begin DoDot:2
+5 NEW DIR
SET DIR(0)="E"
DO ^DIR
IF 'Y
SET GMRAOUT=1
+6 KILL Y
+7 QUIT
End DoDot:2
IF GMRAOUT
QUIT
+8 QUIT
End DoDot:1
IF GMRAOUT
QUIT
+9 IF GMRAOUT
QUIT
+10 IF GMRAPG'=1
WRITE @IOF
+11 WRITE "Report Date: ",$PIECE($$FMTE^XLFDT(GMRADPDT),"@"),?70,"Page: ",GMRAPG
+12 WRITE !,?20,"Frequency Distribution of Causative Agents"
+13 WRITE !,?25,"From: ",$$FMTE^XLFDT(GMAST,"2D")," To: ",$$FMTE^XLFDT(GMAEN,"2D")
+14 WRITE !,"Causative Agents",?34,"Number"
+15 WRITE !,$$REPEAT^XLFSTR("-",79)
+16 SET GMRAPG=GMRAPG+1
+17 ; Check if stopped by user
IF $DATA(ZTQUEUED)
IF $$STPCK^GMRAUTL1
SET GMRAOUT=1
+18 QUIT