GMRAPFT ;HIRMFO/WAA- PRINT FDA REACTION BY DATE ENTERED/TRACKED ;4/10/97 09:30
;;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 a Tracking date range for this report."
D DT^GMRAPL G:GMRAOUT EXIT
D PRINTER
EXIT ; Exit of program kill cleanup
D KILL^XUSCLEAN
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^GMRAPFT",(ZTSAVE("GMRAOUT"),ZTSAVE("GMAST"),ZTSAVE("GMAEN"))=""
. S ZTDESC="List of FDA Reactions over a Date range by Tracking date" D ^%ZTLOAD
. W !!,$S($D(ZTSK):"Request queued...",1:"Request NOT queued please try Later.")
. Q
U IO D PRINT U IO(0)
D EXIT
Q
PRINT ;Queue point for report
D NOW^%DTC S GMRADPDT=X
S GMRADATE=GMAST-.0001,GMRAPG=1
F S GMRADATE=$O(^GMR(120.85,"ARDT",GMRADATE)) Q:GMRADATE<1 Q:GMRADATE>GMAEN D Q:GMRAOUT
.S GMRAPA1=0
.F S GMRAPA1=$O(^GMR(120.85,"ARDT",GMRADATE,GMRAPA1)) Q:GMRAPA1<1 D Q:GMRAOUT
..S GMRAPA1(0)=$G(^GMR(120.85,GMRAPA1,0)) Q:GMRAPA1(0)=""
..Q:+$G(^GMR(120.8,$P(GMRAPA1(0),U,15),"ER")) ;data entered in error
..D HEAD Q:GMRAOUT
..S (GMRAPID,GMRANAME,GMRALOC)=""
..S GMRADFN=$P(GMRAPA1(0),U,2),GMRADDT=$P(GMRAPA1(0),U)
..Q:'$$PRDTST^GMRAUTL1(GMRADFN) ;GMRA*4*33 Exclude test patient from report if production or legacy system.
..D VAD^GMRAUTL1(GMRADFN,GMRADDT,.GMRALOC,.GMRANAME,"",.GMRAPID)
..I GMRALOC="" S GMRALOC="OUT PATIENT"
..E S GMRALOC=$P($G(^DIC(42,GMRALOC,0)),U)
..W !,$E(GMRANAME,1,30) ; Patient Name
..K GMRARAC
..S GMRARAC=0,GMRACNT=1 F S GMRARAC=$O(^GMR(120.85,GMRAPA1,3,GMRARAC)) Q:GMRARAC<1 D
...S GMRARAC(GMRACNT)=$P($G(^GMR(120.85,GMRAPA1,3,GMRARAC,0)),U) Q:GMRARAC(GMRACNT)=""
...S GMRACNT=GMRACNT+1
...Q
..W ?32,"Obs DT: ",$$FMTE^XLFDT($P(GMRAPA1(0),U),"2D") ; Observed Date
..W ?49,$E($G(GMRARAC(1)),1,30) ; The 1st reaction that is listed first
..W !,"(",GMRAPID,")"
..W ?32,"Trk DT: ",$$FMTE^XLFDT($P(GMRAPA1(0),U,18),"2D") ; Tracking Date
..W ?49,$E($G(GMRARAC(2)),1,30) ; The 2nd reaction that is listed
..W !,"Loc: ",GMRALOC
..W ?32,"-------------" ; Separator
..W ?49,$E($G(GMRARAC(3)),1,30) ; The 3rd reaction that is listed
..W !,"Obs: ",$P($G(^VA(200,$P(GMRAPA1(0),U,19),0)),U) ; User entered
..D
...N X1,X2,X,Y
...S X2=$P(GMRAPA1(0),U),X1=$P(GMRAPA1(0),U,18)
...D ^%DTC
...W ?32,X," Days Difference" ;Difference
...Q
..W ?50,$E($G(GMRARAC(4)),1,30) ; The 4th reaction that is listed
..S GMRACNT=4 F S GMRACNT=$O(GMRARAC(GMRACNT)) Q:GMRACNT<1 W !,?50,$E($G(GMRARAC(GMRACNT)),1,30) ; The Nth reaction that is listed
..W ! ; Put a blank line between the ADRs
..Q
.Q
D CLOSE^GMRAUTL
Q
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 !,?22,"Adverse Reaction Tracking Report"
W !,?25,"From: ",$$FMTE^XLFDT(GMAST,"2D")," To: ",$$FMTE^XLFDT(GMAEN,"2D")
W !,"Patient",?40,"Dates",?49,"Related Reaction"
W !,$$REPEAT^XLFSTR("-",78)
S GMRAPG=GMRAPG+1
I $D(ZTQUEUED) S:$$STPCK^GMRAUTL1 GMRAOUT=1 ; Check if stopped by user
Q
GMRAPFT ;HIRMFO/WAA- PRINT FDA REACTION BY DATE ENTERED/TRACKED ;4/10/97 09:30
+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 a Tracking 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 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^GMRAPFT"
SET (ZTSAVE("GMRAOUT"),ZTSAVE("GMAST"),ZTSAVE("GMAEN"))=""
+4 SET ZTDESC="List of FDA Reactions over a Date range by Tracking date"
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 DO EXIT
+9 QUIT
PRINT ;Queue point for report
+1 DO NOW^%DTC
SET GMRADPDT=X
+2 SET GMRADATE=GMAST-.0001
SET GMRAPG=1
+3 FOR
SET GMRADATE=$ORDER(^GMR(120.85,"ARDT",GMRADATE))
IF GMRADATE<1
QUIT
IF GMRADATE>GMAEN
QUIT
Begin DoDot:1
+4 SET GMRAPA1=0
+5 FOR
SET GMRAPA1=$ORDER(^GMR(120.85,"ARDT",GMRADATE,GMRAPA1))
IF GMRAPA1<1
QUIT
Begin DoDot:2
+6 SET GMRAPA1(0)=$GET(^GMR(120.85,GMRAPA1,0))
IF GMRAPA1(0)=""
QUIT
+7 ;data entered in error
IF +$GET(^GMR(120.8,$PIECE(GMRAPA1(0),U,15),"ER"))
QUIT
+8 DO HEAD
IF GMRAOUT
QUIT
+9 SET (GMRAPID,GMRANAME,GMRALOC)=""
+10 SET GMRADFN=$PIECE(GMRAPA1(0),U,2)
SET GMRADDT=$PIECE(GMRAPA1(0),U)
+11 ;GMRA*4*33 Exclude test patient from report if production or legacy system.
IF '$$PRDTST^GMRAUTL1(GMRADFN)
QUIT
+12 DO VAD^GMRAUTL1(GMRADFN,GMRADDT,.GMRALOC,.GMRANAME,"",.GMRAPID)
+13 IF GMRALOC=""
SET GMRALOC="OUT PATIENT"
+14 IF '$TEST
SET GMRALOC=$PIECE($GET(^DIC(42,GMRALOC,0)),U)
+15 ; Patient Name
WRITE !,$EXTRACT(GMRANAME,1,30)
+16 KILL GMRARAC
+17 SET GMRARAC=0
SET GMRACNT=1
FOR
SET GMRARAC=$ORDER(^GMR(120.85,GMRAPA1,3,GMRARAC))
IF GMRARAC<1
QUIT
Begin DoDot:3
+18 SET GMRARAC(GMRACNT)=$PIECE($GET(^GMR(120.85,GMRAPA1,3,GMRARAC,0)),U)
IF GMRARAC(GMRACNT)=""
QUIT
+19 SET GMRACNT=GMRACNT+1
+20 QUIT
End DoDot:3
+21 ; Observed Date
WRITE ?32,"Obs DT: ",$$FMTE^XLFDT($PIECE(GMRAPA1(0),U),"2D")
+22 ; The 1st reaction that is listed first
WRITE ?49,$EXTRACT($GET(GMRARAC(1)),1,30)
+23 WRITE !,"(",GMRAPID,")"
+24 ; Tracking Date
WRITE ?32,"Trk DT: ",$$FMTE^XLFDT($PIECE(GMRAPA1(0),U,18),"2D")
+25 ; The 2nd reaction that is listed
WRITE ?49,$EXTRACT($GET(GMRARAC(2)),1,30)
+26 WRITE !,"Loc: ",GMRALOC
+27 ; Separator
WRITE ?32,"-------------"
+28 ; The 3rd reaction that is listed
WRITE ?49,$EXTRACT($GET(GMRARAC(3)),1,30)
+29 ; User entered
WRITE !,"Obs: ",$PIECE($GET(^VA(200,$PIECE(GMRAPA1(0),U,19),0)),U)
+30 Begin DoDot:3
+31 NEW X1,X2,X,Y
+32 SET X2=$PIECE(GMRAPA1(0),U)
SET X1=$PIECE(GMRAPA1(0),U,18)
+33 DO ^%DTC
+34 ;Difference
WRITE ?32,X," Days Difference"
+35 QUIT
End DoDot:3
+36 ; The 4th reaction that is listed
WRITE ?50,$EXTRACT($GET(GMRARAC(4)),1,30)
+37 ; The Nth reaction that is listed
SET GMRACNT=4
FOR
SET GMRACNT=$ORDER(GMRARAC(GMRACNT))
IF GMRACNT<1
QUIT
WRITE !,?50,$EXTRACT($GET(GMRARAC(GMRACNT)),1,30)
+38 ; Put a blank line between the ADRs
WRITE !
+39 QUIT
End DoDot:2
IF GMRAOUT
QUIT
+40 QUIT
End DoDot:1
IF GMRAOUT
QUIT
+41 DO CLOSE^GMRAUTL
+42 QUIT
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 !,?22,"Adverse Reaction Tracking Report"
+13 WRITE !,?25,"From: ",$$FMTE^XLFDT(GMAST,"2D")," To: ",$$FMTE^XLFDT(GMAEN,"2D")
+14 WRITE !,"Patient",?40,"Dates",?49,"Related Reaction"
+15 WRITE !,$$REPEAT^XLFSTR("-",78)
+16 SET GMRAPG=GMRAPG+1
+17 ; Check if stopped by user
IF $DATA(ZTQUEUED)
IF $$STPCK^GMRAUTL1
SET GMRAOUT=1
+18 QUIT