GMRAPST1 ;HIRMFO/WAA- PRINT LISTING OF FATAL REACTIONS ;3/5/97 14:45
;;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 where the patient has died.
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,"GMRAPST1")
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^GMRAPST1",(ZTSAVE("GMRAOUT"),ZTSAVE("GMAST"),ZTSAVE("GMAEN"))=""
. S ZTDESC="List of Fatal Reaction over a date range" 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.
K ^TMP($J,"GMRAPST1")
D NOW^%DTC S GMRADPDT=X
S GMRADATE=GMAST-.0001,GMRAPG=1
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")) ;data entered in error
..Q:$P(GMRAPA1(0),U,3)'="y" ; If patient did not die of the reaction
..S GMRADFN=$P(GMRAPA1(0),U,2),GMRADDT=$P(GMRAPA1(0),U) ; reaction date
..Q:'$$PRDTST^GMRAUTL1(GMRADFN) ;GMRA*4*33 Exclude test patient from report in production or legacy environments.
..S (GMRAPID,GMRANAME)=""
..D VAD^GMRAUTL1(GMRADFN,GMRADDT,"",.GMRANAME,"",.GMRAPID)
..S GMRADIED=$P($G(^DPT(GMRADFN,.35)),U) ; Date patient died
..S ^TMP($J,"GMRAPST1",$E(GMRANAME,1,30),GMRAPID,GMRADDT,GMRAPA1)=GMRADIED
..Q
.Q
Q:GMRAOUT
I '$D(^TMP($J,"GMRAPST1")) D HEAD W !,"NO DATA FOR THIS REPORT..." Q
S GMRANAME=""
F S GMRANAME=$O(^TMP($J,"GMRAPST1",GMRANAME)) Q:GMRANAME="" D Q:GMRAOUT
.S GMRAPID=""
.F S GMRAPID=$O(^TMP($J,"GMRAPST1",GMRANAME,GMRAPID)) Q:GMRAPID="" D Q:GMRAOUT
..D HEAD Q:GMRAOUT
..W !,$E(GMRANAME,1,22)," (",$E(GMRANAME,1),$P(GMRAPID,"-",3),")"
..S GMRADDT=0
..F S GMRADDT=$O(^TMP($J,"GMRAPST1",GMRANAME,GMRAPID,GMRADDT)) Q:GMRADDT<1 D Q:GMRAOUT
...S GMRAPA1=0
...F S GMRAPA1=$O(^TMP($J,"GMRAPST1",GMRANAME,GMRAPID,GMRADDT,GMRAPA1)) Q:GMRAPA1<1 D Q:GMRAOUT W !
....S GMRADIED=^TMP($J,"GMRAPST1",GMRANAME,GMRAPID,GMRADDT,GMRAPA1)
....W ?31,$$FMTE^XLFDT($P(^GMR(120.85,GMRAPA1,0),U),"2D")
....S GMRAX="",GMRACNT=1 K GMRARX
....F S GMRAX=$O(^GMR(120.85,GMRAPA1,3,"B",GMRAX)) Q:GMRAX="" D
.....S GMRARX(GMRACNT)=GMRAX,GMRACNT=GMRACNT+1
.....Q
....W ?40,GMRARX(1),?70,$$FMTE^XLFDT(GMRADIED,"2D")
....D HEAD Q:GMRAOUT
....S GMRACNT=1 F S GMRACNT=$O(GMRARX(GMRACNT)) Q:GMRACNT<1 D Q:GMRAOUT
.....W !,?40,GMRARX(GMRACNT) D HEAD Q:GMRAOUT
.....Q
....Q
...Q
..W ! D HEAD Q:GMRAOUT
..Q
.Q
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 !,?22,"List of Fatal Reaction over a date range"
W !,?25,"From: ",$$FMTE^XLFDT(GMAST,"2D")," To: ",$$FMTE^XLFDT(GMAEN,"2D")
W !,"Patient",?31,"Dates",?40,"Related Reaction",?70,"Date Died"
W !,$$REPEAT^XLFSTR("-",79)
S GMRAPG=GMRAPG+1
I $D(ZTQUEUED) S:$$STPCK^GMRAUTL1 GMRAOUT=1 ; Check if stopped by user
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HGMRAPST1 3633 printed Dec 13, 2024@01:40:16 Page 2
GMRAPST1 ;HIRMFO/WAA- PRINT LISTING OF FATAL REACTIONS ;3/5/97 14:45
+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 where the patient has died.
+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,"GMRAPST1")
+3 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^GMRAPST1"
SET (ZTSAVE("GMRAOUT"),ZTSAVE("GMAST"),ZTSAVE("GMAEN"))=""
+4 SET ZTDESC="List of Fatal Reaction over a date range"
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.
+2 KILL ^TMP($JOB,"GMRAPST1")
+3 DO NOW^%DTC
SET GMRADPDT=X
+4 SET GMRADATE=GMAST-.0001
SET GMRAPG=1
+5 FOR
SET GMRADATE=$ORDER(^GMR(120.85,"B",GMRADATE))
if GMRADATE<1
QUIT
if GMRADATE>GMAEN
QUIT
Begin DoDot:1
+6 SET GMRAPA1=0
FOR
SET GMRAPA1=$ORDER(^GMR(120.85,"B",GMRADATE,GMRAPA1))
if GMRAPA1<1
QUIT
Begin DoDot:2
+7 ;Bad Node
SET GMRAPA1(0)=$GET(^GMR(120.85,GMRAPA1,0))
if GMRAPA1(0)=""
QUIT
+8 ;data entered in error
if +$GET(^GMR(120.8,$PIECE(GMRAPA1(0),U,15),"ER"))
QUIT
+9 ; If patient did not die of the reaction
if $PIECE(GMRAPA1(0),U,3)'="y"
QUIT
+10 ; reaction date
SET GMRADFN=$PIECE(GMRAPA1(0),U,2)
SET GMRADDT=$PIECE(GMRAPA1(0),U)
+11 ;GMRA*4*33 Exclude test patient from report in production or legacy environments.
if '$$PRDTST^GMRAUTL1(GMRADFN)
QUIT
+12 SET (GMRAPID,GMRANAME)=""
+13 DO VAD^GMRAUTL1(GMRADFN,GMRADDT,"",.GMRANAME,"",.GMRAPID)
+14 ; Date patient died
SET GMRADIED=$PIECE($GET(^DPT(GMRADFN,.35)),U)
+15 SET ^TMP($JOB,"GMRAPST1",$EXTRACT(GMRANAME,1,30),GMRAPID,GMRADDT,GMRAPA1)=GMRADIED
+16 QUIT
End DoDot:2
+17 QUIT
End DoDot:1
+18 if GMRAOUT
QUIT
+19 IF '$DATA(^TMP($JOB,"GMRAPST1"))
DO HEAD
WRITE !,"NO DATA FOR THIS REPORT..."
QUIT
+20 SET GMRANAME=""
+21 FOR
SET GMRANAME=$ORDER(^TMP($JOB,"GMRAPST1",GMRANAME))
if GMRANAME=""
QUIT
Begin DoDot:1
+22 SET GMRAPID=""
+23 FOR
SET GMRAPID=$ORDER(^TMP($JOB,"GMRAPST1",GMRANAME,GMRAPID))
if GMRAPID=""
QUIT
Begin DoDot:2
+24 DO HEAD
if GMRAOUT
QUIT
+25 WRITE !,$EXTRACT(GMRANAME,1,22)," (",$EXTRACT(GMRANAME,1),$PIECE(GMRAPID,"-",3),")"
+26 SET GMRADDT=0
+27 FOR
SET GMRADDT=$ORDER(^TMP($JOB,"GMRAPST1",GMRANAME,GMRAPID,GMRADDT))
if GMRADDT<1
QUIT
Begin DoDot:3
+28 SET GMRAPA1=0
+29 FOR
SET GMRAPA1=$ORDER(^TMP($JOB,"GMRAPST1",GMRANAME,GMRAPID,GMRADDT,GMRAPA1))
if GMRAPA1<1
QUIT
Begin DoDot:4
+30 SET GMRADIED=^TMP($JOB,"GMRAPST1",GMRANAME,GMRAPID,GMRADDT,GMRAPA1)
+31 WRITE ?31,$$FMTE^XLFDT($PIECE(^GMR(120.85,GMRAPA1,0),U),"2D")
+32 SET GMRAX=""
SET GMRACNT=1
KILL GMRARX
+33 FOR
SET GMRAX=$ORDER(^GMR(120.85,GMRAPA1,3,"B",GMRAX))
if GMRAX=""
QUIT
Begin DoDot:5
+34 SET GMRARX(GMRACNT)=GMRAX
SET GMRACNT=GMRACNT+1
+35 QUIT
End DoDot:5
+36 WRITE ?40,GMRARX(1),?70,$$FMTE^XLFDT(GMRADIED,"2D")
+37 DO HEAD
if GMRAOUT
QUIT
+38 SET GMRACNT=1
FOR
SET GMRACNT=$ORDER(GMRARX(GMRACNT))
if GMRACNT<1
QUIT
Begin DoDot:5
+39 WRITE !,?40,GMRARX(GMRACNT)
DO HEAD
if GMRAOUT
QUIT
+40 QUIT
End DoDot:5
if GMRAOUT
QUIT
+41 QUIT
End DoDot:4
if GMRAOUT
QUIT
WRITE !
+42 QUIT
End DoDot:3
if GMRAOUT
QUIT
+43 WRITE !
DO HEAD
if GMRAOUT
QUIT
+44 QUIT
End DoDot:2
if GMRAOUT
QUIT
+45 QUIT
End DoDot:1
if GMRAOUT
QUIT
+46 DO CLOSE^GMRAUTL
+47 QUIT
+48 ;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 !,?22,"List of Fatal Reaction over a date range"
+13 WRITE !,?25,"From: ",$$FMTE^XLFDT(GMAST,"2D")," To: ",$$FMTE^XLFDT(GMAEN,"2D")
+14 WRITE !,"Patient",?31,"Dates",?40,"Related Reaction",?70,"Date Died"
+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